quantlab.dataset.sharadar.point_in_time#

Point-in-time release panels of Sharadar tables on SEP’s trading calendar.

Several Sharadar tables are releases: each row became public on some day (an SF1 filing on its SEC filing date, a 13F quarter 45 days after its end, an 8-K on its filing date), and a panel built from them must never show a row before that day. This module owns that rule (ADR 0003, ADR 0040) and the calendar and axis plumbing around it, so a dataset supplies only its rows and a spec:

  • TradingCalendar is SEP’s trading days up to the day the raw tables are complete through. place gives each row its available date, the first trading day on or after its date (plus a lag), and drops a row the calendar does not reach yet.

  • as_of is the point-in-time rule: on every trading day each security shows its latest row whose available date is on or before that day, and shows nothing once that row’s release date is more than stale_after_days before the day.

  • shown_symbols, on_grid and to_panel are the axes: the securities with a row available by a window’s last day, the (timestamp, symbol) cell grid, and the cells shaped into an xarray.Dataset.

  • ReleasePanelDataset is the dataset of a release table: a subclass implements _released (its rows, each with symbol and available) and _spec (a ReleaseSpec: the variables, the date variables, the column staleness is measured from), and inherits the axes, the windows, the symbols an update adds and the widening fill.

Which rows a dataset keeps stays the dataset’s own: the fundamentals panel drops a later filing of an older period, the fiscal-year history turns the rows into slots, the 13F panel shows one quarter for every security, and a filing panel shows a filing only on its own day. The last two are not shown as of their available date: they override the window and reuse the calendar, the grid and the shaping.

Examples#

A row released on Saturday 2024-01-06 is available on Monday and shown from then on:

>>> import polars as pl
>>> from datetime import date
>>> days = pl.Series("timestamp", ["2024-01-04", "2024-01-05", "2024-01-08"]).str.to_datetime(time_unit="ns")
>>> calendar = TradingCalendar(days, through=date(2024, 1, 8), start="2024-01-01", end="2024-12-31")
>>> rows = calendar.place(pl.DataFrame({"symbol": [101], "date": [date(2024, 1, 6)], "value": [1.0]}))
>>> rows.get_column("available").dt.date().to_list()
[datetime.date(2024, 1, 8)]
>>> spec = ReleaseSpec(variables={"value": {}}, stamp=None)
>>> as_of(rows, calendar.days_in("2024-01-01", "2024-12-31"), [101], spec)["value"].values.ravel().tolist()
[nan, nan, 1.0]

Classes

ReleasePanelDataset

Daily point-in-time panel of one Sharadar release table, keyed by permaticker.

ReleaseSpec

What a release panel shows: its variables and the column its staleness is measured from.

TradingCalendar

SEP's trading days, the calendar every Sharadar release panel is placed on.

Functions

as_of

Return the point-in-time panel: per day and symbol, the latest row available by then.

on_grid

Return every (timestamp, symbol) cell, day by day, with its row and column index.

shown_symbols

Return the symbols with a row available by the last of days, sorted.

to_panel

Shape grid-ordered cells into a (timestamp, symbol) panel.