Stuck on non-descriptive error message 'No position matches'

79 views
Skip to first unread message

Makdisse

unread,
Mar 26, 2020, 7:58:01 PM3/26/20
to Beancount
Hi there,

I'm moving from Pocketsmith to beancount and I've hit a wall.
I've attached a file with just 4 transactions where I'm getting the error:
>> bean-check example.beancount
example
.beancount:32:      No position matches "Posting(account='Assets:Coinbase:ETH', units=4.81321544 ETH, cost=CostSpec(number_per=Decimal('339.82'), number_total=None, currency='GBP', date=None, label=None, merge=False), price=None, flag=None, meta={'filename': 'example.beancount', 'lineno': 33})" against balance (-2.123873000000000000000000000 ETH, 2.13226701 ETH {443.62 GBP, 2018-03-22})


   
2018-04-03 * "Buy ETH"
     
Assets:Coinbase:ETH      4.81321544 ETH {339.82 GBP}
     
Assets:Coinbase:Fees          24.37 GBP
     
Equity:Opening-Balances

I have read all documents on https://docs.google.com/document/d/1RaondTJCS_IUPBHFNdT8oqFKJjVJDsfsn6JEjBG04eA/edit and I still can't understand what I'm doing wrong.

I must be missing some major mental model.

Can you guys please help understand what I'm doing wrong? 

Thanks
example.beancount

Martin Blais

unread,
Mar 27, 2020, 12:06:41 AM3/27/20
to Beancount
You probably have other transactions before this one that make the balance of that account negative, and so it's trying to match that positive ETH posting against existing positions with a cost basis of 339.82.

Run bean-doctor context with the filename and line number around that transaction to see the inventory of the Assets:Coinbase:ETH account just before the transaction gets applied.




--
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 on the web visit https://groups.google.com/d/msgid/beancount/fdcd6381-f782-4a42-8f92-56050774086e%40googlegroups.com.

Makdisse

unread,
Mar 27, 2020, 5:06:51 AM3/27/20
to Beancount
Hi Martin,
Thanks for your answer. But I still can't find a solution.

The ETH account balance is 2.13226701 ETH before the 2 convert transactions.

I then deduct 1.025268+1.098605 == 2.12 from that account.

And then on the erroring transaction I try to add more ETH to the account: Assets:Coinbase:ETH 4.81321544 ETH {339.82 GBP}

When I run bean-doctor I get an empty transaction:
Hash:bde2c9df7c3195dfa5bd9e4b68ed2261
Location: /example.beancount:31


------------ Balances before transaction




------------ Transaction


2018-04-03 * "Buy ETH"






------------ Balances after transaction


And if I try to add {443.62 GBP} to the ETH deduction of both conversions (to specify that the conversion should deduct from the `Assets:Coinbase:ETH 2.13226701 ETH {443.62 GBP}` account) I get a 'Transaction does not balance' error.

To unsubscribe from this group and stop receiving emails from it, send an email to bean...@googlegroups.com.

Martin Blais

unread,
Mar 27, 2020, 8:36:55 AM3/27/20
to Beancount
Your balance has a mix of positive and negative values.
See error message, it includes the balance it is trying to match against.
Its not showing the context because the transaction failed to match, that's a catch-22 but that we need to fix, failing transactions aren't properly handled by the context command.

To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/f51ce28c-54c6-4097-b3df-69be98d90a09%40googlegroups.com.

Makdisse

unread,
Mar 27, 2020, 2:26:06 PM3/27/20
to Beancount
I've tried adding the ETH price to make sure beancount knows against which account it should match:

2018-03-22 * "Buy ETH"
Assets:Coinbase:ETH 2.13226701 ETH {443.62 GBP}
Assets:Coinbase:Fees 14.09 GBP
Equity:Opening-Balances

2018-03-22 * "Convert ETH to XLM"
Assets:Binance:XLM 2324 XLM @@ 1.025268 ETH
Assets:Coinbase:ETH {443.62 GBP}    <-- ADDED PRICE

2018-03-22 * "Convert ETH to EOS"
Assets:Kraken:EOS 90 EOS @@ 1.098605 ETH
Assets:Coinbase:ETH {443.62 GBP}    <-- ADDED PRICE

2018-04-03 * "Buy ETH"
Assets:Coinbase:ETH 4.81321544 ETH {339.82 GBP}
Assets:Coinbase:Fees 24.37 GBP
Equity:Opening-Balances

Now I get a different error: 'Transaction does not balance'. Which doesn't make sense to me because the math seems to be correct.

I've read all documentation you wrote, can you see what mental model I'm missing about how beancount works?

I've tried a lot of different variations to these 4 transactions and every time I get a different error.

Red S

unread,
Mar 28, 2020, 3:46:27 AM3/28/20
to Beancount
Makdisse,
1) Include this line in your earlier source:
2000-01-01 open Assets:Coinbase:ETH "NONE"

and everything would work fine. However, you won't get strict lot reduction, but rather, a mix of positive and negative lots. The point here is to help you build your mental model of how beancount works. Read Martin's response above and see if it makes better sense now. Hint: your source makes beancount think you shorted ETH.

2)     Assets:Coinbase:ETH {443.62 GBP}    <-- ADDED PRICE

That's not valid syntax. You'd have to specify the number you're reducing the lot by.along with the price.

3) try bean-doctor context on the *prior* transaction, and it shows you the state of things.

Makdisse

unread,
Mar 28, 2020, 2:43:21 PM3/28/20
to Beancount
Thanks for that Red!
It works fine with "NONE". And I think I understand how I must track the holding when converting from a currency to another.

Martin Blais

unread,
Mar 28, 2020, 2:49:21 PM3/28/20
to Beancount
On Fri, Mar 27, 2020 at 2:26 PM Makdisse <makd...@gmail.com> wrote:
I've tried adding the ETH price to make sure beancount knows against which account it should match:

2018-03-22 * "Buy ETH"
Assets:Coinbase:ETH 2.13226701 ETH {443.62 GBP}
Assets:Coinbase:Fees 14.09 GBP
Equity:Opening-Balances

2018-03-22 * "Convert ETH to XLM"
Assets:Binance:XLM 2324 XLM @@ 1.025268 ETH
Assets:Coinbase:ETH {443.62 GBP}    <-- ADDED PRICE

What's the balance currency you want?
- The first posting will compute 1.025268 ETH as a balance amount
- The second posting will auto-fill the units (and in this particular case, infer the currency as ETH from the first posting), but then it's intended to produce GBP to balance (because of the cost).
So you have two currency groups: ETH (posting 1), and GBP (posting 2). For each of these groups, Beancount will attempt pretty hard to match and auto-fill, but in this case you have a single posting in each, so it doesn't balance. 

What are you trying to do?

(I'll be honest with you, crypto use cases not super well served by this software, as you'll want to spend money that you track cost basis for, it will leave you unsatisfied, unless you build a bunch of plugins to help you. Normally investments are fewer and require a bit more TLC for matching and cost basis tracking, and spending occurs in cash. Crypto users seem to always want to spend from "investments." Not super well handled by any software, this would require custom software IMO.)
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/68a3b1b7-3f58-4aba-8afe-1c43e0e683ac%40googlegroups.com.

Martin Blais

unread,
Mar 28, 2020, 2:50:41 PM3/28/20
to Beancount
Be careful with NONE booking. "Works" means there will be no lot matching. The only meaningful numbers you can get out of that are
- Sum of units over all postings in that account, currency
- Sum of cost bases over all postings in that account, currency
If you're not getting an error that doesn't mean it's doing what you want it to do.
(What do you want it to do?)



To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/854b691c-1c80-4cdf-a327-6374b65bf18b%40googlegroups.com.

Makdisse

unread,
Mar 29, 2020, 7:20:29 AM3/29/20
to Beancount
So what I ended up doing was tracking the lot for all transactions:


2018-03-22 * "Buy ETH"
Assets:Coinbase:ETH 2.13226701 ETH {443.62 GBP}
Assets:Crypto:Fees 14.09 GBP
Equity:Opening-Balances

2018-03-22 * "Send ETH to Kraken"
Assets:Kraken:ETH 2.13197651 ETH {443.62 GBP}
Assets:Coinbase:ETH -2.13197651 ETH {443.62 GBP,2018-03-22}
Equity:Opening-Balances

2018-03-22 * "Convert ETH to EOS"
Assets:Kraken:EOS 90 EOS {0.0122067222 ETH}
Assets:Kraken:ETH -1.098605 ETH {443.62 GBP,2018-03-22}
Equity:Opening-Balances

2018-03-22 * "Send ETH to Binance"
Assets:Binance:ETH 1.02551 ETH {443.62 GBP}
Assets:Crypto:Fees 0.005 ETH
Assets:Kraken:ETH -1.02551 ETH {443.62 GBP,2018-03-22}
Equity:Opening-Balances

