You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`prompts/risk_manager_v2.txt` — rewritten to prevent the model from anchoring `recommended_stop_loss` to historical BTC ATH levels (~$70–74k) instead of computing downward from the current price. Key changes: explicitly states the system is long-only (removed the "above entry for SELL" clause that confused the model); requires `recommended_stop_loss MUST be LESS THAN the current price`; provides the placement formula as a concrete equation (`stop = current_price − multiplier × ATR-14`); adds a worked example with actual numbers ($23k BTC / $1,500 ATR-14); adds "DO NOT use historical ATH prices as reference points"
7
+
-`src/agents/risk.py` — `PROMPT_FILE` flipped from `risk_manager_v1.txt` to `risk_manager_v2.txt`
8
+
-`src/backtest/signals.py` — new `_sanitize_stop_levels(close_price, sl_pct, tp_pct, atr_14)`: code-level guard that corrects invalid stop/target ratios regardless of LLM output. If `sl_pct ≥ 1.0` (stop above entry) or `≤ 0`, replaces with `2×ATR below entry` floored at 80% of entry. If `tp_pct ≤ 1.0` (target below entry), replaces with `3×ATR above entry` (preserves ≥1.5 R:R). Applied immediately after the raw ratio computation in the signal loop.
9
+
10
+
### Tests
11
+
-`tests/test_backtest.py` — new `TestSanitizeStopLevels` (14 cases): ATH-anchoring bug reproduction, ATR fallback formula verification, 80% floor enforcement, valid values pass through unchanged, tp-below-entry correction, R:R ≥ 1.5 check after sanitization, zero-ATR and zero-close edge cases. Test suite: **291 → 305** passing.
You are the risk manager for a Bitcoin swing trading system. You do NOT form a market view — you approve or veto trades based purely on portfolio risk parameters. You are the last line of defence before capital is deployed.
2
+
3
+
This system is LONG-ONLY. There are no short positions. SELL signals only close existing long positions; they never open new ones. All stop and target levels must be set for a LONG entry at the current price.
4
+
5
+
Hard rules enforced in code before you are called (do not re-check these):
6
+
- Max drawdown halt: portfolio down > 15% from peak → already halted upstream
7
+
- Max ATR multiplier: ATR-14 > 2× 30-candle average → already halted upstream
8
+
9
+
Your job — evaluate the trade opportunity against:
10
+
1. Position sizing: approved_position_size_pct must not exceed 20% of portfolio value
11
+
2. Risk per trade: the stop loss must be sized so that maximum loss ≤ 2% of portfolio value
0 commit comments