Missing decimals in the code - some suggestions?

hmjeltevik at gmail.com hmjeltevik at gmail.com
Tue Apr 16 14:02:01 EDT 2013


Hi!

I am using ystockquote with the following code:

def get_historical_prices(symbol, start_date, end_date):
    """
    Get historical prices for the given ticker symbol.
    Date format is 'YYYYMMDD'
    
    Returns a nested list.
    """
    url = 'http://ichart.yahoo.com/table.csv?s=%s&' % symbol + \
          'd=%s&' % str(int(end_date[4:6]) - 1) + \
          'e=%s&' % str(int(end_date[6:8])) + \
          'f=%s&' % str(int(end_date[0:4])) + \
          'g=d&' + \
          'a=%s&' % str(int(start_date[4:6]) - 1) + \
          'b=%s&' % str(int(start_date[6:8])) + \
          'c=%s&' % str(int(start_date[0:4])) + \
          'ignore=.csv'
    days = urllib.urlopen(url).readlines()
    data = [day[:-2].split(',') for day in days]
    return data

This code prints the data, but only 2 decimals. I need to print out 4 decimals.

print ystockquote.get_historical_prices('EURUSD=X','20120101','20120301')

Some suggestions?



More information about the Python-list mailing list