07.4.3.12 — Real Risk Engine (execution-level)

This commit is contained in:
2026-05-05 20:28:43 +03:00
parent 3c3f0e846a
commit b1513a28ef
6 changed files with 157 additions and 9 deletions

View File

@@ -275,6 +275,14 @@ class ExecutionEngine:
price_move_percent = self._calculate_price_move_percent(current_price)
unrealized_pnl = self._calculate_pnl(current_price)
if self._is_max_loss_hit(state, unrealized_pnl):
return self._close_position(
state,
forced_reason="MAX_LOSS",
forced_exit_price=current_price,
forced_pnl=unrealized_pnl,
)
if self._is_stop_loss_hit(state, price_move_percent):
return self._close_position(
state,
@@ -291,14 +299,6 @@ class ExecutionEngine:
forced_pnl=unrealized_pnl,
)
if self._is_max_loss_hit(state, unrealized_pnl):
return self._close_position(
state,
forced_reason="MAX_LOSS",
forced_exit_price=current_price,
forced_pnl=unrealized_pnl,
)
return None
def _is_stop_loss_hit(