We have documentation for Scheduled Events, Scheduled Events, and below is an exanmple for a Scheduled Event for "SPY".
Setting up a Scheduled Events is done in the Initialized method. Instead of an Equity like "SPY", how would you schedule an AfterMarketOpen event for Futures when the futures contract changes each month or every 3 months?
// Schedule an event to fire every trading day for a security
// The time rule here tells it to fire 10 minutes after SPY's market open
Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 10), () =>
{
Log("EveryDay.SPY 10 min after open: Fired at: " + Time);
});
Rahul Chowdhury
Hi Michael,
There isn't any neat way to create scheduled events using futures contracts. The best practice is to use SPY or another benchmark as a dummy symbol for our scheduled events. We can create our scheduled events for futures trading relative to SPY's trading hours. You can then access the futures data in your scheduled event using self.CurrentSlice, which contains the futures chain data.
Best
Rahul
Eugene
Hi Michael,
here is an example for gold:
var futureGold = AddFuture(RootGold, Resolution.Minute); futureGold.SetFilter(0, 182); Schedule.On(DateRules.EveryDay(futureGold.Symbol), TimeRules.At(17, 00, TimeZones.Chicago), () => // { OnExchangeOpenData(); });
Michael Bloomfield
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!