I logged some data on the SPY wanting to see when the OHLC prices were emitted to the algo.
The first entry in the logging results:
2020-01-01 00:00:00 2020-01-01 00:00:00: Open 320.5 , High 322.125 , Low 320.15, Close 321.86
Am I interpreting this correctly? Midnight 00:00 of 1-1-2020, the algo is aware of its EOD Closing price?
Or is there another time variable to access associated with data["SPY"].Close?
I'd like to exactly when any data is emitted to the algo. Thank you very much for the help!
Per the Docs: The close of a bar is not known until the start of the next bar, which can sometimes be confusing. For example, a price bar for Friday will include all the ticks from Friday 00:00 to Friday 23:59.99999, but it will actually be emitted to your algorithm on Saturday at midnight.
class Milk(QCAlgorithm):
O = None
H = None
L = None
C = None
def Initialize(self):
self.SetStartDate(2020,1,1)
self.SetEndDate(2021,1,1)
self.SetCash(100000)
self.spy = self.AddEquity("SPY", Resolution.Daily)
self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
def OnData(self, data):
if data["SPY"] is not None:
self.Plot("SPY", "SPY", self.Securities["SPY"].Close)
self.O = data["SPY"].Open
self.H = data["SPY"].High
self.L = data["SPY"].Low
self.C = data['SPY'].Close
self.Log(f"{self.Time}: Open {self.O} , High {self.H} , Low {self.L}, Close {self.C}")
Felix C
Now I'm even more confused, particularly with these results if logging timestamp and price at EOD:
2020-01-10 00:00:00 2020-01-10 00:00:00: Open 326.2 , High 326.73 , Low 325.52, Close 326.65
2020-01-10 16:00:00 2020-01-10 15:50:00: Open 326.2 , High 326.73 , Low 325.52, Close 326.65
2020-01-11 00:00:00 2020-01-11 00:00:00: Open 327.36 , High 327.46 , Low 325.205, Close 325.71
2020-01-13 16:00:00 2020-01-13 15:50:00: Open 327.36 , High 327.46 , Low 325.205, Close 325.71
If I were to interpret this, on Friday the 10th, it is aware of its OHLC price at Midnight AND at 3:50PM the price remains the same?
Then on Saturday the 11th at Midnight it is aware of its OHLC price and remains the same until 3:50PM Monday the 13th?
Felix C
Nevermind, I understand this now. The Midnight data is actually the bar from the previous day and then no new bar data is emitted at EOD, only at Midnight the following day.
Felix C
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!