Skip to content

Commit

Permalink
Fix _reconstruct_intervals_batch() calibration bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ValueRaider committed Dec 19, 2022
1 parent cffdbd4 commit 5e54b92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion yfinance/base.py
Expand Up @@ -559,11 +559,16 @@ def _reconstruct_intervals_batch(self, df, interval, tag=-1):
# Calibrate! Check whether 'df_fine' has different split-adjustment.
# If different, then adjust to match 'df'
df_block_calib = df_block[price_cols]
common_index = df_block_calib.index[df_block_calib.index.isin(df_new.index)]
if len(common_index) == 0:
# Can't calibrate so don't attempt repair
continue
df_new_calib = df_new[df_new.index.isin(common_index)][price_cols]
df_block_calib = df_block_calib[df_block_calib.index.isin(common_index)]
calib_filter = (df_block_calib != tag).to_numpy()
if not calib_filter.any():
# Can't calibrate so don't attempt repair
continue
df_new_calib = df_new[df_new.index.isin(df_block_calib.index)][price_cols]
# Avoid divide-by-zero warnings printing:
df_new_calib = df_new_calib.to_numpy()
df_block_calib = df_block_calib.to_numpy()
Expand Down

0 comments on commit 5e54b92

Please sign in to comment.