@@ -61,7 +61,7 @@ def test_resampling(self):
6161 vol_diff_pct0 = (dfr ['Volume' ].iloc [0 ] - df_truth ['Volume' ].iloc [0 ])/ df_truth ['Volume' ].iloc [0 ]
6262 vol_diff_pct1 = (dfr ['Volume' ].iloc [- 1 ] - df_truth ['Volume' ].iloc [- 1 ])/ df_truth ['Volume' ].iloc [- 1 ]
6363 vol_diff_pct = _np .array ([vol_diff_pct0 , vol_diff_pct1 ])
64- vol_match = vol_diff_pct > - 0.23
64+ vol_match = vol_diff_pct > - 0.32
6565 vol_match_nmatch = _np .sum (vol_match )
6666 vol_match_ndiff = len (vol_match ) - vol_match_nmatch
6767 if vol_match .all ():
@@ -78,6 +78,8 @@ def test_resampling(self):
7878
7979 if debug :
8080 print ("- investigate:" )
81+ print (f" - interval = { interval } " )
82+ print (f" - period = { period } " )
8183 print ("- df_truth:" )
8284 print (df_truth )#[['Open', 'Close', 'Volume']])
8385 df_1d = dat .history (interval = '1d' , period = period )
@@ -361,27 +363,23 @@ def test_repair_zeroes_daily(self):
361363 hist = dat ._lazy_load_price_history ()
362364 tz_exchange = dat .fast_info ["timezone" ]
363365
364- df_bad = _pd .DataFrame (data = {"Open" : [0 , 114.37 , 114.20 ],
365- "High" : [0 , 114.40 , 114.40 ],
366- "Low" : [0 , 114.36 , 114.20 ],
367- "Close" : [114.39 , 114.38 , 114.45 ],
368- "Adj Close" : [114.39 , 114.38 , 114.45 ],
369- "Volume" : [9 , 15666 , 1094 ]},
370- index = _pd .to_datetime ([_dt .datetime (2025 , 3 , 17 ),
371- _dt .datetime (2025 , 3 , 14 ),
372- _dt .datetime (2025 , 3 , 13 )]))
373- df_bad = df_bad .sort_index ()
374- df_bad .index .name = "Date"
375- df_bad .index = df_bad .index .tz_localize (tz_exchange )
366+ correct_df = dat .history (period = '1mo' , auto_adjust = False )
367+
368+ dt_bad = correct_df .index [len (correct_df )// 2 ]
369+ df_bad = correct_df .copy ()
370+ for c in df_bad .columns :
371+ df_bad .loc [dt_bad , c ] = _np .nan
376372
377373 repaired_df = hist ._fix_zeroes (df_bad , "1d" , tz_exchange , prepost = False )
378374
379- correct_df = df_bad .copy ()
380- correct_df .loc ["2025-03-17" , "Open" ] = 114.62
381- correct_df .loc ["2025-03-17" , "High" ] = 114.62
382- correct_df .loc ["2025-03-17" , "Low" ] = 114.41
383375 for c in ["Open" , "Low" , "High" , "Close" ]:
384- self .assertTrue (_np .isclose (repaired_df [c ], correct_df [c ], rtol = 1e-7 ).all ())
376+ try :
377+ self .assertTrue (_np .isclose (repaired_df [c ], correct_df [c ], rtol = 1e-7 ).all ())
378+ except Exception :
379+ print (f"# column = { c } " )
380+ print ("# correct:" ) ; print (correct_df [c ])
381+ print ("# repaired:" ) ; print (repaired_df [c ])
382+ raise
385383
386384 self .assertTrue ("Repaired?" in repaired_df .columns )
387385 self .assertFalse (repaired_df ["Repaired?" ].isna ().any ())
@@ -421,7 +419,13 @@ def test_repair_zeroes_daily_adjClose(self):
421419
422420 df_slice_bad_repaired = hist ._fix_zeroes (df_slice_bad , "1d" , tz_exchange , prepost = False )
423421 for c in ["Close" , "Adj Close" ]:
424- self .assertTrue (_np .isclose (df_slice_bad_repaired [c ], df_slice [c ], rtol = rtol ).all ())
422+ try :
423+ self .assertTrue (_np .isclose (df_slice_bad_repaired [c ], df_slice [c ], rtol = rtol ).all ())
424+ except Exception :
425+ print (f"# column = { c } " )
426+ print ("# correct:" ) ; print (df_slice [c ])
427+ print ("# repaired:" ) ; print (df_slice_bad_repaired [c ])
428+ raise
425429 self .assertTrue ("Repaired?" in df_slice_bad_repaired .columns )
426430 self .assertFalse (df_slice_bad_repaired ["Repaired?" ].isna ().any ())
427431
@@ -464,7 +468,7 @@ def test_repair_bad_stock_splits(self):
464468 # Stocks that split in 2022 but no problems in Yahoo data,
465469 # so repair should change nothing
466470 good_tkrs = ['AMZN' , 'DXCM' , 'FTNT' , 'GOOG' , 'GME' , 'PANW' , 'SHOP' , 'TSLA' ]
467- good_tkrs += ['AEI' , 'GHI' , 'IRON' , 'LXU' , 'RSLS' , ' TISI' ]
471+ good_tkrs += ['AEI' , 'GHI' , 'IRON' , 'LXU' , 'TISI' ]
468472 good_tkrs += ['BOL.ST' , 'TUI1.DE' ]
469473 intervals = ['1d' , '1wk' , '1mo' , '3mo' ]
470474 for tkr in good_tkrs :
@@ -589,7 +593,6 @@ def test_repair_bad_div_adjusts(self):
589593
590594 # Div 0.01x
591595 bad_tkrs += ['NVT.L' ]
592- bad_tkrs += ['TENT.L' ]
593596
594597 # Missing div adjusts:
595598 bad_tkrs += ['1398.HK' ]
0 commit comments