Hello,
Maybe I am missing something in the docs, but how do I perform a calculation or computation with close prices from two different timeframes? I have already consolidated the data for the 4H timeframe and have a rolling window setup that is being updated in the OnData() and the OnDataConsolidated() methods. I will add the code to this when I get to my computer if that is helpful but for now- maybe the below is enough for somebody smarter than me.
EG:
asset1 = Daily Timeframe
asset2 = 4H Timeframe
asset1_return = (asset1_price[0].Close - asset1_price[1].Close) * 100 / asset1_price[1].Close
asset2_return (asset2_price[0].Close - asset2_price[1].Close) * 100 / asset2_price[1].Close
delta = asset1_return - asset2_return
I am assuming (possibly incorrectly) that I need to perform these in the OnDataConsolidated() method but QC will not let me access the asset2 data because it is a different timeframe.
I tried to access the asset1 data in the OnData() method but it also gave me an error.
Louis Szeto
Hi Rovick
There is insufficient information for debugging. But if you saved the 2 RoliingWindows as global variables of the class (i.e. self.xxx), they can still be accessed in different instances of the same/different consolidated bar handler. Please attach the code snippets or a backtest for further assistance.
Best
Louis
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.
Rovick
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!