quantlab.dataset.roster.RosterDataset#
- class quantlab.dataset.roster.RosterDataset(config, roster=None)[source]#
Bases:
MarketDatasetconfig.dataseton the symbols ofconfig.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
rosterbeside it.- rosterBaseDataset, optional
The roster dataset, when
configis the wrapped dataset.
- Raises:
- ValueError
If
datasetis not aMarketDatasetorrosternot a dataset.
Examples
With
sepa store on permatickers 1..5 andmembershipa 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
nrows 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
starttoendon 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;
Nonereads the whole roster.- variablessequence of str, optional
Variables to keep, in the order given;
Nonekeeps every one.
- Returns:
- xr.Dataset
The panel on
(timestamp, symbol).
- Raises:
- KeyError
If
symbolsnames a symbol off the roster, or a variable is not in the wrapped store.- ValueError
If
startis afterend.
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
timestampsinto.
Return the wrapped dataset’s renaming of
namesonto 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]