ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.89k stars 2.44k forks source link

BCAN historical data is inaccurate. #2002

Closed mwahal closed 3 months ago

mwahal commented 4 months ago

Describe bug

yfinance-0.2.41-py2.py3-none-any.whl.metadata <== updated to the latest version

Getting the historical data for symbol BCAN. It had a split of 1-190 on March-22, 2024. Yahoo finance clearly shows the split in its data. But, the downloaded data doesn't have the split adjusted values. Here is the output from my program

Simple code that reproduces your problem

histdata = yf.Ticker(ticker) x = histdata.history(period="max", auto_adjust=False).to_string() print(x)

Debug log

Here is the output 2024-03-19 00:00:00-04:00 0.021 0.021000 0.018 0.020 0.020 62375400 0.0 0.000000 2024-03-20 00:00:00-04:00 0.024 0.028000 0.019 0.021 0.021 187242500 0.0 0.000000 2024-03-21 00:00:00-04:00 0.021 0.021000 0.018 0.019 0.019 88724500 0.0 0.000000 2024-03-22 00:00:00-04:00 2.500 2.690000 2.060 2.510 2.510 2691800 0.0 0.005263 2024-03-25 00:00:00-04:00 2.310 2.430000 1.850 1.960 1.960 3601300 0.0 0.000000 2024-03-26 00:00:00-04:00 1.750 1.750000 1.450 1.560 1.560 2748200 0.0 0.000000 2024-03-27 00:00:00-04:00 1.310 1.550000 1.200 1.430 1.430 4520200 0.0 0.000000 2024-03-28 00:00:00-04:00 1.410 1.630000 1.310 1.400 1.400 4327600 0.0 0.000000 2024-04-01 00:00:00-04:00 1.460 1.520000 1.400 1.430 1.430 1987200 0.0 0.000000

Bad data proof

Here is the info from yahoo finance

`

Mar 28, 2024 1.4100 1.6300 1.3100 1.4000 1.4000 4,327,600
Mar 27, 2024 1.3100 1.5500 1.2000 1.4300 1.4300 4,520,200
Mar 26, 2024 1.7500 1.7500 1.4500 1.5600 1.5600 2,748,200
Mar 25, 2024 2.3100 2.4300 1.8500 1.9600 1.9600 3,601,300
Mar 22, 2024 1:190 Stock Splits
Mar 22, 2024 2.5000 2.6900 2.0600 2.5100 2.5100 2,691,800
Mar 21, 2024 0.0210 0.0210 0.0180 0.0190 0.0190 88,724,500
Mar 20, 2024 0.0240 0.0280 0.0190 0.0210 0.0210 187,242,500

`

yfinance version

yfinance-0.2.41-py2.py3

Python version

Python 3.8.0 (default, Oct 16 2019, 11:03:30)

Operating system

5.15.0-112-generic #122-Ubuntu SMP Thu May 23 07:48:21 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

ValueRaider commented 3 months ago

Your 2 tables look identical to me. Where's the difference?

mwahal commented 3 months ago

Ok I thought yfinance will do the split in the price by looking at the split history in the data, but seems like its just reading from Yahoo's data, as is, split adjusted or not. In case of BCAN, yahoo didn't split the price. But, Yahoo did split in NVDA, so it shows correct price.

Same code output for NVDA which split on June 7th, posted on June 10. ` 2024-05-31 00:00:00-04:00 112.519997 112.717003 106.940002 109.633003 109.624001 613263000 0.000000 0.0

2024-06-03 00:00:00-04:00 113.621002 115.000000 112.002998 115.000000 114.990555 438392000 0.000000 0.0

2024-06-04 00:00:00-04:00 115.716003 116.599998 114.044998 116.436996 116.427429 403324000 0.000000 0.0

2024-06-05 00:00:00-04:00 118.371002 122.448997 117.468002 122.440002 122.429947 528402000 0.000000 0.0

2024-06-06 00:00:00-04:00 124.047997 125.586998 118.320000 120.998001 120.988060 664696000 0.000000 0.0

2024-06-07 00:00:00-04:00 119.769997 121.692001 118.022003 120.888000 120.878075 412386000 0.000000 0.0

2024-06-10 00:00:00-04:00 120.370003 123.099998 117.010002 121.790001 121.779999 314162700 0.000000 10.0

2024-06-11 00:00:00-04:00 121.769997 122.870003 118.739998 120.910004 120.910004 222551200 0.010000 0.0 `

You dont see any sudden jump in the prices, unlike BCAN, which jumped by a 190x.

Here is the output of NVDA from yahoo

` Jun 12, 2024 123.06 126.88 122.57 125.20 125.20 299,595,000
Jun 11, 2024 0.01 Dividend
Jun 11, 2024 121.77 122.87 118.74 120.91 120.91 222,551,200
Jun 10, 2024 10:1 Stock Splits
Jun 10, 2024 120.37 123.10 117.01 121.79 121.78 314,162,700
Jun 7, 2024 119.77 121.69 118.02 120.89 120.88 412,386,000

`

ValueRaider commented 3 months ago

yfinance mostly just fetches data. Price repair might help.