quantlab.dataset.config.BadPrintMaskedDatasetConfig#
- class quantlab.dataset.config.BadPrintMaskedDatasetConfig(*, datasets, name=None, jump=5.0, volume_ratio=20.0, lookback=20, price_variable='adjClose', volume_variable='adjVolume', masked_variables=('open', 'high', 'low', 'close', 'adjOpen', 'adjHigh', 'adjLow', 'adjClose', 'marketcap'), intrabar_variables=('adjOpen',))[source]#
Bases:
MergedDatasetConfigConfig of a merged dataset whose bad prints are masked (#223).
The inputs as for
MergedDatasetConfig, plus the rule ofquantlab.dataset._support.cleaning.bad_print_maskand the variables it reads and masks, all in the merged panel’s shared names. The defaults name the Sharadar panels’ variables (SEP’sadjCloseandadjVolume, DAILY’smarketcap); name another input’s own, or the panel raisesKeyErrorfor a variable the rule reads and none holds.Examples
>>> cfg = BadPrintMaskedDatasetConfig(datasets=[sep, daily]) >>> cfg.jump, cfg.volume_ratio, cfg.lookback (5.0, 20.0, 20)
- intrabar_variables = ('adjOpen',)#
Adjusted intrabar prices checked on their own against the bar’s close and the close before (
intrabar_bad_print_mask); a flagged one is set to NaN with its unadjusted twin (adjOpenwithopen) and the rest of the bar is kept.()switches the check off. The open only by default: a real day’s high or low can be far from both closes (TPST on 2023-10-11 gapped up 7 times and closed 40 times up, so its low is more than 5 times from either), while an open far from both is wrong in every case found since 2016 (25 bars, among them SLND’s 2000.00).
- jump = 5.0#
Fold move beyond which a bar is a candidate (
bad_print_mask).
- lookback = 20#
Bars before a bar the rule reads.
- masked_variables = ('open', 'high', 'low', 'close', 'adjOpen', 'adjHigh', 'adjLow', 'adjClose', 'marketcap')#
Variables set to NaN at a bad print, where the panel holds them: the prices and the market cap, which is a price times shares.
- price_variable = 'adjClose'#
The adjusted price the rule reads.
- volume_ratio = 20.0#
A candidate on less than this many times its lookback’s mean volume is a bad print.
- volume_variable = 'adjVolume'#
The volume the rule reads, on the adjusted price’s share basis.