trading.analyzer.data.data_prep
trading.analyzer.data.data_prep
get_param_columns
get_param_columns(df: DataFrame, exclude_constant: bool = True) -> list[str]
Returns the columns in df that represent swept strategy parameters, inferred
by exclusion of known metric column names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame produced by |
required |
exclude_constant
|
bool
|
If True (default), drop parameters that only take a
single unique value across all rows (e.g. a fixed |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of parameter column names. |
Source code in src\contango\trading\analyzer\data\data_prep.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
results_to_dataframe
results_to_dataframe(results: list[BacktestExperimentResult]) -> pd.DataFrame
Flattens a list of BacktestExperimentResult into a tidy DataFrame.
Each row = one experiment. Columns: - one column per parameter key in experiment.parameters - flattened metric columns (total_return, sharpe_ratio, max_drawdown, ...) - "equity_curve" / "monthly_returns": kept as raw tuples (object dtype), consumed directly by the equity-curve / underwater-plot charts - "experiment_id": a human-readable label built from the parameter values, used for hover text, legends, and shortlist filtering
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[BacktestExperimentResult]
|
The list of BacktestExperimentResult from ResearchRunner.run(...). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A pandas DataFrame with one row per experiment. |
Source code in src\contango\trading\analyzer\data\data_prep.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |