| name | trading212-cli |
| description | Manage Trading 212 portfolio via CLI - account summary, cash, positions, orders, historical orders, dividends, transactions, instruments search, CSV reports, and investment pies. Use when the user mentions Trading 212, portfolio, positions, P&L, dividends, trading orders, or investment pies. |
| category | finance |
trading212-cli
CLI for the Trading 212 Public API. Manage portfolio, orders, positions, and history.
Auth is pre-configured. Always use --json when calling programmatically.
Resources
account
| Action | Command | Key Flags |
|---|
| Get summary | trading212-cli account summary | --json, --format |
Returns: account ID, currency (USD), totalValue, cash (availableToTrade, reservedForOrders, inPies), investments (currentValue, totalCost, realizedProfitLoss, unrealizedProfitLoss).
positions
| Action | Command | Key Flags |
|---|
| List all | trading212-cli positions list | --json, --ticker <t>, --sort <field>, --fields |
Sort options: ticker, quantity, pnl, value. Each position includes instrument info, quantity, averagePricePaid, currentPrice, and walletImpact (totalCost, currentValue, unrealizedProfitLoss, fxImpact).
orders
| Action | Command | Key Flags |
|---|
| List pending | trading212-cli orders list | --json, --fields |
| Get by ID | trading212-cli orders get <id> | --json |
| Place market | trading212-cli orders market | --ticker, --quantity, --extended-hours, --json |
| Place limit | trading212-cli orders limit | --ticker, --quantity, --limit-price, --time-validity, --json |
| Place stop | trading212-cli orders stop | --ticker, --quantity, --stop-price, --time-validity, --json |
| Place stop-limit | trading212-cli orders stop-limit | --ticker, --quantity, --stop-price, --limit-price, --time-validity, --json |
| Cancel | trading212-cli orders cancel <id> | --json |
Important: Quantity is positive for BUY, negative for SELL. Time validity: DAY or GOOD_TILL_CANCEL. Tickers use Trading 212 format (e.g. AAPL_US_EQ). Use instruments list --search to find tickers.
instruments
| Action | Command | Key Flags |
|---|
| List all | trading212-cli instruments list | --json, --type <STOCK|ETF|...>, --search <query>, --fields |
| List exchanges | trading212-cli instruments exchanges | --json |
history
| Action | Command | Key Flags |
|---|
| Historical orders | trading212-cli history orders | --json, --limit, --cursor, --ticker, --all |
| Dividends | trading212-cli history dividends | --json, --limit, --cursor, --ticker, --all |
| Transactions | trading212-cli history transactions | --json, --limit, --cursor, --time <ISO>, --all |
| Request CSV | trading212-cli history request-report | --from <ISO>, --to <ISO>, --include-orders, --include-dividends, --include-transactions, --include-interest |
| List reports | trading212-cli history reports | --json |
Use --all to auto-paginate and fetch everything. Max 50 items per page.
pies
| Action | Command | Key Flags |
|---|
| List all | trading212-cli pies list | --json |
| Get details | trading212-cli pies get <id> | --json |
| Create | trading212-cli pies create | --name, --instruments <json>, --goal, --dividend-action, --json |
| Update | trading212-cli pies update <id> | --name, --instruments <json>, --goal, --json |
| Delete | trading212-cli pies delete <id> | --json |
| Duplicate | trading212-cli pies duplicate <id> | --name, --json |
Instruments JSON format: '{"AAPL_US_EQ":0.5,"MSFT_US_EQ":0.5}' (ticker: share weight).
Quick Reference
trading212-cli --help
trading212-cli <resource> --help
trading212-cli <resource> <action> --help
Output Format
With --json: { "ok": true, "data": ..., "meta": { "total": N } }
Other formats: --format text (default tables), --format csv, --format yaml
Rate Limits
- Account summary: 1 req / 5s
- Positions: 1 req / 1s
- Pending orders: 1 req / 5s
- Market order: 50 req / 1min
- Limit/stop/stop-limit: 1 req / 2s
- Cancel order: 50 req / 1min
- Historical data: 6 req / 1min
- Instruments: 1 req / 50s
- Exchanges: 1 req / 30s
- Reports: 1 req / 1min (list), 1 req / 30s (request)
- Pies: 1 req / 5s (CRUD), 1 req / 30s (list)
The CLI has built-in retry on 429 (rate limit) with backoff.
Auth
Pre-configured. To re-set: trading212-cli auth set "API_KEY:API_SECRET"
Token stored at ~/.config/tokens/trading212-cli.txt (chmod 600). Uses HTTP Basic auth.