Read-only Trading 212 portfolio terminal
Project description
t212
A terminal dashboard for your Trading 212 account. Read-only by design — it
can show you everything and touch nothing: the only HTTP verb in the client is
GET.
Quick start
uvx t212-tui
That's it — first run opens a guided setup that validates your API key against the live API before saving, or lets you browse sample data with no key at all.
Other ways to run it:
uv tool install t212-tui # installs the `t212` command
pipx install t212-tui # same, via pipx
pip install t212-tui # plain pip
Getting an API key
Trading 212 app → Settings → API (Beta) → generate a key. Enable the read scopes: Account, Portfolio, Pies, Metadata, History. Orders read is optional (it powers the pending-orders panel). Works with Invest and Stocks ISA accounts.
You can also configure outside the TUI:
export TRADING212_API_KEY="<keyId>:<secret>" # env var, or
t212 config set-key # prompt → saved chmod 600
Screens
- Dashboard — value, unrealised/realised P&L, cash breakdown, pending orders, dividend & interest income, net deposits vs. current value, allocation, top movers, equity curve.
- Positions — sortable table with P&L, FX impact and weight;
◔marks quantity held inside pies; detail view per holding. - Pies — value, return, dividends and goal progress per AutoInvest pie; drill in for target-vs-actual drift and flagged instrument issues.
- History — orders with realised P&L and fees, dividends with running
totals (cash interest included), transactions with running balance;
mpages further back. - Search — the full tradeable universe, filtered as you type, with market hours in the detail view.
- Equity curve — the API has no account-value history, so t212 records a local SQLite snapshot on each poll. The curve grows the longer you use it and is labelled since first run; nothing is back-filled.
Plus: three themes (t), privacy blur for screen-sharing (z), and
gains/losses always carry an arrow and sign — never colour alone.
Commands & keys
t212 # live account
t212 --demo # practice account
t212 --mock # sample data, no key needed
t212 --once # plain-text summary to stdout, then exit
t212 --refresh 15 # poll interval in seconds
| Key | Action | Key | Action |
|---|---|---|---|
1–5 |
Switch tab | s |
Sort (Positions) |
↑/↓ j/k |
Move | m |
Load more (History) |
Enter / Esc |
Open / close detail | z |
Privacy blur |
← → |
History section | t |
Theme |
r |
Refresh now | ? |
Help |
How it behaves
- Talks to Trading 212's
/api/v0endpoints with HTTP BasickeyId:secretauth. - The API is REST-only, so data is polled — each endpoint on its own cadence
within its documented rate limit, with jitter and automatic back-off on
429. Only the active tab's data is fetched. - Credentials live in
~/.config/t212/config.toml(chmod 600), are sent nowhere except trading212.com, and are never logged or rendered. Snapshots are stored per account in~/.local/share/t212/.
Development
uv sync
uv run pytest -q # fixture-driven, no network
uv run t212 --mock # full UI offline
uv run --with playwright python scripts/screenshots.py # regenerate screenshots
src/t212/
models.py pydantic models for the API
api/ client protocol · httpx client · mock client · rate limiter
scheduler.py per-tab polling
store.py sqlite snapshots + instrument cache
app.py Textual app shell
screens/ dashboard · positions · pies · history · search · setup · details
widgets/ header · tab bar · hint bar · render primitives
Disclaimer
Unofficial, not affiliated with Trading 212. The API is in beta and may change. Not financial advice; use at your own risk.
MIT © shadowhusky
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file t212_tui-0.3.0.tar.gz.
File metadata
- Download URL: t212_tui-0.3.0.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
456b8aa733781215df7a6a886f335a916d35f977350b72752ec9faa98af72429
|
|
| MD5 |
90c071f22669917cd27c91e8f92b744c
|
|
| BLAKE2b-256 |
7123c78d8572481b45546d07f06ce52b68a7319e77ea6e88d601a484879c0806
|
File details
Details for the file t212_tui-0.3.0-py3-none-any.whl.
File metadata
- Download URL: t212_tui-0.3.0-py3-none-any.whl
- Upload date:
- Size: 51.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6ae178233eb3a95e961c02c3ef9f604e3f34821ac9f9c3b53f0bf1a98e9b92e
|
|
| MD5 |
2a47eaa87a0f3b1524bb55b69953b4a7
|
|
| BLAKE2b-256 |
2b04af318a2185925dd5bfc46d5a3b00731ed1175fc0079a5dafedc95b39d759
|