Safety and security
Around real money
Section titled “Around real money”| Guard | What it prevents |
|---|---|
| No default environment | Running against live because nobody said otherwise |
| Only Trading 212’s demo host trades by default | A demo script, or one behind a proxy, placing real orders |
| Orders are never retried | Buying twice because the first answer was slow |
OrderOutcomeUnknownError |
Treating “maybe executed” as “failed” and resending |
NetworkError with sent: false |
Being unsure when a request certainly never left |
buy() and sell() set the sign |
A stray minus sign turning a sale into a purchase |
| Validation before sending | Wasting rate limit on requests Trading 212 would refuse |
truncateQuantity() and sellAll() |
Rounding up past what you own |
dryRun |
Not knowing exactly what will be sent |
Your credentials
Section titled “Your credentials”- The key and secret live in private class fields, not on any enumerable property, so
JSON.stringify,console.logandutil.inspectof the client show only the environment. - Every log line, error, hook event and test recording is redacted; see Logging and hooks.
- Requests go only to
https://demo.trading212.comorhttps://live.trading212.com, unless you setbaseUrl, which must behttps://(orhttp://localhostfor tests) and logs a warning. - Redirects are never followed, because following one would send your credentials wherever it pointed.
nextPagePathis followed only to the same endpoint on the same host.- Report downloads go to a signed link without your credentials.
- The client refuses to run in a browser.
- The doctor never prints the key or secret, and redacts its own output as well.
Advice
Section titled “Advice”- Make one key per program, with the fewest permissions it needs. A dashboard needs no
orders:execute. - Restrict keys to fixed IP addresses where you can.
- Keep demo and live keys apart;
T212_DEMO_*andT212_LIVE_*help. - Preview live orders with
{ dryRun: true }before you enable trading.
Supply chain
Section titled “Supply chain”Zero runtime dependencies. Releases are published from GitHub Actions with npm provenance, so you can check a version was built from this repository. Development dependencies are pinned by the lockfile and audited in CI.