UK CGT tax calculator for Interactive Brokers

Sharky

Staff
Messages
5,949
Likes
614
This is a project we're about to start work on. Currently if you trade with Interactive Brokers as a UK trader, you'll appreciate there's no simple tax report you can run off to use to fill out your annual self assessment. Our plan is to provide a simple tool, whereby you can upload your trade report, exported from IB, and we'll generate a report calculating your CGT - simple!

We'll be utilising Rob Carver's excellent open source library 'Python UK trading tax calculator'. Those with a smattering of knowledge of python and git can go direct to source and run this locally, you'll just need to source the FX rates. Those without, or just too lazy to set it up themselves, will be able to use the tool here on T2W. Thanks to Rob aka @globalarbtrader who I've run the idea past and likes it.

We'll need some beta testers at some point, so if this sounds interesting to you, then do let us know and we'll include you in any testing we do.
 
Having just completed my UK self assessment tax return, and having had for the first time to account for unsheltered options trades in an Interactive Brokers account, I can tell you first hand, it's painful! My hope was to use Rob's calculator to assist; but it quickly became apparent there were a couple of major issues. Firstly, the code that deals with fx rates from a quandl, a free source, is outdated an no longer working; secondly, options isn't supported presumably because Rob doesn't trade options; it's easy enough to enable the processing of options trades, but I'd need more time to understand what the implications are of handling the various options outcomes would mean. So in the end I pulled in the data to an excel spreadsheet from IB's reporting and looked at the trades one by one. One of the gotcha that I discovered was if you have any sort of spread options trade with say one side selling to open (thus taking into a credit), if you haven't closed that leg prior to the end of the tax year; it's considered by hmrc an immediate taxable capital gain; meaning that in the following tax year when you buy to close it; you then have to claim the capital loss; the cost of closing it 🤦‍♂️

For my UK and US stock trades, I ended up writing javascript code to take as an input IB's activity report (trades list) and output it in a format that can be read by http://www.cgtcalculator.com/ at the same time calculating the fx rates for all the US stocks on the days of the trades; this way you're covered for things like same day rule, 30 day rule, section104 holding.

I get the impression that others perhaps don't even take this trouble, and probably just send the activity reports in IB to their accountant expecting them to be able to use the summary information.. and going from my experience with accountants they probably just do that; and not take the trouble to do the math; end result as proven from this recent experience is that the actual CGT numbers differ wildly.
 
It would be very much in the interest of HMRC to tax capital gains as soon as they deem it liable as it will give a major boost to tax income. As you say, it is unlikely that all accountants will even begin to understand how this works. Maybe there is an opportunity to set up an automated way for traders to do these calculations as it appears to be much needed. Are you still using Steady Options ?
 
I think there's definitely a need in the UK for such a tool, I'm just not sure how big an opportunity it is. Steady options - no, I was trading their SteadyVol strategy but IB isn't viable, because of the commission costs - it would have to be with one of the US brokers where the commission on options trade, especially multi-legged trades is much cheaper, and I preferred to stick with IB.
 
Hi,

I recently put together a web wrapper for another tool Bittytax. It is at https://cgt.edce.uk/ A bit similar to cgtcalculator but does the currency conversions. The software is crypto focused but does all the UK share matching rules.

It works fine for stocks and should work for options (in a way at least), I have had a bit of a go with it, but I am not at tax season yet. Anyway I use options on IBKR.
 
Hello,

I have created a tool for interactive brokers UK tax reporting (using Flex query statements) and are in need of more people to try it out.
Any feedback would be appreciated.

Alternatively manual input of trades are also supported.

Nice work! Any chance of expanding this to include options?
 
Hi Alex - thanks so much for sharing this tool. I have recently started trading options on IBKR but my main worry was the added complexity of UK CGT calculations, and how much time it would take me to go through. I am not keen on having to rely 100% on an accountant I like to understand how the numbers work. I used the cgtaxcalulator last year, but with options I have many more trades so I was looking for more automated options. So I was very happy to find your tool.

I started testing flex query import on 24/25 trades so far, however I am not sure the calculations are correct for selling call or put options.

