|
54 | 54 | "dual_drive_volatility_delever_vetoed", |
55 | 55 | "dual_drive_volatility_delever_redirect_symbol", |
56 | 56 | ) |
| 57 | +_SOXL_RISK_CONTROL_EXECUTION_FIELDS = ( |
| 58 | + "blend_gate_volatility_delever_enabled", |
| 59 | + "blend_gate_volatility_delever_symbol", |
| 60 | + "blend_gate_volatility_delever_window", |
| 61 | + "blend_gate_volatility_delever_threshold_mode", |
| 62 | + "blend_gate_volatility_delever_threshold", |
| 63 | + "blend_gate_volatility_delever_dynamic_threshold", |
| 64 | + "blend_gate_volatility_delever_dynamic_sample_count", |
| 65 | + "blend_gate_volatility_delever_dynamic_lookback", |
| 66 | + "blend_gate_volatility_delever_dynamic_percentile", |
| 67 | + "blend_gate_volatility_delever_dynamic_min_periods", |
| 68 | + "blend_gate_volatility_delever_dynamic_floor", |
| 69 | + "blend_gate_volatility_delever_dynamic_cap", |
| 70 | + "blend_gate_volatility_delever_metric", |
| 71 | + "blend_gate_volatility_delever_triggered", |
| 72 | + "blend_gate_volatility_delever_retention_ratio", |
| 73 | + "blend_gate_volatility_delever_redirect_symbol", |
| 74 | + "blend_gate_volatility_delever_removed_ratio", |
| 75 | +) |
57 | 76 |
|
58 | 77 |
|
59 | 78 | def _build_portfolio_inputs( |
@@ -176,6 +195,27 @@ def _attach_tqqq_risk_control_execution_fields( |
176 | 195 | execution[field] = value |
177 | 196 |
|
178 | 197 |
|
| 198 | +def _attach_soxl_risk_control_execution_fields( |
| 199 | + plan: dict[str, Any], |
| 200 | + *, |
| 201 | + decision: StrategyDecision, |
| 202 | + runtime_metadata: Mapping[str, Any] | None, |
| 203 | +) -> None: |
| 204 | + if _resolve_canonical_profile(str(plan.get("strategy_profile") or "")) != "soxl_soxx_trend_income": |
| 205 | + return |
| 206 | + execution = plan.get("execution") |
| 207 | + if not isinstance(execution, dict): |
| 208 | + return |
| 209 | + diagnostics = {**dict(runtime_metadata or {}), **dict(decision.diagnostics)} |
| 210 | + annotations = diagnostics.get("execution_annotations") |
| 211 | + if isinstance(annotations, Mapping): |
| 212 | + diagnostics = {**diagnostics, **dict(annotations)} |
| 213 | + for field in _SOXL_RISK_CONTROL_EXECUTION_FIELDS: |
| 214 | + value = diagnostics.get(field) |
| 215 | + if value not in (None, ""): |
| 216 | + execution[field] = value |
| 217 | + |
| 218 | + |
179 | 219 | def _apply_reserved_cash_policy( |
180 | 220 | annotations: ValueTargetExecutionAnnotations, |
181 | 221 | *, |
@@ -610,4 +650,9 @@ def map_strategy_decision_to_plan( |
610 | 650 | decision=normalized_decision, |
611 | 651 | runtime_metadata=runtime_metadata, |
612 | 652 | ) |
| 653 | + _attach_soxl_risk_control_execution_fields( |
| 654 | + plan, |
| 655 | + decision=normalized_decision, |
| 656 | + runtime_metadata=runtime_metadata, |
| 657 | + ) |
613 | 658 | return plan |
0 commit comments