Oanda and resampling
-
Sorry folks but a second post with the same title - a related problem.
I am sporadically getting this error:
Traceback (most recent call last): File "anz48-notify.py", line 369, in <module> runstrategy( ) File "anz48-notify.py", line 303, in runstrategy cycles = cerebro.run() File "/home/lallen/.local/lib/python3.6/site-packages/backtrader/cerebro.py", line 1127, in run runstrat = self.runstrategies(iterstrat) File "/home/lallen/.local/lib/python3.6/site-packages/backtrader/cerebro.py", line 1298, in runstrategies self._runnext(runstrats) File "/home/lallen/.local/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
I have seen this error reported a couple of times here, but in those cases the problem was determined to be the program was not identifying the timeframe in the underlying datafeed. But I am doing so:
import btoandav20 ... cerebro = bt.Cerebro() broker = BrokerCls( token='my token', account='my account', practice=False ) cerebro.setbroker(broker) DataFactory = DataCls data = DataFactory( dataname='EUR_USD', timeframe=bt.TimeFrame.Minutes, compression=5 ) cerebro.adddata(data) cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=60, rightedge=True) cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=180, rightedge=True) cerebro.addstrategy(TestStrategy) cycles = cerebro.run()
The really weird part is, this is sporadic. The program runs fine for hours and then fails with this error. Or it runs fine on some currency pairs and fails on others.
-
@leecallen said in Oanda and resampling:
The really weird part is, this is sporadic. The program runs fine for hours and then fails with this error. Or it runs fine on some currency pairs and fails on others.
Edit:
The really weird part is, this is sporadic.
The program runs fine for hours and then fails with this error. OrIt runs fine on some currency pairs and fails on others. -
I need to edit that remark again. I am running 16 instances of my program against different forex currency pairs. Eventually all of them fail with this error. Most of them get through the backfill data and at least a few bars into live data before they fail.
I could really use some advice on this, I can't figure out a workaround.
-
This issue was discussed several times on this forum already - although no real fix was provided AFAIK - there were few hacks that 'fixed' the symptom though.
Please see the following posts:
https://community.backtrader.com/topic/26/example-of-adding-live-data-to-static-in-strategy (this is a long thread)
https://community.backtrader.com/topic/2996/live-trading-data-ib-issueNot sure I fully understand the problem, but it looks like a bug to me. Will try to find a time to investigate it further.
-
Thank you, I am going to try dasch's "ugly solution"
-
@vladisld that change seems to be working fine for me. Thank you.