Tools for cgtcalculator.com

Conversion utilities for cgtcalculator.com

  • Download_T212_Convert_v11.6.zip - For Trading 212. Run from Windows by double-clicking on extracted .exe file (.exe + .py source code). Accepts multiple csv files, stock split bugfix.
  • Download_ii_Convert_v4.5.zip - For Interactive Investor. Run from Windows by double-clicking on extracted exe file (.exe + .py source code). Accepts multiple csv files. Stock split action currently untested.
The included .py Python scripts can be run from a Windows, Linux or Macintosh command line.

Introduction

cgtcalculator.com is a free website that will calculate the capital gains on your share/stock sales.

It requires data in this format (data separated by spaces - no header row)...

B 12/01/2004 AVG 10000 0.525 10.0   26.25
S 23/02/2004 NCH 5000 1.75         12.50   0.0

which corresponds to this type of structure...

B/SDateCompanySharesPriceChargesTax
B12/01/2004AVG100000.52510.026.25
S23/02/2004NCH50001.7512.500.0


You can highlight all cells from an Excel spreadsheet and paste them into the calculator or load a .txt file directly from the calculator.

Instructions for its use are here.

Your broker (e.g. Trading 212, Interactive Investor, etc.) will allow you to download your orders data (usually as a .csv file or .xlsx) but it will not be in the format required for cgtcalculator.com.

Although some conversion facilities for some brokers are provided on the cgtcalculator.com convert page, there is no converter for Trading 212. Also the Interactive Investor converter on the site has a bug (it does not handle stocks which are bought in $USD accurately).

In addition, most brokers only allow you to download 1 or 2 years of transactions at a time. This means you will have to manually combine all the downloaded files into one file before you can use these converters.

My 'Convert' utilities

I have developed some Windows executable files (.exe) which you can use to convert all your downloaded transaction files into a single text (.txt) file suitable for use with cgtcalculator.com.

Step 1 - download the .csv transaction files

The last transaction date must be at least 6th May after the end of the tax year (because trades within 30 days of April 5th can affect CGT calculations due to the 30 day rule). I suggest naming files for each calendar year, Jan 1 to Dec 31 - e.g. t212_2024.csv, ii_2024.csv, etc.

Trading 212 .CSV - select your Invest account. Use the three bar hamburger menu - History and Orders. Click the download icon.  
Now download ALL your transactions for ALL years. Select only ORDERS not all transactions. Don't worry if some files have overlapping dates, the convert app will remove duplicate trades - just don't miss out any dates!

Interactive Investor .CSV - on the website (not the ii app) - click on 'Site Map' at the bottom of the page and choose 'Transaction History'. Choose the time period and then click the download icon 


Repeat for all years. I suggest making 2 year downloads, each starting at 1 Jan and ending on 31 Dec. Pick CSV not PDF.

Step 2 - Run the Windows Convert program




Example when multiple .csv files are picked.

Download the Convert utility and unzip it. The .exe can be copied to the same folder as your .csv files or it can be placed on the Windows Desktop. The .py is the Python source file and is not required but is just for your reference.

The convert program will allow you to pick one or more .csv files by using Ctrl+click on each of your .csv files. Select ALL your downloaded files for ALL years.

The convert program will output a .txt file (amongst other files).

If you see many 'possible split' errors, you probably have missing orders. Check the output csv or txt file for missing dates. The first trade listed should be the first Buy when you first opened the account. All trades up to May 6th of the last year should be included.

On Mac\Linux platforms, you can run the .py program from the command line once you have installed Python (Python+Tkinter is required). e.g.

python3 T212_convert_v11.6.py 2024.csv 2025.csv 2026.csv

Step 3 - Use cgtcalculator.com

Go to the cgtcalculator.com site and click on 'Choose File' and then select the .txt file that was made by the Convert program. 

  1. Now click on 'Format/Sort' and check it looks OK (optional - it sorts by date)
  2. Ensure the 'apply rounding' option is unchecked - see picture below.
  3. Enter the desired tax year if you don't want all years. 
  4. Finally click on the red CALCULATE button.

Note that the CapitalGain figure (e.g. 6713) can be used in your tax return.

Note: cgtcalculator.com does not calculate ERI on accumulating ETFs and so does not subtract ERI from any gains. If you are a basic rate tax payer, this may mean you will be paying slightly too much capital gains tax.

Note that my conversion tools calculate the share price from the total return or total cost divided by the number of shares, so the charges and tax columns will be 0 because they are amortised into the share price.

About ERI

Excess Reportable Income (ERI) is the portion of income accumulating funds receive but are not distributed to investors - essentially, income that’s reinvested back into the fund.

Even though you don’t receive this income as cash, HMRC still considers it taxable.

ERI applies to the accumulating share classes (marked as “Acc” or “Accumulating”) of offshore funds (i.e. most Irish or Luxembourg-domiciled ETFs). 

ERI is usually counted as dividends, but some types of funds may class them as Interest (e.g. some Money Market Funds).

