Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
FEAR & GREED DIA VS GLD PAIR SPREAD TRADE

This dollar neutral pair trade setup waits for a 10% divergence on both sides of spread and accumulates a dollar neutral position with each leg of spread equaling 2.5% of cash on hand. Exit trade at pair equilibrium or when portfolio cash is less than 1/2 of initial base.

15 responses

Constrained the leverage.

TOTAL RETURN STILL RISING

I have the feeling this algorithm is almost never trading during your backtest period. Did I miss something?

@Vincent, There is a leverage component attached (dow_value >context.min_notional: and gold_value >context.min_notional :) which prevents trading when (context.min_notional = -1MM) . The attached version removes the leverage and notice in the transaction section that it continuously trades and never confined by borrowing power or position limits which produces huge gains. If you have a prop firm situation that allows 30:1 or 50:1 leverage then these types of trades may be permitted.
Does that clarify?

Sorry what I meant is that if I copied your algo correctly it looks like if your were almost never trading between 2006 and 2011. You open trades -especially one- that you keep running for a while -years for the latest one in 2005. Am I understanding correctly the transaction window?

In the first model you are correct but if you click on go to back-test on the version I recently posted you will see the strategy trades as long as the initial spread condition is met.( the biggest no trade period is between 2009-2011 when the conditions aren't True).
2006-06-20 20:00:00 GLD BUY 372 $58.37 $21,715.13
2006-06-21 20:00:00 DIA SELL -192 $110.13 ($21,144.19)
2007-11-08 19:00:00 GLD BUY 244 $82.22 $20,062.66
2007-11-11 19:00:00 DIA SELL -154 $129.93 ($20,008.60)
2008-09-15 20:00:00 DIA SELL -112 $110.78 ($12,406.91)
2008-09-15 20:00:00 GLD BUY 159 $76.65 $12,187.99

FEAR & GREED DIA VS GLD PAIR SPREAD TRADE

Adjusting numbers in that last backtest with no leverage, no borrowing, no negative cash, some high results ($100K -> $6M) sort of off-the-cuff although I'm not sure where my tuning maybe becomes overfitting.

On Quantopian str(dir) stopped producing output 2014-12-01 so the previous algo and all of my algorithms (except one) are now broken.

Hi, may I ask to one of you guys clarify what is the logic behind this algo ?

dd=dret/pamo  
gd=gret/pamo  
mom=gd-dd  
    if dd>1.10 and gd<.90  
    if gd>1.10 and dd<.90  

Gary - did you have any algorithms live trading? What happened to them when str(dir) stopped working?

If a live trading algorithm stops running (because it hit a code error or any other reason), we get an immediate system alert and notify the affected customer. We don't see the algorithm code, rather we pass along the high-level message. If you need help debugging we can work with you to get the algo back up and running!

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.

@Matt I had paper, it errored out , stopped. More detail, new thread on str(dir).
@Florent Yeah I'd love to see some commenting in that code so I could understand it better. The chances of Pamo revisiting it might be slim because it was posted last year and had been quiet since Feb 2014 until I started tweaking numbers and wanted to point to those huge results. I'm wondering if it really is genuinely doing so well or what I overlooked. I was like Trog on a keyboard. Change number. Run. More bigger. Cool. More good. :)

in case you dont want to use short positions, I have tried to change the algo to use SDOW and DGLD as short positions