OrchestrationIntermediate

Scheduling

Scheduling is the automated triggering of trading tasks at precise times using cron or a scheduler, made market-aware through trading-hours and holiday logic, orderly warm-up and shutdown routines, and reliable clock synchronisation.

Quick Answer

Scheduling fires trading tasks at precise clock times using cron or a scheduler — a pre-market warm-up, the session start, an end-of-day square-off. It is made market-aware with trading-hours and NSE holiday logic so nothing runs on a closed day, and it depends on a synchronised clock, because a drifting server time can trigger a job minutes early or late.

Definition: Scheduling

Scheduling is the automated triggering of trading tasks at set times, gated by market-hours and holiday awareness plus orderly startup and shutdown routines.

Key takeaways: Scheduling

  • Use cron or a scheduler for crude timing, but gate every job on a market-aware calendar
  • Check the exchange holiday calendar and session hours before acting — weekdays are not all trading days
  • Run deterministic warm-up (auth, data, reconcile) and graceful shutdown (cancel, square-off, persist)
  • Keep the clock NTP-synchronised and handle time zones explicitly, or timing and timestamps drift

Scheduling at a glance

Scheduling — key facts at a glance, Indian algorithmic-trading context.
PurposeTrigger trading tasks at set times
MechanismCron or a job scheduler
Market-awareTrading-hours + NSE holiday gating
PhasesWarm-up, live session, shutdown/square-off
DependencySynchronised server clock
Failure modeJob fires on a closed day or wrong time
Best forDeterministic, unattended daily runs

Scheduling in simple words

Scheduling is what makes your system do the right thing at the right moment without you starting it manually. It launches the pre-market preparation, keeps the live loop running only during trading hours, skips holidays, and shuts down cleanly at the close. Because trading is time-sensitive, the schedule has to know the market's calendar and your computer's clock has to be accurate.

What Scheduling is for

Scheduling exists so that an automated system runs unattended and on time — warming up before the open, acting only when the market is live, and shutting down safely — rather than depending on a human to press start and stop each day.

Scheduling — professional explanation

Cron and schedulers

The classic tool is cron, which triggers a command at times specified by a five-field expression (minute, hour, day-of-month, month, day-of-week); a scheduler like a systemd timer, a cloud scheduler, or an in-process scheduling library does the same job with more control. Cron is simple and reliable for coarse timing — start the pre-market job at a fixed time each weekday — but it is calendar-naive: it does not know about exchange holidays or that the market opens at a specific local time, and it happily fires on a day the exchange is closed. So cron typically handles the crude when, while the job itself applies the market-aware logic to decide whether to actually proceed. Overlap protection matters too: guard against a slow run still executing when the next trigger fires.

Market-hours awareness

A trading system must act only when the market is in the right session, so schedules are gated by trading hours rather than wall-clock alone. The system needs to know the pre-open session, the continuous session (illustratively 9:15 to 15:30 for NSE equities), and any post-close windows, and to behave differently in each. Placing a normal order at 15:29 versus 15:31 is the difference between a fill and a rejection. Hardcoding these times is fragile; the robust approach is a session calendar the code consults, so that a change in market timing is a data change, not a code change. The schedule should also distinguish segments — equity, F&O and commodity sessions differ.

Holidays and the trading calendar

Exchanges close on numerous holidays that do not follow a simple weekly pattern, and some days are partial or special sessions (a rare Saturday session, or a Muhurat trading window). A scheduler that assumes every weekday is a trading day will wake up, prepare, and either idle uselessly or, worse, attempt actions the exchange rejects. The correct design maintains an exchange holiday calendar — ideally sourced or updated from the exchange rather than hand-typed — and every scheduled job first checks is-today-a-trading-day before doing anything. This single guard prevents a large class of holiday-related misbehaviour, including chasing a data feed that is silent because the market is shut.

Warm-up routines

A system cannot go from cold to trading instantly; it needs a warm-up phase before the open. Warm-up typically includes: authenticating and obtaining the day's access token, loading the instrument master and any contracts that change (F&O expiries roll), fetching the previous session's positions and open orders to reconcile state, pre-loading historical data so indicators have enough history to compute (an indicator needing 20 bars cannot act on bar one), subscribing to the market-data stream, and running self-checks (connectivity, funds, risk limits). Sequencing this deterministically before the first tick means the strategy is fully primed at the open rather than making decisions on incomplete state.

Shutdown routines

Just as important is a clean shutdown at or before the close. A graceful end-of-day routine cancels any resting orders that should not carry over, squares off intraday (MIS) positions if the strategy requires it before the exchange's auto-square-off, persists state and the day's logs, closes stream connections, and produces a reconciliation report. An abrupt kill instead of a graceful shutdown can leave orders resting, positions unmanaged overnight, or state unpersisted, so the shutdown path deserves the same care as startup. The system should also handle unexpected shutdowns (a crash) by reconciling on the next startup rather than assuming a clean prior exit.

Time synchronisation

Every schedule and timestamp depends on the clock being correct. A machine whose clock has drifted by even a few seconds can trigger jobs late, misjudge whether the market is open, and — critically — attach wrong timestamps to orders and logs, which corrupts reconciliation and any latency measurement. The standard remedy is to synchronise the system clock continuously via NTP, and to be explicit about time zones: store and reason in a defined zone (India Standard Time for NSE, or UTC internally with conversion at the edges) so that daylight-saving assumptions in libraries never silently shift your session boundaries. Never trust an unsynchronised local clock for anything time-sensitive.

