-M and -B not working

48 views
Skip to first unread message

Albert

unread,
Mar 10, 2023, 4:50:15 PM3/10/23
to Ledger
Hi guys I can't get my monthly BTC total invest. Cause params -M and -B are not working well.

Example file:
2023/01/01 balance inicial
activos:bancos $1500
capital:inicial

2023/01/02 compra BTC
activos:btc 1 BTC @ $500
activos:bancos

For: ledger reg btc -M 
I get:
23-Jan-01 - 23-Jan-31    activos:btc    1 BTC    1 BTC

But when I try: ledger reg btc -M -B
I get:
23-Jan-01 - 23-Jan-31    activos:btc    1 BTC    1 BTC

But what I expect is:
23-Jan-01 - 23-Jan-31    activos:btc    $500    $500

federico lopez

unread,
Mar 11, 2023, 6:27:06 AM3/11/23
to ledge...@googlegroups.com, alber...@gmail.com
On Fri, Mar 10, 2023 at 9:50 PM Albert <alber...@gmail.com> wrote:
Hi guys I can't get my monthly BTC total invest. Cause params -M and -B are not working well.


For: ledger reg btc -M 
I get:
23-Jan-01 - 23-Jan-31    activos:btc    1 BTC    1 BTC

Can you try 
ledger reg btc --exchange $   
or
ledger reg btc --market $

Note: The flag -M is for --monthly

Albert

unread,
Mar 11, 2023, 9:35:48 AM3/11/23
to Ledger
Tx Federico but what I get in bot examples you suggest is the same I get with: ledger reg btc -M -V
I extended my example file to clarify the issue

Example file:
2023/01/01 balance inicial
activos:bancos $1500
capital:inicial

2023/01/02 compra BTC
activos:btc 1 BTC @ $500
activos:bancos

2023/01/03 compra BTC
activos:btc 1 BTC @ $700
activos:bancos



For: ledger reg btc -M 
I get: OK
23-Jan-01 - 23-Jan-31    activos:btc    2 BTC    2 BTC

For: ledger reg btc -M -V
I get: OK
23-Jan-01 - 23-Jan-31    activos:btc    $1,400  $1,400

The error is here: ledger reg btc -M -B
I get: error?
23-Jan-01 - 23-Jan-31    activos:btc    2 BTC    2 BTC
I think the correct result should be:
23-Jan-01 - 23-Jan-31    activos:btc    $1,200  $1,200


federico lopez

unread,
Mar 11, 2023, 10:27:54 AM3/11/23
to ledge...@googlegroups.com
On Sat, Mar 11, 2023 at 2:35 PM Albert <alber...@gmail.com> wrote:

I think the correct result should be:
23-Jan-01 - 23-Jan-31    activos:btc    $1,200  $1,200

It seems that ledger takes the first currency as "base"  

Not a solution but, if you  invert the transaction it reports the $ currency as base:

2023/01/02 compra BTC
activos:btc $500 @ 1 BTC
activos:bancos

2023/01/03 compra BTC
activos:btc $700 @ 1 BTC
activos:bancos

ledger  reg btc -M -B
2023/01/01 - 23-Jan-31          activos:btc               $1,200.00    $1,200.00


federico lopez

unread,
Mar 11, 2023, 11:07:22 AM3/11/23
to ledge...@googlegroups.com, alber...@gmail.com
The manual suggest to use --basis in conjunction with --exchange COMMODITY  so maybe you can try:

ledger reg btc -M -X $ -B

Albert

unread,
Mar 11, 2023, 12:48:43 PM3/11/23
to Ledger
I tried your suggested command and got same result, monthly accumulated of the actual market price and I want monthly accumulated of the total capital invested (cost).

I think its a bug. The -B param works perfectly all the time, except when there is a group command too, like -M or -Y for example.

federico lopez

unread,
Mar 12, 2023, 5:47:58 AM3/12/23
to ledge...@googlegroups.com
On Sat, Mar 11, 2023 at 5:48 PM Albert <alber...@gmail.com> wrote:
I tried your suggested command and got same result, monthly accumulated of the actual market price and I want monthly accumulated of the total capital invested (cost).

I think its a bug. The -B param works perfectly all the time, except when there is a group command too, like -M or -Y for example.

As a workaround you can try:

ledger reg btc -B --group-by 'format_date(date, "%Y-%m")'

Albert

unread,
Mar 13, 2023, 6:42:26 PM3/13/23
to Ledger
Thanks for the help Federico.

Finally had to download and compile the 2.5 version and the params -M and -B worked perfectly nice together.
Reply all
Reply to author
Forward
0 new messages