Running strategies on the minute
#1
Hi Mike,

I've noticed that when I backtest my strategies, I can get quite radically different results if my starting hour:min is 00:00 vs something random like 05:22 on the exchange data.

It seems things work best if strategies run on the minute not at some random time halfway through a minute etc. I guess this is because everyone is looking at candles that fit the specific time, so thats how the trends work best.

Also I have 15 min strategies, Ideally these should run every 15mins, so 12:15, 12:30, 12:45 etc.. not 12:09, 12:24, 12:39 or whatever time the strategy was started.

I've noticed this seems to also be a issue with live strategies, where the 15min cycle is from the time the script booted up and decided to start running.. but not necessarily actually 15 mins past hour. Which means the candles my bot is using vary compared to what I see in TradingView.com etc.. so also hard to go back and see whats happened. Ideally it should review the candle at 12:15 and 01 seconds.

Has anyone else had this issue? Is there a way to sync the strategy to run at the right time?

I'm currently running from the command line as a service so the strategy can kick off at any time. And it's annoying to have to wait till it's close to on the hour or 15mins past to start it up and hope it's going to be close enough to the time candles are forming.

Cheers,
Richard.
  Reply
#2
Hi Richard
Never tryed this but the gekko Graph matches pretty close to Kraken. (--ui LiveGekko marketgraph)
Sometime i use the Line-view instead of candle view for to see what it does 
Noticed for example at Binance the line is fixed to 1 minute.
As workaround i choose a moving Average and set the candlesize of my Strat (12min) but its a bit round not straight lines.
  Reply
#3
Hi Richard
I tryed with
22days * 24h = 528h * 60 = 31680 Minutes
When i change the Backtest Time by ONLY one minute i get this:

00:00=20%
00:01=30%
00:02=8%
00:03=6%
00:04=20.8%
00:05=30.8%
00:06=54,5%
00:07=4.3%
00:08=5.3%
00:09=19.8%

Hmm... How does theese Backtest Results change by that much ?!?!!
  Reply
#4
(02-23-2018, 10:50 PM)susitronix Wrote: Hi Richard
I tryed with
22days * 24h = 528h * 60 = 31680 Minutes
When i change the Backtest Time by ONLY one minute i get this:

00:00=20%
00:01=30%
00:02=8%
00:03=6%
00:04=20.8%
00:05=30.8%
00:06=54,5%
00:07=4.3%
00:08=5.3%
00:09=19.8%

Hmm... How does theese Backtest Results change by that much ?!?!!

Yes! This is exactly the issue.
At the moment I always make sure I configure the backtest start time correctly.. e.g. for 5min stratergy always either 00:00 or 00:05 or 00:15 etc.. 

I can handle doing that for Backtesting, but my real concern is with live trading strategies.. It appears to cycle based on the start seconds. At the moment I'm literally counting down the seconds and then hit the go button. Also by the time the strat bot pulls down the warmup history, sends the notification email and gets going this can eat up 5 - 10 seconds (even with local data).. worth noting if you are running a 1 min strategy, this can be a big difference if your strategy is running 10seconds behind the candles.. then takes 20 - 40 seconds to actually do the trade.
  Reply
#5
My guess is your strategies are way over optimized.

Or something is broken.


Edit:

Okay, maybe not. This is really weird.

Now I'm revisiting a thought I had when I first looked at Gekko: why candlesticks?

Candlesticks are a tool for humans to look at. Computers are smarter or at least more accurate. They don't need that sort of representation.
Small timeframes and long moving averages. Hmm.
Then strategies will be more adaptive.
Maybe.
  Reply
#6
Yes, I think you'll find using 1-minute candles and changing all your averages to much larger numbers will help create much more reliable strategies.  Multiply the MA numbers by the number of candles you were using.

I'm not sure that 1-minute candles is the ultimate.  But if you're going to use the candlestick model then it looks like they're the best to auto-trade with.  More testing necessary ...

Give it a try and see what you think.

No more worries about where you start in the data ... And more likely to work better on other data.  Looks like less draw-downs too.
  Reply
#7
I also noticed this on 15 minutes candles. I got results from 1x to 3x by changing the start time.
  Reply
#8
Is this still happening in 0.6.x?

I found something similar a while ago.

Here's what don't get, the candles are stored as 1m in the db so.....

In a backtest starting midway through a candle should change nothing. Is this the case?

In live trading is the 1m candle always calculates as 59 seconds from the 1st second that the strat starts?

Where does all the logic for this sit?
  Reply
#9
I haven't changed anything related to this.

Quote:Hmm... How does theese Backtest Results change by that much ?!?!!
Quote: I also noticed this on 15 minutes candles. I got results from 1x to 3x by changing the start time.

Minor discrepancies are to be expected but this is ridiculous. I will do more investigation on my part.

Quote:In live trading is the 1m candle always calculates as 59 seconds from the 1st second that the strat starts?

No: everything is always rounded to full minutes. But bigger candles (say 20 min) are rounded (per minute) based on what you started it.
  Reply


Forum Jump:


Users browsing this thread: