keep_position=true.
How It Works
When an executor terminates, it can either:- Close the position and report realized P&L
- Hand over the position to the agent’s inventory for later management
keep_position Behavior
Executor Defaults
The Handover Flow
1. Executor Creates Trades
2. Executor Terminates
When the executor terminates (e.g., stop loss hit withkeep_position=true):
3. Position Added to Inventory
The Position Hold aggregates with any existing position:4. Agent Manages on Next Tick
On the next tick, the agent sees the position:- Wait for recovery
- Spawn a new executor to exit
- Hedge with another position
- Add to the position
Example: Grid Stop-Loss Recovery
LP Position Handover
LP positions work differently:- On-chain position always closes when executor terminates
- If
keep_position=true, the net token change is tracked - ADD events → SELL (tokens left wallet)
- REMOVE events → BUY (tokens + fees returned)
Position Accumulation
Multiple executors can add to the same position:When to Use keep_position
Related
- Inventory - The virtual portfolio concept
- Executors Overview - All executor types

