I've only found really old posts regarding methods to get the opening price for multiple symbols and could use some guidance on the cleanest/efficient method possible.
In my case, I would like to get the opening price at one minute after market open each day (9:31) for equities from a course & fine universe filter.
I've thought about using a scheduled event set for 9:31 to save each opening price. Am I headed in the right direction?
Justin E
The code didn't attach, here is the current state I was referring to above.
Louis Szeto
Hi Justin
We suggest using an auto-updating Identity indicator with Field.Open selector:
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.
Yuri Lopukhov
Hi, Louis Szeto but with Daily resolution the indicator will get current day's bar only at Midnight, isn't it? That's quite a delay to get the opening price. In general I think the Justin's approach is good enough, if it works. It may not work for non-liquid stocks if they didn't have any trades before 9:31 though.
Justin E
Thanks Louis, I tried your suggestion and implemented it as follows with backtest below.
A few oddities upon doing a quality check: I see the opening prices are different compared to Etrade data. Below are some checks against a few tickers in the backtest. The Etrade opening price is from daily historical data. How large is the slice (in terms of time) does QC use for opening price (tick, minute, etc.)?
7/20/22, XPEV: $26.59 Etrade, QC backtest $28.00
7/22/22, TWLO: $91.72 Etrade data, QC backtest $92.41
7/29/22, TTD: $43.39 Etrade data, QC backtest $45.93
Another question is why my algorithm sells so fast, my trailing stop isn't being hit but it repeatedly buys and sells the same ticker each minute. A max of 1 buy order per day per ticker, otherwise, it should wait until the next day.
For background, the algo strategy is a placeholder/dummy strategy designed to watch for higher daily highs and then buy the ticker, just once per day.
Louis Szeto
Hi Justin
The auto-update of the bar is done after OnData. Hence, there is discrepancy at the point of your debug message. You might move the whole trading and debug logic on a indicator update event handler:
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.
Justin E
Ok interesting, that would explain it. I instead chose to simply include a check for opening price in a scheduled event occurring one minute after open. I'll keep the above methods in mind for the future. Thanks Louis.
Justin E
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!