Closed CaffeinatedFunctionality closed 8 years ago
Can you post an example?
I've experienced a similar issue with stocks trading at less than 10 cents.
If a penny stock closes at a round number (full cent rather than fraction of a cent) then the API results are rounded to two decimal places instead of three.
This is a bug with Yahoo Finance API. As far as I can tell there's no way to force the API to use the correct number of decimals.
For example, if a stock closes at 0.029
then the next day it closes at 0.030
, the API rounds the close to 0.03
. As a direct result of this, the change
returned from the API is 0.00
; however the change_in_percent
remains accurate. Some other variables such as the 52 week high and 52 week low are also rounded to two decimals.
Here's an example.
$ curl -isk "https://download.finance.yahoo.com/d/quotes.csv?s=WOF.AX&f=l1cc1pjkw"
HTTP/1.1 200 OK
Date: Fri, 18 Nov 2016 03:39:11 GMT
P3P: policyref="https://policies.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Cache-Control: private, no-cache, no-store
Content-Length: 58
Content-Type: application/octet-stream
Age: 0
Strict-Transport-Security: max-age=0
Via: http/1.1 media-router-api10.prod.media.bf1.yahoo.com (ApacheTrafficServer [cMsSf ]), https/1.1 r02.ycpi.aue.yahoo.net (ApacheTrafficServer [cMsSf ])
Server: ATS
Connection: keep-alive
0.02,"+0.00 - +33.33%",+0.00,0.01,0.00,0.04,"0.00 - 0.04"
### Edit ^^:
l1 ,c ,c1 ,p ,j ,k ,w
l1 = last
c = change & percent
c1 = change
p = previous close
j = 52 week low
k = 52 week high
w = 52 week range
The last trade price was 0.020 and is shown as 0.02.
Note the change is +0.00 however change in percentage is +33.33%. The real change is 0.005.
Also note the 52 week low and high are shown as 0.00 and 0.04 respectively. The correct values are 0.004 and 0.036.
This rounding issue affects all stocks, not just penny stocks.
This issue isn't limited to the API either. The Yahoo Finance website is wrong due to rounding errors.
Yahoo
Change: 0.010
ASX
Change: 0.005
All of the percentages that I keep getting are showing zero. using :chance_and_percent_change and :change_in_percent both return zero for me and any stock that is under 10cents a share makes it 0cents.