mirror of
https://github.com/kernc/backtesting.py.git
synced 2024-01-28 15:29:30 +03:00
MNT: Adapt for pandas 1.0.0 (bug workaround + two depr warnings)
This commit is contained in:
@@ -33,10 +33,7 @@ def _as_list(value):
|
||||
|
||||
def _data_period(df):
|
||||
"""Return data index period as pd.Timedelta"""
|
||||
if df.index.is_all_dates:
|
||||
values = df.index[:100].to_series(keep_tz=True)
|
||||
else:
|
||||
values = df.index[:100].to_series()
|
||||
values = df.index[-100:].to_series()
|
||||
return values.diff().median()
|
||||
|
||||
|
||||
|
||||
@@ -896,7 +896,7 @@ class Backtest:
|
||||
resolution = getattr(_period, 'resolution_string', None) or _period.resolution
|
||||
return value.ceil(resolution)
|
||||
|
||||
s = pd.Series()
|
||||
s = pd.Series(dtype=object)
|
||||
s.loc['Start'] = df.index[0]
|
||||
s.loc['End'] = df.index[-1]
|
||||
s.loc['Duration'] = s.End - s.Start
|
||||
|
||||
@@ -209,6 +209,7 @@ def resample_apply(rule: str,
|
||||
'or a `Strategy.data.*` array'
|
||||
series = series.to_series()
|
||||
|
||||
series = series.copy() # XXX: pandas 1.0.1 bug https://github.com/pandas-dev/pandas/issues/31710
|
||||
resampled = series.resample(rule, label='right').agg(agg).dropna()
|
||||
resampled.name = _as_str(series) + '[' + rule + ']'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user