mirror of
https://github.com/kernc/backtesting.py.git
synced 2024-01-28 15:29:30 +03:00
@@ -26,7 +26,11 @@ def _as_list(value):
|
||||
|
||||
def _data_period(df):
|
||||
"""Return data index period as pd.Timedelta"""
|
||||
return df.index[:100].to_series(keep_tz=True).diff().median()
|
||||
if df.index.is_all_dates:
|
||||
values = df.index[:100].to_series(keep_tz=True)
|
||||
else:
|
||||
values = df.index[:100].to_series()
|
||||
return values.diff().median()
|
||||
|
||||
|
||||
class _Array(np.ndarray):
|
||||
|
||||
@@ -870,8 +870,7 @@ class Backtest:
|
||||
df['Drawdown Duration'] = dd_dur
|
||||
dd_dur = df['Drawdown Duration']
|
||||
|
||||
# Strip timezone info, otherwise pandas 0.24.2 errors when filling `s` ahead
|
||||
df.index = data.index.tz_convert(None)
|
||||
df.index = data.index
|
||||
|
||||
def _round_timedelta(value, _period=_data_period(df)):
|
||||
if not isinstance(value, pd.Timedelta):
|
||||
|
||||
Reference in New Issue
Block a user