returns_panel¶
Defined in fynance.research
- returns_panel(experiments)[source]
Build a
(T, n_configs)returns panel from research experiments.One column per
Experiment, taken from its storedseries["returns"](the per-period net returnsrun_experimentrecords). When an experiment carries onlyseries["equity"](e.g. a hand-built record), the column is derived as the equity curve’s percentage change,R_t = E_t / E_{t-1} - 1fort = 1..T-1— one observation shorter than the equity curve, since the first equity point has no preceding value to return from.- Parameters:
- experimentslist of Experiment
The configurations to stack into a panel (>= 1).
- Returns:
- numpy.ndarray, shape (T, n_configs)
Per-period returns, one config per column.
- Raises:
- ValueError
If
experimentsis empty, an experiment carries neither a"returns"nor an"equity"series (or an equity curve too short to derive a return from), or the resulting columns have mismatched lengths.
Examples
>>> from fynance.research import Experiment, returns_panel >>> a = Experiment(name="a", series={"returns": [0.01, -0.02, 0.03]}) >>> b = Experiment(name="b", series={"equity": [100.0, 101.0, 99.0, 102.0]}) >>> returns_panel([a, b]).shape (3, 2)