ranaroussi / yfinance

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

Different Prices of Day and Hour Data for TSLA. #1876

Open eiphy opened 8 months ago

eiphy commented 8 months ago

Describe bug

The data of TSLA are inconsistent before 2022-08-24: Hourly data: image Daily data: image

Simple code that reproduces your problem

import yfinance as yf

yf.enable_debug_mode()

ticker = yf.Ticker("TSLA")
df = ticker.history(
    interval="1h",
    period="2y",
    prepost=False,
    actions=True,
    auto_adjust=False,
    repair=True,
    keepna=False,
    rounding=False,
)

print(df.loc["2022-08-24":"2022-08-25"])

df = ticker.history(
    interval="1d",
    period="2y",
    prepost=False,
    actions=True,
    auto_adjust=False,
    repair=True,
    keepna=False,
    rounding=False,
)

print(df.loc["2022-08-23":"2022-08-26"])

Debug log

DEBUG Entering history() DEBUG Entering history() DEBUG TSLA: Yahoo GET parameters: {'range': '2y', 'interval': '1h', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/TSLA DEBUG params={'range': '2y', 'interval': '1h', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG loaded persistent cookie DEBUG reusing cookie DEBUG crumb = 'tDC09c.KkEZ' DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() DEBUG TSLA: yfinance received OHLC data: 2022-03-07 14:30:00 -> 2024-03-04 20:30:00 DEBUG TSLA: OHLC after cleaning: 2022-03-07 09:30:00-05:00 -> 2024-03-04 15:30:00-05:00 DEBUG TSLA: OHLC after combining events: 2022-03-07 09:30:00-05:00 -> 2024-03-04 15:30:00-05:00 DEBUG TSLA: checking OHLC for repairs ... DEBUG Entering _fix_unit_mixups() DEBUG Entering _fix_unit_switch() DEBUG Entering _fix_prices_sudden_change() DEBUG price-repair-split: appears_suspended=True, idx_latest_active=8 (2024-03-01) INFO price-repair-split: No 100x errors detected DEBUG Exiting _fix_prices_sudden_change() DEBUG Exiting _fix_unit_switch() DEBUG Entering _fix_unit_random_mixups() INFO price-repair-100x: No sporadic 100x errors DEBUG Exiting _fix_unit_random_mixups() DEBUG Exiting _fix_unit_mixups() DEBUG Entering _fix_bad_stock_split() DEBUG Exiting _fix_bad_stock_split() DEBUG Entering _fix_zeroes() DEBUG Entering _reconstruct_intervals_batch() DEBUG min_dt=2024-01-06 00:00:00-05:00 interval=1h sub_interval=30m INFO Data too old to repair DEBUG Exiting _reconstruct_intervals_batch() DEBUG Exiting _fix_zeroes() DEBUG Entering _fix_missing_div_adjust() DEBUG Exiting _fix_missing_div_adjust() DEBUG TSLA: yfinance returning OHLC: 2022-03-07 09:30:00-05:00 -> 2024-03-01 15:30:00-05:00 DEBUG Exiting history() DEBUG Exiting history() Open High Low Close Adj Close Volume Dividends Stock Splits Repaired? Datetime
2022-08-24 09:30:00-04:00 892.690002 910.940002 891.049988 907.104614 907.104614 7021349 0.0 0.0 False 2022-08-24 10:30:00-04:00 907.572998 908.400024 901.059998 904.039978 904.039978 2737542 0.0 0.0 False 2022-08-24 11:30:00-04:00 904.260010 907.559998 902.119995 905.380005 905.380005 1554554 0.0 0.0 False 2022-08-24 12:30:00-04:00 905.340027 906.400024 895.479980 896.107727 896.107727 1997977 0.0 0.0 False 2022-08-24 13:30:00-04:00 895.940002 900.309998 895.340027 897.099976 897.099976 1378497 0.0 0.0 False 2022-08-24 14:30:00-04:00 897.049988 897.340027 889.500000 892.789978 892.789978 2078101 0.0 0.0 False 2022-08-24 15:30:00-04:00 892.775024 894.979980 890.000000 891.450012 891.450012 1366247 0.0 0.0 False 2022-08-25 09:30:00-04:00 302.359985 302.959991 293.140106 297.492096 297.492096 20100512 0.0 0.0 False 2022-08-25 10:30:00-04:00 297.549988 298.089996 291.600006 293.070007 293.070007 9438207 0.0 0.0 False 2022-08-25 11:30:00-04:00 293.149994 294.980011 291.920105 293.850098 293.850098 5161989 0.0 0.0 False 2022-08-25 12:30:00-04:00 293.950012 295.692993 292.799988 294.836609 294.836609 4205521 0.0 0.0 False 2022-08-25 13:30:00-04:00 294.837799 295.640686 293.114288 293.309998 293.309998 3702607 0.0 0.0 False 2022-08-25 14:30:00-04:00 293.380005 293.679993 291.799988 293.440002 293.440002 4667132 0.0 0.0 False 2022-08-25 15:30:00-04:00 293.427612 296.149994 293.021088 296.109985 296.109985 4241512 0.0 0.0 False DEBUG Entering history() DEBUG Entering history() DEBUG TSLA: Yahoo GET parameters: {'range': '2y', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/TSLA DEBUG params={'range': '2y', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG reusing cookie DEBUG reusing crumb DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() DEBUG TSLA: yfinance received OHLC data: 2022-03-07 14:30:00 -> 2024-03-04 14:30:00 DEBUG TSLA: OHLC after cleaning: 2022-03-07 09:30:00-05:00 -> 2024-03-04 09:30:00-05:00 DEBUG TSLA: OHLC after combining events: 2022-03-07 00:00:00-05:00 -> 2024-03-04 00:00:00-05:00 DEBUG TSLA: checking OHLC for repairs ... DEBUG Entering _fix_unit_mixups() DEBUG Entering _fix_unit_switch() DEBUG Entering _fix_prices_sudden_change() DEBUG price-repair-split: appears_suspended=True, idx_latest_active=2 (2024-02-29) INFO price-repair-split: No 100x errors detected DEBUG Exiting _fix_prices_sudden_change() DEBUG Exiting _fix_unit_switch() DEBUG Entering _fix_unit_random_mixups() INFO price-repair-100x: No sporadic 100x errors DEBUG Exiting _fix_unit_random_mixups() DEBUG Exiting _fix_unit_mixups() DEBUG Entering _fix_bad_stock_split() DEBUG price-repair-split: No splits in data DEBUG Exiting _fix_bad_stock_split() DEBUG Entering _fix_zeroes() DEBUG Entering _reconstruct_intervals_batch() DEBUG min_dt=2022-03-07 00:00:00-05:00 interval=1d sub_interval=1h DEBUG grp_max_size = relativedelta(years=+1) DEBUG Repair groups: DEBUG - 2024-03-04 00:00:00-05:00 -> 2024-03-04 00:00:00-05:00 DEBUG df_block: Open High Low Close Adj Close Volume Dividends Stock Splits Repaired? 2024-02-29 00:00:00-05:00 204.179993 205.279999 198.449997 201.880005 201.880005 85907000.0 0.0 0.0 False 2024-03-01 00:00:00-05:00 200.520004 204.520004 198.500000 202.639999 202.639999 82099200.0 0.0 0.0 False 2024-03-04 00:00:00-05:00 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.0 0.0 0.0 False DEBUG Fetching 1h prepost=True 2024-02-28->2024-03-06 DEBUG Entering history() DEBUG TSLA: Yahoo GET parameters: {'period1': '2024-02-28 00:00:00-05:00', 'period2': '2024-03-06 00:00:00-05:00', 'interval': '1h', 'includePrePost': True, 'events': 'div,splits,capitalGains'} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/TSLA DEBUG params={'period1': 1709096400, 'period2': 1709701200, 'interval': '1h', 'includePrePost': True, 'events': 'div,splits,capitalGains'} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG reusing cookie DEBUG reusing crumb DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() DEBUG TSLA: yfinance received OHLC data: 2024-02-28 09:00:00 -> 2024-03-04 13:00:00 DEBUG TSLA: OHLC after cleaning: 2024-02-28 04:00:00-05:00 -> 2024-03-04 08:00:00-05:00 DEBUG TSLA: OHLC after combining events: 2024-02-28 04:00:00-05:00 -> 2024-03-04 08:00:00-05:00 DEBUG TSLA: checking OHLC for repairs ... DEBUG Entering _fix_unit_mixups() DEBUG Entering _fix_unit_switch() DEBUG Entering _fix_prices_sudden_change() DEBUG price-repair-split: appears_suspended=False, idx_latest_active=0 (2024-03-04) INFO price-repair-split: No 100x errors detected DEBUG Exiting _fix_prices_sudden_change() DEBUG Exiting _fix_unit_switch() DEBUG Entering _fix_unit_random_mixups() INFO price-repair-100x: No sporadic 100x errors DEBUG Exiting _fix_unit_random_mixups() DEBUG Exiting _fix_unit_mixups() DEBUG Entering _fix_bad_stock_split() DEBUG Exiting _fix_bad_stock_split() DEBUG Entering _fix_zeroes() DEBUG Entering _reconstruct_intervals_batch() DEBUG min_dt=2024-01-06 00:00:00-05:00 interval=1h sub_interval=30m DEBUG grp_max_size = 30 days, 0:00:00 DEBUG Repair groups: DEBUG - 2024-02-28 04:00:00-05:00 -> 2024-03-04 08:00:00-05:00 DEBUG df_block: Open High Low Close Adj Close Volume Dividends Stock Splits Repaired? 2024-02-28 04:00:00-05:00 200.000000 201.450000 199.110000 200.170000 200.170000 -1 0.0 0.0 False 2024-02-28 05:00:00-05:00 200.130000 200.550000 199.500000 200.240000 200.240000 -1 0.0 0.0 False 2024-02-28 06:00:00-05:00 200.190000 200.240000 199.630000 199.980000 199.980000 -1 0.0 0.0 False 2024-02-28 07:00:00-05:00 199.950000 200.860000 199.930000 200.790000 200.790000 -1 0.0 0.0 False 2024-02-28 08:00:00-05:00 200.800000 202.300000 199.270000 200.130000 200.130000 -1 0.0 0.0 False 2024-02-28 09:00:00-05:00 200.080000 205.235000 198.710000 200.204000 200.204000 -1 0.0 0.0 False 2024-02-28 09:30:00-05:00 200.929993 203.330002 198.440002 202.750000 202.750000 30192577 0.0 0.0 False 2024-02-28 10:30:00-05:00 202.757996 205.199997 202.429993 205.119995 205.119995 20692187 0.0 0.0 False 2024-02-28 11:30:00-05:00 205.130005 205.300003 202.940002 203.259995 203.259995 12857169 0.0 0.0 False 2024-02-28 12:30:00-05:00 203.270004 203.750000 202.419998 202.800095 202.800095 9438532 0.0 0.0 False 2024-02-28 13:30:00-05:00 202.820007 203.729996 202.149994 202.164993 202.164993 9291830 0.0 0.0 False 2024-02-28 14:30:00-05:00 202.166901 202.439896 201.300003 202.051300 202.051300 9589475 0.0 0.0 False 2024-02-28 15:30:00-05:00 202.061401 202.410004 201.660095 202.149994 202.149994 4898985 0.0 0.0 False 2024-02-28 16:00:00-05:00 202.040000 204.969280 188.837390 200.860000 200.860000 -1 0.0 0.0 False 2024-02-28 17:00:00-05:00 200.890000 202.040000 200.280000 200.790000 200.790000 -1 0.0 0.0 False 2024-02-28 18:00:00-05:00 200.780000 201.290000 200.650000 201.210000 201.210000 -1 0.0 0.0 False 2024-02-29 04:00:00-05:00 201.390000 202.740000 201.130000 201.900000 201.900000 -1 0.0 0.0 False 2024-02-29 05:00:00-05:00 201.840000 202.420000 201.770000 202.010000 202.010000 -1 0.0 0.0 False 2024-02-29 06:00:00-05:00 201.980000 202.550000 201.600000 202.370000 202.370000 -1 0.0 0.0 False 2024-02-29 07:00:00-05:00 202.450000 202.590000 201.510000 201.650000 201.650000 -1 0.0 0.0 False 2024-02-29 08:00:00-05:00 201.640000 202.735200 201.000000 201.320000 201.320000 -1 0.0 0.0 False 2024-02-29 09:00:00-05:00 201.230000 204.880000 199.145000 204.520000 204.520000 -1 0.0 0.0 False 2024-02-29 09:30:00-05:00 205.020004 205.029907 200.500000 202.039993 202.039993 28276200 0.0 0.0 False 2024-02-29 10:30:00-05:00 202.031998 202.220001 199.509995 199.669998 199.669998 14655480 0.0 0.0 False 2024-02-29 11:30:00-05:00 199.656006 200.419998 198.446304 199.570007 199.570007 10060500 0.0 0.0 False 2024-02-29 12:30:00-05:00 199.570007 200.869995 199.509995 200.610001 200.610001 6074078 0.0 0.0 False 2024-02-29 13:30:00-05:00 200.619995 201.059998 199.830093 200.054001 200.054001 6668995 0.0 0.0 False 2024-02-29 14:30:00-05:00 200.050003 201.250000 199.990005 200.863998 200.863998 5775801 0.0 0.0 False 2024-02-29 15:30:00-05:00 200.865005 202.190002 200.740005 201.750000 201.750000 6496202 0.0 0.0 False 2024-02-29 16:00:00-05:00 201.880000 212.744540 195.216000 200.450000 200.450000 -1 0.0 0.0 False 2024-02-29 17:00:00-05:00 200.500000 201.880000 199.880000 200.480000 200.480000 -1 0.0 0.0 False 2024-02-29 18:00:00-05:00 200.450000 200.700000 200.100000 200.420000 200.420000 -1 0.0 0.0 False 2024-03-01 04:00:00-05:00 201.950000 202.000000 200.940000 201.690000 201.690000 -1 0.0 0.0 False 2024-03-01 05:00:00-05:00 201.690000 201.740000 200.000000 200.580000 200.580000 -1 0.0 0.0 False 2024-03-01 06:00:00-05:00 200.560000 200.900000 200.220000 200.780000 200.780000 -1 0.0 0.0 False 2024-03-01 07:00:00-05:00 200.730000 201.290000 200.550000 200.580000 200.580000 -1 0.0 0.0 False 2024-03-01 08:00:00-05:00 200.560000 202.780000 200.131500 201.400000 201.400000 -1 0.0 0.0 False 2024-03-01 09:00:00-05:00 201.390000 201.880000 200.700000 200.870000 200.870000 -1 0.0 0.0 False 2024-03-01 09:30:00-05:00 200.250000 201.460007 198.500000 199.557999 199.557999 15958936 0.0 0.0 False 2024-03-01 10:30:00-05:00 199.559998 200.990005 198.910004 200.860001 200.860001 17865566 0.0 0.0 False 2024-03-01 11:30:00-05:00 200.866806 202.679993 200.520004 202.445007 202.445007 11235160 0.0 0.0 False 2024-03-01 12:30:00-05:00 202.460007 204.429993 202.169998 204.270004 204.270004 10961678 0.0 0.0 False 2024-03-01 13:30:00-05:00 204.279999 204.520004 203.020004 203.580002 203.580002 9969421 0.0 0.0 False 2024-03-01 14:30:00-05:00 203.570007 203.800003 202.470001 203.329895 203.329895 8269849 0.0 0.0 False 2024-03-01 15:30:00-05:00 203.320007 203.389999 202.509995 202.699905 202.699905 5299727 0.0 0.0 False 2024-03-01 16:00:00-05:00 202.640000 207.577290 191.905840 202.460000 202.460000 -1 0.0 0.0 False 2024-03-01 17:00:00-05:00 202.455000 202.620000 202.346300 202.400000 202.400000 -1 0.0 0.0 False 2024-03-01 18:00:00-05:00 202.440000 202.500000 202.250000 202.330000 202.330000 -1 0.0 0.0 False 2024-03-01 19:00:00-05:00 202.450000 202.600000 202.250000 202.270000 202.270000 -1 0.0 0.0 False 2024-03-04 04:00:00-05:00 201.690000 202.500000 198.210000 198.950000 198.950000 -1 0.0 0.0 False 2024-03-04 05:00:00-05:00 198.910000 200.200000 198.900000 199.520000 199.520000 -1 0.0 0.0 False 2024-03-04 06:00:00-05:00 199.480000 199.890000 199.260000 199.480000 199.480000 -1 0.0 0.0 False 2024-03-04 07:00:00-05:00 199.480000 200.799000 199.250000 199.760000 199.760000 -1 0.0 0.0 False 2024-03-04 08:00:00-05:00 199.700000 202.500000 198.469000 199.960000 199.960000 -1 0.0 0.0 False DEBUG Fetching 30m prepost=True 2024-02-27->2024-03-06 DEBUG Entering history() DEBUG TSLA: Yahoo GET parameters: {'period1': '2024-02-27 00:00:00-05:00', 'period2': '2024-03-06 00:00:00-05:00', 'interval': '15m', 'includePrePost': True, 'events': 'div,splits,capitalGains'} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/TSLA DEBUG params={'period1': 1709010000, 'period2': 1709701200, 'interval': '15m', 'includePrePost': True, 'events': 'div,splits,capitalGains'} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG reusing cookie DEBUG reusing crumb DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() DEBUG TSLA: yfinance received OHLC data: 2024-02-27 09:00:00 -> 2024-03-04 13:30:00 DEBUG TSLA: resampling 30m OHLC from 15m DEBUG TSLA: OHLC after cleaning: 2024-02-27 04:00:00-05:00 -> 2024-03-04 08:30:00-05:00 DEBUG TSLA: OHLC after combining events: 2024-02-27 04:00:00-05:00 -> 2024-03-04 08:30:00-05:00 DEBUG TSLA: checking OHLC for repairs ... DEBUG Entering _fix_unit_mixups() DEBUG Entering _fix_unit_switch() DEBUG Entering _fix_prices_sudden_change() DEBUG price-repair-split: appears_suspended=False, idx_latest_active=0 (2024-03-04) INFO price-repair-split: No 100x errors detected DEBUG Exiting _fix_prices_sudden_change() DEBUG Exiting _fix_unit_switch() DEBUG Entering _fix_unit_random_mixups() INFO price-repair-100x: No sporadic 100x errors DEBUG Exiting _fix_unit_random_mixups() DEBUG Exiting _fix_unit_mixups() DEBUG Entering _fix_bad_stock_split() DEBUG Exiting _fix_bad_stock_split() DEBUG Entering _fix_zeroes() DEBUG Entering _reconstruct_intervals_batch() DEBUG TSLA: Price repair has hit max depth of 2 ('1d'->'1h'->'30m') DEBUG Exiting _reconstruct_intervals_batch() DEBUG Exiting _fix_zeroes() DEBUG Entering _fix_missing_div_adjust() DEBUG Exiting _fix_missing_div_adjust() DEBUG TSLA: yfinance returning OHLC: 2024-02-27 04:00:00-05:00 -> 2024-03-04 08:30:00-05:00 DEBUG Exiting history() DEBUG df_new: Open Close Adj Close Low High Dividends Volume 2024-02-28 04:00:00-05:00 200.000000 199.610000 199.610000 199.110000 201.450000 0.0 0 2024-02-28 05:00:00-05:00 199.610000 200.030000 200.030000 199.500000 200.250000 0.0 0 2024-02-28 06:00:00-05:00 200.080000 200.300000 200.300000 199.890000 200.580000 0.0 0 2024-02-28 07:00:00-05:00 200.290000 200.280000 200.280000 200.060000 200.870000 0.0 0 2024-02-28 08:00:00-05:00 200.290000 200.850000 200.850000 198.710000 205.235000 0.0 0 2024-02-28 09:00:00-05:00 200.850000 200.204000 200.204000 199.950000 200.950000 0.0 0 2024-02-28 09:30:00-05:00 200.929993 202.750000 202.750000 198.440002 203.330002 0.0 30192577 2024-02-28 10:30:00-05:00 202.757996 205.119995 205.119995 202.429993 205.199997 0.0 20692187 2024-02-28 11:30:00-05:00 205.130005 203.259995 203.259995 202.940002 205.300003 0.0 12857169 2024-02-28 12:30:00-05:00 203.270004 202.800095 202.800095 202.419998 203.750000 0.0 9438532 2024-02-28 13:30:00-05:00 202.820007 202.164993 202.164993 202.149994 203.729996 0.0 9291830 2024-02-28 14:30:00-05:00 202.166901 202.051300 202.051300 201.300003 202.439896 0.0 9589475 2024-02-28 15:30:00-05:00 202.061401 202.149994 202.149994 201.660095 202.410004 0.0 4898985 2024-02-28 16:00:00-05:00 202.040000 200.860000 200.860000 188.837390 204.969280 0.0 0 2024-02-28 17:00:00-05:00 200.890000 200.790000 200.790000 200.280000 202.040000 0.0 0 2024-02-28 18:00:00-05:00 200.780000 201.210000 201.210000 200.650000 201.290000 0.0 0 2024-02-29 04:00:00-05:00 201.390000 202.270000 202.270000 201.130000 202.740000 0.0 0 2024-02-29 05:00:00-05:00 202.240000 201.920000 201.920000 201.600000 202.290000 0.0 0 2024-02-29 06:00:00-05:00 201.890000 202.450000 202.450000 201.790000 202.590000 0.0 0 2024-02-29 07:00:00-05:00 202.450000 201.590000 201.590000 201.450000 202.500000 0.0 0 2024-02-29 08:00:00-05:00 202.250000 204.200900 204.200900 199.145000 204.880000 0.0 0 2024-02-29 09:00:00-05:00 204.250000 204.520000 204.520000 204.210000 204.800000 0.0 0 2024-02-29 09:30:00-05:00 205.020004 202.039993 202.039993 200.500000 205.029907 0.0 28276200 2024-02-29 10:30:00-05:00 202.031998 199.669998 199.669998 199.509995 202.220001 0.0 14655480 2024-02-29 11:30:00-05:00 199.656006 199.570007 199.570007 198.446304 200.419998 0.0 10060500 2024-02-29 12:30:00-05:00 199.570007 200.610001 200.610001 199.509995 200.869995 0.0 6074078 2024-02-29 13:30:00-05:00 200.619995 200.054001 200.054001 199.830093 201.059998 0.0 6668995 2024-02-29 14:30:00-05:00 200.050003 200.863998 200.863998 199.990005 201.250000 0.0 5775801 2024-02-29 15:30:00-05:00 200.865005 201.750000 201.750000 200.740005 202.190002 0.0 6496202 2024-02-29 16:00:00-05:00 201.880000 200.450000 200.450000 195.216000 212.744540 0.0 0 2024-02-29 17:00:00-05:00 200.500000 200.480000 200.480000 199.880000 201.880000 0.0 0 2024-02-29 18:00:00-05:00 200.450000 200.420000 200.420000 200.100000 200.700000 0.0 0 2024-03-01 04:00:00-05:00 201.950000 201.410000 201.410000 200.940000 202.000000 0.0 0 2024-03-01 05:00:00-05:00 201.410000 200.730000 200.730000 200.000000 201.520000 0.0 0 2024-03-01 06:00:00-05:00 200.700000 200.970000 200.970000 200.220000 201.290000 0.0 0 2024-03-01 07:00:00-05:00 200.960000 200.960000 200.960000 200.400000 201.280000 0.0 0 2024-03-01 08:00:00-05:00 200.960000 201.420000 201.420000 200.131500 202.780000 0.0 0 2024-03-01 09:00:00-05:00 201.440000 200.870000 200.870000 200.700000 201.880000 0.0 0 2024-03-01 09:30:00-05:00 200.250000 199.557999 199.557999 198.500000 201.460007 0.0 15958936 2024-03-01 10:30:00-05:00 199.559998 200.860001 200.860001 198.910004 200.990005 0.0 17865566 2024-03-01 11:30:00-05:00 200.866806 202.445007 202.445007 200.520004 202.679993 0.0 11235160 2024-03-01 12:30:00-05:00 202.460007 204.270004 204.270004 202.169998 204.429993 0.0 10961678 2024-03-01 13:30:00-05:00 204.279999 203.580002 203.580002 203.020004 204.520004 0.0 9969421 2024-03-01 14:30:00-05:00 203.570007 203.329895 203.329895 202.470001 203.800003 0.0 8269849 2024-03-01 15:30:00-05:00 203.320007 202.699905 202.699905 202.509995 203.389999 0.0 5299727 2024-03-01 16:00:00-05:00 202.640000 202.460000 202.460000 191.905840 207.577290 0.0 0 2024-03-01 17:00:00-05:00 202.455000 202.400000 202.400000 202.346300 202.620000 0.0 0 2024-03-01 18:00:00-05:00 202.440000 202.330000 202.330000 202.250000 202.500000 0.0 0 2024-03-01 19:00:00-05:00 202.450000 202.270000 202.270000 202.250000 202.600000 0.0 0 2024-03-04 04:00:00-05:00 201.690000 198.950000 198.950000 198.210000 202.500000 0.0 0 2024-03-04 05:00:00-05:00 198.910000 199.520000 199.520000 198.900000 200.200000 0.0 0 2024-03-04 06:00:00-05:00 199.480000 199.480000 199.480000 199.260000 199.890000 0.0 0 2024-03-04 07:00:00-05:00 199.480000 199.760000 199.760000 199.250000 200.799000 0.0 0 2024-03-04 08:00:00-05:00 199.700000 199.960000 199.960000 198.469000 202.500000 0.0 0 DEBUG Price calibration ratio (raw) = 0.999884 DEBUG Exiting _reconstruct_intervals_batch() INFO price-repair-missing: TSLA: fixed 33/33 value=0 errors in 1h price data DEBUG Exiting _fix_zeroes() DEBUG Entering _fix_missing_div_adjust() DEBUG Exiting _fix_missing_div_adjust() DEBUG TSLA: yfinance returning OHLC: 2024-02-28 04:00:00-05:00 -> 2024-03-04 08:00:00-05:00 DEBUG Exiting history() DEBUG df_new: Open Close Adj Close Low High Dividends Volume Day Start
2024-02-29 00:00:00-05:00 201.39 200.42 200.42 195.21600 212.74454 0.0 78007256 2024-03-01 00:00:00-05:00 201.95 202.27 202.27 191.90584 207.57729 0.0 79560337 2024-03-04 00:00:00-05:00 201.69 199.96 199.96 198.21000 202.50000 0.0 0 DEBUG Price calibration ratio (raw) = 1.003772 DEBUG Exiting _reconstruct_intervals_batch() INFO price-repair-missing: TSLA: fixed 6/6 value=0 errors in 1d price data DEBUG Exiting _fix_zeroes() DEBUG Entering _fix_missing_div_adjust() DEBUG div-adjust-repair: No dividends to check DEBUG Exiting _fix_missing_div_adjust() DEBUG TSLA: yfinance returning OHLC: 2022-03-07 00:00:00-05:00 -> 2024-03-04 00:00:00-05:00 DEBUG Exiting history() DEBUG Exiting history() Open High Low Close Adj Close Volume Dividends Stock Splits Repaired? Date
2022-08-23 00:00:00-04:00 291.453339 298.826660 287.923340 296.453339 296.453339 63984900 0.0 0.0 False 2022-08-24 00:00:00-04:00 297.563324 303.646667 296.500000 297.096680 297.096680 57259800 0.0 0.0 False 2022-08-25 00:00:00-04:00 302.359985 302.959991 291.600006 296.070007 296.070007 53230000 0.0 0.0 False 2022-08-26 00:00:00-04:00 297.429993 302.000000 287.470001 288.089996 288.089996 57163900 0.0 0.0 False

Bad data proof

No response

yfinance version

0.2.37

Python version

3.11.7

Operating system

WSL2

ValueRaider commented 8 months ago

I can't reproduce. What happens if you disable repair?

eiphy commented 8 months ago

Hi @ValueRaider , thank you for looking into this! I have tried to use disable repare but it doesn't help. Will it have anything to do with regions? Previously, there's a issue that .meta() does not work in regions outside of US. image

ValueRaider commented 8 months ago

No idea. Repost debug log with repair disabled, it'll be a lot shorter.

eiphy commented 8 months ago

Hi @ValueRaider , the debug log: DEBUG Entering history() DEBUG Entering history() DEBUG TSLA: Yahoo GET parameters: {'period1': '2022-08-24 00:00:00-04:00', 'period2': '2022-08-26 00:00:00-04:00', 'interval': '1h', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/TSLA DEBUG params=frozendict.frozendict({'period1': 1661313600, 'period2': 1661486400, 'interval': '1h', 'includePrePost': False, 'events': 'div,splits,capitalGains'}) DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG fetched basic cookie = <Cookie A3=d=AQABBH-q52UCEM9bsfeRx5Pjn08Qms8drhcFEgEBAQH76GXxZa9D8HgB_eMAAA&S=AQAAAlIL0WVAezo1MqRv5bitsfE for .yahoo.com/> DEBUG reusing cookie DEBUG crumb = 'cKaZy.sBWM0' DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() DEBUG TSLA: yfinance received OHLC data: 2022-08-24 13:30:00 -> 2022-08-25 19:30:00 DEBUG TSLA: OHLC after cleaning: 2022-08-24 09:30:00-04:00 -> 2022-08-25 15:30:00-04:00 DEBUG TSLA: OHLC after combining events: 2022-08-24 09:30:00-04:00 -> 2022-08-25 15:30:00-04:00 DEBUG TSLA: yfinance returning OHLC: 2022-08-24 09:30:00-04:00 -> 2022-08-25 15:30:00-04:00 DEBUG Exiting history() DEBUG Exiting history() Open High Low Close Adj Close Volume Dividends Stock Splits Datetime
2022-08-24 09:30:00-04:00 892.690002 910.940002 891.049988 907.104614 907.104614 7021349 0.0 0.0 2022-08-24 10:30:00-04:00 907.572998 908.400024 901.059998 904.039978 904.039978 2737542 0.0 0.0 2022-08-24 11:30:00-04:00 904.260010 907.559998 902.119995 905.380005 905.380005 1554554 0.0 0.0 2022-08-24 12:30:00-04:00 905.340027 906.400024 895.479980 896.107727 896.107727 1997977 0.0 0.0 2022-08-24 13:30:00-04:00 895.940002 900.309998 895.340027 897.099976 897.099976 1378497 0.0 0.0 2022-08-24 14:30:00-04:00 897.049988 897.340027 889.500000 892.789978 892.789978 2078101 0.0 0.0 2022-08-24 15:30:00-04:00 892.775024 894.979980 890.000000 891.450012 891.450012 1366247 0.0 0.0 2022-08-25 09:30:00-04:00 302.359985 302.959991 293.140106 297.492096 297.492096 20100512 0.0 0.0 2022-08-25 10:30:00-04:00 297.549988 298.089996 291.600006 293.070007 293.070007 9438207 0.0 0.0 2022-08-25 11:30:00-04:00 293.149994 294.980011 291.920105 293.850098 293.850098 5161989 0.0 0.0 2022-08-25 12:30:00-04:00 293.950012 295.692993 292.799988 294.836609 294.836609 4205521 0.0 0.0 2022-08-25 13:30:00-04:00 294.837799 295.640686 293.114288 293.309998 293.309998 3702607 0.0 0.0 2022-08-25 14:30:00-04:00 293.380005 293.679993 291.799988 293.440002 293.440002 4667132 0.0 0.0 2022-08-25 15:30:00-04:00 293.427612 296.149994 293.021088 296.109985 296.109985 4241512 0.0 0.0 DEBUG Entering history() DEBUG Entering history() DEBUG TSLA: Yahoo GET parameters: {'period1': '2022-08-24 00:00:00-04:00', 'period2': '2022-08-26 00:00:00-04:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/TSLA DEBUG params=frozendict.frozendict({'period1': 1661313600, 'period2': 1661486400, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}) DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG reusing cookie DEBUG reusing crumb DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() DEBUG TSLA: yfinance received OHLC data: 2022-08-24 13:30:00 -> 2022-08-25 13:30:00 DEBUG TSLA: OHLC after cleaning: 2022-08-24 09:30:00-04:00 -> 2022-08-25 09:30:00-04:00 DEBUG TSLA: OHLC after combining events: 2022-08-24 00:00:00-04:00 -> 2022-08-25 00:00:00-04:00 DEBUG TSLA: yfinance returning OHLC: 2022-08-24 00:00:00-04:00 -> 2022-08-25 00:00:00-04:00 DEBUG Exiting history() DEBUG Exiting history() Open High Low Close Adj Close Volume Dividends Stock Splits Date
2022-08-24 00:00:00-04:00 297.563324 303.646667 296.500000 297.096680 297.096680 57259800 0.0 0.0 2022-08-25 00:00:00-04:00 302.359985 302.959991 291.600006 296.070007 296.070007 53230000 0.0 0.0

eiphy commented 8 months ago

The log said "v8" in the url. Is this correct version?