Complete reference for every broker-cli command. Every response uses a stable JSON envelope:{ok,data,error,meta}with request IDs for tracing and audit correlation. Use supported flags where available and note command-specific behavior in each section.
Install-time onboarding and cleanup. E*Trade OAuth is handled inside `broker setup`.
broker setupInteractive setup wizard: choose provider, configure credentials, and complete E*Trade OAuth.
broker setup
Use this command for all provider onboarding.
broker updateSync broker-cli source checkout to the latest commit on origin/main.
broker update [OPTIONS]
| --force | Discard tracked local changes before syncing |
| --reinstall / --no-reinstall | Reinstall editable packages after syncing |
$ broker update
{"ok":true,"data":{"updated":true,"branch":"main","from":"...","to":"..."},"error":null,"meta":{"schema_version":"v1","command":"update.sync","request_id":"...","timestamp":"..."}}broker schemaReturn machine-readable JSON Schema for command params/results.
broker schema [COMMAND]
$ broker schema quote.snapshot
{"ok":true,"data":{"schema_version":"v1","command":"quote.snapshot","schema":{"params":{...},"result":{...}},"envelope":{...}},"error":null,"meta":{"schema_version":"v1","command":"schema.get","request_id":"...","timestamp":"..."}}Use this in agent bootstrapping to validate payloads before command execution.
broker uninstallRemove broker-cli install/setup artifacts (config, state, data, runtime, wrappers, completions).
broker uninstall [OPTIONS]
| --yes | Skip interactive confirmation |
| --keep-ib-app | Keep installed IB Gateway app |
| --keep-source | Keep source checkout under ~/.local/share/broker/source |
Manage the broker daemon process. The daemon maintains the broker connection and handles all API communication.
broker daemon startStart the trading daemon and wait for socket readiness.
broker daemon start [OPTIONS]
| --paper | Use paper trading port (4002) |
| --gateway HOST:PORT | Override gateway endpoint |
| --client-id INT | Override IB client ID |
$ broker daemon start
{"ok":true,"data":{"socket":"~/.local/state/broker/broker.sock"},"error":null,"meta":{"schema_version":"v1","command":"daemon.start","request_id":"...","timestamp":"..."}}
$ broker daemon start --paper
{"ok":true,"data":{"socket":"~/.local/state/broker/broker.sock"},"error":null,"meta":{"schema_version":"v1","command":"daemon.start","request_id":"...","timestamp":"..."}}broker daemon stopRequest graceful daemon shutdown.
broker daemon stop
$ broker daemon stop
{"ok":true,"data":{"stopping":true},"error":null,"meta":{"schema_version":"v1","command":"daemon.stop","request_id":"...","timestamp":"..."}}broker daemon statusShow daemon uptime and broker connection state.
broker daemon status
$ broker daemon status
{"ok":true,"data":{"uptime_seconds":3421.4,"connection":{"connected":true,"account_id":"..."},"socket":"~/.local/state/broker/broker.sock"},"error":null,"meta":{"schema_version":"v1","command":"daemon.status","request_id":"...","timestamp":"..."}}broker daemon restartStop then start the daemon.
broker daemon restart [OPTIONS]
| --paper | Restart using paper trading port |
Real-time quotes, streaming, option chains, and historical bars.
broker quoteSnapshot quote for one or more symbols.
broker quote SYMBOL [SYMBOL...]
$ broker quote AAPL MSFT
{"ok":true,"data":[{"symbol":"AAPL","bid":185.2,"ask":185.25,"last":185.22,"volume":48291033},{"symbol":"MSFT","bid":412.1,"ask":412.15,"last":412.12,"volume":22104891}],"error":null,"meta":{"schema_version":"v1","command":"quote.snapshot","request_id":"...","timestamp":"..."}}broker watchContinuously refresh quote fields in the terminal. Ctrl+C to stop.
broker watch SYMBOL [OPTIONS]
| --fields FIELDS | Comma-separated: bid, ask, last, volume, timestamp, exchange, currency, symbol(default: bid,ask,last,volume) |
| --interval INTERVAL | Refresh rate (e.g. 250ms, 1s, 2m)(default: 1s) |
$ broker watch AAPL --fields bid,ask,last --interval 500ms
{"ok":true,"data":{"bid":185.2,"ask":185.25,"last":185.22},"error":null,"meta":{"schema_version":"v1","command":"quote.watch","request_id":"...","timestamp":"..."}}broker chainFetch an option chain with paging and field selection controls for agent-efficient payloads.
broker chain SYMBOL [OPTIONS]
| --expiry YYYY-MM | Filter by expiration month |
| --strike-range LOW:HIGH | Relative range around current price(default: 0.9:1.1) |
| --type call|put | Filter by option type |
| --limit INT | Max entries returned after filtering(default: 200) |
| --offset INT | Offset into filtered entries(default: 0) |
| --fields LIST | Comma-separated entry fields (e.g. strike,expiry,bid,ask) |
$ broker chain AAPL --type call --strike-range 0.95:1.05 --limit 5 --fields strike,expiry,bid,ask
{"ok":true,"data":{"symbol":"AAPL","underlying_price":263.3,"entries":[{"strike":252.5,"expiry":"2026-02-20","bid":null,"ask":null}],"pagination":{"total_entries":80,"offset":0,"limit":5,"returned_entries":5},"fields":["strike","expiry","bid","ask"]},"error":null,"meta":{"schema_version":"v1","command":"market.chain","request_id":"...","timestamp":"..."}}broker historyFetch historical price bars for a symbol.
broker history SYMBOL --period PERIOD --bar SIZE [OPTIONS]
| --period 1d|5d|30d|90d|1y | Lookback period |
| --bar 1m|5m|15m|1h|1d | Bar size |
| --rth-only | Restrict to regular trading hours |
$ broker history AAPL --period 5d --bar 1h
{"ok":true,"data":[{"symbol":"AAPL","time":"2026-02-18T00:00:00","open":265.1,"close":263.29}],"error":null,"meta":{"schema_version":"v1","command":"market.history","request_id":"...","timestamp":"..."}}Available on Interactive Brokers only.
Place, monitor, and cancel orders. Supports market, limit, stop, and bracket orders.
broker order buyPlace a buy order. Market by default unless --limit or --stop is set.
broker order buy SYMBOL QTY [OPTIONS]
| --limit PRICE | Limit price (creates limit order) |
| --stop PRICE | Stop trigger price (creates stop order) |
| --tif DAY|GTC|IOC | Time in force(default: DAY) |
| --dry-run | Preview order without submitting |
| --idempotency-key KEY | Stable retry key mapped to client_order_id |
$ broker order buy AAPL 100 --limit 185.00 --idempotency-key rebalance-aapl-1
{"ok":true,"data":{"order":{"client_order_id":"rebalance-aapl-1","status":"Submitted"},"dry_run":false,"submit_allowed":true},"error":null,"meta":{"schema_version":"v1","command":"order.place","request_id":"...","timestamp":"..."}}
$ broker order buy AAPL 10 --limit 185 --dry-run
{"ok":true,"data":{"order":{"client_order_id":"dryrun-...","status":"DryRunAccepted"},"dry_run":true,"submit_allowed":true},"error":null,"meta":{"schema_version":"v1","command":"order.place","request_id":"...","timestamp":"..."}}broker order sellPlace a sell order. Market by default unless --limit or --stop is set.
broker order sell SYMBOL QTY [OPTIONS]
| --limit PRICE | Limit price |
| --stop PRICE | Stop trigger price |
| --tif DAY|GTC|IOC | Time in force(default: DAY) |
| --dry-run | Preview order without submitting |
| --idempotency-key KEY | Stable retry key mapped to client_order_id |
$ broker order sell AAPL 50 --limit 190.00 --tif GTC
broker order bracketPlace a bracket order: entry + take profit + stop loss.
broker order bracket SYMBOL QTY --entry PRICE --tp PRICE --sl PRICE [OPTIONS]
| --entry PRICE | Entry limit price (required) |
| --tp PRICE | Take-profit price (required) |
| --sl PRICE | Stop-loss price (required) |
| --side buy|sell | Order side(default: buy) |
| --tif DAY|GTC|IOC | Time in force(default: DAY) |
$ broker order bracket AAPL 100 --entry 185 --tp 195 --sl 180
Available on Interactive Brokers only.
broker order statusShow status for a single order by client order ID.
broker order status ORDER_ID
$ broker order status a1b2c3
{"ok":true,"data":{"client_order_id":"a1b2c3","status":"Filled","fill_qty":100,"fill_price":185.02},"error":null,"meta":{"schema_version":"v1","command":"order.status","request_id":"...","timestamp":"..."}}broker ordersList orders with optional status and date filters.
broker orders [OPTIONS]
| --status active|filled|cancelled|all | Filter by status(default: all) |
| --since YYYY-MM-DD | Filter by date |
$ broker orders --status active
{"ok":true,"data":[{"client_order_id":"...","status":"Submitted","symbol":"AAPL"}],"error":null,"meta":{"schema_version":"v1","command":"orders.list","request_id":"...","timestamp":"..."}}broker cancelCancel a single order by ID, or all open orders with --all.
broker cancel [ORDER_ID] [OPTIONS]
| --all | Cancel all open orders |
| --confirm | Required with --all in interactive mode |
$ broker cancel a1b2c3
{"ok":true,"data":{"client_order_id":"a1b2c3","cancelled":true},"error":null,"meta":{"schema_version":"v1","command":"order.cancel","request_id":"...","timestamp":"..."}}
$ broker cancel --all
{"ok":true,"data":{"cancelled":true},"error":null,"meta":{"schema_version":"v1","command":"orders.cancel_all","request_id":"...","timestamp":"..."}}broker fillsList fill/execution history.
broker fills [OPTIONS]
| --since YYYY-MM-DD | Filter by date |
| --symbol SYMBOL | Filter by symbol |
$ broker fills --since 2026-02-01 --symbol AAPL
{"ok":true,"data":[{"fill_id":"...","symbol":"AAPL","qty":100,"price":185.02}],"error":null,"meta":{"schema_version":"v1","command":"fills.list","request_id":"...","timestamp":"..."}}Positions, P&L, balances, and exposure analysis.
broker positionsShow current positions with unrealized P&L.
broker positions [OPTIONS]
| --symbol SYMBOL | Filter to a single symbol |
$ broker positions
{"ok":true,"data":[{"symbol":"AAPL","qty":200,"avg_cost":178.5,"market_value":37044.0,"unrealized_pnl":344.0},{"symbol":"MSFT","qty":100,"avg_cost":405.2,"market_value":41212.0,"unrealized_pnl":692.0}],"error":null,"meta":{"schema_version":"v1","command":"portfolio.positions","request_id":"...","timestamp":"..."}}broker pnlShow P&L summary for today, a named period, or since a specific date.
broker pnl [OPTIONS]
| --today | Today's P&L window |
| --period PERIOD | Named period (e.g. 7d) |
| --since YYYY-MM-DD | Custom start date |
$ broker pnl --today
{"ok":true,"data":{"date":"2026-02-19","realized":1250.0,"unrealized":1036.0,"total":2286.0},"error":null,"meta":{"schema_version":"v1","command":"portfolio.pnl","request_id":"...","timestamp":"..."}}Only one of --today, --period, or --since can be used. Defaults to --today.
broker balanceShow account balances and margin metrics.
broker balance
$ broker balance
{"ok":true,"data":{"net_liquidation":125000.0,"cash":42000.0,"buying_power":84000.0,"margin_used":41000.0},"error":null,"meta":{"schema_version":"v1","command":"portfolio.balance","request_id":"...","timestamp":"..."}}broker exposureShow portfolio exposure grouped by dimension. Returns percentage of net liquidation value.
broker exposure [OPTIONS]
| --by symbol|sector|asset_class|currency | Grouping dimension(default: symbol) |
$ broker exposure --by symbol
{"ok":true,"data":[{"key":"AAPL","exposure_pct":29.6},{"key":"MSFT","exposure_pct":33.0},{"key":"cash","exposure_pct":37.4}],"error":null,"meta":{"schema_version":"v1","command":"portfolio.exposure","request_id":"...","timestamp":"..."}}
$ broker exposure --by sector
{"ok":true,"data":[{"key":"Technology","exposure_pct":62.6},{"key":"cash","exposure_pct":37.4}],"error":null,"meta":{"schema_version":"v1","command":"portfolio.exposure","request_id":"...","timestamp":"..."}}broker snapshotSingle-call state snapshot for agent loops: quotes, positions, balance, pnl, exposure, and connection.
broker snapshot [OPTIONS]
| --symbols SYMBOLS | Comma-separated symbol list for quote snapshot |
| --exposure-by symbol|sector|asset_class|currency | Exposure grouping(default: symbol) |
$ broker snapshot --symbols AAPL,MSFT
{"ok":true,"data":{"symbols":["AAPL","MSFT"],"quotes":[...],"positions":[...],"balance":{...},"pnl":{...},"exposure":[...],"connection":{"connected":true}},"error":null,"meta":{"schema_version":"v1","command":"portfolio.snapshot","request_id":"...","timestamp":"..."}}Query order history and command invocations. Export to CSV.
broker audit ordersQuery order lifecycle records from audit storage.
broker audit orders [OPTIONS]
| --since YYYY-MM-DD | Filter by date |
| --status active|filled|cancelled|all | Filter by status |
broker audit commandsQuery command invocation audit records.
broker audit commands [OPTIONS]
| --source cli|sdk|ts_sdk | Filter by source |
| --since YYYY-MM-DD | Filter by date |
| --request-id ID | Filter to a single command execution trace |
$ broker audit commands --request-id 647a8306-...
{"ok":true,"data":[{"timestamp":"...","source":"cli","command":"order.place","result_code":0,"request_id":"647a8306-..."}],"error":null,"meta":{"schema_version":"v1","command":"audit.commands","request_id":"...","timestamp":"..."}}broker audit exportExport audit rows to CSV.
broker audit export --table TABLE [OPTIONS]
| --table orders|commands | Which audit table to export |
| --format csv | Output format(default: csv) |
| --request-id ID | When table=commands, filter export by request_id |
broker-cli uses a JSON config file and supports environment variable overrides.
Default location: ~/.config/broker/config.json
{
"broker": {
"provider": "ib",
"etrade": {
"consumer_key": "...",
"consumer_secret": "...",
"persistent_auth": true,
"username": "...",
"password": "...",
"sandbox": false
},
"gateway": {
"host": "127.0.0.1",
"port": 4002,
"client_id": 1
},
"runtime": {
"request_timeout_seconds": 15
}
}
}Environment variables override config file values.
| BROKER_PROVIDER | Provider name (etrade, ib) |
| BROKER_ETRADE_CONSUMER_KEY | E*Trade consumer key |
| BROKER_ETRADE_CONSUMER_SECRET | E*Trade consumer secret |
| BROKER_ETRADE_USERNAME | E*Trade username (persistent auth) |
| BROKER_ETRADE_PASSWORD | E*Trade password (persistent auth) |
| BROKER_ETRADE_PERSISTENT_AUTH | Enable persistent auth (true/false) |
| BROKER_GATEWAY_HOST | IB gateway host |
| BROKER_GATEWAY_PORT | IB gateway port (4001=live, 4002=paper) |
| BROKER_GATEWAY_CLIENT_ID | IB client ID |
| Config | ~/.config/broker/config.json |
| Skill file | ~/.local/share/broker/source/skills/broker/SKILL.md |
| E*Trade tokens | ~/.config/broker/etrade_tokens.json |
| Daemon socket | ~/.local/state/broker/broker.sock |
| Daemon log | ~/.local/state/broker/broker.log |
| Audit data | ~/.local/share/broker/ |