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.2.0.tar.gz (32.7 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.2.0-py3-none-any.whl (49.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: t212_tui-0.2.0.tar.gz
  • Upload date:
  • Size: 32.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 ef6273c3e7d1bbb4f66c01deb1ca184df345a2aefde4122b8bd588454b5755fb
MD5 569fb6dde1b2ad187e4166cf0e0c6f1e
BLAKE2b-256 22ab1e226d343e5c4676c9f094a000bdf841851d2255c6d3bdb4b26c9dddd833

See more details on using hashes here.

File details

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

File metadata

  • Download URL: t212_tui-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 49.9 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0690f21719921cc9e6259d99f7b0a0b144c074c2241716545d0ecf960e048c52
MD5 a762f2fc087eadf3d998f67f5f99d3fa
BLAKE2b-256 f95bce23cb9af6753b0bbe379615329a5104408a7a4ae46ee47f41749d137196

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