Skip to main content

UK capital gains tax calculator for Charles Schwab and Trading 212 accounts

Project description

UK capital gains calculator

CI PyPI version

Calculate capital gains tax by transaction history exported from Charles Schwab and Trading 212. Generate PDF report with calculations.

Automatically convert all prices to GBP and apply HMRC rules to calculate capital gains tax: "same day" rule, "bed and breakfast" rule, section 104 holding.

Report example

calculations_example.pdf

Installation

Install it with pipx (or regular pip):

pipx install cgt-calc

Prerequisites

  • Python 3.8 or above.
  • pdflatex is required to generate the report.

Install LaTeX

MacOS

brew install --cask mactex-no-gui

Debian based

apt install texlive-latex-base

Windows

Install MiKTeX.

Usage

You will need several input files:

  • Exported transaction history from Schwab in CSV format since the beginning. Or at least since you first acquired the shares, which you were holding during the tax year. See example.
  • Exported transaction history from Trading 212. You can use several files here since Trading 212 limit the statements to 1 year periods. See example.
  • CSV file with initial stock prices in USD at the moment of vesting, split, etc. initial_prices.csv comes pre-packaged, you need to use the same format.
  • (Optional) Monthly GBP/USD prices from gov.uk. GBP_USD_monthly_history.csv comes pre-packaged, you need to use the same format if you want to override it.

Then run (you can omit the brokers you don't use):

cgt-calc --year 2020 --schwab schwab_transactions.csv --trading212 trading212/

See cgt-calc --help for the full list of settings.

Disclaimer

Please be aware that I'm not a tax adviser so use this data at your own risk.

Contribute

All contributions are highly welcomed. If you notice any bugs please open an issue or send a PR to fix it.

Feel free to add new parsers to support transaction history from more brokers.

Testing

This project uses Poetry for managing dependencies.

  • For local testing you need to install it.
  • After that run poetry install to install all dependencies.
  • Then activate pre-commit hook: poetry run pre-commit install

You can also run all linters and tests manually with this command:

poetry run pre-commit run --all-files

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

cgt-calc-1.0.0.tar.gz (19.8 kB view hashes)

Uploaded Source

Built Distribution

cgt_calc-1.0.0-py3-none-any.whl (24.1 kB view hashes)

Uploaded Python 3

Supported by

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