Getting weekly data in next(self) when data source is sparse hourly data
My data source is hourly with many hours missing but I only need weekly data in my custom indicator/strategy. I used timeframe=bt.TimeFrame.Weeks when calling bt.feeds.GenericCSVData(..) but I'm still getting every tick from my hourly data in the next() method, where I only want one value a week (same for my strategy where every data point should be weekly), how can I achieve that? Thanks.
I did use timeframe=bt.TimeFrame.Weeks, still getting every point of data, one after another in the next
ab_trader last edited by ab_trader
@paindemie please show the code. if you call correctly
cerebro.resampledata(data, **kwargs)it should be weekly bars returned.
data = bt.feeds.GenericCSVData( dataname=data_source, fromdate=start, todate=stop, nullvalue=0.0, dtformat=('%Y-%m-%d %H:%M:%S'), tmformat=('%Y-%m-%d %H:%M:%S'), openinterest=-1, timeframe=bt.TimeFrame.Days, compression=1, plot=False) # Create a cerebro entity cerebro = bt.Cerebro(stdstats=True) #cerebro.adddata(data) cerebro.resampledata(data, bt.TimeFrame.Weeks)
in next self.data[-1] is the DAY before self.data where it should be 7 days before if Im not missing smith obvious..
ab_trader last edited by
All examples that I've seen use the following syntax:
resampledatamethod doesn't recognize
timeframein your case.
That won't resample to anything unless you use the right syntax (as pointed out by @ab_trader)
Maybe resampledata method doesn't recognize timeframe in your case.
It doesn't because the
timeframenamed argument is not being provided.
Aaah got it thanks