* Martin Blais <[email protected]> [2014-06-12 02:05]:
> 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 {}):
...
> How does this work under the covers?
When you specify a cost with @, ledger internally keeps this cost
around. You'll have 15 ShareA {€20}. You can see this with
--lot-prices:
15 ShareA {€20} Share A
5 ShareB {€100} Share B
So when you sell, what you do by saying 5 ShareB {€100} @ €120 is that
you're selling the 5 particular ShareB with a cost of €100.
Consider you bought 5 ShareB at 100€ and 5 at 110€. Then you'd have:
5 ShareB {€100}
5 ShareB {€110} Share B
So which one are you selling? You indicate that by using the {..}
syntax.
> 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".
I think I actually disagree with this particular example. When I get
JPY out of an ATM, I'd say that a very clear exchange rate is attached
to those JPY (because you know exactly how much you paid in your local
currency).
But let's imagine you travel to Japan twice and you still have some
JPY left over from the previous trip. And now you go to the ATM
again. Then you have, let's say:
20000 JPY {$0.0090}
10000 JPY {$0.0098} Assets:Cash
So now things get complicated. The best solution would probably be to
just calculate the average cost and use that.
I suspect most people don't handle this correctly (me included :)
When you use --lot-prices, you actually see what's going on. I
suspect most people do something like this:
2014-03-01 * Buy JPY
Assets:Cash 10000 JPY @@ $98
Assets:Cash
2014-03-02 * Spend JPY
Expenses:Foo 10000 JPY
Assets:Cash -10000 JPY
And now ledger will say: ledger -f ~/e bal ets:cash
$-98 Assets:Cash
So everything *looks* great. But if you add --lot-prices, you see
that it's a mess:
$-98
-10000 JPY
10000 JPY {$0.0098} Assets:Cash
You have -10000 JPY and 10000 JPY {$0.0098}. This is because you
didn't specify the cost. You should have done:
2014-03-02 * Spend JPY
Expenses:Foo 10000 JPY {$0.0098}
Assets:Cash -10000 JPY {$0.0098}
But who does that?
> (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).
Yes, I agree. Unfortunately, this situation applies to me and I
struggle with this all the time.
> 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?
Fortunately, I don't have a lot of realized capital gains, so I was
mostly able to avoid the problem.
--
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].
For more options, visit https://groups.google.com/d/optout.