Scheduled Events

Scheduled events allow you to trigger code blocks for execution at specific times according to rules you set. This feature helps coordinate your algorithm activities and perform analysis at regular intervals; while letting the trading engine take care of market holidays.

The scheduling is set with two rules: the DateRules and TimeRules classes. The schedule manager takes one of each and executes an action code block:

Schedule.On(DateRules.On(2013, 10, 7), TimeRules.At(13, 0), () => 
{
         Debug("Specific Time: Fired at : " + Time);
});

The date rules can be specified as below:

Scheduled Events Date Rules
DateRules.On(2013, 10, 7) On a specific date
DateRules.EveryDay("SPY") Every trading day for SPY
DateRules.Every(DayOfWeek.Monday, ...) On specific days of week
DateRules.EveryDay() Every day
DateRules.MonthStart("SPY") SPY trading start of each month

The time rules trigger specify when on the day the event should be triggered. They can be specified as below:

Scheduled Events Time Rules
TimeRules.At(13, 0) At a specific time, 1:00pm
TimeRules.AfterMarketOpen("SPY", 10) Run 10 minutes after market open for SPY
TimeRules.BeforeMarketClose("SPY", 10) Run 10 minutes before market close for SPY
TimeRules.Every(TimeSpan.FromMinutes(10)) Every 10 minutes during day specified

For a demonstration see the tutorial video below:

Avatar

By: Jared Broad

Founder & CEO

29.03.2017
img Back to Blog

Related Articles

algorithmic trading

New Machine Learning Package: MlFinLab

By: Jared Broad • 17.10.2022 algorithmic trading

Living Our Mission 🚀

By: Jared Broad • 20.09.2022 crowdfunding

Own a Part of QuantConnect

By: Jared Broad • 08.09.2022 algorithmic trading

Docs V2 Released

By: Jared Broad • 13.07.2022

New Low-Latency FIX Integration to Atreyu

By: Carey • 26.10.2021