Hey, folks. I was just wondering if there is away to get rid of this 300sec backtest limit? Everytime when backtest takes more than 300 seconds it stops automatically.
I bought a starter account hoping that it will give me an access to unlimited backtesting but apparently unlimited backtesting means something else.
So, anyways, the question is - how can I backtest complex strategies with long periods?
limit computation time
- use talib instead of strategy api
talib.MA('close_array', 10) # fast
data[PAIR].ma(10) # slow
- use float instead of decimal
Decimal(1)/Decimal(2) # slow
- if you don't need all the data don't call it
data[PAIR].period(2,'close') # fast
data[PAIR].warmup_period('close') # slow
- limit size of lists stored to what is actually needed
my_list = my_list[-10:] # limits size
- limit things that only need to be done when live:
LIVE = False
try: end = info.end
except: LIVE = True
Depending on the strategy you might save 80% of run time doing these things.
The maximum the engine can handle in a single backtest on 5m is 8600 candles; or one month.
Another way around your issue... If you indications are "slow" enough would be to aggregate them.
That is if you're running a 5m 120/240 sma cross as:
if data[PAIR].ma(120) > data[PAIR].ma(240):
You could call that equivalently as:
if data(interval=7200)[PAIR].ma(5) > data(interval=7200)[PAIR].ma(10):
and you could then backtest the algo against 2h candles for an entire year of data; and it would perform functionally the same on 5m candles when deployed live.
In addition to @litepresence comment, are you expecting the backtest to take more than 5 mins? We usually increase the time limits based on trader recommendations, so if you have any estimates let us know.
Any progress on "stopping" a backtest?
Thank you for your recommendations. I will try to optimize my code.
However, I'd suggest in the future to add an account with truly unlimited backtesting capabilities or may be not as a separate account type but as a paid feature. I think it's something worth paying for.
I think it would be helpful to remove the candle limit. For example:
import time as t
storage.start = storage.get('start', t.time())
I can run that for only 1 month on 5m candles due to the candle limit; but it only takes 21 seconds of run time.
[2015-01-30 23:55:00] 8639
[2015-01-30 23:55:00] 21.3093979359
How can I do that?
That's on tradewave's end.
To that regard it would be really helpful if they removed any and all timeperiod limits.
For example... I would REALLY like to backtest vs BOTH the mtgox and btce dataset on 12h. From 2010 to 2012 use mtgox data; post 2012 use btce data; all in one backtest.
But if you select both data sets you're limit to backtest only where they overlap.
Likewise; if I import Quandl data... It would be nice to be able to test an algo against a forex from say 1995 through 2010; but I can't do that because I can't select those time periods from the pulldown menu and there is no manual override.
sorry, I saw your posts so many times, that i decided you are a part of Tradewave
I've been here since pretty early on and they offer me free live trading in exchange for daily tech support in the forums and pioneering the marketplace. I'm otherwise unaffiliated... well I can change thread titles... but that's about it
still, thanks for your help!