I'm trying to understand why the following values are different if OnData happens once per hour (subscribed to hourly timeframe):
Debug($"Val1: {data[ticker].Price} Val2: {data.Bars[ticker].Close} ");
My understanding is Price is the last price of the period (where new candle starts) and Close is the close of the candle. Thus the two should be identical?
Louis Szeto
Hi Franky
The listed price is NOT necessarily equal to the last traded price of that asset.
E.g. An asset last traded $100 in that bar, at the end of that bar, ask: $95, bid: $99, so the listed price will be $97 by data provider, but close price is $100.
Cheers
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.
Franky
Hi Louis, thanks for the reply. My understanding is that a Slice is a slice in time, meaning the close of the candle should be the exact same time as the last price ? Why would the price be at a different time ?
Varad Kabade
Hi Franky,
The difference occurs because of the data[ticker].Price comes from the quote bar and data.Bars[ticker].Close comes from the TradeBar. We need to understand that if the Slice object (data) has QuoteBars and TradeBars for symbol, it will return QuoteBar; if not, it will return TradeBar for data[ticker].
Best,
Varad Kabade
Franky
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!