I am trying to test a futures strategy that makes computation using continuous contracts and then trades the current mapped contracts. I am using the ForwardPanamaCanal data normalization and was expecting the constant offset for a given mapped contract. In other words, there should be constant difference between the continuous contract and the current mapped contract but it is not what I am seeing. Instead, the offset varies within the bar (i.e. it is different for O, H, L, and C) and between the bars as illustrated in the linked code. Is it a bug or am I missing something? In case you are wondering why I need to know the offset, I need it to correctly compute the limit and stop prices for my orders. For example, if strategy computed the limit price as X for continuous contract, the actual limit price for the mapped contract will be X+current_offset.
Alexandre Catarino
Hi Profit ,
Please replace the historical data request with the latest TradeBar value:
I have found the following values:
There is a mismatch, ←, when the symbol changes which is related to the data resolution. If we use hourly resolution instead, we find:
We will look into the resolution issue, and reply back to this thread.
Best regards,
Alex
Profit
Hi Alex,
Thanks a lot! I played a bit with the code and learned that the discrepancy appears to be caused by using data[self.f.Symbol] instead of data.Bars[self.f.Symbol].
This will give you result consistent with my code. Could you please explain the difference between data and data.Bars?
Louis Szeto
Hi Profit
The timeslice that OnData handler received was an aggregated bar on tick data. It was aggregated on all Quote and Trade data and set the Close property with the very last tick regardless of its data type (quote/trade). So data might be a bid/ask close data but not coming from an actual trade. data.Bars was only aggregating the trade data instead.
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.
Profit
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!