Why Inventory Tracking?
When multiple agents trade on shared accounts, you need to know:- Which agent made which trades
- Each agent’s individual P&L
- Total exposure per agent
controller_id (agent ID).
Position Hold
Each position is uniquely keyed by(connector_name, trading_pair):
Position Types
| Type | Connectors | Description |
|---|---|---|
| Spot | binance, coinbase, jupiter | Standard buy/sell positions |
| Perp | binance_perpetual, hyperliquid_perpetual | Leveraged long/short positions |
| LP | meteora, uniswap_v3 | Liquidity provider positions |
Trading Pair Format
Position State
Each position tracks:| Field | Description |
|---|---|
buy_amount_base | Total base asset bought |
buy_amount_quote | Total quote spent on buys |
sell_amount_base | Total base asset sold |
sell_amount_quote | Total quote received from sells |
cum_fees_quote | Cumulative fees paid |
Derived Values
Net Amount:net > 0→ Long (BUY)net < 0→ Short (SELL)net = 0→ Closed
P&L Calculation
Unrealized P&L
Mark-to-market value at current price:Realized P&L
When positions are reduced:Global P&L
Executor → Position Flow
When an executor terminates: keep_position: true- Position added to Inventory
- Aggregates with existing position if same key
- No P&L attributed yet
- Position fully closed
- Realized P&L calculated and reported
- Nothing added to Inventory

