quantlab.dataset.roster.RosterDataset#

class quantlab.dataset.roster.RosterDataset(config, roster=None)[source]#

Bases: MarketDataset

config.dataset on the symbols of config.roster.

The roster is the symbol axis of the roster dataset’s store. It is cast to the type of the wrapped store’s symbol axis (an integer permaticker axis against a text one), and the symbols the wrapped store lacks are left out, the count logged: a symbol without values is a fact of the data, not an error. The kept symbols are in the wrapped store’s order.

Parameters:
configRosterDatasetConfig or MarketDataset

The config, or the wrapped dataset with roster beside it.

rosterBaseDataset, optional

The roster dataset, when config is the wrapped dataset.

Raises:
ValueError

If dataset is not a MarketDataset or roster not a dataset.

Examples

With sep a store on permatickers 1..5 and membership a universe’s membership store on 2 and 4:

>>> prices = RosterDataset(sep, membership)
>>> prices.panel("2024-01-02", "2024-01-05")["symbol"].values.tolist()
[2, 4]
config_cls#

The config class used to rebuild this dataset from a saved config.

alias of RosterDatasetConfig

copy()[source]#

Return a roster view over copies of the wrapped and roster datasets.

Examples

>>> other = prices.copy()
>>> other == prices, other.dataset is prices.dataset
(True, False)
property dataset#

The wrapped dataset.

Examples

>>> RosterDataset(sep, membership).dataset is sep
True
delisting_bars(prices, valuation_column)[source]#

Return the wrapped dataset’s delisting bars of a panel of this view.

Examples

>>> panel = prices.panel("2024-01-02", "2024-01-05")
>>> prices.delisting_bars(panel, "adjClose").equals(sep.delisting_bars(panel, "adjClose"))
True
head(n)[source]#

Return up to n rows of the wrapped dataset, for its column names and dtypes.

Examples

>>> prices.head(0).collect_schema().names() == sep.head(0).collect_schema().names()
True
inputs()[source]#

Return the wrapped dataset and the roster dataset, both read by panel.

Examples

>>> RosterDataset(sep, membership).inputs() == (sep, membership)
True
own_names(names)[source]#

Return the wrapped dataset’s own names of the shared names.

Examples

>>> prices.own_names(["adjClose"])
['adjClose']
panel(start, end, symbols=None, variables=None)[source]#

Return the wrapped dataset’s panel from start to end on the roster.

Parameters:
start, endstr, datetime.date or pd.Timestamp

The range to return, both inclusive.

symbolssequence, optional

Narrows the roster further, in the order given; None reads the whole roster.

variablessequence of str, optional

Variables to keep, in the order given; None keeps every one.

Returns:
xr.Dataset

The panel on (timestamp, symbol).

Raises:
KeyError

If symbols names a symbol off the roster, or a variable is not in the wrapped store.

ValueError

If start is after end.

Examples

>>> prices.panel("2024-01-02", "2024-01-05", symbols=[4])["symbol"].values.tolist()
[4]
>>> prices.panel("2024-01-02", "2024-01-05", symbols=[3])
Traceback (most recent call last):
KeyError: 'RosterDataset.panel(): symbol(s) [3] are not on the roster ...'
resample_labels(timestamps, freq)[source]#

Return the bars the wrapped dataset cuts timestamps into.

shared_name_map(names)[source]#

Return the wrapped dataset’s renaming of names onto the shared names.

Examples

>>> prices.shared_name_map(["adjClose"])
{}
stored_symbols()[source]#

Return the roster’s symbols the wrapped store holds, in its axis order.

Only the two symbol axes are read, never a data variable.

Examples

>>> RosterDataset(sep, membership).stored_symbols()
[2, 4]
ticker_lookup()[source]#

Return the wrapped dataset’s ticker lookup.

Examples

With sep a Sharadar SEP dataset whose ticker sidecar names permaticker 199059 AAPL:

>>> RosterDataset(sep, membership).ticker_lookup().label([199059], date(2024, 1, 2))
['AAPL']
tradable_bars(prices, fill_column)[source]#

Return the wrapped dataset’s tradable bars of a panel of this view.

Examples

>>> panel = prices.panel("2024-01-02", "2024-01-05")
>>> prices.tradable_bars(panel, "adjOpen").equals(sep.tradable_bars(panel, "adjOpen"))
True