Easily calculate UK Capital Gains Tax from your investment transaction history.
Supported sources include Charles Schwab, Trading 212, Morgan Stanley, Sharesight, Vanguard, Freetrade, or a custom RAW format.
The tool generates a detailed PDF report with all calculations.
All prices are automatically converted to GBP, and all HMRC rules are applied — including the same-day, bed and breakfast, and Section 104 holding rules.
The PDF report includes separate Capital Gains and Interest and Dividens sections, with a summary at the end. Interest is grouped monthly per broker to keep reports concise, even for brokers that pay daily interest.
Here's what a generated PDF report looks like:
👉 View full example report (PDF)
PATH (required for generating PDF reports)You can install the calculator using
uv,
pipx, or standard pip:
uv tool install cgt-calc
Or run it directly without installing:
uvx cgt-calc
brew install --cask mactex-no-gui
apt install texlive-latex-base
cgt-calc --year 2020 --schwab schwab_transactions.csv --trading212-dir trading212/ --mssb-dir mmsb_report/
cgt-calc --help for all available options.🏦 Instructions for Charles Schwab
You will need:
Example usage for the tax year 2020/21:
cgt-calc --year 2020 --schwab schwab_transactions.csv --schwab-award schwab_awards.csv
Note: For historic reasons, it is possible to provide the Equity Awards history in JSON format with
--schwab-equity-award-json. Instructions are available at the top of this
parser file. Please use the CSV method above if
possible.
🏦 Instructions for Trading212
You will need:
Example usage for the tax year 2024/25:
cgt-calc --year 2024 --trading212-dir trading212_trxs_dir/
🏦 Instructions for Morgan Stanley
You will need:
Example usage for the tax year 2024/25:
cgt-calc --year 2024 --mssb-dir morgan_stanley_trxs_dir/
🏦 Instructions for Sharesight
You will need:
Comments:
Sharesight aggregates transactions from multiple brokers, but doesn't necessarily have balance
information. Use the --no-balance-check flag to avoid spurious errors.
Since there is no direct support for equity grants, add Stock Activity as part of the comment
associated with any vesting transactions - making sure they have the grant price filled
(see example).
Example usage for the tax year 2024/25:
cgt-calc --year 2024 --no-balance-check --sharesight-dir sharesight_trxs_dir/
🏦 Instructions for Vanguard
You will need:
Example usage for the tax year 2024/25:
cgt-calc --year 2024 --vanguard-file vanguard.csv
🏦 Instructions for Freetrade
You will need:
Example usage for the tax year 2024/25:
cgt-calc --year 2024 --freetrade-file freetrade_GIA.csv
🏦 Instructions for Interactive Brokers (IBKR)
You will need:
Example usage for the tax year 2025/26:
cgt-calc --year 2025 --interactive-brokers-file U000000-TRANSACTIONS.csv
🏦 Instructions for RAW format
You will need:
CSV using the RAW format. If your broker isn't natively supported you might choose to convert whatever report you can produce into this basic format. See example. Include the header row shown below (lower-case column names in this order). The parser can infer the column order when the header is missing, but it will emit a warning so you can update your export the next time.
date – transaction date in YYYY-MM-DD format.
action – one of the supported broker actions (see ActionType).symbol – instrument ticker; leave blank for cash movements if not applicable.quantity – number of shares or units involved (blank for cash-only transactions).price – price per unit in the transaction currency (blank when not applicable).fees – fees associated with the transaction (blank or 0 if none).currency – ISO currency code of the transaction amounts (for example USD).Example usage for the tax year 2024/25:
cgt-calc --year 2024 --raw-file raw_data.csv
For correct taxation on offshore funds you need to specify the yearly excess reported income (ERI) from each fund you have owned. You can find the full list of funds that requires this at HMRC.
The tool already includes such yearly history in the resources folder. You can check if your fund is already included, or provide a custom ERI history file following the instructions here. We strongly suggest sharing compiled ERI data so it can be added to the package as it can save significant time to other users that hold the same fund.
Currently bundled data:
The ERI funds are indexed by ISIN and the tool provides automatic translation from ISIN to tickers, in case your broker doesn't supply the ISIN in their transaction history. For instructions on how to override ISIN translation look at the Extra options section below.
There are a few unsupported functionalities at the moment for taxation on offshore funds:
Check ERI data additional instrunctions for more information.
The following configuration files and options allow you to customize the calculator's behavior:
Exchange rates. Monthly GBP exchange rates are automatically downloaded from the
UK Trade Tariff API and saved to
out/exchange_rates.csv. You can override these by providing your own file in the same format
using the --exchange-rates-file option.
ISIN to ticker translation. When your broker doesn't provide ticker symbols, the tool
automatically translates ISIN codes using the
Open FIGI API. This is used for calculating Excess
Reportable Income (ERI) on offshore funds. The results are saved to out/isin_translation.csv.
Pre-packaged mappings are available in
initial_isin_translation.csv, which you can
extend using --isin-translation-file option.
Initial stock prices. Required for special events like vesting, splits, or spin-offs when
historical prices aren't available from your broker. Prices should be in USD.
initial_prices.csv comes pre-packaged. The program will
inform you when a required price is missing, and you can supply custom data with
--initial-prices-file.
Spin-off transactions. Provide additional details for spin-off events using the
--spin-offs-file option.
Interest fund tickers. Some bond funds and ETFs should be taxed as interest rather than
dividends. Specify these funds via the --interest-fund-tickers CLI option, using a
comma-separated list of ticker symbols.
These steps will build and run the calculator in a self-contained environment, in case you would rather not have a systemwide LaTeX installation (or don't want to interfere with an existing one). The following steps are tested on an Apple silicon Mac and may need to be slightly modified on other platforms. With the cloned repository as the current working directory:
$ docker buildx build --platform linux/amd64 --tag capital-gains-calculator .
Now you've built and tagged the calculator image, you can drop into a shell with cgt-calc
installed on $PATH. Navigate to where you store your transaction data, and run:
$ cd ~/Taxes/Transactions
$ docker run --rm -it -v "$PWD":/data capital-gains-calculator:latest
a4800eca1914:/data# cgt-calc [...]
This will create a temporary Docker container with the current directory on the host (where your
transaction data is) mounted inside the container at /data. Follow the usage instructions below as
normal, and when you're done, simply exit the shell. You will be dropped back into the shell on your
host, with your output report pdf etc..
Your financial data stays on your computer. This tool processes all transactions locally and does **not send your transaction history or personal in
$ claude mcp add capital-gains-calculator \
-- python -m otcore.mcp_server <graph>