Capital gains and trading commissions

185 views
Skip to first unread message

James Cook

unread,
May 4, 2021, 9:42:18 AM5/4/21
to bean...@googlegroups.com
Hi beancount list,

I have three questions about capital gains and trading commissions:

1. I understand Beancount 2 doesn't have good support for factoring
trading commissions into capital gains calculations. Is my example
below a reasonable workaround, or is there a better way? (See bottom
of email. I think this more or less implements the suggestion at
https://beancount.github.io/docs/trading_with_beancount.html#commissions)

2. Is there a syntax for specifying the total cost of a lot, instead of the
per-unit cost? E.g. instead of

Assets:Brokerage:ACME 10 ACME {10.50 USD}

I would like to write something like

Assets:Brokerage:ACME 10 ACME {@@ 105.00 USD}

or even

Assets:Brokerage:ACME 10 ACME {@@ 100.00 + 5.00 USD}

The latter two would be more pleasant to use when the cost per unit
is not a nice round number.

3. Is there a plan for dealing with this in a clever way? I found a
reference to a "proposal" at

https://beancount.github.io/docs/trading_with_beancount.html#commissions

but when I click the link I get a 404 at

https://beancount.github.io/docs/a_proposal_for_an_improvement_on_inventory_booking.md

Thanks for your time.


For question #1: here is how I am thinking of dealing with it. First,
here's a ledger before the workaround. Capital gains will be computed
incorrectly. (My ledger is like this right now.)


option "operating_currency" "USD"

plugin "beancount.plugins.auto_accounts"

2000-01-01 * "Buy ACME"
Assets:Brokerage:ACME 10 ACME {10.00 USD}
Expenses:Trading-commissions 5.00 USD
Assets:Brokerage:Cash -105.00 USD

2000-01-02 * "Sell 1 ACME"
Assets:Brokerage:ACME -1 ACME {10.00 USD} @ 12.00 USD
Expenses:Trading-commissions 2.00 USD
Assets:Brokerage:Cash 10.00 USD
Income:Capital-gains

2000-01-02 * "Sell 9 ACME"
Assets:Brokerage:ACME -9 ACME {10.00 USD} @ 20.00 USD
Expenses:Trading-commissions 2.00 USD
Assets:Brokerage:Cash 178.00 USD
Income:Capital-gains


And here is what I'm thinking of changing that to. The
Expenses:Trading-commissions account disappears, but now commissions
are subtracted from capital gains, which my tax jurisdictions allow.


option "operating_currency" "USD"

plugin "beancount.plugins.auto_accounts"

2000-01-01 * "Buy ACME"
Assets:Brokerage:ACME 10 ACME {10.50 USD}
Assets:Brokerage:Cash -105.00 USD

2000-01-02 * "Sell 1 ACME"
Assets:Brokerage:ACME -1 ACME {10.50 USD} @ 12.00 USD
Assets:Brokerage:Cash 10.00 USD
Income:Capital-gains

2000-01-02 * "Sell 9 ACME"
Assets:Brokerage:ACME -9 ACME {10.50 USD} @ 20.00 USD
Assets:Brokerage:Cash 178.00 USD
Income:Capital-gains


--
James

Ben Blount

unread,
May 4, 2021, 1:11:04 PM5/4/21
to Beancount
There's a total cost syntax, it's double curlys {{ }}. The main downside of it: we have limited control over the precision for non-round numbers, so the costs can be long (and an exact match is required if you ever want to match by cost).

Also there's a # syntax for specifying an expense like a commission. I'm not sure if Martin intends either to be 'general availability' yet.

Note you can't currently combine double curly total cost with the # function.

The # operator absorbs the commission into the basis:
2013-05-18 * ""
  Assets:Investments:MSFT      10 MSFT { 200 # 9.95 USD }
  Assets:Investments:Cash  -2009.95 USD


resolves to:
   2013-05-18 *
     Assets:Investments:MSFT        10 MSFT {200.995 USD, 2013-05-18}
     Assets:Investments:Cash  -2009.95 USD

--
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/20210504134212.pczxfpx54isjchif%40moth.falsifian.org.

James Cook

unread,
May 4, 2021, 1:52:22 PM5/4/21
to bean...@googlegroups.com
On Tue, May 04, 2021 at 10:10:50AM -0700, Ben Blount wrote:
> There's a total cost syntax, it's double curlys {{ }}. The main downside of
> it: we have limited control over the precision for non-round numbers, so
> the costs can be long (and an exact match is required if you ever want to
> match by cost).
>
> Also there's a # syntax for specifying an expense like a commission. I'm
> not sure if Martin intends either to be 'general availability' yet.
>
> Here's an example from the tests of cost basis syntax (#)
> <https://github.com/beancount/beancount/blob/v2/beancount/parser/booking_full_test.py#L745>
> .
> Note you can't currently combine double curly total cost with the #
> function.
>
> The # operator absorbs the commission into the basis:
> 2013-05-18 * ""
> Assets:Investments:MSFT 10 MSFT { 200 # 9.95 USD }
> Assets:Investments:Cash -2009.95 USD
>
> resolves to:
> 2013-05-18 *
> Assets:Investments:MSFT 10 MSFT {200.995 USD, 2013-05-18}
> Assets:Investments:Cash -2009.95 USD

Ooh, the # syntax looks nice. It looks like it already works; at least
bean-check (beancount 2.3.3) accepts

2000-01-01 * "buy"
Assets:B 10 ACME { 10.00 # 6.00 USD }
Assets:A

When I view it with fava, it just shows the cost as 10.60 USD. Is that
the whole story --- is { 10.00 # 6.00 USD } semantically identical to
{ 10.60 USD }?

{{ }} also seems to work, and thanks for the note about digits. I'll
make sure I can disambiguate lots some other way.


--
James
Reply all
Reply to author
Forward
0 new messages