Trade Republic data exporter with Portfolio Performance support — fork of pytr
Project description
pytrpp2: Trade Republic data exporter with Portfolio Performance support
This is a tool for the private API of the Trade Republic online brokerage. This package and its authors are not affiliated with Trade Republic Bank GmbH.
Credits and lineage
pytrpp2 builds on the work of two projects:
pytr— the actively maintained Trade Republic API client that pytrpp2 forks. All core functionality (timeline download, document download, transaction export, price alarms, etc.) comes from pytr.pytrppby Martin Scharrer — an earlier extension of pytr that pioneered Portfolio Performance CSV export for Trade Republic data. pytrpp appears to be inactive, so pytrpp2 picks up that work: the PP-specific conversion logic (export_pp,build_classification,check_mappings) is ported and extended from pytrpp.
What pytrpp2 adds compared to pytr
pytrpp2 is a fork of pytr and includes all of its original functionality. On top of that, pytrpp2 adds three subcommands specifically for Portfolio Performance users:
| Added subcommand | What it does |
|---|---|
export_pp |
Downloads your full TR timeline and converts it to Portfolio Performance-compatible CSV files (payments.csv, orders.csv). Handles all TR event types including the post-2025 API format. Optionally downloads PDF documents. |
build_classification |
Reads the raw events JSON from export_pp and generates a classification.json taxonomy (Asset Allocation: RISKY / CASH) ready to import into Portfolio Performance under Wertpapiere → Klassifizierungen. |
check_mappings |
Reads an events JSON and reports any TR event types that have no converter handler — useful after a Trade Republic API update to spot silent data loss before it happens. |
The CSV format produced by export_pp matches exactly what Portfolio Performance expects:
payments.csv→ Account Transactions (dividends, interest, coupons, bond repayments, transfers)orders.csv→ Portfolio Transactions (buy / sell / savings plan orders)
Installation
Requires Python 3.10 or newer.
pip install pytrpp2
export_pp — Portfolio Performance export
Downloads your Trade Republic timeline and converts it to files ready to import into Portfolio Performance.
Quick start
# Export CSVs and event log into a directory:
pytrpp2 export_pp -n +49123456789 -p 1234 -D /path/to/output
# Also download PDF documents into a timestamped subfolder:
pytrpp2 export_pp -n +49123456789 -p 1234 -D /path/to/output -F /path/to/docs
# Incremental — only fetch events since the last run:
pytrpp2 export_pp -n +49123456789 -p 1234 -D /path/to/output --incremental
Each run with -D creates a timestamped subfolder (YYYY-MM-DD_HH-MM-SS) inside the given directory. Pass --incremental to automatically start from where the last run left off — pytrpp2 scans the directory for the most recent subfolder and fetches only events after that timestamp. If no previous run is found, all events are fetched.
If phone number or PIN is omitted, pytrpp2 will prompt for them or read them from ~/.pytr/credentials (first line: phone number, second line: PIN).
Full argument reference
usage: pytrpp2 export_pp [-h] [-n PHONE_NO] [-p PIN] [--applogin]
[--waf-token WAF_TOKEN] [--store_credentials]
[-D DIR] [-E EVENTS_FILE] [-P PAYMENTS_FILE]
[-O ORDERS_FILE] [-F DOCS_DIR] [--workers WORKERS]
[--last_days DAYS] [--days_until DAYS]
Authentication:
-n, --phone_no PHONE_NO TradeRepublic phone number (international format)
-p, --pin PIN TradeRepublic PIN
--applogin Use app login instead of web login
--waf-token WAF_TOKEN Manually provide an aws-waf-token cookie value
--store_credentials Store credentials for next run
Output (use -D to set all at once, or specify individually):
-D, --dir DIR Main output directory. Sets default paths for
events.json, payments.csv, and orders.csv.
Does NOT trigger PDF download — use -F for that.
-E, --events-file FILE Write raw event data to this JSON file
-P, --payments-file FILE Write payments (dividends, interest, etc.) to this CSV
-O, --orders-file FILE Write orders (buy/sell) to this CSV
-F, --docs-dir DIR Download PDF documents into this directory.
A timestamped subfolder (YYYY-MM-DD_HH-MM-SS) is
created automatically on each run.
Download options:
--workers N Number of parallel download workers (default: 8)
Date range (both default to 0 = include everything):
--last_days DAYS Include only the last N days of data
--days_until DAYS Exclude the most recent N days (offset the end date)
--incremental Only fetch events after the last run (requires -D).
Scans -D for existing timestamped subfolders and uses
the most recent one as the start time.
Output files
| File | Contents | Portfolio Performance import |
|---|---|---|
payments.csv |
Dividends, interest, coupons, bond repayments, transfers | Account Transactions |
orders.csv |
Buy / sell / savings plan orders | Portfolio Transactions |
events.json |
Full raw event data from TR timeline | — (audit / debugging) |
DOCS_DIR/YYYY-MM-DD_HH-MM-SS/ |
PDF documents (contract notes, tax statements) | — |
After conversion, export_pp automatically runs a mapping gap check (see check_mappings below) and prints event counts.
WIP - build_classification — Asset Allocation taxonomy
Reads the events JSON from export_pp and generates a classification.json for Portfolio Performance's Klassifizierungen feature. It collects every security ISIN from your transaction history and assigns each one to a category based on an optional config file.
# Minimal — all ISINs default to RISKY:
pytrpp2 build_classification /path/to/events.json classification.json
# With explicit config:
pytrpp2 build_classification /path/to/events.json classification.json --config /path/to/classifications_config.json
Import the result in Portfolio Performance under:
Wertpapiere → Klassifizierungen → [taxonomy] → ⋮ → Importieren
Config file format
Copy pytr/classifications_config.example.json to ~/.pytr/classifications_config.json and edit it:
{
"classifications": {
"IE00B4L5Y983": "RISKY",
"IE00B3WJKG14": "CASH",
"DE0001030542": "CASH"
}
}
Valid keys: RISKY (Risikobehafteter Portfolioteil) and CASH (Risikoarmer Anteil). ISINs not listed default to RISKY. After each run, any unconfigured ISINs are printed to the console.
If --config is not provided, pytrpp2 looks for ~/.pytr/classifications_config.json automatically.
check_mappings — Gap detector
Checks an events JSON for TR event types that have no handler in the converter. These would be silently dropped from payments.csv and orders.csv — typically caused by Trade Republic renaming or introducing event types after a platform update.
pytrpp2 check_mappings /path/to/events.json
Output:
- WARNING + table of unmapped types with counts (if any gaps exist)
- Intentionally ignored types (account events, notifications — expected)
- Registered handlers not seen in this export (old TR names / unused handlers)
export_pp runs this check automatically after every conversion, so you only need to call it manually to re-check an older events JSON.
Authentication
Authentication works the same as in pytr. See pytr's README for details on web login, app login, and the credentials file.
Development
See pytr's README for general setup, linting, and formatting instructions — the toolchain is identical (uv, ruff, mypy).
Clone and install this fork:
git clone https://github.com/JonathanWillnow/pytrpp2.git
cd pytrpp2
uv sync --group dev
uv run pytest
A pre-commit hook runs the full test suite automatically before every commit.
Bugs and contributing
For bugs or feature requests in the PP-specific functionality (export_pp, build_classification, check_mappings), open an issue in this repository. For issues with core Trade Republic API behaviour, do not forget to report them upstream in pytr.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 pytrpp2-0.1.1.tar.gz.
File metadata
- Download URL: pytrpp2-0.1.1.tar.gz
- Upload date:
- Size: 121.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
871ca1e39a7a4e9baaace3aa65bc8bd2df8a8dc50496c94e153e48b5b0af3edc
|
|
| MD5 |
530489aebe347b4bdfca295b750f49dc
|
|
| BLAKE2b-256 |
a7e476db1a4aced7069d12ef4646bac8f63944d2a872b0ccccae1d31b5abbcd0
|
Provenance
The following attestation bundles were made for pytrpp2-0.1.1.tar.gz:
Publisher:
release.yml on JonathanWillnow/pytrpp2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytrpp2-0.1.1.tar.gz -
Subject digest:
871ca1e39a7a4e9baaace3aa65bc8bd2df8a8dc50496c94e153e48b5b0af3edc - Sigstore transparency entry: 1191120676
- Sigstore integration time:
-
Permalink:
JonathanWillnow/pytrpp2@7cfec9f1c0e285f82fc793b3302ea617bec7a1e8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/JonathanWillnow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7cfec9f1c0e285f82fc793b3302ea617bec7a1e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytrpp2-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pytrpp2-0.1.1-py3-none-any.whl
- Upload date:
- Size: 92.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4819f638b112091eb48f135705011bd8d0e2faf7685651bc5c4d61f7d7bbc6e9
|
|
| MD5 |
8b92156ddcfd9081fd627e95d70b14a8
|
|
| BLAKE2b-256 |
eb19a34a6d5a0267668b0dc4802430b6dfb0bbf0ee2d9dc04134c1f22ecfd4bf
|
Provenance
The following attestation bundles were made for pytrpp2-0.1.1-py3-none-any.whl:
Publisher:
release.yml on JonathanWillnow/pytrpp2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytrpp2-0.1.1-py3-none-any.whl -
Subject digest:
4819f638b112091eb48f135705011bd8d0e2faf7685651bc5c4d61f7d7bbc6e9 - Sigstore transparency entry: 1191120680
- Sigstore integration time:
-
Permalink:
JonathanWillnow/pytrpp2@7cfec9f1c0e285f82fc793b3302ea617bec7a1e8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/JonathanWillnow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7cfec9f1c0e285f82fc793b3302ea617bec7a1e8 -
Trigger Event:
push
-
Statement type: