currency trading accounts

125 views
Skip to first unread message

Pierre Bastoul

unread,
Dec 29, 2021, 12:51:22 PM12/29/21
to Ledger
Hello,

I'm working on tracking my cryptocurrencies trades with ledger-cli as described in the "Multiple currencies with currency trading accounts" wiki page.

My first idea is not to have a default Fiat, I prefer not having a local currency point of view. I want to be able to track trades for all pairs like BTC to USDT, then BTC to ETH, the ETH to USD, and be able to do "swaps" in all available possible combinations.

So I started with only one trading account, expressed in many currencies:
Equity:Trading:USD
Equity:Trading:ETH
Equity:Trading:BTC
Equity:Trading:JPY
....

Then I made a trading account per currency, with multiple currencies in each:
Equity:Trading:ETH:USD
Equity:Trading:ETH:JPY
Equity:Trading:ETH:BTC
Equity:Trading:BTC:USD
Equity:Trading:BTC:JPY
because I want to be able to calculate Gain/loss for each currencies.

And then, discovered another chart naming model in the recent update in the wiki page:
Equity:Trading:ETH-BTC:USD
Equity:Trading:ETH-BTC:JPY
Equity:Trading:ETH-BTC:BTC
Equity:Trading:ETH-BTC:ETH

Do someone, or the author itself can explain the reason why accounts names were converted from AUD:EUR to AUD-EUR:EUR and AUD-EUR:AUD? Why this revision was made? for what usage?

I'm not able to calculate Cost  of a trade. But it seems feasible as described in point 5.3 https://www.mathstat.dal.ca/~selinger/accounting/tutorial.html#4 









o1bigtenor

unread,
Dec 29, 2021, 4:47:30 PM12/29/21
to Ledger
On Wed, Dec 29, 2021 at 11:51 AM Pierre Bastoul <pie...@o10c.fr> wrote:
>
> Hello,
>
> I'm working on tracking my cryptocurrencies trades with ledger-cli as described in the "Multiple currencies with currency trading accounts" wiki page.
>
> My first idea is not to have a default Fiat, I prefer not having a local currency point of view. I want to be able to track trades for all pairs like BTC to USDT, then BTC to ETH, the ETH to USD, and be able to do "swaps" in all available possible combinations.
>
> So I started with only one trading account, expressed in many currencies:
> Equity:Trading:USD
> Equity:Trading:ETH
> Equity:Trading:BTC
> Equity:Trading:JPY
> ....
>

Greetings

Hmmmmmm - - - well - - - most of us keep our records (record keeping -
- - -most
commonly called accounting) as much for the tax man (the man) as we do
to manage
our businesses or our finances.

The requirement for 'books' for the taxman is that 'everything' is in
ONE currency.
If other currencies are used everything is linked back to that 'home' currency.

The tax man really doesn't care about your costs or what you're spending money
on or most of any other details. They're looking to see that your income is
reported accurately and that you're not trying to 'fiddle the books' by either
misreporting income or expenses.
So if you're insisting that any currency goes - - - - well - - - I hope you
really never get audited. My guess is that that process would be very
very painful.

Haven't had the joy myself but I've heard that they use a fine toothed
comb to make sure that not one hair is out of place on your hemorrhoids.

I'm trying to come up with a way to use ledger for invoicing which
would be hugely useful for business purposes. I would suggest that
what you're looking for would be fine if you do it for just you but I
wouldn't suggest that a any currency goes in a general ledger be
a normal thing. (And yes, right now I'm usually only using 3 currencies
so I'm not just using a 'home' currency.) Just because one can
do something doesn't mean that you 'should' do it.

Regards

Pierre

unread,
Dec 30, 2021, 12:21:09 AM12/30/21
to Ledger
oh, I'm sorry but what  the "tax man" has to do here? I've  poorly explained, but my point is not to hide something. In the country I live, I'm not supposed to provide a book of records to the "tax man", it is not mandatory for personal finance.

I probably do not understand your answer. 

I just want to use Ledger mainly because I suppose it can help me see clearly what my money does, and answer very precisely what are my loss/gains, expenses/incomes...
Buying some BTC with USDT is not a strange operation nowadays, after 2 or 3 trades of this kind, getting loss or gains is not so trivial, I hoped that Ledger could help me on that. Even if that kind of transaction does not involve or is linked to my own home currencies. We can probably think of that as a trade made directly between apples and oranges, does it change something if we call them cryptocurrencies?

As I understand the -X operator for ledger,  will give me a full report in the home currency if I want it.

 




John Wiegley

unread,
Dec 30, 2021, 1:58:38 AM12/30/21
to Pierre Bastoul, Ledger
>>>>> "PB" == Pierre Bastoul <pie...@o10c.fr> writes:

PB> I'm working on tracking my cryptocurrencies trades with ledger-cli as
PB> described in the "Multiple currencies with currency trading accounts "
PB> wiki page.

I'd like to note that my trade-journal project:

https://github.com/jwiegley/trade-journal

Is aiming at providing good support for crypto transactions, including
taxation laws for different countries (it will be a modular system). The first
version will work on CSV exports of Coinbase fills, and so far only support
staking operation for one crypto (ICP). But again, it's meant to be fully
modular.

The idea is to take data from a crypto exchange, apply know-how in terms of
staking taxation events and local tax laws, and then to output a Ledger file
that allows you to do your year-end and performance reporting.

John

d10

unread,
Dec 30, 2021, 6:35:48 PM12/30/21
to Ledger
On Wednesday, December 29, 2021 at 12:51:22 PM UTC-5 Pierre wrote:
Hello,

I'm working on tracking my cryptocurrencies trades with ledger-cli as described in the "Multiple currencies with currency trading accounts" wiki page.


Check out lotter, https://src.d10.dev/lotter.  It's goal is to let you express your trades in ledger-cli and calculate cost basis for you.
 

Pierre Bastoul

unread,
Dec 31, 2021, 1:25:40 PM12/31/21
to Ledger
Thank you guys for that 2 tools. I will try to understand them.

the.so...@gmail.com

unread,
Feb 13, 2022, 7:17:41 AM2/13/22
to Ledger
Dear Pierre,
I just today saw this discussion. I made the change to the wiki, and would like to explain the change.

Multiple functions are served by commodity/currency trading accounts:

1. They enable the trial balance to be "0", regardless of the commodity which you use (with `-X`)
2. They act as a store of unrealized gains, when prices are changed using price directives.

Function 1 will be served regardless of the naming pattern of the commodity trading accounts.

However, for fully realizing Function 2, the naming convention makes a difference.  Depending on the naming pattern, you can either find out your total unrealized gains (for instance, from all your stocks, etc., taken together), or you can find out unrealized gains from each commodity pair (for instance, the gain for each stock separately).  

If you want more granular reporting of unrealized gains, having a "parent" sub-account where both commodities in a commodity pair are represented is important. Without that, you can't get a single account balance to tell you the gain/loss: you'll need the balance of two accounts. 

So using `Equity:Trading:AUD-EUR:AUD` and `Equity:Trading:AUD-EUR:EUR` will allow you to see the unrealized gains for the AUD-EUR pair by running `ledger bal Equity:Trading;AUD-EUR -X EUR` which, if you use `Equity:Trading:AUD:EUR` and `Equity:Trading:EUR:AUD` will need two separate accounts to be mentioned: `ledger bal Equity:Trading:AUD:EUR Equity:Trading:EUR:AUD -X EUR`.

Now, if you have multiple commodity pairs, and want a tree view, then the `AUD:EUR` / `EUR:AUD` naming pattern makes it very difficult. Whereas with `--depth`, getting unrealized gains for multiple commodity pairs is very easy if you use the `:COMM1-COMM2:` naming pattern.  Of course, you need to be consistent in which of the two commodities you use as "COMM1".  I tend to think of a single currency as the "base" currency in the transaction, and use that as "COMM1".  You could also just go by alphabetical order.

I hope that helps.  In case it is still not clear, try constructing an example journal with multiple commodities (at least 3) in both styles and play around with the reports.  That ought to help.

Cheers,
Pranesh

Alan Schmitt

unread,
Feb 13, 2022, 11:10:57 AM2/13/22
to the.so...@gmail.com, Ledger
Hello,

Would you also recommend this method to track investments, such as
stocks?

Best regards,

Alan Schmitt
signature.asc

the.so...@gmail.com

unread,
Feb 13, 2022, 2:45:54 PM2/13/22
to Ledger
On Sunday, 13 February, 2022 at 9:40:57 pm UTC+5:30 alan.s...@polytechnique.org wrote:
Hello,

Would you also recommend this method to track investments, such as
stocks?

This is indeed the method I use for all commodity conversions, including stocks.  I use the ISIN of the stocks as the commodity symbol, and use the stock exchange scrip symbol as well in the account, and follow this pattern:

Equity:Trading:Shares:JUNIORBEES:INR-INF732E01045:INF732E01045
Equity:Trading:Shares:JUNIORBEES:INR-INF732E01045:INR

... and the asset follows the pattern:

Assets:Investment:Equity:Shares:JUNIORBEES

(Do note that the "Equity" in the account name here refers to the type of investment, rather than the (Assets – Liabilities).  I use this to know how much of my investments are in equity, how much in debt, how much in cash & cash equivalents, how much in property, and how much in tangibles.)

To know the cost (the invested amount), one can use the query:
`ledger bal Equity:Trading:Shares:JUNIORBEES:INR-INF732E01045:INR`

or for all your shares:

`ledger bal '^Equity:Trading:Shares:.*:INR$'`

I hope that helps.

Cheers,
Pranesh

Alan Schmitt

unread,
Feb 14, 2022, 2:55:37 AM2/14/22
to the.so...@gmail.com, Ledger

> I hope that helps.

It does, thank you very much.

Alan
signature.asc

Pierre

unread,
Feb 14, 2022, 1:53:59 PM2/14/22
to Ledger
Big step for my comprehension. Thank you @Pranesh 
Reply all
Reply to author
Forward
0 new messages