Hello,
I am trying to implement a pair trading strategy based on the following paper:
https://www.math.nyu.edu/faculty/avellane/AvellanedaLeeStatArb071108.pdf
I tried to code the strategy (the paper is not hard to understand) but it appears that the algorithm doesn't liquidate stocks .How can I fix this small problem?
Thank you
Pierre Vidal
Hi,
Thanks for interesting share.
The main problem I noticed is that your function CoarseSelectionAndPCA sets the dataframes self.weights_buy etc to new/empty on all but a single day of the backtesting period (2001-01-17). Consequently trades occured only on that day. You can see that this is happening by placing self.Log or self.Debug commands. I have not debugged further why this is happening.
Moreover additional changes will probably be required around the SetHoldings calls:
if self.Securities[symbol].Invested: continue self.SetHoldings(symbol, -weight)
Bests
Wawes23
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!