Alerts & sessions

Reference

Alerts & sessions

Two small surfaces: the alert model with its channels, routing and cooldown gate; and the trading-hours model — templates, sessions, holidays, the resolver/provider seams and the session iterator.

Alerts — TradeStrike.Pipeline.Alerts

Raise an Alert and hand it to an IAlertSink. The host fans it out to enabled IAlertChannels subject to an AlertRoutingPolicy; use an AlertCooldownGate to suppress repeats.

Type Members
Alert record (string Id, string Source, string Title, string Message, DateTime TimeUtc, AlertSeverity Severity = Info, string? Symbol = null, string? SoundPath = null, double RearmSeconds = 0, IReadOnlyList<string>? Channels = null, IReadOnlyDictionary<string,string>? Data = null).
AlertSeverity enum: Info, Warning, Critical.
IAlertChannel string Id, string DisplayName, AlertChannelCapabilities Capabilities, bool Enabled, Task<AlertSendResult> SendAsync(Alert alert, CancellationToken ct).
AlertChannelCapabilities readonly record struct (bool SupportsSound, bool SupportsRichText, bool IsRemote).
AlertSendResult readonly record struct (bool Ok, string? FailureReason = null, bool Retryable = false); static Success, Fail(reason), Transient(reason).
IAlertSink void Dispatch(Alert alert).
IAlertDispatcher : IAlertSink, IAsyncDisposable dispatching variant disposed by the host.
AlertRoute record (string ChannelId, bool Enabled = true, AlertSeverity MinSeverity = Info, IReadOnlySet<string>? SourceAllowList = null, IReadOnlySet<string>? SymbolAllowList = null); bool Accepts(Alert alert).
AlertRoutingPolicy record (IReadOnlyList<AlertRoute> Routes); static Empty, IEnumerable<AlertRoute> RoutesFor(Alert alert).
AlertCooldownGate AlertCooldownGate(int cooldownSeconds); int CooldownSeconds, bool TryFire(string key, DateTime now), bool TryFire(string key, DateTime now, double cooldownSeconds), void Reset().

Trading hours — TradeStrike.Pipeline.Indicators.TradingHours

A TradingHoursTemplate is a named set of weekly TradingSessions plus holiday rules in an exchange time zone. Resolve one for an instrument through ITradingHoursResolver (or the ambient holder) and iterate sessions with ISessionIterator.

Type Members
TradingHoursTemplate TradingHoursTemplate(string name, IReadOnlyList<TradingSession> sessions, IReadOnlyList<HolidayRule> holidays, TimeZoneInfo exchangeTimeZone); Name, Sessions, Holidays, ExchangeTimeZone; static Create(name, sessions, holidays, string windowsTimeZoneId).
TradingHoursTemplates static helpers: const string TwentyFourSevenName, TwentyFourSeven(tz?), TwentyFourFive(tz?), CmeEth(), CmeRth().
TradingSession readonly record struct (DayOfWeek BeginDay, TradingTime BeginTime, DayOfWeek EndDay, TradingTime EndTime, DayOfWeek TradingDay); BeginOffsetMinutes, EndOffsetMinutes, DurationMinutes.
TradingTime readonly record struct (int hhmm); Hhmm, Hour, Minute, MinutesFromMidnight, IsEndOfDaySentinel; static FromMinutes(int), FromTimeOnly(TimeOnly); TimeOnly ToTimeOnly().
HolidayRule readonly record struct (DateOnly TradingDate, HolidayKind Kind, TradingSession? Constraint, string? Description).
HolidayKind enum: FullDay, Replace, EarlyClose, LateOpen, Modify.
ITradingHoursResolver TradingHoursTemplate Resolve(string instrumentId), TradingHoursTemplate Resolve(string instrumentId, string? templateName), bool TryResolveName(string instrumentId, out string templateName), IReadOnlyList<string> ListTemplateNames().
ITradingHoursProvider TradingHoursTemplate? GetTemplate().
TradingHoursAmbient static: ITradingHoursResolver Resolver, void SetResolver(ITradingHoursResolver?), IDisposable Use(ITradingHoursResolver); NullTradingHoursResolver.Instance.

Sessions

The session iterator (namespace …TradingHours) walks trading days; the SessionWindow helpers (namespace TradeStrike.Pipeline.Indicators.Sessions) are static in-session tests for a simple start/end time pair.

Type Members
ISessionIterator DateTime GetTradingDay(DateTime time), bool IsNewSession(DateTime time, bool includesEndTimestamp), void GetNextSession(...), DateTime CalculateTradingDay(...), bool IsInSession(DateTime time, bool includesEndTimestamp, bool isIntraday), bool IsTradingDayDefined(DateTime date), GetTradingDayBeginLocal/EndLocal(...), void Reset(); ActualSessionBegin, ActualSessionEnd, ActualTradingDayExchange, ActualTradingDayEndLocal.
SessionWindow static: bool IsInSession(DateTime barTime, TimeOnly start, TimeOnly end), DateOnly SessionDate(DateTime barTime, TimeOnly start, TimeOnly end), bool IsSessionOpenBar(DateTime currentTime, DateTime previousTime, TimeOnly start, TimeOnly end).