Frontier Analysis
Section B: Risk/reward frontiers and knee point detection.
frontiers
Frontier analysis: risk/reward boundaries and knee points.
frontier_risk_constrained(trades, dd_grid, q=0.9, min_sample=5)
Compute risk-constrained frontier: Max MFE for given MAE limits.
For each drawdown cap in dd_grid, find the q-th quantile of MFE among trades that stay within that drawdown limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trades
|
TradeSet
|
Trade geometry data |
required |
dd_grid
|
ndarray
|
Array of drawdown limits (positive values, e.g., [0.5, 1.0, 1.5, ...]) |
required |
q
|
float
|
Quantile for MFE (e.g., 0.9 = 90th percentile) |
0.9
|
min_sample
|
int
|
Minimum number of trades required for valid point |
5
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing: - 'dd': array of drawdown caps (x-axis) - 'mfe': array of MFE quantiles (y-axis) - 'counts': array of sample counts at each point - 'knee': tuple of (knee_dd, knee_mfe) |
Source code in signal_analyzer/analysis/frontiers.py
frontier_opportunity_constrained(trades, tp_grid, q=0.8, min_sample=5)
Compute opportunity-constrained frontier: Min MAE for desired MFE targets.
For each profit target in tp_grid, find the q-th quantile of MAE (drawdown) among trades that achieved that target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trades
|
TradeSet
|
Trade geometry data |
required |
tp_grid
|
ndarray
|
Array of profit targets (positive values, e.g., [0.5, 1.0, 1.5, ...]) |
required |
q
|
float
|
Quantile for MAE/drawdown (e.g., 0.8 = 80th percentile worst drawdown) |
0.8
|
min_sample
|
int
|
Minimum number of trades required for valid point |
5
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing: - 'tp': array of profit targets (x-axis) - 'dd': array of drawdown quantiles (y-axis, positive values) - 'counts': array of sample counts at each point - 'knee': tuple of (knee_tp, knee_dd) |
Source code in signal_analyzer/analysis/frontiers.py
compute_frontiers(trades, dd_grid=None, tp_grid=None, risk_q=0.9, opp_q=0.8)
Compute both risk-constrained and opportunity-constrained frontiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trades
|
TradeSet
|
Trade geometry data |
required |
dd_grid
|
ndarray
|
Drawdown grid for risk-constrained frontier. If None, auto-generate based on data. |
None
|
tp_grid
|
ndarray
|
Profit target grid for opportunity-constrained frontier. If None, auto-generate based on data. |
None
|
risk_q
|
float
|
Quantile for risk-constrained frontier MFE |
0.9
|
opp_q
|
float
|
Quantile for opportunity-constrained frontier MAE |
0.8
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with keys: - 'risk_constrained': output from frontier_risk_constrained - 'opportunity_constrained': output from frontier_opportunity_constrained |