Hello everyone, as discussed in the doc
self.schedule.on(self.date_rules.every_day("SPY"), self.time_rules.after_market_open("SPY", 10), self.every_day_after_market_open)
self.schedule.on takes an method(function) that revoke on specific condition define in schedule.
So I want to know I'm working with daily resolution data, and I got daily data at a sharp 4'O clock. and based on some condition I generate Alpha Signal then place an order, since market is close , My broker does decline after market order,
So now I want to fetch daily data at market open mean 9:30am So how can I schedule my Alpha model?
Mia Alissi
To schedule your Alpha model to fetch daily data at market open (9:30 AM), you can use the
self.schedule.on
method in your QuantConnect algorithm. Here's how you can set it up:Add the Security: Ensure you have added the necessary security to your algorithm. For example, if you're working with SPY, you can add it using:
Schedule the Event: Use the
self.schedule.on
method to create a scheduled event. You'll need to specify both date and time rules.Date Rule: Use
self.date_rules.every_day("SPY")
to ensure the event is triggered every trading day.Time Rule: Use
self.time_rules.after_market_open("SPY", 0)
to trigger the event exactly at market open.Define the Method: Create a method, such as
self.fetch_daily_data
, which will contain the logic to fetch daily data and generate your Alpha signal.Schedule the Method: Pass the defined method as the third argument in the
self.schedule.on
method to execute it at the scheduled time.Here's an example implementation:
Make sureTo schedule your Alpha model to fetch daily data at market open (9:30 AM), you can use the
self.schedule.on
method in your QuantConnect algorithm. Here's how you can set it up:Add the Security: Ensure you have added the necessary security to your algorithm. For example, if you're working with SPY, you can add it using:
Schedule the Event: Use the
self.schedule.on
method to create a scheduled event. You'll need to specify both date and time rules.Date Rule: Use
self.date_rules.every_day("SPY")
to ensure the event is triggered every trading day.Time Rule: Use
self.time_rules.after_market_open("SPY", 0)
to trigger the event exactly at market open.Define the Method: Create a method, such as
self.fetch_daily_data
, which will contain the logic to fetch daily data and generate your Alpha signal.Schedule the Method: Pass the defined method as the third argument in the
self.schedule.on
method to execute it at the scheduled time.Here's an example implementation:
Make sure to replace
some_condition
with the actual condition you want to check before placing orders. This setup will ensure that your algorithm fetches daily data and processes it at market open, allowing you to generate signals and place orders during market hours.Sources: Scheduled Events - QuantConnect.com, Dual Thrust Trading Algorithm, Scheduled Events Algorithm, Extended Market Trading Regression Algorithm, Market On Open On Close Algorithm
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.
Sukhvinder Pal Singh
can you suggest me the code How can I update my alpha Model after market open ?
Louis Szeto
Hi Sukhvinder
My suggestion will be storing the 4am insight and emit at next loop of update.
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.
Sukhvinder Pal Singh
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!