I'm trying to write an algo that uses ES Futures.
def Initialize(self):
self.SetStartDate(2022, 6, 1)
self.security = self.AddFuture("ES", dataNormalizationMode = DataNormalizationMode.BackwardsPanamaCanal)
I'm printing prices to the console like this:
def OnData(self, data):
if self.Time == datetime(2022, 6, 1, 10, 0, 0): # 2022-06-01 10:00:00
price = self.Securities[self.security.Symbol].Price
self.Debug(f"{self.Time} - price is {price}
I'm getting the output:
2022-06-01 10:00:00 - price is 4205.25
The issue is that I'm checking them against Interactive brokers prices and it's not matching up.
On 2022-06-01 the contract that's being traded could either be the June or the September contract, but for both of them the prices aren't close to 4205.25.
# 2022-June (In NY Timezone)
date_and_time, high, low, close, volume
2022-06-01 09:59:00,4151.500000,4147.750000,4149.000000,2050
2022-06-01 10:00:00,4153.750000,4148.500000,4150.500000,1610 <--- DOESN'T MATCH
2022-06-01 10:01:00,4155.000000,4137.500000,4141.250000,10188
# 2022-September (In NY Timezone)
date_and_time, high, low, close, volume
2022-06-01 09:59:00,4151.000000,4151.000000,4151.000000,1
2022-06-01 10:00:00,4153.250000,4152.750000,4153.250000,2 <--- DOESN'T MATCH
2022-06-01 10:01:00,4155.000000,4140.500000,4145.000000,97
Where does the 4205.25 price in QuantConnect come from?
Louis Szeto
Hi Michael
That was because of the adjustment from the Backwards Panama Canal data normalization. If we switch the data normalization mode to raw, we'll obtain the raw price of the 17 June 2022 expiring contract, which is $4150.5, matching the IB's number.
Read this thread to know more on continuous futures' data normalization.
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.
Michael Chuprin
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!