ERI paid as dividends is subject to dividend tax. When you sell the fund, all the ERI that you notionally received over the years can be added to the cost of the fund (i.e. any gain you report can be reduced by the total amount of ERI paid on those shares over the time they were held since you will have paid dividend tax on that portion).

ERI is not accounted for in cgtcalculator.com. If you are a Basic Rate tax payer, then you may be paying slightly more tax than you need to (dividend tax is less than CGT for basic rate taxpayers), but calculating ERI is extremely tedious. For this reason, most people avoid accumulating ETFs in a GIA and instead they just buy distributing ETFs.

No ERI reporting or any type of tax is applicable for ISA or SIPP accounts.

Older cgtcalculator.com conversion programs for Windows

Older versions (v1-10 only run from Windows command line)
Download T212_Convert_v2.exe - ignores duplicate rows
Download T212_Convert_v3.exe - enhanced error checking and reporting
Download_T212_Convert_v4.exe - corrects small discrepancies in t212 csv files
Download_T212_Convert_v5.exe - warns of same day or 30-day buy back issues
Download_T212_Convert_v6.zip - extra checking, etc. includes .py source file and .exe Windows file
Download_T212_Convert_v9.zip - copes with Stock Splits if detected (.exe and .py)
Download_T212_Convert_v10.zip - Latest command line version (.exe and .py)

Download_ii_Convert_v3.zip - converts Interactive Investor csv file (.py and .exe) - command line and single file only. To combine .csv input files, use the copy command (e.g. copy ii_2024_25.csv + ii_2026.csv ii_all.csv)

If you don't trust running strange .exe files from me then you can examine and run the .py script after you have installed python onto your Windows/Linux/Mac system.

*Check this page for future revisions or contact me. Unzip to extract the .exe file.

An interactive investor (ii) program is also available because there are bugs in the converter for ii that is on the cgtcalculator.com site.

Extract the .exe file to the same folder that you have your .csv files in when using a command line version.

The .exe program is written in Python and has then been compiled into a Windows .exe. I used ChatGPT to make it for me since I don't know Python very well.

Action of T212_convert (latest version)

  • Read in all .csv files - this may contain multiple files and duplicate lines. Files containing orders can be downloaded from T212 - ALL ORDERS for ALL YEARS must be downloaded and added to the one file - if you held the account for 6 years then all trades for all 6 years are needed. Downloads for the last year must be done after May 6th as trades up to 30 days after the tax year may affect the calculations. Later versions (v11+) allow you to select multiple files from a Windows pop-up.
  • Ignore non-trade/non-split rows and deduplicate.
  • Check and sort Buy and Sell orders
  • Adjust Qty and Price in shares if a stock split is present or detected
  • Check for Oversells (selling more shares than you hold) and small discrepancies (e.g. hold 9.0 but sell 9.0000001 shares)
  • Adjust Qty and Price for any declared stock splits
  • Check for any Buy within 30 days of a sell (HMRC same day and 30-day rules will apply when processed later) - warn user
  • List number of Buys and Sells and total orders
  • List files output inc a Warnings .csv and a stocks .csv (with same data as the output .txt file) which a user can manipulate and then cut and paste into cgtcalculator.com
  • List orders which have been changed by the program (due to small discrepancies, splits, etc.)
  • The output .txt file can be directly imported into cgtcalculator.com

Note: Sometimes, in cgtcalculator.com, the sells do not match the buys by a very small amount due to very small decimal errors (the sells in the T212 downloaded csv dont always add up exactly to the buys). These may be detected and corrected automatically.

cgtcalculator.com may display an error:

**** ERROR in trades data(283) There are more SELLS than BUYS for stock SOFI OR your dates are incorrect (make sure at some time you havent sold more than you own) for stock SOFI

An easy way to fix this is to very slightly increase the number of the shares bought. e.g. increase 4.53212 shares bought to 4.53213 shares bought or very slightly decrease the number sold within the cgtcalculator.com edit box. T212_convert version 4+ and ii_convert_v3 may automatically fix these small discrepancies for you.


Tip: Saving as .csv file

When saving in Excel as a .csv, only use the first .csv option - do not use the MS-DOS or Macintosh options for a .csv file or you will get strange characters in the .csv file...

The xxx_warnings_CVT.csv output files contains lines which cannot be handled by the conversion program - e.g. stock split notifications.

Links

For more information:
  • Blog article on the development and details about these tools
  • Save tax (ERI) article
  • Avoid paying too much tax (ERI) article
  • NEW! - UK Tax Calculator (includes support for ERI) - New and alternative calculator that supports Interactive Brokers, Charles Schwab, Trading 212, Vanguard UK so far. A nice PDF report is produced for your tax return. I cannot vouch for it's accuracy however but it seems to be OK and returns similar results to cgtcalculator.com. Multiple .csv files can be loaded at one time making it extremely easy to use - just download all your trade .csv files and load them into the app, no converter program is needed.

Contact me on easy2boot at gmail . com  if you have any queries.

If you want s similar conversion program for your broker, you will need to send me your .csv files for test purposes. If possible, with examples of stock splits in them.

No comments:

Post a Comment