Skip to content

Fix/strategy optimization#24

Merged
LeFi8 merged 3 commits into
mainfrom
fix/strategy-optimization
Jun 8, 2026
Merged

Fix/strategy optimization#24
LeFi8 merged 3 commits into
mainfrom
fix/strategy-optimization

Conversation

@LeFi8

@LeFi8 LeFi8 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a hybrid gating mechanism that allows a trade-off between target metric degradation and annualized return improvement, configured via metric_return_tradeoff and metric_floor. The changes span configuration schemas, gate evaluation logic, orchestrator warnings, and unit tests. The review feedback highlights two important issues: first, the absolute metric_floor constraint is skipped when no baseline is present because it is nested inside the baseline-dependent check; second, there is a naming and description mismatch in the API reference documentation compared to the actual implementation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/autobacktest/gate.py
Comment on lines 272 to 277
if baseline is not None:
result = _check_metric_improvement(report, baseline, target_metric, min_improvement)
result = _check_metric_improvement(
report, baseline, target_metric, min_improvement, tradeoff_coeff, metric_floor
)
if not result.accepted:
return result

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The absolute metric_floor constraint is currently only checked inside _check_metric_improvement, which is skipped entirely if baseline is None. This means candidates will not be checked against the absolute target-metric floor when evaluated without a baseline. The absolute floor check should be performed independently of the baseline presence.

Suggested change
if baseline is not None:
result = _check_metric_improvement(report, baseline, target_metric, min_improvement)
result = _check_metric_improvement(
report, baseline, target_metric, min_improvement, tradeoff_coeff, metric_floor
)
if not result.accepted:
return result
if metric_floor is not None:
candidate_val = _get_in_sample_metric_val(report, target_metric)
if math.isnan(candidate_val) or candidate_val <= metric_floor:
msg = (
f"Candidate {target_metric.value} ({candidate_val:.4f}) is below the"
f" required floor of {metric_floor:.4f}."
)
report.is_accepted = False
report.rejection_reason = msg
return GateResult(accepted=False, reason=msg, failed_gate="metric_floor")
if baseline is not None:
result = _check_metric_improvement(
report, baseline, target_metric, min_improvement, tradeoff_coeff, metric_floor
)
if not result.accepted:
return result

Comment thread docs/api-reference.md Outdated
Comment on lines +306 to +307
| `sharpe_return_tradeoff` | `float` | `0.0` | Acceptable target metric reduction per 100% (1.0) increase in annualized return; `0.0` disables trade-off |
| `min_metric_floor` | `float\|None` | `None` | Absolute target metric floor below which candidates are always rejected regardless of trade-off; `None` disables |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The parameter names and descriptions in the API reference do not match the actual implementation in StrategyConfig (defined in src/autobacktest/strategy/config_schema.py). The fields are implemented as metric_return_tradeoff and metric_floor (not sharpe_return_tradeoff and min_metric_floor), and the tradeoff scaling is per 1pp (0.01) increase in annualized return rather than per 100% (1.0) increase.

Suggested change
| `sharpe_return_tradeoff` | `float` | `0.0` | Acceptable target metric reduction per 100% (1.0) increase in annualized return; `0.0` disables trade-off |
| `min_metric_floor` | `float\|None` | `None` | Absolute target metric floor below which candidates are always rejected regardless of trade-off; `None` disables |
| `metric_return_tradeoff` | `float` | `0.0` | Metric reduction tolerated per 1pp (0.01) increase in annualized return; `0.0` disables |
| `metric_floor` | `float\|None` | `None` | Absolute target-metric floor below which candidates are always rejected regardless of trade-off; `None` disables |

@LeFi8 LeFi8 merged commit 08bcc37 into main Jun 8, 2026
3 checks passed
@LeFi8 LeFi8 deleted the fix/strategy-optimization branch June 8, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant