oandav20 resampling from 15m to 4h shows extra bars.
-
I'm using oandav20 and resampling from 15m up to 4h and the 1D. The problem is in 4h chart data I see non-aligned bars and it looks like the time axis is broken:
I've tried various combinations of the bar2edge and rightedge and adjbartime flags but still has the problem. I've also tried shifting the sessionstart but the daily chart needs this to be at 23 (aligning with broker time).
When I search through the data dump (using the writer) I see extra bars coming out of the resampling aligning to the yellow arrows:
2020-05-14 00:00:00 2020-05-14 04:00:00 2020-05-14 08:00:00 2020-05-14 12:00:00 2020-05-14 13:45:00. <-- what? 2020-05-14 16:00:00 2020-05-14 20:00:00 ... 2020-05-19 04:00:00 2020-05-19 08:00:00 2020-05-19 11:15:00 <-- what? 2020-05-19 12:00:00
any pointer appreciated, I've been a coder for 15 years so hit me with the hardcore detail if needed
Here's my setup, if this is of help. Cheers
datakwargs = dict( timeframe=bt.TimeFrame.Minutes, compression=15, stream_timeout=60, historical=args.historical, fromdate=fromdate, tz=args.timezone, backfill_start=True, backfill=True, sessionstart=datetime.time(23, 00), #oanda uses singapore time so 23 in BST. sessionend=datetime.time(23, 00) ) rekwargs4h = dict( timeframe=bt.TimeFrame.Minutes, compression=240, bar2edge=False, adjbartime=False, rightedge=False, takelate=False ) rekwargs1d = dict( timeframe=bt.TimeFrame.Days, compression=1, bar2edge=False, adjbartime=False, rightedge=False, takelate=False ) #Loop through the list adding to cerebro. for i in range(len(datalist)): data = DataFactory(dataname=datalist[i], **datakwargs) # enabling this seems to break daily graph cerebro.resampledata(data, name=datalist[i], timeframe=datakwargs['timeframe'], compression=datakwargs['compression']) cerebro.resampledata(data, name=datalist[i], **rekwargs4h) # day cerebro.resampledata(data, name=datalist[i], **rekwargs1d) config = dict() ``
-
ok I've moved this to the right topic, admins feel free to delete
-
this may be due to the sessionend value and the first time you receive a data update. but this is just a guess. If this does not appear without the session end value, investigate this.
-
Can you provide the entire source code or a link to it?
-
These two settings:
sessionstart=datetime.time(23, 00), #oanda uses singapore time so 23 in BST.
sessionend=datetime.time(23, 00) -
@dasch How are we supposed to get data in different timeframe like 30mins or 1h rather than 1d which is a default.
-
Use compression, as above, compression 1 for 1 minute bars if you wish, as below:
timeframe=bt.TimeFrame.Minutes, compression=barsize, useRTH=False, #outsideRth=True, fill orders outside rth -- use for orders, not here... sessionstart=datetime.time(9, 30, 0), sessionend=datetime.time(16, 30, 0),
...and then your adddata or resample line using these arguments.
-
@bigdavediode Thanks sir!!! I had a lot of problem because forgot use this parameter in my custom data feed!