Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Simple Pair

Hi there,

I try to implement this strategy (http://www.quantifiedstrategies.com/a-simple-pair-trade-strategy-in-liquid-etfs/).
It's a nice strategy: I don't know why it performs so different according to the blog.
It will be perfect know where is the difference. Help me to check it :)

Also, I'm not satisfied with the code quality (i'm not familiar with Python):
- The strategy uses open and close orders, it's a daily strategy but i had to use minute/minute time frame.
- High of day and LOD was calculated manually, i think that must be a better way to do it.
- Also, i don't like the way that i use to go cash

Best!

6 responses

it might be performing just as well... just over a smaller date range?

Yeah, like Andrew said, they start their backtest in 2005. I tried to do that here, but it seems like one security wasn't traded until a later date since I got some error. Maybe that site is actually talking about a different security? Not sure here.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

I made a new simplified version about the same strategy with day/day timeframe.

Looks good Martin. One thing to watch out for, though, is sudden rises around 2009 due to the recession. Due to the volatile market, the difference between a good performance and a bad performance can come down to whether your strategy buys or sells on only a few days. So sudden rises surrounded by consistency just means an algorithm works during a fraction of the backtest's time. Not to say that the strategy doesn't work, just that it's inconsistent. Although, my claim may only apply to a backtest and not the strategy itself. The page you linked to actually has a graph that looks really consistent.

Thanks Gus!
Yes it looks different. Also, the strategy is different.
I couldn't reproduce the consistency according to the blog.

I glanced at your code, have you considered testing what happens when you can't execute on close? Remember, it's actually impossible to calculate your signal on close and execute at the same exact time. Also the end-to-end daily generation may differ from your minute resolution backtest due to the fact that the daily closing prices are actually the closing auction price and not last tick.