Skip to main content

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.

dashboard

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

positions history
pies help
  • 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; m pages 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
15 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/v0 endpoints with HTTP Basic keyId:secret auth.
  • 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

t212_tui-0.4.0.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t212_tui-0.4.0-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

Details for the file t212_tui-0.4.0.tar.gz.

File metadata

  • Download URL: t212_tui-0.4.0.tar.gz
  • Upload date:
  • Size: 34.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

Hashes for t212_tui-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c644a26eb093f4f5527be1144102b8f45baaa89542677a5b28ac413a8de77f03
MD5 5c5901d9197a8f15f03df6261156293e
BLAKE2b-256 16d4eec2555f6e1fd5c1dc9855c65db48bb7a1045d725ef64831642e1af397f6

See more details on using hashes here.

File details

Details for the file t212_tui-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: t212_tui-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 52.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

Hashes for t212_tui-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c401e29af1e6106377d2cdb623c7f274c641591b2689545f61f317e07299173
MD5 1f5e08ca9859dc5248ea5b31d5179193
BLAKE2b-256 d826b198be00a30dbca77439bb78561f383d68932bdd84b26f4092eecc754bee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page