I have this strategy that buys and holds the top 5 stocks with the highest sharpe ratios for 1 year. The current problem I have with this strategy is that the results differ from 1 backtest to another, even though the code remains the same. Can someone help me?
Xavier Boudreau
This is the other backtest with 5.5% more PSR with the same code:
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.
Mia Alissi
Here are the key findings and suggestions for improvement based on the code review:
Datetime Conversion in
sharpe
Function:Rolling Window Management:
SymbolData
class must properly accumulate and handle data indaily_rw
. Verify the data is correctly being added to theRollingWindow
and is used in calculations without causing any misalignment or data loss.Liquidation Logic:
Liquidate
method should be checked to ensure it's executed intentionally, especially inside theon_data
method. Avoid frequent calls unless necessary as it might sell assets unexpectedly, causing varying backtest results.Buying Time Management:
nextBuyTime
to ensure it allows for one-year holding periods as intended. The logic of advancingnextBuyTime
by an unrealistic number of days like100000
might cause issues with expected behavior over time.Error Handling:
Data Accuracy in Backtesting:
Review these areas carefully to improve the stability and predictability of your backtest results. If issues persist, consider running smaller sections of the backtest for debugging purposes.
Sources: Momentum Effect In Commodities Futures, Head & Shoulders TA Pattern Detection, Asset Growth Effect, Upcoming Holiday Momentum for Amazon, Accrual Anomaly
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.
Xavier Boudreau
The fixes above did not fix anything, does anyone else have any ideas?
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!