mrv.pipeline – Labels-first validation pipeline

mrv.pipeline – Labels-first validation pipeline.

Core API (no model fitting – users supply labels):

from mrv.pipeline import validate_rep, validate_res

# Representation invariance: user provides labels from their own models
result = validate_rep(labels={
    "SPY": {"rep_a": labels_a, "rep_b": labels_b, "rep_c": labels_c}
})

# Resolution invariance: user provides labels at each frequency
result = validate_res(labels={
    "SPY": {"5m": labels_5m, "15m": labels_15m, "1h": labels_1h, "1d": labels_1d}
})

Convenience API (model fitting included – requires pip install scikit-learn):

from mrv.pipeline import run

run("config.yaml", "rep")   # data → factors → model → validate → report
mrv.pipeline.validate_rep(labels, risk_proxy=None, prices=None, cfg=None, impact_fn=None)[source]

Representation invariance test – labels in, metrics out.

Parameters:
Return type:

Dict[str, Any]

mrv.pipeline.validate_res(labels, event_window=None, calm_window=None, cfg=None, impact_fn=None)[source]

Resolution invariance test – labels in, metrics out.

Parameters:
  • labels (Dict[str, Dict[str, Series]]) – {asset: {freq: pd.Series}}. At least 2 frequencies per asset.

  • event_window (Optional[Any]) – (start_date, end_date) for event-period analysis.

  • calm_window (Optional[Any]) – (start_date, end_date) for calm-period analysis.

  • cfg (Optional[Dict[str, Any]]) – Config for report paths / thresholds.

Return type:

Dict[str, Any]

mrv.pipeline.report(json_path, template=None, cfg=None)[source]

Generate PDF report from JSON.

Return type:

Optional[Path]

mrv.pipeline.download(config=None, cfg=None)[source]

Download data from Yahoo Finance or IB Gateway (based on config).

The download.source field in config.yaml controls the data source: yahoo (default, free) or ib (requires IB Gateway running).

Return type:

Dict[str, Any]

mrv.pipeline.run(config=None, validator='rep', cfg=None, impact_fn=None)[source]

Convenience: config → data → model → validate → report.

This is the full pipeline for users who want mrv-lib to handle everything including model fitting. Requires pip install scikit-learn.

For the labels-first API (recommended), use validate_rep() or validate_res() directly.

Return type:

Optional[Path]

mrv.pipeline.validate(config=None, validator='rep', cfg=None, impact_fn=None)[source]

Dispatch a validation run by name, using the convenience pipeline.

Wraps _run_rep_convenience / _run_res_convenience and returns the result dict. Used internally by mrv.validator.monitor.monitor().

Parameters:
  • config (path to config.yaml (or None if ``cfg` is provided).`)

  • validator (str)

  • cfg (Optional[Dict[str, Any]])

  • impact_fn (optional business-impact callback.)

Return type:

Dict[str, Any]