0

Complete beginner here.

I'm trying to write a program in Python which takes a user input and plugs it into a Panda block of code to produce a table of stock prices in a date range.

So far, my input block looks like this:

StockCount = input ('Input the number of stocks in the portfolio: ')

StockTickerArray = list()

for i in range(1,StockCount+1):
   StockTicker = raw_input ('Enter Stock Ticker '+str(i)+': ')
   StockTickerArray.append(str(StockTicker))
   """
   print "you entered", StockTicker
   """

print 'ARRAY: ', StockTickerArray

So, let's say you enter just 1 stock: AAPL. That's the input. I want to be able to take AAPL and plug it in DataReader where it says "Stock Goes Here". Is that possible?

from pandas.io.data import DataReader
from datetime import datetime

stock = DataReader("STOCK GOES HERE",  "yahoo", datetime(2009,1,1))
print stock ["Adj Close"]

Thanks

user2373506
  • 45
  • 2
  • 4

1 Answers1

0
StockTicker = raw_input ('Enter Stock Ticker '+str(i)+': ')
stock = DataReader(StockTicker,  "yahoo", datetime(2009,1,1))
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677