Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43695

Re: Missing decimals in the code - some suggestions?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'skip:[ 20': 0.04; 'api.': 0.05; '"""': 0.07; 'nested': 0.07; 'skip:u 30': 0.07; 'subject:code': 0.07; 'python': 0.11; 'def': 0.12; 'question.': 0.14; 'csv': 0.16; 'precision.': 0.16; 'url:%s': 0.16; 'wrote:': 0.18; 'print': 0.22; 'code:': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'prints': 0.31; 'subject:some': 0.31; 'file': 0.32; 'subject:the': 0.34; 'received:209.85': 0.35; 'received:209.85.160.46': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'data,': 0.36; 'subject:?': 0.36; 'list.': 0.37; 'received:209': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'days': 0.60; 'prices': 0.60; 'more': 0.64; 'day': 0.76; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=GIMgM3RDFHdeUz9av1qJd4+WbAcZ/JP7HVtmmQBEEac=; b=mT/LyxU/yO3JafqjvwoANikCLOVbg2UaVGIQ9RAvnEAXFrDDvFSPiF6XUjZ5bC7jgr eY53kLCCs7Pb5dCQFicrmEcO3oxeqciE6GWbE4o75mhhbbBHv/oMorUWFG0JyFc49Q6Q IRq4boEA25+NaVn4m9j5lYK2s6O33CUyVtb1IXv17AiBgDBmRwIYvQUOE8bwkWmFiek5 IE6PsSpDwTg4MTqD3X3EveJcZ7qHk1sF8ZQLK4JMqpKHjcJn8jgjYyQSR/8VESgWQYqi MY4grqDDj3rpTaVz+SbVf02HzNoUrcX4KqsiLmUnaHQk8GLzzcUxnsdIqqw6quim0XXv dnlg==
X-Received by 10.68.252.227 with SMTP id zv3mr5099197pbc.14.1366136458333; Tue, 16 Apr 2013 11:20:58 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com>
References <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 16 Apr 2013 12:20:18 -0600
Subject Re: Missing decimals in the code - some suggestions?
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.683.1366136461.3114.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366136461 news.xs4all.nl 2661 [2001:888:2000:d::a6]:48126
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43695

Show key headers only | View raw


On Tue, Apr 16, 2013 at 12:02 PM,  <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?

This isn't a Python question.  If you take a look at the csv file that
you download from Yahoo, you will see that it only contains 2 digits
of precision.  There's no way to make Python print out 4 digits of
precision when it is only provided with 2.  You will need to find out
if there is a way to ask for more precision in the Yahoo API.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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