Skip to content

Commit bd32769

Browse files
committed
Prices: bugfix for merging intraday with divs/splits
1 parent 99b2db6 commit bd32769

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

yfinance/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,13 @@ def safe_merge_dfs(df_main, df_sub, interval):
750750
if df_sub.empty:
751751
df_main['Dividends'] = 0.0
752752
return df_main
753+
754+
# df_sub changed so recalc indices:
755+
df_main['_date'] = df_main.index.date
756+
df_sub['_date'] = df_sub.index.date
757+
indices = _np.searchsorted(_np.append(df_main['_date'], [df_main['_date'].iloc[-1]+td]), df_sub['_date'], side='left')
758+
df_main = df_main.drop('_date', axis=1)
759+
df_sub = df_sub.drop('_date', axis=1)
753760
else:
754761
empty_row_data = {**{c:[_np.nan] for c in const._PRICE_COLNAMES_}, 'Volume':[0]}
755762
if interval == '1d':

0 commit comments

Comments
 (0)