What is wrong with this record?

86 views
Skip to first unread message

Alen Šiljak

unread,
May 4, 2025, 8:49:59 AM5/4/25
to Beancount
During the migration, I have identified a record that causes problems and I don't really understand why.
I am going through the trading documentation to understand the concepts better but if someone can point me in the right direction, that would be much appreciated.

The case seems rather simple:
```
1970-01-01 open Assets:Investments:Shares:BYE
1970-01-01 open Assets:Investments:Cash
1970-01-01 open Expenses:Commissions

2013-02-25 txn "Buy BYE"
  Assets:Investments:Shares:BYE         10595 BYE @ 0.47 YEN
  Expenses:Commissions                  19.95 YEN
  Assets:Investments:Cash            -4999.60 YEN

2014-06-02 txn "Sell BYE"
  Assets:Investments:Shares:BYE            -5000 BYE {0.47 YEN, 2013-02-25} @ 0.95 YEN
  Expenses:Commissions                     19.95 YEN
  ;Income:Investment:Capital-Gains         -2400.00 YEN
  Assets:Investments:Cash                4730.05 YEN
```
yet bean-check throws
```
No position matches "Posting(account='Assets:Investments:Shares:BYE', units=-5000 BYE, cost=CostSpec(number_per=Decimal('0.47'), number_total=None, currency='YEN', date=datetime.date(2013, 2, 25), label=None, merge=False), price=0.95 YEN, flag=None, meta={'filename': '/mnt/x/pim/beancount/test.bean', 'lineno': 13})" against balance (10595 BYE)
```

Stefano Mihai Canta

unread,
May 4, 2025, 8:55:47 AM5/4/25
to bean...@googlegroups.com
Replying from my phone, so I'll be quick. The first transaction requires to be booked at cost, but you only specified the price. 

10595 BYE {} @ 0.47 YEN

The empty bracket content {0.47 YEN} should be automatically filled out by beancount.

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/beancount/21f2f590-0df2-48d2-ae50-5a6e213b9ef7n%40googlegroups.com.
Message has been deleted

Alen Šiljak

unread,
May 5, 2025, 4:29:11 PM5/5/25
to Beancount
Aha, thank you very much! I need to read a bit more about this in the doc but also to work out if ledger2beancount can do this during conversion.

Martin Michlmayr

unread,
May 9, 2025, 3:42:27 AM5/9/25
to 'Alen Šiljak' via Beancount
* 'Alen Šiljak' via Beancount <bean...@googlegroups.com> [2025-05-04 05:49]:
> During the migration, I have identified a record that causes problems and I
> don't really understand why.

> 2013-02-25 txn "Buy BYE"
> Assets:Investments:Shares:BYE 10595 BYE @ 0.47 YEN
> Expenses:Commissions 19.95 YEN
> Assets:Investments:Cash -4999.60 YEN

Stefano already answered your question but just to expand a bit.

Ledger treats costs ({...}) and prices (@ ...) as very similar whereas
there's an explicit difference in beancount.

So if we take your transaction:

2013-02-25 * "Buy BYE"
Assets:Investments:Shares:BYE 10595 BYE @ 0.47 YEN
Expenses:Commissions 19.95 YEN
Assets:Investments:Cash -4999.60 YEN

If you look at the ledger balance report with --lots, you'll see that
ledger added a cost:

ledger -f a1 bal :bye --lots
10595 BYE {0.47 YEN} [2013-02-25] Assets:Investments:Shares:BYE

But this is not how it works in beancount. You need to specify a cost
explicitly if you want one -- in many cases (e.g. cash / currencies) I
won't want FOO @ BAR to create a cost (ledger "lot).

People are often not aware of this in ledger-land because ledger
allows you to remove a lot that doesn't exist (*); which beancount
wisely doesn't allow.

(*) You only see the mess if you look at it with "bal --ledger".

--
Martin Michlmayr
https://www.cyrius.com/

Alen Šiljak

unread,
May 9, 2025, 3:45:36 AM5/9/25
to Beancount
Thanks for the explanation, Martin.
The lot dates are already inferred from the transaction. I wonder why would the cost not be inferred from the price, either. It would be a shortcut of convenience.
Reply all
Reply to author
Forward
0 new messages