The method used in the cookbook, is not correct. The cookbook uses the example of buying 10 shares of IBM at $160 and then selling those shares at $170. Without commissions, that would amount to a realized gain of $100, $1700 (the sales price) - $1600 (the cost basis). With commissions, however, the reportable gain is really $1700 (the sales price) - $9.95 (commission on the sale) - $1600 (basis) - $9.95 (commission on purchase) = $80.10. The method in the cookbook only accounts for the sale commission when figuring the capital gain.
So what's the right way to do this, accounting for commission on purchase. Note that if only part of the purchased shares are sold the commission is prorated, so the actual basis is $1609.95 or $160.995 per share. On Wednesday, June 11, 2014 11:05:54 PM UTC-7, Martin Blais wrote: > > Christophe, > I was going to reply with the detail to this email, but I decided to write > it up in my cookbook instead: > http://furius.ca/beancount/doc/cookbook > > I've been fantasizing for a while about writing up detailed examples for > all the things I've discovered for myself about bookkeeping over the years, > and waiting to finish the whole document just hasn't served me well, might > as well deliver it piecemeal. So here I wrote up much of the "Stock > Trading" section for you, and I hope you will find it explains well how > this is meant to be booked in our systems, Ledger or Beancount the same (I > think). > > > Michael: I don't understand how it works in your example. You're entering > the positions with price conversion, using the @ sign: > > 2014-01-01 Details for shares > Assets:Investments:Stocks:Share A 15 ShareA @ 20€ > Assets:Investments:Stocks:Share B 5 ShareB @ 100€ > Equity:Opening Balance > > But his sale is using the "cost" syntax (with {}): > > 2014-04-01 Selling 2 ShareB > Assets:Bank:Check Account 240,00 € > Assets:Investments:Stocks:Share B -2 ShareB {100€} @ 120€ > Income:Investments Gains > > How does this work under the covers? > I'm not sure how Ledger works in this regard actually, I'd love to know, I > should probably dig in the source code. In my system, these are two > completely different kinds of events. The first one is a "price > conversion", such that no memory is maintained regarding the cost of the > units converted. The price/rate is used to balance the transaction but the > units are deposited in the account without associated cost. This is what > you would do, for instance, if you were making a withdrawal in a foreign > country, e.g. in JPY and then spend it locally: you never think of these > yen in your wallet as "being held at such and such" exchange rate, once > converted, they have no "cost" to them anymore, all the bills are just > "yen". (In fact, if you're homed in multiple countries and hold assets in > many places, holding currencies at cost creates incredible unnecessary > complexities, I'm quite certain this is not what's happening). These > conversion events are relatively rare in practice. > > The semantics I attach to the second one is explained in a good amount of > detail in the link to my document above. But it requires that when I enter > a position, I say "this is held at cost" by virtue of using the {} syntax. > It then attaches the cost to the lot as it accumulates balances for each > posting of an account. > > If someone could provide some insight, that would be interesting. > > > Finally, without the fix you provided in the github ticket, I don't > understand how you've been using the system to track capital gains until > now. With virtual transactions? How did this use to work? > > Thank you, > > > > > > > > > > On Wed, Jun 11, 2014 at 6:56 PM, Martin Michlmayr <[email protected] > <javascript:>> wrote: > >> * Christophe Schockaert <[email protected] <javascript:>> [2014-06-11 >> 22:10]: >> > ; Details of shares at 2014/01/01 >> > 2014-01-01 Details for shares >> > Assets:Investments:Stocks:Total Value >> >> This is incorrect (see below). >> >> > Assets:Investments:Stocks:Share A 15 ShareA @ 20€ >> > Assets:Investments:Stocks:Share B 5 ShareB @ 100€ >> > >> > Then, I run "ledger --real -B -V balance", which returns: >> > : 5000,00 € Assets >> > : 5000,00 € Bank:Check Account >> > : 0 Investments:Stocks >> > : 300,00 € Share A >> > : 500,00 € Share B >> > : -800,00 € Total Value >> > : -5000,00 € Equity:Opening Balance >> > : -------------------- >> > : 0 >> > >> > That's fine. I understand that doing this, only the gains and loss will >> end in >> > the assets. I put the "Total Value" entry in order to see at a glance >> the value >> > of all shares. >> >> This "Total Value" entry is incorrect. It's not the total value, but >> the cost. You have share A worth 300 and share B worth 500. How did >> you pay for those shares? You either have to reduce cash, or your >> case, use Equity:Opening Balance. >> >> What you want is something like this: >> >> 2014-01-01 Details for shares >> Assets:Investments:Stocks:Share A 15 ShareA @ 20€ >> Assets:Investments:Stocks:Share B 5 ShareB @ 100€ >> Equity:Opening Balance >> >> Also, -B -V doesn't make much sense together. -B is the cost (what >> you paid), -V is the current value (what it's worth now). Look here: >> >> 2014-01-01 Details for shares >> Assets:Investments:Stocks:Share A 15 ShareA @ 20€ >> Assets:Investments:Stocks:Share B 5 ShareB @ 100€ >> Equity:Opening Balance >> >> P 2014-02-01 ShareA 30€ >> >> bal 'Assets:Investments:Stocks:Share A' -B >> €300 Assets:Investments:Stocks:Share A >> bal 'Assets:Investments:Stocks:Share A' -V >> €450 Assets:Investments:Stocks:Share A >> >> > In my second try (case B), I wish to see the contribution of my stocks >> within >> > the assets (I don't know if that's a valid practice but it gives me an >> overview >> > of the whole money available a time "t"). >> >> I don't know what you're trying to say exactly, but in any case, this >> is the correct accounting practice to use. >> >> > The, I sell some shares of stock B at a higher price, in both cases. >> > This is were problems rises for me. >> ... >> > There are a few things that bother me: >> > 1) The presence of the "Equity:Capital Gains", which I understand >> balances the >> > entry, but it is automatically added and I can't choose its name. I >> thought >> > the balance would go to the "Income:Investments Gains" in fact. >> >> These Equity entries ledger generates are wrong. This is bug >> http://bugs.ledger-cli.org/show_bug.cgi?id=712 >> The good news is that John and I agreed on a fix recently. You can >> try the 713-costs branch and see if it does what you expect. >> >> > So, what's the status for this question ? >> >> There's a fix. We're just waiting for more people to test it. >> >> > 2) The left-over for "Share B" shows 260€, which does not render the >> fact that >> > I still have 3 plain stocks, which would at least value 300€ (from >> their >> > initial value), or 360€ for the current value. >> >> This is http://bugs.ledger-cli.org/show_bug.cgi?id=713 >> which should be fixed on the 713-costs branch. >> >> > 3) I would like to have a view of the left-over value of the stocks, >> at time >> > "t". In "case A", the total still show "800€" which is the initial >> value, >> > and in "case B", I see 560€, which reflects the "800€-240€", but >> not the >> > sum of the 10 ShareA and the 3 remaining ShareB. >> >> I'm not entirely sure I understand, but with the 713-costs branch, >> you should get the correct result: >> >> bal 'Assets:Investments:Stocks' -B >> 600,00 € Assets:Investments:Stocks >> 300,00 € Share A >> 300,00 € Share B >> -------------------- >> 600,00 € >> >> bal 'Assets:Investments:Stocks' -V >> 660,00 € Assets:Investments:Stocks >> 300,00 € Share A >> 360,00 € Share B >> -------------------- >> 660,00 € >> >> -B is the cost: you originally paid 20 for A and 100 for B: 3 * 100 + >> 15*20 = 600 >> >> -V is the current value. A is worth 20, B is worth 120: 3 * 120 + 15*20 >> = 660 >> >> > However, I run into other issues, mainly that it only uses the last >> value, even >> > for the initial value, and if I mix the notation in "plain shares" (-2 >> ShareB) >> > and the notation with attributed values (-2 ShareB {100€} @ 120€), they >> don't >> > get along very well. >> >> I'm not sure I understand. >> >> BTW, you use Assets:Investments:Stocks:Share A and >> Assets:Investments:Stocks:Share B >> as account names. General practice on this list appears to be not to >> use too many subaccounts. I'd just use Assets:Investments:Stocks for >> both. If you want to see what Share A is worth only, you can do >> -l "commodity == 'ShareA'" >> >> -- >> Martin Michlmayr >> http://www.cyrius.com/ >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "Ledger" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- --- You received this message because you are subscribed to the Google Groups "Ledger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
