Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Arbitrage algo failure, please help!

This algorithm takes a tuple of etfs and measures the spread between the highest and the lowest returns.
Whenever the spread exceeds a certain level (recorded as tolerance) it is supposed to short the best performing and buy the worst performing, as soon as the spread returns to a normal level, all positions should be exited!
Somehow I failed terribly at writing a proper code, can someone halp me out?

4 responses

Hey Jakob, looks interesting. So, more specifically, what is your code doing incorrectly?

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'm not quite sure yet, but i think the exit of the positions does not go as smooth as it is supposed to. It seems like there are open positions left when the spread has already entered the tolerance zone!

One thing I notice is that context.spreadslist never gets populated. Could that be your problem, or part of it? Maybe you have some misnamed variables. It's pretty difficult to solve problems where I don't know what the code is doing incorrectly and I'm not sure what each line is supposed to be doing. I'd suggest logging some variables with log.info() and checking to make sure they behave as expected in the log output. Let me know if that helps!

That might be the problem, thank you so far!
I will add some comments in the code and repost that version.