Trade Management

The order is live. Now the engine only has to watch it home.

Stop and target ride on the broker. The engine enforces the time limit and flattens before the weekend. Nothing else to touch.

TradeManager.py
# once per closed candle, per strategy
def manage_open_trade(pos):
    if not pos.is_open:
        return          # broker closed it
    if pos.age_candles >= MAX_LIFE:
        close(pos)      # time is up
    if weekend_ahead():
        close(pos)      # flat before gap

One position, three ways out

Every open trade ends in exactly one of them. Then it closes, and the story is handed on.

OPEN position live Stop loss / Take profit on the broker · natural close Maximum life candle limit reached · engine closes Weekend flat closed before the market gap CLOSED execution done Journal records the trade

One at a time

A strategy holds a single position. A fresh signal while one is open is never stacked, it is logged, with its reason.

Position openthe strategy is busy
New signal arrivesa valid trigger on the same strategy
Logged, not executedrecorded with the reason, never stacked

Then it hands over

The moment the trade closes, execution steps back and the journal takes it from there.

Trade closes Execution done Journal takes over