Stream metadata

A stream’s trading calendar, closures, custom fields and lineage, read and set over the data protocol.

class mirexa.StreamMetadata(working_hours: WorkingHours | None = None, gap_threshold_low: int = 0, gap_threshold_high: int = 0, closures: list[Closure] = <factory>, custom_fields: dict[str, str]=<factory>, lineage: Lineage | None = None)

Everything a node keeps about a stream besides its data.

gap_threshold_low is the shortest gap filed at all; gap_threshold_high is, on a stream with no working hours, the length past which a gap counts as a closure. lineage is set only with set_stream_lineage: set_stream_metadata keeps the stream’s own and refuses metadata carrying one.

class mirexa.WorkingHours(timezone: str, schedule: tuple[DaySchedule, ...] = ())

A weekly schedule in an IANA timezone. Outside it a gap is market closure (OFF_TIME), never missing data.

classmethod weekly(timezone: str, *windows: TimeWindow, days: Iterable[Weekday] = (Weekday.MONDAY, Weekday.TUESDAY, Weekday.WEDNESDAY, Weekday.THURSDAY, Weekday.FRIDAY)) → WorkingHours

The same windows on each of days, Monday to Friday by default.

For example:

WorkingHours.weekly("America/New_York", TimeWindow("09:30", "16:00"))
class mirexa.DaySchedule(day: Weekday, windows: tuple[TimeWindow, ...])

One weekday’s trading windows.

class mirexa.TimeWindow(open: str, close: str)

One trading window within a day, local time, "HH:MM" each. "24:00" is the day’s end.

class mirexa.Weekday(*values)

A day of the week as the server numbers it: Sunday is 0 (Go’s time.Weekday), unlike Python’s datetime.weekday().

class mirexa.Closure(start: int, end: int, note: str = '')

A declared closure — a holiday, a halt — [start, end) in Unix ns.

class mirexa.Lineage(source: StreamID, kind: SourceKind, close_grace: int = 0, no_trade_limit: int = 0, since: int = 0, rederive: bool = False)

Says a stream’s candles are derived from source’s ticks or shorter candles. close_grace and no_trade_limit are nanoseconds; 0 means the node’s default. since and rederive are the node’s: it stamps them when the lineage is declared, and a declaration must leave them 0.

class mirexa.SourceKind(*values)

What a derived stream is made from.

TICKS = 1

The source stream’s trades.

CANDLES = 2

The source stream’s shorter candles.

class mirexa.LineageHistory(*values)

What a lineage declaration does with the source’s existing history.

CLEAR = 0

Make the stream a plain one again (no lineage).

FROM_NOW = 1

Derive what the source receives from now on.

REDERIVE = 2

Also derive everything the source already holds.

class mirexa.MetadataChange(metadata: StreamMetadata, created: bool = False, refiled_ns: int = 0)

What a metadata change answers: the metadata as the node now holds it, whether the change registered the stream, and how many nanoseconds of the stream’s filed gaps it re-classified.