quantlab.runs.run_metrics.slice_ranges#

quantlab.runs.run_metrics.slice_ranges(split)[source]#

Return the ranges of the in_sample and out_of_sample slices of a split.

in_sample comes from split["in_sample_ranges"] when present (a stitched run_cv() account) and from the single split["in_sample_range"] otherwise; out_of_sample from split["out_of_sample_ranges"]. A slice without a bar has no range. A split without out_of_sample_ranges (None or empty: a run of given weights, which has no training window) has no slices.

Parameters:
splitMapping or None

The split keys of a run, as metrics.json records them.

Returns:
dict

{"in_sample": ranges, "out_of_sample": ranges}, or {}.

Examples

>>> slice_ranges({"training_window": ("2024-01-01", "2024-03-29"),
...               "in_sample_range": None,
...               "out_of_sample_ranges": [("2024-04-01", "2024-06-28")]})
{'in_sample': [], 'out_of_sample': [('2024-04-01', '2024-06-28')]}
>>> slice_ranges(None)
{}