Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'receives': 0.04; 'skip:[ 20': 0.04; '"""': 0.07; 'nested': 0.07; 'skip:u 30': 0.07; 'subject:code': 0.07; 'def': 0.12; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'rounding': 0.16; 'url:%s': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header:User- Agent:1': 0.23; 'looks': 0.24; 'code:': 0.26; 'header:In-Reply- To:1': 0.27; 'code': 0.31; "skip:' 10": 0.31; 'decimal': 0.31; 'prints': 0.31; 'question:': 0.31; 'subject:some': 0.31; 'another': 0.32; 'says': 0.33; 'subject:the': 0.34; 'received:84': 0.35; 'but': 0.35; 'data,': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'list.': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'days': 0.60; 'prices': 0.60; "you'll": 0.62; 'email addr:gmail.com': 0.63; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'day': 0.76; 'reply- to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=N54QSQNB c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=7r5RyK9Ok68A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=S710esHnPx4A:10 a=pGLkceISAAAA:8 a=CjxXgO3LAAAA:8 a=uPZiAMpXAAAA:8 a=wLGuFzbe589yo6SnpQIA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 X-AUTH: mrabarnett:2500 Date: Tue, 16 Apr 2013 19:35:10 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Missing decimals in the code - some suggestions? References: <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com> In-Reply-To: <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366137310 news.xs4all.nl 2668 [2001:888:2000:d::a6]:57432 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43699 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.