Skip to content

Commit

Permalink
Price repair: fix 2x syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ValueRaider committed Jul 18, 2024
1 parent 0681a77 commit c894b9e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ def _fix_unit_random_mixups(self, df, interval, tz_exchange, prepost):
df_orig = df[~f_zeroes] # all row slicing must be applied to both df and df2
else:
df2_zeroes = None
df_orig = df
if df2.shape[0] <= 1:
logger.info("price-repair-100x: Insufficient good data for detecting 100x price errors")
if "Repaired?" not in df.columns:
Expand Down Expand Up @@ -1073,7 +1074,8 @@ def _fix_zeroes(self, df, interval, tz_exchange, prepost):
for i in range(len(price_cols)):
c = price_cols[i]
df2.loc[f_prices_bad[:, i], c] = tag
df2.loc[f_vol_bad, "Volume"] = tag
if f_vol_bad is not None:
df2.loc[f_vol_bad, "Volume"] = tag
# If volume=0 or NaN for bad prices, then tag volume for repair
f_vol_zero_or_nan = (df2["Volume"].to_numpy() == 0) | (df2["Volume"].isna().to_numpy())
df2.loc[f_prices_bad.any(axis=1) & f_vol_zero_or_nan, "Volume"] = tag
Expand Down

0 comments on commit c894b9e

Please sign in to comment.