Skip to content

Scheduling

A trading session should run when its market is open and stop when it closes. ClearEdge is market-hours aware so you can automate start/stop instead of babysitting it.

The system knows each instrument’s trading calendar (via exchange-calendars), so a daily strategy acts on the right sessions and an intraday strategy is flat by the close. Crypto trades 24/7 and is scheduled accordingly.

Add --until 16:05 (Eastern) to a paper/live runner and the session stops itself cleanly at that time — the same code path as the kill switch, so positions flatten on stop. To start sessions automatically on weekday mornings, cron the supervised wrapper scripts/run-paper.sh (it relaunches after crashes but respects intentional stops):

# m h dom mon dow command
25 9 * * 1-5 cd /path/to/clearedge-algo && ./scripts/run-paper.sh \
--strategy ibs_reversion --instrument QQQ.NASDAQ --until 16:05 >> .run/scheduled.log 2>&1

(macOS alternative: a launchd plist with StartCalendarInterval. Times are local — keep the clock on Eastern or adjust.) Crypto trades 24/7, so there’s no market-hours gating for crypto sessions. See paper trading for the runner flags.

The IB Gateway needs periodic restarts; in the Dockerized setup, IBC handles the nightly/weekly gateway restart on its own, and the gateway monitor alerts you if a gateway goes unhealthy between restarts.