df['timestamp'] = pd.to_datetime(df['timestamp'])
df = df.set_index(['timestamp'])
self.kijun_m15 = self.I(Kijun, self.data.High, self.data.Low)
self.kijun_h1 = resample_apply('H', Kijun, self.data.High, self.data.Low)
self.kijun_h4 = resample_apply('4H', Kijun, self.data.High, self.data.Low)
Any idea on what it could mean? I know it's a pandas error but I'm kind of lost here
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1860 try:
-> 1861 values, tz_parsed = conversion.datetime_to_datetime64(data)
1862 # If tzaware, these values represent unix timestamps, so we
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.datetime_to_datetime64()
TypeError: Unrecognized value type: <class 'int'>
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-114-2634449b147c> in <module>
2
3 bt = Backtest(df_backtest, Ichimoku, cash=10000, commission=.00015)
----> 4 bt.run()
~\Anaconda3\envs\Machine Learning\lib\site-packages\backtesting\backtesting.py in run(self, **kwargs)
673 strategy._set_params(**kwargs)
674
--> 675 strategy.init()
676 indicator_attrs = {attr: indicator
677 for attr, indicator in strategy.__dict__.items()
<ipython-input-113-8506b452361b> in init(self)
13
14 #H1
---> 15 self.kijun_h1 = resample_apply('H', Kijun, self.data.High, self.data.Low)
16 self.tenkan_h1 = resample_apply('H', Tenkan, self.data.High, self.data.Low)
17 self.senkou_a_h1 = resample_apply('H', SenkouA, self.data.High, self.data.Low)
~\Anaconda3\envs\Machine Learning\lib\site-packages\backtesting\lib.py in resample_apply(rule, func, series, *args, **kwargs)
228 wrap_func.__name__ = func.__name__
229
--> 230 array = strategy_I(wrap_func, resampled, *args, **kwargs)
231 return array
232
~\Anaconda3\envs\Machine Learning\lib\site-packages\backtesting\backtesting.py in I(self, func, name, plot, overlay, color, *args, **kwargs)
122 **dict(zip(kwargs.keys(), map(_as_str, kwargs.values()))))
123
--> 124 value = func(*args, **kwargs)
125
126 try:
~\Anaconda3\envs\Machine Learning\lib\site-packages\backtesting\lib.py in wrap_func(resampled, *args, **kwargs)
222 def wrap_func(resampled, *args, **kwargs):
223 ind = func(resampled, *args, **kwargs)
--> 224 ind = ind.reindex(index=series.index | ind.index,
225 method='ffill').reindex(series.index)
226 return ind
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\indexes\base.py in __or__(self, other)
2221
2222 def __or__(self, other):
-> 2223 return self.union(other)
2224
2225 def __xor__(self, other):
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\indexes\datetimes.py in union(self, other)
482 if not isinstance(other, DatetimeIndex):
483 try:
--> 484 other = DatetimeIndex(other)
485 except TypeError:
486 pass
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\indexes\datetimes.py in __new__(cls, data, freq, start, end, periods, tz, normalize, closed, ambiguous, dayfirst, yearfirst, dtype, copy, name, verify_integrity)
301 data, dtype=dtype, copy=copy, tz=tz, freq=freq,
302 dayfirst=dayfirst, yearfirst=yearfirst, ambiguous=ambiguous,
--> 303 int_as_wall_time=True)
304
305 subarr = cls._simple_new(dtarr, name=name,
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\arrays\datetimes.py in _from_sequence(cls, data, dtype, copy, tz, freq, dayfirst, yearfirst, ambiguous, int_as_wall_time)
374 data, dtype=dtype, copy=copy, tz=tz,
375 dayfirst=dayfirst, yearfirst=yearfirst,
--> 376 ambiguous=ambiguous, int_as_wall_time=int_as_wall_time)
377
378 freq, freq_infer = dtl.validate_inferred_freq(freq, inferred_freq,
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\arrays\datetimes.py in sequence_to_dt64ns(data, dtype, copy, tz, dayfirst, yearfirst, ambiguous, int_as_wall_time)
1755 # or M8[ns] to denote wall times
1756 data, inferred_tz = objects_to_datetime64ns(
-> 1757 data, dayfirst=dayfirst, yearfirst=yearfirst)
1758 tz = maybe_infer_tz(tz, inferred_tz)
1759 # When a sequence of timestamp objects is passed, we always
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1864 return values.view('i8'), tz_parsed
1865 except (ValueError, TypeError):
-> 1866 raise e
1867
1868 if tz_parsed is not None:
~\Anaconda3\envs\Machine Learning\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1855 dayfirst=dayfirst,
1856 yearfirst=yearfirst,
-> 1857 require_iso8601=require_iso8601
1858 )
1859 except ValueError as e:
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
ValueError: mixed datetimes and integers in passed array