diff --git a/backtesting/_plotting.py b/backtesting/_plotting.py index 5e1b1a2b..844318aa 100644 --- a/backtesting/_plotting.py +++ b/backtesting/_plotting.py @@ -145,7 +145,7 @@ def f(s, new_index=pd.Index(df.index.view(int)), bars=trades[column]): if s.size: # Via int64 because on pandas recently broken datetime mean_time = int(bars.loc[s.index].view(int).mean()) - new_bar_idx = new_index.get_loc(mean_time, method='nearest') + new_bar_idx = new_index.get_indexer([mean_time], method='nearest')[0] return new_bar_idx return f