07.4.3.12 — Real Risk Engine (execution-level)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user