My trading algorithm will use minute resolution with extended market hours to make orders and use SMA with daily and weekly resolution. How can I directly request minute and daily resolution at the same time?
I tried to consolidate minute data to daily data but it won't work. Because the daily bar should reflect the regular trading hours. And there is also some early close trading day.
Mia Alissi
You can request minute resolution data with extended market hours and daily resolution data at the same time by using the
AddEquity
method.For minute resolution data with extended market hours, you can use the following code:
This code will subscribe to SPY data at minute resolution and include data from pre and post-market trading hours.
For daily resolution data, you can use the following code:
This code will subscribe to SPY data at daily resolution and only include data from regular trading hours.
Remember, you only receive extended market hours data if you create the subscription with minute, second, or tick resolution. If you create the subscription with daily or hourly resolution, the bars only reflect the regular trading hours.
For more information, you can refer to the QuantConnect Documentation.
Regarding the issue with consolidating minute data to daily data, it's important to note that the daily bar should indeed reflect the regular trading hours. If you're trying to consolidate minute data to daily data but also want to include extended market hours, you might run into issues because the daily bar is designed to only reflect regular trading hours.
If you need to work with data from extended market hours, you should stick with minute, second, or tick resolution. If you need to analyze data at a daily level, you could consider using rolling windows or other techniques to aggregate the minute-level data in a way that suits your needs.
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.
Shuai Liu
During warm up periods I can only access minute resolution but I need warm up my daily SMA.
Mia Alissi
You can warm up your daily Simple Moving Average (SMA) indicator in QuantConnect. The warm-up period allows your algorithm to load and update the indicator with historical data before the start of the algorithm.
Here is an example of how you can warm up a daily SMA in Python:
In this example,
SetWarmUp(20)
sets the warm-up period to 20 days, which is the same period as the SMA. This ensures that the SMA is fully ready when the algorithm starts.If you want to warm up the indicator with a resolution that's different from the security resolution, you can use the
WarmUpIndicator
method. Here is an example:In this example, the
WarmUpIndicator
method warms up the SMA with daily bars.For more information, you can refer to the QuantConnect Documentation.
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.
Shuai Liu
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!