Commit ·
9d444de
1
Parent(s): b64ba5a
fix(signals): tighten rescaled stop clamp to 8 percent
Browse files- crew/crew.py +13 -6
crew/crew.py
CHANGED
|
@@ -324,17 +324,24 @@ class FinAgentCrew:
|
|
| 324 |
new_target = None if _bad(target) else round(target * scale, 2)
|
| 325 |
|
| 326 |
# Extra guard: after rescaling, stop / target should still be
|
| 327 |
-
# within a reasonable band of the new entry
|
| 328 |
-
#
|
| 329 |
-
#
|
| 330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
if v is None:
|
| 332 |
return True
|
| 333 |
return abs(v - live_entry) / live_entry > 0.15
|
| 334 |
|
| 335 |
-
if
|
| 336 |
new_stop = None
|
| 337 |
-
if
|
| 338 |
new_target = None
|
| 339 |
|
| 340 |
rescaled = TradingSignal(
|
|
|
|
| 324 |
new_target = None if _bad(target) else round(target * scale, 2)
|
| 325 |
|
| 326 |
# Extra guard: after rescaling, stop / target should still be
|
| 327 |
+
# within a reasonable band of the new entry. Stops must stay
|
| 328 |
+
# tight (<= 8 %) so the R:R remains sane for a retail card;
|
| 329 |
+
# targets can be more ambitious (<= 15 %). If the LLM emitted
|
| 330 |
+
# something implausibly wide we let the back-fill replace it
|
| 331 |
+
# with the default 3 % / 5 % band.
|
| 332 |
+
def _stop_unreasonable(v: Optional[float]) -> bool:
|
| 333 |
+
if v is None:
|
| 334 |
+
return True
|
| 335 |
+
return abs(v - live_entry) / live_entry > 0.08
|
| 336 |
+
|
| 337 |
+
def _target_unreasonable(v: Optional[float]) -> bool:
|
| 338 |
if v is None:
|
| 339 |
return True
|
| 340 |
return abs(v - live_entry) / live_entry > 0.15
|
| 341 |
|
| 342 |
+
if _stop_unreasonable(new_stop):
|
| 343 |
new_stop = None
|
| 344 |
+
if _target_unreasonable(new_target):
|
| 345 |
new_target = None
|
| 346 |
|
| 347 |
rescaled = TradingSignal(
|