- I sold a put and then closed it a few days later but it shows as a 'bed and breakfast' trade instead of normal CGT on the settled trade
- I sold puts that are not yet expired / closed but those show as disposals with the full premium as gain amount. My understanding is that for CGT purpose there is no tax event when the put is sold, but CGT is calculated at expiry or when it gets closed. So on the 'matched trade' if an option is unmatched or not yet expired (don't know if expiry is an entry in the exported xml) it should show 0 as CGT?

Most likely it's a misunderstanding on my side as I am still wrapping my head around those calculations.
Please let me know what you think -

Cheers
 
One of the gotcha that I discovered was if you have any sort of spread options trade with say one side selling to open (thus taking into a credit), if you haven't closed that leg prior to the end of the tax year; it's considered by hmrc an immediate taxable capital gain; meaning that in the following tax year when you buy to close it; you then have to claim the capital loss; the cost of closing it
@nicorama so there actually is a tax event when you sell any call or put option (see my earlier quote), I wasn't aware at the time and now I'd be a lot more careful as you're going to hike up your CGT as a result
 
@nicorama so there actually is a tax event when you sell any call or put option (see my earlier quote), I wasn't aware at the time and now I'd be a lot more careful as you're going to hike up your CGT as a result
Thank you Alex.

I did more research to decipher HMRC docs into plain English. It completely confirms what you are saying for when option expires or close after the tax year cutoff. However, not sure the tool works correctly when a sold option position expires or get closed during the same tax year, esp regarding pooling / cost basis. For my own sanity, here is summary of the rules I got from a session with chatGPT o3-mini:

-----
1. Overall Treatment as a Single Transaction:

In principle, the rules are designed so that if you wait until the option is either exercised or closed, you should be able to calculate your overall gain or loss as one net result. For example, if you sell (write) a put and receive a $1000 premium and later buy it back for $500, your overall net gain is $500.

2. Timing and Reporting Across Tax Years:

– If the option is opened (i.e. the put is sold) and remains open at the end of the tax year, HMRC requires that you recognise the premium received as a gain in that tax year (TY2425 in your example).

– When you later close the position (buy to close) in the following tax year (TY2526), you realise a loss relative to the premium that was originally received.

This later “closing” transaction effectively reduces your overall gain to the correct amount. However, because of the split in timing, the loss is reported in the later year. You then use that loss (or negative adjustment) to offset other gains in TY2526 or carry it forward. In other words, you are not “refunding” tax already paid in TY2425—but you are adjusting your overall taxable result.
-----

So I think the following applies:
- if an option is closed or expires during the same tax year, both sides should match and be treated as one transaction and one CG number
- if an option is still open at end of tax year, then treat it as 2 transactions, making sure that the second leg offsets

So for example, on Jan 25, I sell June 25 puts for $10 ($1000 premium).
- scenario 1:
In March, I close those puts by buying back at $4, for $400
both transactions are matched, and effectively I have one transaction with $600 gain for TY2425

- scenario 2:
It expires in June worthless.
For TY2425 I have the full premium shown as CG, eg $1000.
For TY2526, since option expired worthless, there is nothing to declare since CG of $1000 was already declared for TY2425

- scenario 3
I close it in April for $2
For TY2425 I have the full premium shown as CG, eg $1000.
For TY2526, I have a net loss of $200 (cost to close) which offsets my declared gain of $1000 in TY2425

Did I get that right?

Looking at the results from your tool, I see at least one thing that might not be correct:
I have trades that fall under scenario 1 (bought to close, same tax year), but in the 'trade matching' pane, I see some of those marked as 'same day' or 'bed and breakfast' for 'match type' when I closed them close to the date where I sold them. Based on the above, I don't think those matching rules apply to selling those options, instead they need to use pooling rule cost. Unfortunately it seems HMRC has different pooling rules for options than stocks. Here is what I got from my research:

------
The underlying principle is the same for both shares and options—to ensure you’re taxed on the net economic result of your trading—but the mechanics differ because of the nature of the instruments and the way HMRC’s guidance is written.



For Shares (Section 104 Pooling)

Fixed Pool and No “Same‑Day” Matching Requirement:

When you acquire shares (outside of a tax‐free wrapper), each purchase is added to a Section 104 pool. When you sell shares, you use a simple weighted‑average cost from that pool to determine your gain or loss. There’s no special “same‑day” or “bed and breakfast” matching because all acquisitions and disposals are aggregated continuously, regardless of when they occur.

30-Day Rule for Bed and Breakfasting:

For shares there is a well‑known rule (often referred to as the “bed and breakfast” rule) that if you sell shares and then buy them back within 30 days, HMRC matches the repurchase with the sale so that the loss cannot be immediately used to offset gains—the holding period is effectively suspended.



For Options

Pooling by Series, Not a Continuous Pool:

With options, HMRC requires that all transactions within the same option series (identical in terms of underlying asset, strike, expiry, etc.) are pooled together. This pooling is similar in spirit to the Section 104 pool for shares but is applied on a per‑series basis.

Matching of Transactions:

In practice, when you write (sell) an option and later close it (buy to close) within the same series, you must match the opening and closing transactions so that the gain or loss is computed on the net result. For example, if you write puts and then buy to close part or all of that position, you calculate the gain or loss on the closed contracts using the weighted‑average premium from the pool.

Same‑Day or Short‑Period Transactions:

While there isn’t a strict “30‑day bed and breakfast” rule for options as there is for shares, HMRC’s guidance does include provisions that require same‑day (or very near same‑day) transactions to be matched. This prevents you from artificially timing separate trades within a very short period to create or defer a loss. In effect, if you write and then close an option on the same day (or within a short window defined by the guidance), those transactions are treated as one combined event rather than two separate taxable events.

Spread Trades and Matching:

Similarly, if you are involved in a spread (where one leg is a sale and another is a purchase within the same series), the rules require that you match the legs to determine the overall gain or loss. This ensures you can’t cherry‑pick which leg to report as a gain or loss to manipulate your tax position.



So, How Do These Matching Rules Differ?

For Shares:

The bed and breakfast rules are explicit—a sale and subsequent repurchase within 30 days are matched to prevent loss harvesting. The Section 104 pool continuously aggregates all transactions.

For Options:

There isn’t a “30‑day” rule per se; instead, all transactions in a given option series are pooled. However, if you execute a same‑day (or very short‑term) opening and closing, HMRC’s matching rules will require that you calculate the gain or loss as a single net transaction. This prevents you from, for example, selling an option to record a gain (or loss) and then later closing it in a separate transaction with a different price in an attempt to alter the reported result.

• In other words, while the specific “bed and breakfast” concept as applied to shares does not directly apply to options, HMRC has put in place analogous matching rules within the pooling method to ensure that if transactions occur in rapid succession (or are part of a spread), they are combined and the net result is used for tax purposes."
----


Thoughts? Sorry for the long post, writing this also for my own understanding and you are clearly way ahead of me there.

PS: for the wishlist, would be great to get more readable option series label in the summary tables, something like what's shown on IBKR (example: "IWM June 21'25 200 PUT')
 
Will be definitely trying these out come April, for my next tax return - many thanks for creating and sharing!
Scoured the internet for quite a while, seems like this might be a robust solution from reading about it (albeit not tried any yet)
 
Back
Top