I've been trying to implement a DCA strategy into my LEAPs. The way the algo works is combining the ROC in and out strategy by buying leaps, and DCA into them when we are at the bear market.
When backtesting, it seems to work pretty well, except for a couple of contracts;
- SPY 220121C00315000
- SPY 201218C00285000
So what happened is that those two contracts are supposed to be liquidated as they met the condition to liquidate near expiry.
But instead of selling them off, it buys them - I cant seem to get a fix this. Hoping someone with expertise could help out. Please find the attached backtest.
Ashutosh
Hi Muhammad Yusuf Bin Salleh
Great work on the logic and code.
I was curious to check the code.
For the contracts that you mentioned:
1) SPY 220121C00315000 → Expires on: 2022-01-21
2) SPY 201218C00285000 → Expires on: 2020-12-18
The buy and sell signals for these contracts as per the logic:
You can create a check to not buy these contracts again.
Let me know if this is useful.
Best,
Ashutosh
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.
Muhammad Yusuf Bin Salleh
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!