capital-gains-calculator icon indicating copy to clipboard operation
capital-gains-calculator copied to clipboard

Fix bed&breakfast calculation when stock is split

Open sygi opened this issue 9 months ago • 7 comments

The stock split action in the code is considered a 0-priced acquisition. This works as long as there is no bed&breakfast to consider (no sale in the previous 30 days).

It would be nice to fix the calculation to handle this case as well, or, at a very least, to throw an error to avoid silently incorrect calculation.

sygi avatar May 06 '24 13:05 sygi

Can you add some minimal examples to test in whatever csv format you are using? Alongside what should be correct reported gain/loss, these cases would help:

  • Buy, sell, split, buy within 30 days
  • Buy, sell, split within 30 days
  • Buy, sell, split, buy after 30 days

Also I believe this is still a hard case because if you sell everything the stock split won't even show up in your export, and there's no way to detect it or warn about that.

vmartinv avatar Jun 09 '24 22:06 vmartinv

I attach a CSV file with an example split. I also created a test here: #541 which shows where the problem lies (the library consider a split as an 0-cost acquisition). schwab.csv

sygi avatar Jul 02 '24 10:07 sygi

I attach a CSV file with an example split. I also created a test here: #541 which shows where the problem lies (the library consider a split as an 0-cost acquisition). schwab.csv

I wouldn't worry about fixing it at the moment, I had one idea about it. Just having the 3 examples I listed would be helpful

vmartinv avatar Jul 02 '24 14:07 vmartinv

Please find the three examples attached. Note that no2 and 3 are actually the same in terms of cgt, as both split and buy after 30 days are tax neutral.

schwab2_5_00.csv schwab_5_00.csv schwab_18_00.csv

sygi avatar Jul 03 '24 09:07 sygi

I guess the first thing we should do is detect b&b when split is involved and abort as unsupported case. Until someone figure out how to calculate this cases properly.

KapJI avatar Jul 03 '24 09:07 KapJI

I am quite sure you do the b&b matching rules with the matching quantity adjusted for the share split ratio. https://www.gov.uk/government/publications/share-reorganisations-company-takeovers-and-capital-gains-tax-hs285-self-assessment-helpsheet/hs285-share-reorganisations-company-takeovers-and-capital-gains-tax-2021

alexpung avatar Jul 07 '24 12:07 alexpung

Yes, this is what I advocate above and propose strategies for implementing of #541

sygi avatar Jul 07 '24 14:07 sygi