Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
converting daily to minute strategy and have approximately the same results (GDX,NUGT,DUST pairs)

I try to capture the thinking of a great trader i know who seems to trade the pair DUST/NUGT based on the indicators of GDX or HUI

As long as I test in daily mode: good result and I approximate his results. However, putting it though a minute test makes it terrible. I tried playing with the scheduled time (open, close, open +30min, noon) but it doesnt get the same result.

What time do I need to set the scheduler to mimic daily results in minute mode?

any help appreciated

7 responses

Peter, it's interesting how large the difference is between daily and minutely mode on this algo, there is usually a difference, but not usually so large. When running on daily bars, the algo uses daily close prices, but orders do not fill until the next bar, so there is actually a full day of lag when using daily prices. I can't seem to approximate the daily results with minute data either. Maybe you can lag the minutely data by a full day, but then you are trying to fit the data to algorithm, which is not a good idea. I would suggest trusting the minute data more than the daily, it is a more realistic simulation.

David

I know that this is a late reply, but I was also wondering what caused such a potentially great algorithm to behave so differently on daily vs minutely data.

The essential problem is that this algorithm as written and as tested on daily bars looks into the future. The reason is this:
prices = history(200, '1d', 'close_price').apply( lambda x: x.fillna(x.mean()),axis=0).apply( lambda x: x.fillna(0),axis=0)

This function will give you the close_price of the securities, including today's date when run set to daily. This could be considered to be a flaw in the backtester or just something to be careful of.

Calling history with '1d' while in minute mode should only give you today's bar up until the close of the previous minute. I haven't double-checked this, but it had better be the case!!

Yes, calling history with '1d' while in minute mode does only give you today's bare up to the close of the previous minute, but calling history with '1d' in daily mode gives you the daily close even if you have a schedule_function call to execute a buy at a particular minute of day. The original poster had asked why the results were so different in "daily" vs "minute" mode and I think that's why.

This may not be a bug so much as a "algo trader beware" type of issue, but I think I've seen a few other algos on these pages that suffer from the same problem.

Hmm I mean I guess that's true, but if your strategy depends on specific intraday scheduling then daily mode simulation doesn't make any sense at all. I don't think it's a bug since none of your orders will execute until the following day anyway...

Maybe you want to try executing your orders at today's close (3:59) based on yesterday's signal?

Totally agree that this algorithm makes no sense in daily mode! Mostly just pointing out that the differences between daily mode and minute mode are not necessarily obvious for novice algo writers here, and if you are noticing huge differences in daily mode vs minute mode you may have to dig to find the reason. I'm still not 100% sure I understand all the edge cases around daily mode. For now, I've personally decided to use exclusively minute mode, even for daily/weekly algorithms, because schedule_function provides the necessary flexibility without having to think through exactly what daily mode is doing.

In fact, now that we have schedule_function, there may be a reasonable argument for deprecating daily mode... do any of the other serious writers around here use daily mode? I noticed that all algos entered into the contest are minute mode.