Trying to call the future data at market close(16:00 or 17:00). However, the data in 25 Oct 2017 seems not correct. Am I doing something wrong?
2017-10-25 17:00:00 : Bar high 2564.75 low 2564.75
from AlgorithmImports import *
from System.Drawing import Color
class TestAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017,10,1)
self.SetEndDate(2017,10,30)
self.SetCash(300000)
self.future = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, extendedMarketHours=True, dataNormalizationMode = DataNormalizationMode.Raw,
dataMappingMode = DataMappingMode.OpenInterest,
contractDepthOffset = 0)
self.future.SetFilter(TimeSpan.FromDays(10), TimeSpan.FromDays(90))
self.consolidator = TradeBarConsolidator(timedelta(1))
self.consolidator.DataConsolidated += self.consolidation_handler
self.SubscriptionManager.AddConsolidator(self.future.Symbol, self.consolidator)
def consolidation_handler(self, sender, bar):
pass
def OnData(self, data):
if not data.Bars.ContainsKey(self.future.Symbol):
return
if data.Time.hour == 17 and data.Time.minute == 00:
bar = self.consolidator.WorkingBar
self.Log("Bar high {} low {}".format(bar.High,bar.Low))
Louis Szeto
Hi VidalÂ
The setting of `TradeBarConsolidator(timedelta(1))` will not gaurantee the bar represents data between Day 1 16:01/17:01 till Day 2 16:01/17:01. Instead, we should use a calendar consolidator with custom period to specify the start time and duration of each consolidated bar. For example, the following implementation is what you might seek for:
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.
Vidal boreal
Hi Louis,
Thank you for your suggestion. I think I got what I need by the below calendar consolidation code. However, the data in 25 Oct 2017 still does not tally with the data in Tradingview while that in other days tally.
2017-10-22 18:01:00 : Bar high 2574.5 low 2559.5
2017-10-23 18:01:00 : Bar high 2577.25 low 2561.5
2017-10-24 18:01:00 : Bar high 2570.25 low 2562.25
2017-10-25 18:01:00 : Bar high 2565.75 low 2562.5
2017-10-26 18:01:00 : Bar high 2565.0 low 2555.5
Vidal boreal
Another example:
2014-12-23 18:01:00 : Bar high 2084.5 low 2071.5
2014-12-26 00:01:00 : Bar high 2083.5 low 2077.5
2014-12-28 18:01:00 : Bar high 2088.75 low 2078.5
2014-12-29 18:01:00 : Bar high 2088.75 low 2076.0
2014-12-30 18:01:00 : Bar high 2088.5 low 2073.0
2014-12-31 18:01:00 : Bar high 2082.75 low 2050.75
2015-01-02 00:01:00 : Bar high 2054.0 low 2054.0
2015-01-04 18:01:00 : Bar high 2067.25 low 2038.75
2015-01-05 18:01:00 : Bar high 2048.25 low 2009.5
Louis Szeto
Hi Vidal
We believe the 2017-10-25 bar is a data issue. Please refer to this ticket for the fixing progress. As per the below
We believe it was differed due to the day-counting method. You might need to do some more adjustment in your consolidation to match the TV's data.
Then you can use an if-condition check to accept the bar in your consolidation handler if the end time is at 17:00.
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.
Vidal boreal
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!