So, I was wondering how I can get say, the daily data and the hourly data all in the slice. So for example, perhaps I wanted to do this: ((data["EURUSD"].Hour.Close-data["EURUSD"].Daily.Open)/data["EURUSD"].Daily.Open)*(100);
The compiler doesn't like that.
Just trying to access multiple resolutions basically.
Jing Wu
For data in multiple resolutions, you can request the data with the hourly resolution (the smaller resolution) and consolidate the hourly bar into the daily bar. The documentation and the example algorithm explain data consolidation in greater details.
You can use the rolling window to save the latest consolidated daily bar data.
dailyWindow = new RollingWindow<TradeBar>(1);
The consolidated daily bar is available in the bar handler method. Each time the consolidator produces a new daily bar, this function will be called automatically. You can update the rolling window in the helper method with the new consolidated bar.
private void DailyEurUsdBarHandler(TradeBar consolidated) { // the consolidated daily bar // consolidated.Open, consolidated.High, consolidated.Low, consolidated.Close dailyWindow.Add(consolidated) }
The slice data with the smallest resolution is available in OnData(),
public override void OnData(Slice data) { // daily open dailyWindow[0].Open // hourly open data[symbol].Open }
You can find the rolling window example in the documentation.
Garret Fields
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!