Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43700
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'skip:[ 20': 0.04; '"""': 0.07; 'nested': 0.07; 'skip:u 30': 0.07; 'subject:code': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'complained': 0.16; 'did.': 0.16; 'nearest': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'url:%s': 0.16; 'wrote:': 0.18; 'spread': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'code:': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; "skip:' 10": 0.31; 'prints': 0.31; 'subject:some': 0.31; 'subject:the': 0.34; 'but': 0.35; 'data,': 0.36; 'subject:?': 0.36; 'too': 0.37; 'list.': 0.37; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'days': 0.60; 'prices': 0.60; 'ago,': 0.61; 'received:173': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'market': 0.66; 'day': 0.76; '2:02': 0.84; 'received:fios.verizon.net': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Jan Reedy <tjreedy@udel.edu> |
| Subject | Re: Missing decimals in the code - some suggestions? |
| Date | Tue, 16 Apr 2013 14:37:40 -0400 |
| References | <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-251-66.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
| In-Reply-To | <8e158cbe-4b81-476a-ac48-a0d967956277@googlegroups.com> |
| 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.687.1366137472.3114.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366137472 news.xs4all.nl 2566 [2001:888:2000:d::a6]:60768 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43700 |
Show key headers only | View raw
On 4/16/2013 2: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.
As far as I know, prices are only defined to the nearest penny* (2
decimals) so I don't know what more you expect.
*Not too long ago, prices were in 1/8ths of a dollar. Market makers
complained about decimalization because it would squeeze the spread that
they profited from -- which it did.
> print ystockquote.get_historical_prices('EURUSD=X','20120101','20120301')
>
> Some suggestions?
Back to comp.lang.python | Previous | Next — Previous 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