Hello everyone,, i just wanted to share some thoughts. When subscribing to symbols in the tutorial if we are only trading a few times per day it is conveyed to us that choosing an Hourly resolution is fine but have a look at the attached backest and vary res= Resolution.Minute and res = Resolution.Hour…. clearly it makes a world of difference and this is just a simple example of where hopefully Resolution.Minute appears to give a completely different result than Hourly even though you would expect the two to match….. so sadly this is an issue that we need to be aware of and raises a question whether Resolution.Minute is accurate given the discrepancy for the hourly and minute results on the backtest…
any thoughts on this would be very helpful!!
Mia Alissi
The difference in results between using
Resolution.Minute
andResolution.Hour
in your backtest is expected due to the nature of how these resolutions work.When you set the resolution to
Minute
, the algorithm receives data and can make trading decisions every minute. On the other hand, when you set the resolution toHour
, the algorithm receives data and can make trading decisions only every hour.In your algorithm, you are scheduling a function
rebalance_when_in_the_market
to run every day, 30 minutes after the market opens. This function checks if the current day is an odd or even day and sets the holdings accordingly.If you use
Resolution.Minute
, this function will be able to execute exactly 30 minutes after the market opens because the algorithm is receiving data every minute. However, if you useResolution.Hour
, this function will not be able to execute exactly 30 minutes after the market opens because the algorithm is only receiving data every hour. Therefore, the function will execute at the next available data point, which is one hour after the market opens.This difference in execution times can lead to different trading decisions and hence different backtest results.
In terms of accuracy, both
Resolution.Minute
andResolution.Hour
are accurate in the sense that they provide data at the specified intervals. The choice between them depends on your trading strategy and how frequently you want your algorithm to make trading decisions.Here are the relevant extracts that explain this concept:
I hope this helps! Let me know if you have any other questions.
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.
Pavel Fedorov
Mia,
If what you say was actually true then by setting the trading time at 60 minutes after the market open should yield exactly the same performance whether using hourly or minute data… Here is the attached backtest.. if you change it to Minutely you will find a vastly different result (in fact Hourly gives 5% better CAGR than minute resolution)
Mia Alissi
The difference in results between using
Resolution.Minute
andResolution.Hour
in your backtest, even when scheduling the function to run 60 minutes after the market opens, can be attributed to the way the data is sampled and the trading decisions are made.When you set the resolution to
Minute
, the algorithm receives data and can make trading decisions every minute. On the other hand, when you set the resolution toHour
, the algorithm receives data and can make trading decisions only every hour.In your algorithm, you are scheduling a function
rebalance_when_in_the_market
to run every day, 60 minutes after the market opens. This function checks if the current day is an odd or even day and sets the holdings accordingly.If you use
Resolution.Minute
, this function will be able to execute exactly 60 minutes after the market opens because the algorithm is receiving data every minute. However, if you useResolution.Hour
, this function will not be able to execute exactly 60 minutes after the market opens because the algorithm is only receiving data every hour. Therefore, the function will execute at the next available data point, which is one hour after the market opens.This difference in execution times can lead to different trading decisions and hence different backtest results.
In terms of accuracy, both
Resolution.Minute
andResolution.Hour
are accurate in the sense that they provide data at the specified intervals. The choice between them depends on your trading strategy and how frequently you want your algorithm to make trading decisions.Here are the relevant extracts that explain this concept:
I hope this helps! Let me know if you have any other questions.
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.
Pavel Fedorov
Mia you said it yourself that at 60 minutes after the market open in both cases the algorithm will initiate a trade.. the prices in both cases available should be the same and i think you confirm this as well. in that case I dont see any reason why the backtests should be different and yet they are not only different,, they are vastly different
Mia Alissi
I understand your confusion, Pavel. The difference in results between using
Resolution.Minute
andResolution.Hour
in your backtest, even when scheduling the function to run 60 minutes after the market opens, can be attributed to the way the data is sampled and the trading decisions are made.In live trading, bars have a slight delay, so you may receive them milliseconds after the top of each minute. This means that the Scheduled Event executes at exactly 10:00 AM but your algorithm may receive the 9:59-10:00 AM bar at 10:00:00.01 AM. Therefore, when you check the price in the Scheduled Event, the price from the 9:58-9:59 AM bar is the latest price. In backtesting, the Scheduled Event gets the price from the 9:59-10:00 AM bar since your algorithm receives the bar at perfect timing. This is explained in the documentation.
Moreover, in live trading, orders fill asynchronously. We send your order to the API of your brokerage and wait for their response to update the state of your algorithm and portfolio. The timing of live order fills doesn't depend on the resolution of your security subscriptions. When your order fills, the fill price and fee is set by your brokerage. In backtesting, the trade fill timing depends on the resolution of your security subscription. For example, if you subscribe to a security with minute resolution data, the algorithm only receives data in one-minute time slices. As a result, the fill model can only evaluate if the order should fill on a minute-by-minute frequency. This is also explained in the documentation.
These factors can lead to different trading decisions and hence different backtest results.
I hope this helps! Let me know if you have any other questions.
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.
Pavel Fedorov
Also if we look at the first day of trading we have:
for Resolution.Minute:
+2018-01-02 10:30:00GDXSell MarketFill: $22.421548152 USD
-22232Filled +2018-01-02 10:30:00OEFBuy MarketFill: $108.665025066 USD
4588FilledFor Resolution.Hour:
+2018-01-02 10:30:00GDXSell MarketFill: $22.421548152 USD
-22241FilledWarning: No quote information available at 01/02/2018 10:00:00 America/New_York, order filled using TradeBar data+2018-01-02 10:30:00OEFBuy MarketFill: $108.519337082 USD
4595FilledWarning: No quote information available at 01/02/2018 10:00:00 America/New_York, order filled using TradeBar dataSo we see that the Fill price for OEF is very different in the two cases…
Mia Alissi
The difference in fill prices for "OEF" between
Resolution.Minute
andResolution.Hour
can be attributed to the way QuantConnect handles order fills in backtesting.In backtesting, the fill price of orders is based on the best price available in the current backtesting data. If you're using
Resolution.Minute
, the fill price is determined based on the best available price in the minute bar data. If you're usingResolution.Hour
, the fill price is determined based on the best available price in the hourly bar data.Since minute and hourly bar data can have different best available prices, this can lead to different fill prices between
Resolution.Minute
andResolution.Hour
.Moreover, if you fill an order in a backtest with stale data, deviations between backtesting and live trading can occur because the order is filled at a price that is likely different from the real market price. Stale order fills commonly occur in backtests when you create a Scheduled Event with an incompatible data resolution.
This is explained in the documentation.
I hope this helps! Let me know if you have any other questions.
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.
Pavel Fedorov
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!