Get market price indirectly (convert via intermediary commodity)

76 views
Skip to first unread message

Peter

unread,
Dec 26, 2020, 5:53:39 AM12/26/20
to Beancount
Hi all,

is it possible to convert a lot/commodity to the current market value of my base currency using an intermediary currency?

Use case:
I fetch prices for cryptocurrencies from binance. My base currency is EUR. Binance supports EUR quotes only for a few big cryptos. Most other cryptos have USDT (Tether, a stable coin representing a fixed value of 1 USD) quotes.

Is it possible to use that to convert a crypto to EUR, like: CoinXY is currently 10 USDT; 1 USD(T) is currently 0.75 EUR; therefore CoinXY is 0.75 EUR? 

E.g:

2020-12-01 * "" "Opening"
Equity:Opening-Balances     -0.1 MKR {441 EUR} @ 441 EUR
Assets:Crypto:MKR:Coinbase   0.1 MKR {441 EUR} @ 441 EUR

2017-01-01 price USDT    1.0 USD
2020-12-25 price MKR  528.64 USDT
2020-12-25 price USD     0.82 EUR
2020-12-25 price USDT    0.82 EUR

Is there a way to convert the 0.1 MKR to EUR by calculating 0.1 MKR * 0.82 USDT using bean-query?

Regards

Patrick Ruckstuhl

unread,
Dec 26, 2020, 11:03:18 AM12/26/20
to Peter, Beancount
Hi,

I created a plugin that should help you there. It calculates the missing cross rates to your base rate

https://github.com/tarioch/beancounttools

Kirill Goncharov

unread,
Dec 26, 2020, 11:16:40 AM12/26/20
to Beancount
In BQL it is possible to apply CONVERT multiple times, for example:

SELECT CONVERT(CONVERT(position, 'USDT'), 'EUR')

You can also take a look at CoinGecko price source from https://github.com/xuhcc/beancount-cryptoassets that can fetch price in EUR:

$ bean-price --no-cache -e 'EUR:beancount_cryptoassets.coingecko/MKR:EUR'
2020-12-26 price MKR:EUR                            436.94 EUR

Reply all
Reply to author
Forward
0 new messages