Getting errors when using resample
-
I have data in 1H intervals, and I'm trying to resample it to 1D.
My data looks like this:
time open high low close volume 0 2018-07-02 11:00:00 48.89 49.05 48.54 49.03 1792700 1 2018-07-02 12:00:00 49.03 49.19 48.84 49.07 941700 2 2018-07-02 13:00:00 49.07 49.13 48.70 48.90 736600 3 2018-07-02 14:00:00 48.90 48.91 48.70 48.79 534500 4 2018-07-02 15:00:00 48.79 48.81 48.52 48.66 1296200 5 2018-07-02 16:00:00 48.66 48.82 48.61 48.62 910300 6 2018-07-02 17:00:00 48.62 48.86 48.60 48.69 1199300 7 2018-07-02 18:00:00 48.69 48.90 48.68 48.90 811500 8 2018-07-03 11:00:00 49.30 49.49 48.89 48.99 1908400 9 2018-07-03 12:00:00 48.99 49.10 48.45 48.71 2134600
The code that loads it into Cerebro is:
data_hour = btfeeds.PandasData( dataname=df, fromdate=datetime(2018, 7, 3), todate=datetime(2018, 10, 24), datetime=0, open=1, high=2, low=3, close=4, volume=5, openinterest=-1 ) cerebro = bt.Cerebro() cerebro.adddata(data_hour) cerebro.resampledata(data_hour, timeframe=bt.TimeFrame.Weeks, compression=1)
and my
next
function is just apass
.Still, I get the error:
Traceback (most recent call last): File "test.py", line 65, in <module> cerebro.run() File "~/miniconda3/envs/algo_testing/lib/python3.6/site-packages/backtrader/cerebro.py", line 1127, in run runstrat = self.runstrategies(iterstrat) File "~/miniconda3/envs/algo_testing/lib/python3.6/site-packages/backtrader/cerebro.py", line 1298, in runstrategies self._runnext(runstrats) File "~/miniconda3/envs/algo_testing/lib/python3.6/site-packages/backtrader/cerebro.py", line 1557, in _runnext dt0 = min((d for i, d in enumerate(dts) ValueError: min() arg is an empty sequence
When I change my
next
toprint(self.datetime.date(ago=0))
, it prints the dates up to the second to last one, and then it fails.Can anyone help me?
-
@phillbeck said in Getting errors when using resample:
I have data in 1H intervals
Your data may be
1-hour
, but where do you tell the platform that it is so?@phillbeck said in Getting errors when using resample:
data_hour = btfeeds.PandasData( dataname=df, fromdate=datetime(2018, 7, 3), todate=datetime(2018, 10, 24), datetime=0, open=1, high=2, low=3, close=4, volume=5, openinterest=-1 )
There is no artificial intelligence there to parse your data and understand that it is
1-hour
.You should clearly state with the
timeframe
andcompression
parameters what your data is. See Community - FAQ@phillbeck said in Getting errors when using resample:
and I'm trying to resample it to 1D.
Apparently not.
@phillbeck said in Getting errors when using resample:
cerebro.resampledata(data_hour, timeframe=bt.TimeFrame.Weeks, compression=1)