2018-03-22 * "Send EOS to Binance"
Assets:Binance:EOS 89.5 EOS {0.0122067222 ETH}
Assets:Crypto:Fees 0.5 EOS
Assets:Kraken:EOS -89.5 EOS {0.0122067222 ETH,2018-03-22}
Equity:Opening-Balances

2018-03-22 * "Convert ETH to XLM"
Assets:Binance:XLM 2324 XLM {0.0004411652 ETH}
Assets:Binance:ETH -1.025268 ETH {443.62 GBP,2018-03-22}
Equity:Opening-Balances

There's always a rest that I must put on Opening-Balances.
Whenever I transfer or convert a crypto I try to track which lot I'm talking about.

The problem I have now is that I have lots of different types of EOS holding for example. Each one with a different 'Cost Currency'.
So what I'm trying to do is to convert all Cost Currencies to GBP (by simulating a sell and a buy from GBP).

Eg:
Assets:Coinbase:EOS -89.1 EOS {0.0122067222 ETH,2018-03-31}
Assets:Coinbase:EOS 89.1 EOS {4.65 GBP}
Assets:Coinbase:EOS -151.784400 EOS {0.0150213065 ETH,2020-01-06}
Assets:Coinbase:EOS 151.784400 EOS {5 GBP}
Assets:Coinbase:EOS -23.907400 EOS {0.0158946602 ETH,2020-01-06}
Assets:Coinbase:EOS 23.907400 EOS {5 GBP}

The only thing I think is being missed in the documentation is a big beancount file with lots of examples. I know that there are some sparse examples in the google docs, but having a big ledger file with every day examples and all well commented would be very useful to understand how people should do day to day transactions.

Maybe a new documentation section on the best patterns to deal with crypto?

Thanks

Martin Blais

unread,
Mar 29, 2020, 2:43:05 PM3/29/20
to Beancount
This is incorrect
see in attachment my comments and output of bean-query <file> print
Basically, your usage of an automated posting everywhere makes you think it works but it does, it just absorbs all the errors.


To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/41a5fece-c99b-4341-a95c-e350730f1661%40googlegroups.com.
makdisse2.beancount
makdisse2.print

Makdisse

unread,
Mar 31, 2020, 2:49:49 PM3/31/20
to Beancount
Thanks for that Martin.
The reason why I was using Equity:Opening-Balances at the end of everything is because:
1) Something simply won't balance out - for example, I'm getting the error `Transaction does not balance: (-0.00000020 GBP)` and I'm unable to get rid of it
2) Sometimes the checking account where the money came from is real old and I'm not really interested in the balance of that account. So I use the opening-balances to get the money to start so that I can track what matters for me, which are the crypto holdings I have

Are there better work around for the above 2 issues where I don't need to resort to using the opening-balances to absorb persistent rests or create money (about which I don't care) to track something I want.

Thanks

Martin Blais

unread,
Mar 31, 2020, 4:49:56 PM3/31/20
to Beancount
On Tue, Mar 31, 2020 at 2:49 PM Makdisse <makd...@gmail.com> wrote:
Thanks for that Martin.
The reason why I was using Equity:Opening-Balances at the end of everything is because:
1) Something simply won't balance out - for example, I'm getting the error `Transaction does not balance: (-0.00000020 GBP)` and I'm unable to get rid of it

Set the tolerance explicitly using infer_tolerance_default for GBP.
That should fix that one.

 
2) Sometimes the checking account where the money came from is real old and I'm not really interested in the balance of that account. So I use the opening-balances to get the money to start so that I can track what matters for me, which are the crypto holdings I have

That's the legitimate use for opening balances.
The problem is that if you use it as an auto-posting (i.e., without an amount), it also absorbs errors.
I would use a specific amount on that opening balances leg if I were you, at least for now.

 
Are there better work around for the above 2 issues where I don't need to resort to using the opening-balances to absorb persistent rests or create money (about which I don't care) to track something I want.

Understand currency groups. This is at the start of the booking process. 
- First, each of the postings is categorized in a particular currency group based on its cost / price or just the units (if no cost / price).
- For each currency group, for each posting, it then tries to match positions based on the inventory (content) of each account.
- Finally, it attempts to fill in and infer missing amounts automatically (interpolation) within the group.

Read this:
and this:

Also realize that what you're going to be doing with crypto is probably at the edge of what this thing has been designed for. If I redesigned it with crypto in mind I would make a different set of compromises and choices.

Have to run

To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/adb67cf0-c5b6-4b32-a64c-f6f4fa419be4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages