There's one small mistake in the comments in the example journal I provided:
Equity:Trading:EUR-USD:USD:20220103 120.00 USD ; balance: 100 USD
ought to be
Equity:Trading:EUR-USD:USD:20220103 120.00 USD ; balance: 120 USD
On Monday, 7 February, 2022 at 8:24:11 pm UTC+5:30 [email protected]
wrote:
> Hi,
> I'm guessing the wiki page you're referring to is:
>
> https://github.com/ledger/ledger/wiki/Multiple-currencies-with-currency-trading-accounts
>
> The trading accounts method is not incorrect: it simply doesn't match what
> you expect. The trading accounts method will always give you a 0 balance,
> regardless of the currency in which you calculate the balance, which is not
> the case for postings using @ (which will differ, depending on the
> currency). The downside is that in the trading accounts method, you have
> to note capital gains and losses by hand. It is not auto-calculated.
>
> To handle lots with trading accounts, you'll need to use dated
> sub-accounts:
>
> cat temp.j
> P 2022-01-01 EUR 1.0 USD
>
> 2022-01-01 Salary
> Assets:Bank:EUR 100.00 EUR
> Equity:Trading:EUR-USD:EUR:20220101 -100.00 EUR
> Equity:Trading:EUR-USD:USD:20220101 100.00 USD
> Income:Salary -100.00 USD
>
>
> P 2022-01-02 EUR 1.1 USD
>
> 2022-01-02 Bank | Convert 50 EUR to 55 USD
> Assets:Bank:USD 55.00 USD
> Equity:Trading:EUR-USD:USD:20220101 -50.00 USD ; balance: 50 USD
> Equity:Trading:EUR-USD:EUR:20220101 50.00 EUR ; balance: -50 EUR
> Income:Capital:Short-Term -5.00 USD
> Assets:Bank:EUR -50.00 EUR
>
>
> P 2022-01-03 EUR 1.2 USD
>
> 2022-01-03 Salary
> Assets:Bank:EUR 100.00 EUR
> Equity:Trading:EUR-USD:EUR:20220103 -100.00 EUR ; balance: -100 EUR
> Equity:Trading:EUR-USD:USD:20220103 120.00 USD ; balance: 100 USD
> Income:Salary -120.00 USD
>
>
> P 2022-01-04 EUR 1.3 USD
>
> 2022-01-04 Bank | Convert 100 EUR to 130 USD
> Assets:Bank:USD 130.00 USD
> Equity:Trading:EUR-USD:USD:20220101 -50.00 USD ; balance: 0 USD
> Equity:Trading:EUR-USD:USD:20220103 -60.00 USD ; balance: 60 USD
> Equity:Trading:EUR-USD:EUR:20220101 50.00 EUR ; balance: 0 EUR
> Equity:Trading:EUR-USD:EUR:20220103 50.00 EUR ; balance: -50 EUR
> Income:Capital:Short-Term -20.00 USD
> Assets:Bank:EUR -100.00 EUR
>
>
> P 2022-01-05 EUR 1.4 USD
>
>
> with that you get
>
> ledger -f temp.j bal -X USD
> 255.00 USD Assets:Bank
> 70.00 USD EUR
> 185.00 USD USD
> -10.00 USD Equity:Trading:EUR-USD
> -70.00 USD EUR:20220103
> 60.00 USD USD:20220103
> -245.00 USD Income
> -25.00 USD Capital:Short-Term
> -220.00 USD Salary
> --------------------
> 0
>
> So,
> Cash = 255.00 USD (balance of Assets:Bank)
> Income:Salary = 220.00 USD (balance of Income:Salary)
> Realized Gains = 25.00 USD (balance of Income:Capital:Short-Term)
> Unrealized Gains = 10.00 USD (balance of Equity:Trading:EUR-USD)
>
> I hope this helps.
>
> Regards,
> Pranesh
> On Sunday, 23 January, 2022 at 8:05:58 pm UTC+5:30 [email protected]
> wrote:
>
>> This is copy of reddit post. Wiki example does not work for me or it's
>> wrong
>>
>> Let we have following transaction:
>> Income 100 EUR @ 1.0
>> Sell 50 EUR @ 1.1
>> Income 100 EUR @ 1.2
>> Sell 100 EUR @ 1.3
>> Now @ 1.4
>>
>> If calculate everything in USD I expect to have balance
>>
>> Assets.Cash 50 * 1.4 + 50 * 1.1 + 100 * 1.3 = 255 USD
>> Income 100 * 1 + 100 * 1.2 = 220 USD
>> Equity.Realized 50 * (1.1 - 1.0) + 50 * (1.3 - 1.0) + 50 * (1.3 - 1.2) =
>> 25 USD
>> Equity.Unrealized 50 * (1.4 - 1.2) = 10 USD
>>
>> I tried trading account according to wiki and results are unadequate
>>
>> P 2022-01-01 EUR 1.0 USD
>> 2022-01-01 Salary
>> Assets:Bank 100.00 EUR
>> Income:Salary
>>
>> P 2022-01-02 EUR 1.1 USD
>> 2022-01-02 Transaction 1
>> Assets:Bank -50.00 EUR
>> Equity:Trading:USD 50.00 EUR
>> Equity:Trading:EUR -55.00 USD
>> Assets:Bank 55.00 USD
>>
>> P 2022-01-03 EUR 1.2 USD
>> 2022-01-03 Salary
>> Assets:Bank 100.00 EUR
>> Income:Salary
>>
>> P 2022-01-04 EUR 1.3 USD
>> 2022-01-04 Transaction 1
>> Assets:Bank -100.00 EUR
>> Equity:Trading:USD 100.00 EUR
>> Equity:Trading:EUR -130.00 USD
>> Assets:Bank 130.00 USD
>>
>> P 2022-01-05 EUR 1.4 USD
>>
>> Income is not adequate
>>
>> $ ledger bal -f trade.txt -X USD
>> 255.00 USD Assets:Bank
>> 25.00 USD Equity:Trading
>> -185.00 USD EUR
>> 210.00 USD USD
>> -280.00 USD Income:Salary
>> --------------------
>> 0
>>
>> If I put FIFO logic manually
>>
>> P 2022-01-01 EUR 1.0 USD
>> 2022-01-01 Salary
>> Assets:Bank 100.00 EUR @ 1.0 USD
>> Income:Salary
>>
>> P 2022-01-02 EUR 1.1 USD
>> 2022-01-02 Transaction 1
>> Assets:Bank -50.00 EUR {1.0 USD} @ 1.1 USD
>> Assets:Bank 55.00 USD
>> Equity:Realized Gains -5.00 USD
>>
>> P 2022-01-03 EUR 1.2 USD
>> 2022-01-03 Salary
>> Assets:Bank 100.00 EUR @ 1.2 USD
>> Income:Salary
>>
>> P 2022-01-04 EUR 1.3 USD
>> 2022-01-04 Transaction 1
>> Assets:Bank -50.00 EUR {1.0 USD} @ 1.3 USD
>> Assets:Bank -50.00 EUR {1.2 USD} @ 1.3 USD
>> Assets:Bank 130.00 USD
>> Equity:Realized Gains -20.00 USD
>>
>> P 2022-01-05 EUR 1.4 USD
>>
>> balance is correct
>>
>> $ ledger bal -f trade2.txt -X USD
>> 255.00 USD Assets:Bank
>> -25.00 USD Equity:Realized Gains
>> -220.00 USD Income:Salary
>> --------------------
>> 10.00 USD
>>
>> But I have to manually keep track of every income transaction.
>>
>> Quiestion: is there a better way to do it or I miss something?
>>
>
--
---
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ledger-cli/0326bcbe-f300-4b5f-b5d3-61394d2740dbn%40googlegroups.com.