How to book (and store) transaction feess/costs of a (stock) lot for tax reasons?

99 views
Skip to first unread message

Peter

unread,
Oct 29, 2022, 1:45:58 PM10/29/22
to Beancount
Hi,

I'm looking for some beancount (and maybe general accounting?) advice here:

Investing successfully in stocks makes you a subject for capital gains taxes. But investing in stocks comes with a cost for buying and selling shares. That cost is deductible from your capital gains and, therefore, lowers your taxes.

I'd like to keep track of my capital gains tax liabilities over the course of the year. This prevents me from spending/investing money I don't have/actually own. I'm wondering how I could do that, while being accurate and factoring in the deductible costs.

My first approach to book/track my stock investments was really simple:

option "booking_method" "FIFO"
option "operating_currency" "EUR"
plugin "beancount.plugins.auto_accounts"

2017-06-26 * "" "Open broker account"
 Assets:Broker:Cash                      385 USD
 Equity:Opening-Account

2017-06-26 * "" "Buy AAPL"
 Assets:Broker:Stocks:AAPL                10 AAPL { 38.37 USD }
 Assets:Broker:Cash                     -385 USD
 Expenses:Broker:Fees                    1.3 USD

2018-06-26 * "" "Sell AAPL"
 Assets:Broker:Stocks:AAPL               -10 AAPL { } @ 48.55 USD
 Assets:Broker:Cash                      484 USD
 Expenses:Broker:Fees                    1.5 USD
 Income:CapitalGain                  -101.80 USD


I didn't care about tracking outstanding taxes and I just booked the fees as cost.

My next iteration factors in my tax liabilities (assuming a fantasy 10% capital gains tax):

option "booking_method" "FIFO"
option "operating_currency" "EUR"
plugin "beancount.plugins.auto_accounts"

2017-06-26 * "" "Open broker account"
 Assets:Broker:Cash                      385 USD
 Equity:Opening-Account

2017-06-26 * "" "Buy AAPL"
 Assets:Broker:Stocks:AAPL                10 AAPL { 38.37 USD }
 Assets:Broker:Cash                     -385 USD
 Expenses:Broker:Fees                    1.3 USD

2018-06-26 * "" "Sell AAPL"
 Assets:Broker:Stocks:AAPL               -10 AAPL { } @ 48.55 USD
 Assets:Broker:Cash                      484 USD
 Expenses:Broker:Fees                    1.5 USD
 Income:CapitalGain                   -91.62 USD
 Liabilities:Tax:TY2018:CapitalGain   -10.18 USD
 ; Net worth is 473.82 USD, because there are 10.18 USD taxes outstanding


This approach is okay and gives me a rough estimation of my tax liabilities. My problem is: It doesn't factor in the deductible fees. (Well, it does factor in the fess paid in the selling transaction, actually, but it disregards the costs from the buying txn(s).)

While this is a minor problem for this particular example it can become quite relevant for bigger numbers/more buying txn coming with more fees.

So, how do I account for costs resulting from purchases correctly?

I guess, a possibility would be to allocate the buying fees proportionally to the buy share price. This approach would increase the 2017-06-26 share price from 38.37 to 38.37+1.3/10=38.5 USD.
The major disadvantage would be that I wouldn't really know how much fees I actually paid. Hence, that is an option I rather dislike.

Are there other/better options/approaches dealing with that?

Kind regards

Martin Blais

unread,
Oct 29, 2022, 10:16:36 PM10/29/22
to bean...@googlegroups.com
I looked at doing this within the constraints of the syntax and it's hard (surprisingly so).
I developed https://github.com/beancount/johnny  to do much more complex things with investing, including cross-referencing against my broker's CSV files for matches, and more.  Unfortunately Johnny is not integrated with Beancount and also not really a thing I spent much time making easy to use for others.


I guess, a possibility would be to allocate the buying fees proportionally to the buy share price. This approach would increase the 2017-06-26 share price from 38.37 to 38.37+1.3/10=38.5 USD.
The major disadvantage would be that I wouldn't really know how much fees I actually paid. Hence, that is an option I rather dislike.

Are there other/better options/approaches dealing with that?

Kind regards

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/695809c8-ef06-4876-aca4-7e18d3ee6765n%40googlegroups.com.

fin

unread,
Mar 27, 2023, 11:49:51 AM3/27/23
to bean...@googlegroups.com
Peter wrote:

hello,

after getting all my ancient transactions typed in i'm now
back to looking at this and so far my approach has been to
add the fees upfront to the cost so that i'm using the cost
per share adjusted by the fees (as my basis).

when i sell i'll use the price per share adjusted by
subtracting the fees for the sell to get the actual tax
reported PnL.


as asides...


in going through these old transactions i've come across
at least one error where the broker gave me a refund on part
of a commission and i forgot to adjust my basis for those
shares so i over-reported my income by a few $. oh well,
water over the dam at this point and long gone. i had to
make up a transaction for adjusting the fees for that
stock symbol overall, but to not adjust the basis (and
while i was at it i made up a generic function that would
allow me to adjust any field in my table that is a number
just in case i do have to adjust some transaction as i'm
working forwards).

since the accounts are going to be moved to Schwab in
a few weeks/months this is all rather an academic exercise
as i'm not sure they're going to carry forward the basis of
anything correctly (TDAmeritrade has no idea how to deal
with some things in my history as it is as i have shares
doing back before TDW (which used to be WHS) merged with
Ameritrade.)

sometimes i think brokerages merge just to be able to
throw away their account histories...


...
> Hi,
>
> I'm looking for some beancount (and maybe general accounting?) advice here:
>
> Investing successfully in stocks makes you a subject for capital gains
> taxes. But investing in stocks comes with a cost for buying and selling
> shares. That cost is deductible from your capital gains and, therefore,
> lowers your taxes.
...


fin

Reply all
Reply to author
Forward
0 new messages