Folks,
I am trying to get open,close,high, and low data for certain market day. I have put together python script to what I think it should give me what I need. However, I am having 2 concerns here:
1. I requested only 1 day data (1/3/2019), however, onData methind is triggered twice and ended up with 2 sets of data instead of one day.
2. Data desplayed in 2nd set, seem to be close to what I see in thinkorswim charting software but there are not exact!
Also, how can I go to previous day data if I had requested data for one week?
Thanks for your help
Script
class getDailyCandleStick(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 3) # Set Start Date
self.SetEndDate(2019,1,3)
self.SetCash(100000) # Set Strategy Cash
self.symbol = "SPY"
self.equty = self.AddEquity(self.symbol, Resolution.Daily)
self.equty.SetDataNormalizationMode(DataNormalizationMode.Raw)
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
self.Debug("OPen Price:" + str(data[self.symbol].Open))
self.Debug("Close Price:" + str(data[self.symbol].Close))
self.Debug("High Price:" + str(data[self.symbol].High))
self.Debug("Low Price:" + str(data[self.symbol].Low))
Output:
155 | 15:19:12:
Launching analysis for 8d79c65545fea28f8ef696fad964863a with LEAN Engine v2.4.0.0.5954
156 | 15:19:13: OPen Price: 245.98
157 | 15:19:13: Close Price: 250.26
158 | 15:19:13: High Price: 251.21
159 | 15:19:13: Low Price: 245.95
60 | 15:19:13:
Algorithm (8d79c65545fea28f8ef696fad964863a) Completed.
161 | 15:19:13: OPen Price: 248.26
162 | 15:19:13: Close Price: 244.13
163 | 15:19:13: High Price: 248.57
164 | 15:19:13: Low Price: 243.66
165 | 15:19:13: Algorithm Id:(8d79c65545fea28f8ef696fad964863a) completed in 0.51 seconds at 0k data points per second. Processing total of 3 data points.
√√