Worked example: Scheduling

Illustrative example (Indian market)

A schedule triggers the pre-market job at 08:45 IST every weekday. The job first checks the exchange calendar; on a holiday it logs and exits. On a trading day it authenticates for the day's token, rolls to the current F&O expiry, reconciles yesterday's positions, pre-loads 30 bars of history so a 20-bar indicator is ready, and subscribes to the feed. At 09:15 the live loop begins acting; at 15:20 a shutdown routine cancels resting orders and squares off intraday positions ahead of the exchange auto-square-off, then persists logs. NTP keeps the clock accurate throughout. All times are illustrative of NSE conventions.

NSE observes many holidays a year with no fixed weekly pattern, plus occasional special sessions such as Muhurat trading, so a weekday-only cron assumption is wrong on both counts. Intraday (MIS) positions are auto-squared-off by brokers near the close, so a scheduled shutdown that flattens positions a little earlier avoids being force-closed at an uncontrolled price.

Cron vs a market-aware scheduler

Cron vs a market-aware scheduler — Scheduling, summarised for Indian F&O context.
AspectPlain cronMarket-aware scheduling
Knows holidaysNoYes — checks trading calendar
Knows sessionsNoYes — gates on market hours
Warm-up/shutdownNot modelledExplicit routines
Good forCrude fixed timingCorrect trading-day behaviour

Advantages of Scheduling

  • Runs the system unattended and on time, day after day
  • Market-aware gating prevents acting on holidays or outside session hours
  • Deterministic warm-up ensures the strategy is fully primed at the open
  • Graceful shutdown avoids stranded orders and unmanaged overnight positions

Limitations of Scheduling

  • Plain cron is calendar-naive and will fire on holidays without extra guards
  • Holiday and session calendars must be maintained and updated as the exchange changes them
  • Clock drift silently corrupts timing, session judgement and timestamps
  • Time-zone and daylight-saving handling is error-prone across libraries and machines
  • A crash between scheduled jobs can leave state unreconciled until the next startup

How professionals treat Scheduling

Professional systems drive timing from an explicit exchange calendar and session model rather than raw cron, so every job first asks whether it is a trading day and which session is active. Warm-up and shutdown are first-class, deterministic routines with self-checks, and the machine clock is NTP-synchronised with time zones handled explicitly. Scheduled jobs are idempotent and overlap-protected, and a crash is recovered by reconciling on the next startup rather than assuming a clean prior state.

Common misconceptions about Scheduling

Misconception: You should hardcode market open and close times.

Reality: Hardcoding is fragile because timings and segments can change. Consult a maintainable session calendar so a timing change is a data update, not a code edit, and so different segments — equity, F&O, commodity — are handled correctly.

Common mistakes with Scheduling

  • Assuming every weekday is a trading day and skipping the holiday-calendar check
  • Hardcoding session times in code instead of consulting a maintainable calendar
  • Relying on an unsynchronised local clock for order timestamps and session decisions
  • Skipping warm-up so indicators act on insufficient history at the open
  • Killing the process abruptly instead of running a graceful shutdown that squares off and persists state
  • Ignoring time zones or daylight-saving, silently shifting session boundaries

Scheduling: frequently asked questions

What is scheduling in a trading system?

It is the automated triggering of tasks at precise times — pre-market preparation, the live loop, end-of-day shutdown — using cron or a scheduler, gated by market-hours and holiday logic so the system runs unattended and only acts when it should.

What is cron?

Cron is a time-based job trigger that runs a command on a schedule set by a five-field expression. It is simple and reliable for fixed timing, but it is calendar-naive — it does not know exchange holidays or sessions, so the job itself must apply market-aware logic.

Why does my scheduler need to know market hours?

Because a trading system must act only in the right session. Placing an order seconds after the close is rejected, and acting outside hours is meaningless or harmful. Gating jobs on session times, ideally from a calendar rather than hardcoded, keeps behaviour correct.

How do I handle exchange holidays?

Maintain an exchange holiday calendar and have every scheduled job first check whether today is a trading day before doing anything. Assuming every weekday is open causes idle runs or rejected actions on the many non-weekly holidays exchanges observe.

What is a warm-up routine?

It is the deterministic startup sequence before the open: authenticate for the day's token, load the instrument master and current expiries, reconcile prior positions, pre-load historical bars so indicators are ready, subscribe to the feed, and run self-checks. It ensures the strategy is fully primed at the first tick.

How should I handle time zones?

Be explicit: reason in a defined zone such as India Standard Time for NSE, or store UTC internally and convert at the edges. Leaving zones implicit lets library daylight-saving assumptions silently shift your session boundaries.

Sources & references

  • Ernest P. Chan, “Quantitative Trading: How to Build Your Own Algorithmic Trading Business”, 2nd ed., Wiley, 2021
  • Robert Kissell, “The Science of Algorithmic Trading and Portfolio Management”, Academic Press (Elsevier), 2013

Published 10 July 2026. Educational content only — not investment advice. Markets and rules change; verify current conventions with SEBI, NSE/BSE and your broker.

Educational content only — not investment advice. Examples use illustrative numbers and simplified models. Algorithmic trading and derivatives involve substantial risk. See our Risk Disclosure and SEBI Disclaimer.