Newbie Question (Virtual Posting)

61 views
Skip to first unread message

Charles Lindsay

unread,
Jul 1, 2020, 1:31:41 PM7/1/20
to Ledger

Basically I want to insert a virtual transaction of a different commodity price based on the price of the commodity in the pricedb.

I need help converting the currency in the virtual posting.

Given the following ledger:

=====================================================================

P 2020/06/29 BTC 7497.15 GBP

 = expr 'account =~ /Accounts:Client/'

  (Btc:Stock)  -(??? Need Help Here??? BTC)

2020-06-30  *  (4284af3d-dc3d-4b83-a3c0-f87f013f06f3) 03378c0c

  ; :Credit:Payments:

  Accounts:Client:9cc2fdda06e04c29a40071  35.00 GBP

  Accounts:External:bfc20917a2bd4ca18fb259

=====================================================================

I want the rules to save the 35.00 GBP in BTC as calculated from the pricesdb, i.e. -(35.00 GBP / 7497.15 GBP) or -0.004668440674122833 BTC

Any help is appreciated.

d10

unread,
Jul 5, 2020, 11:03:57 AM7/5/20
to Ledger
Maybe take a look at `lotter` (https://src.d10.dev/lotter).  While it does not do exactly what you're asking for, it does something close.  Maybe you could modify it to suit your needs.

Lotter supports a "base" operation, which observes price data, and will convert values from other currencies into the base currency.  But it does this only when a cost is expressed in a non-base currency, and a price converting that currency to the base is known on the same day.

In your example, the transaction involves only GBP, and there's nothing about it that hints BTC is involved in any way.  For this reason, I think you'll have to modify your ledger file in some way to get accounting for the BTC.  You might need to explicity add a split with an amount like "35.00 GBP @@ 0.00466844 BTC".

Charles Lindsay

unread,
Jul 5, 2020, 3:46:16 PM7/5/20
to Ledger
Thanks for the response.  Maybe I should have made it more clear that the first line in my ledger was for the pricesdb which would give ledger the daily conversion rate for BTC-GBP, which from what I read should be enough.

=====================================================================

P 2020/06/29 BTC 7497.15 GBP

=====================================================================  

I feel like ledger was made to do this, just not clear on how to make it do it as a virtual posting.
Reply all
Reply to author
Forward
0 new messages