run_experiment

Defined in fynance.research

run_experiment(strategy, data, *, name, X=None, y=None, walk_forward=None, costs=None, period=252, seed=0, code=None, feature_names=None, feature_desc=None, data_desc=None, output_dir=None)[source]

Run a strategy experiment and return a populated Experiment.

Parameters:
strategyfynance.strategy.Strategy

The composed strategy (features -> model -> signal -> cost).

dataPriceSeries or array-like

Price series the strategy runs on (coerced to float64).

namestr

Experiment slug (also the output sub-directory).

Xarray-like, optional

Precomputed feature matrix aligned with data (rows = time). Passed through to the strategy — the way to feed exogenous / regime / multi-venue features the price-only featurizer cannot build. Must be causal.

yarray-like, optional

Supervised target for a model-based strategy run via walk_forward. Defaults to zeros (ignored by rule-based strategies).

walk_forwarddict, optional

Window params for Strategy.run_walk_forward (train/test/step/purge). None runs a single pass.

costsCostModel, optional

Overrides the strategy’s own cost model for this run when given.

periodint

Annualization factor for the metrics.

seedint

Master seed (numpy + torch).

codestr, optional

Generated strategy source, stored verbatim on the experiment.

feature_nameslist of str, optional

Column names of X — recorded in the provenance so a report shows what each feature is. Ignored when X is None.

feature_descstr, optional

Free-text description of how X was built (the feature recipe), recorded in the provenance. Ignored when X is None.

data_descstr, optional

Free-text description of the price data (source, instrument, resolution), recorded in the provenance.

output_dirstr or pathlib.Path, optional

When given, the experiment is saved under <output_dir>/<name>/.

Returns:
Experiment

Populated with spec, metrics and series.

Notes

The returned experiment’s spec carries a self-describing provenance block (data, features, model, signal, walk_forward, cost, period, seed) so an artifact always records what produced it. fynance.research.write_report renders it as a Provenance table.