quantlab.dataset.crsp.resolve_security_filter#
- quantlab.dataset.crsp.resolve_security_filter(value, *, owner='CrspStockDataset')[source]#
Resolve a
security_filtervalue to{column: allowed values}.A preset name is replaced by its entry in
SECURITY_FILTER_PRESETS. A mapping is checked againstFILTERABLE_COLUMNSand returned with each list of allowed values turned into a tuple of strings. An unknown preset raises instead of falling back to the default or to “keep everything”, because a silently different panel looks exactly like a correct one.- Parameters:
- valuestr or dict
A preset name or a
{column: allowed values}mapping.- ownerstr, default “CrspStockDataset”
Class name used as the prefix of every error message.
- Returns:
- dict of str to tuple of str
The resolved mapping; empty for the
"none"preset.
- Raises:
- ValueError
If the preset name is unknown,
valueis neither a string nor a dict, a column is not filterable, or a list of allowed values is a bare string or empty.
Examples
>>> resolve_security_filter("none") {} >>> resolve_security_filter("equity_common")["sharetype"] ('NS', 'SB', 'CE') >>> resolve_security_filter({"securitytype": ["EQTY"], "primaryexch": ["N"]}) {'securitytype': ('EQTY',), 'primaryexch': ('N',)} >>> resolve_security_filter("common") Traceback (most recent call last): ValueError: CrspStockDataset: security_filter 'common' is not a preset. ...