* Lanrete Li <
jeo...@gmail.com> [2023-07-04 23:52]:
> 2023/07/01 * Buy ETF
> Assets:Bank -130 USD
> Assets:Fund:xxxx 100 "FD_xxxx" @@ 130 USD
>
> In my understanding, this will create an internal commodity record that says
> "FD_xxxx" = 1.3 USD at 07/01
You can run "ledger bal --lots" to see the lot information.
> I'm not exactly happy with this because
Unfortunately, afaik you have to do it manually at the moment because
ledger has no built-in mechanism to do it for you.
> Lastly, I sw some one will record the "incremental gain" as
> `Income:CapitalGain` when selling the fund, for example, in the official
> document there is:
>
> 2004/05/01 Stock purchase
> Assets:Broker 50 AAPL @ $30.00
> Expenses:Broker:Commissions $19.95
> Assets:Broker $-1,519.95
>
> 2005/08/01 Stock sale
> Assets:Broker -50 AAPL {$30.00} @ $50.00
> Expenses:Broker:Commissions $19.95
> Income:Capital Gains $-1,000.00
> Assets:Broker $2,480.05
Yes, this is correct. Actually, it's slightly incorrect because you
also have to give the date:
2005/08/01 Stock sale
Assets:Broker -50 AAPL {$30.00} [2004/05/01] @ $50.00
Expenses:Broker:Commissions $19.95
Income:Capital Gains $-1,000.00
Assets:Broker $2,480.05
> It seems to me that the later transaction can be just written as
>
> 2005/08/01 Stock sale
> Assets:Broker -50 AAPL @ $50.00
> Expenses:Broker:Commissions $19.95
> Assets:Broker $2,480.05
> Both ledger will balance, which one SHOULD i follow?
The correct one. You have to specify {} @ manually. Only
this way ledger knows what you're talking about exactly.
Run "bal --lots" - if the lots are red, you have a problem.
> what if my 50 share of AAPL is purchased at different date and
> therefore different price?
You can do something like this:
Assets:Broker -25 AAPL {$25.00} [2003/03/02] @ $50.00
Assets:Broker -25 AAPL {$30.00} [2004/05/01] @ $50.00
Unfortunately, all of this is quite a manual process.
Basically: run "ledger bal --lots assets:Broker", copy&paste the info,
afterwards run "bal --lots assets:broker" again and make sure nothing
is red.
If something is red, it means you removed a lot that doesn't exist.
This can be because you forgot to write the date (as in the example
above).
--
Martin Michlmayr
https://www.cyrius.com/