How strategies trade real money: dollar amounts, automatic reconciliation, close-all, and the kill switch.
The trading portfolio is the set of strategies allowed to place real orders. Each strategy in it gets a fixed dollar amount; the reconciler daemon then keeps your exchange positions converged to the combined target — you never place these orders yourself.
strategy.py ──► state.json ──────────────┐
(cron) ├──► reconciler.py ──► exchange
amounts ──► portfolio_config.json ───┘
Each strategy in the portfolio is assigned an amount in account currency (e.g. USD) — what the strategy trades with when its signal is at full size. The target position per symbol is the sum across strategies:
target[symbol] = Σ ( amount × position )
position is the strategy's signal and can be fractional (a vol-scaled strategy may emit 0.5 or 1.8). The amount you set is exactly what sizes positions — it does not drift with account equity.
manager/portfolio_config.json by hand. Set amounts from the workspace Trading setup page or ask the agent; optimizer weights are applied only through manager.py, which is dry-run by default and writes the config only with --apply after you confirm.
The reconciler is a daemon that polls every 5 seconds and reconciles whenever:
state.json changes)Each pass compares the target against your actual exchange positions and places market orders to close the gap; differences under $10 are ignored. A position flip (long → short) is split into a reduce-only close plus a fresh open, so hedge-mode accounts never hold both sides at once.
If reading positions from the exchange fails 3 times in a row (revoked key, IP not whitelisted, outage), the reconciler trips the kill switch automatically. It never clears it — only you do.
The Close all positions button in the workspace (or python3 manager/flatten.py) market-closes every open position on every connected exchange. It is a panic button, not portfolio management:
While the kill switch is on, any order that would add exposure is refused at the code level. Closing positions, stop-loss / take-profit, and cancels still go through — a halt never traps a position you are trying to reduce.
It is set by Pause trading or Close all positions in the workspace, by telling the agent to stop trading, or automatically on exchange disconnect. It is never cleared automatically — trading resumes only when you press Start trading or explicitly ask the agent to resume. Every order attempt and denial is written to an audit log.
Every executed order is appended to manager/orders.jsonl with its legs — the exchange-confirmed fill price and executed quantity of each individual leg. A position flip records two legs: the closing leg carries the exit price, the opening leg the entry price.
Partial failures are recorded too: if a flip's closing leg filled but the opening leg failed, the entry is kept and marked failed — the history never hides an order that moved real money. The workspace Order History tab renders this file.