Skip to content

Sessions

Trading-session and holiday gates.

Start with the topic guide for worked examples. Signatures below show the available arguments.

after(time_str: str) -> bool

True strictly after HH:MM on the current bar's market-local clock; equality is false. This reads bar time rather than the computer's wall clock.

at(time_str: str) -> bool

Matches the current bar's market-local hour/minute to HH:MM. No observation at that minute means no match; the event is not queued for later.

before(time_str: str) -> bool

True strictly before HH:MM on the current bar's market-local clock; equality is false.

in_session(venue: str, *, between=None, skip_open=None, skip_close=None) -> bool

venue is a configured code such as NSE or NYSE. between narrows to an inclusive (start, end) pair of HH:MM strings or Python time values; regular sessions exclude their close. skip_open/skip_close are duration objects, but datetime imports are currently rejected by checked strategy rules, so prefer HH:MM strings in drafts. Filters combine and do not flatten holdings. Unknown venue raises KeyError. See trading hours for calendar and always-open behaviour.

is_holiday(venue: str, d: date) -> bool

Checks a Python date against the exact venue's configured holiday calendar. It does not prove the venue is open on all other dates; weekday/session rules are separate.

list_venues() -> list[str]

Returns the configured venue codes. This lists calendar support, not broker instrument availability.

on_event(key)

Import from atom.library.clock_decorators, then use as a decorator for a supplied event key such as earnings. Requires the run's event feed; the decorator does not create events. Missing feed can prevent setup. See clocks.

recompute(spec)

Import from atom.library.clock_decorators, then use as a decorator on a supported entry point, for example @recompute('monthly') above book(). Accepted specs include daily, weekly, monthly, twice-monthly and every_n_bars=N. Observed period boundaries, including the first bar, determine scheduling. See clocks.

should_rebalance(frequency: str = daily) -> bool

Returns true once per observed daily, weekly or monthly period (default daily), beginning with the first bar. It consumes the gate when called, so save one result if several actions need the same decision. Dates use supplied bar timestamps. Use inside on_tick; it does not place orders. See clocks.

venue_hours(venue: str) -> VenueHours

Returns the configured hours for the exact venue code. Unknown codes raise KeyError. The configuration's holiday coverage may be incomplete.