why do I get different results for “buy and hold”
if I change the equity resolution from Daily to hour?
this strategy is only purchasing the equity once….
def Initialize(self):
self.SetStartDate(2022,1 , 1 ) # Set Start Date
self.SetCash(100000)
self.AddEquity("SPY", Resolution.Daily)
def OnData(self, data: Slice):
if not self.Portfolio.Invested:
self.SetHoldings("SPY", 1)
Mia Alissi
The difference in results when changing the resolution from Daily to Hourly in a "buy and hold" strategy can be attributed to the way QuantConnect handles data at different resolutions.
When you're using the Daily resolution, the
OnData
method is called once per day at the end of the trading day. This means that the order for the equity is placed at the end of the trading day.However, when you're using Hourly resolution, the
OnData
method is called every hour. This means that the order for the equity could be placed at any hour of the trading day, which could lead to different results due to price fluctuations throughout the day.Here's an example from the forum discussion SPY STRATEGY PROBLEM WITH RESOLUTIONS:
So, even though your strategy is only purchasing the equity once, the time at which the order is placed can vary depending on the resolution, which can lead to different results.
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.
Ilan pinto
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!