Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43699
| Date | 2013-04-16 19:35 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Missing decimals in the code - some suggestions? |
| References | <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.686.1366137310.3114.python-list@python.org> (permalink) |
On 16/04/2013 19:02, hmjeltevik@gmail.com wrote:
> 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?
>
The code prints what it receives; the data it receives has only 2
decimal places.
This question:
http://stackoverflow.com/questions/11496418/yql-forex-historical-prices-queries-how-to-change-default-precision
says that it's Yahoo doing the rounding to 2 decimal places.
It looks like you'll have to find another way to get what you want.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Missing decimals in the code - some suggestions? hmjeltevik@gmail.com - 2013-04-16 11:02 -0700
Re: Missing decimals in the code - some suggestions? Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-16 12:20 -0600
Re: Missing decimals in the code - some suggestions? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-17 06:23 +0000
Re: Missing decimals in the code - some suggestions? Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-17 00:56 -0600
Re: Missing decimals in the code - some suggestions? MRAB <python@mrabarnett.plus.com> - 2013-04-16 19:35 +0100
Re: Missing decimals in the code - some suggestions? Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-16 14:37 -0400
csiph-web