title: How can I store the historical stock prices (using an array)?
body: <p>I am using the yahoo finance library that can be found here:
  <a href="https://pypi.python.org/pypi/yahoo-finance/1.2.1" rel="nofollow">https://pypi.python.org/pypi/yahoo-finance/1.2.1</a></p>
  
  <p>I have a text file with ticker symbols. I am going through the ticker symbols and printing historical data for the stock prices. </p>
  
  <p>How can I take the closing prices and store them so that I can use them later (to calculate averages)? </p>
  
  <p>here is my code: </p>
  
  <pre><code>from yahoo_finance import Share
  
  from pprint import pprint #for easy to view historical data
  
  import calendar
  import datetime 
  import time
  
  
  
  
  
  cal = calendar.TextCalendar(calendar.SUNDAY)
  #cal.prmonth(today)
  
  #using datetime below:
  
  today = datetime.date.today() #todays date
  todayH = str(today) # because in .get_historical I need to use a string 
  
  yesterday = (today.toordinal()-10) #yesterdays date mathamatically
  
  dateYes =  datetime.date.fromordinal(yesterday) #yesterdays date in format we want
  dateYesH = str(dateYes) # because in .get_historical I need to use a string 
  
  
  print 'today:', today
  print dateYesH
  print 'ordinal:', today.toordinal()
  
  
  rand = Share('yhoo')
  # print rand.get_price() (works)
  #pprint(rand.get_historical(dateYesH, todayH))
  
  
  #reading text file
  file1 = open('TickerF.txt', 'r')
  words = file1.read().split(' ')
  length = len(words)
  #print words 
  #print len(words)
  #print file1.read()
  file1.close()
  
  
  c = 0
  
  try :
      while c &lt; length:
          for i in words:
              symbol = str(i)
              stock = Share(symbol)
              c= c+1
              print i
          #print c
              pprint(stock.get_historical(dateYesH, todayH))
  
  except: 
      pass
  </code></pre>
  
  <p>my output is : </p>
  
  <pre><code>today: 2015-12-06
  2015-11-26
  ordinal: 735938
  YHOO
  [{'Adj_Close': '34.91',
    'Close': '34.91',
    'Date': '2015-12-04',
    'High': '35.200001',
    'Low': '34.18',
    'Open': '34.34',
    'Symbol': 'YHOO',
    'Volume': '15502700'},
   {'Adj_Close': '34.34',
    'Close': '34.34',
    'Date': '2015-12-03',
    'High': '35.720001',
    'Low': '34.099998',
    'Open': '35.59',
    'Symbol': 'YHOO',
    'Volume': '17068000'},
   {'Adj_Close': '35.650002',
    'Close': '35.650002',
    'Date': '2015-12-02',
    'High': '36.389999',
    'Low': '34.77',
    'Open': '35.00',
    'Symbol': 'YHOO',
    'Volume': '56614000'},
   {'Adj_Close': '33.709999',
    'Close': '33.709999',
    'Date': '2015-12-01',
    'High': '33.889999',
    'Low': '33.470001',
    'Open': '33.869999',
    'Symbol': 'YHOO',
    'Volume': '10862500'},
   {'Adj_Close': '33.810001',
    'Close': '33.810001',
    'Date': '2015-11-30',
    'High': '33.830002',
    'Low': '32.849998',
    'Open': '33.029999',
    'Symbol': 'YHOO',
    'Volume': '17363600'},
   {'Adj_Close': '32.939999',
    'Close': '32.939999',
    'Date': '2015-11-27',
    'High': '33.09',
    'Low': '32.439999',
    'Open': '32.790001',
    'Symbol': 'YHOO',
    'Volume': '5313400'}]
  </code></pre>
  
  <p>How can I store the 'close' values while I go through my array? I have an idea to create another array which will store the 'close' values, but how do I make it so that the array only stores the close values and not any of the other values?</p>