bean-price: how to do unrealized gains?

83 views
Skip to first unread message

nug get

unread,
Nov 19, 2019, 4:59:58 PM11/19/19
to Beancount
Dear all,
I am in a (long...) process of setting up my new beancount ledger, based on 2 years of gnucash accounting history.
Finally, I want to integrate my VTI holdings to my ledger, and I could not so far figure out how I use bean-price to get current market prices and according net worth (or come up with an unrealized PnL):


;; -*- mode: org; mode: beancount; coding: utf-8; fill-column: 400; -*-
option "operating_currency" "USD"
plugin "beancount.plugins.unrealized" "PnL"

; initiate VTI (=Fund) commodity
1970-01-01 commodity VTI
    name"VTI"
    price"USD:yahoo/VTI"

; open USD, VTI & PnL Accounts
1970-01-01 open Assets:VTI  VTI
1970-01-01 open Assets:VTI:PnL  USD
1970-01-01 open Assets:Cash  USD

; open the money press
1970-01-01 open Equity:Opening-Balance:USD  USD

; give me some toy-money
2018-12-31 pad Assets:Cash Equity:Opening-Balance:USD 
2019-01-01 balance Assets:Cash               10000.00 USD 

;Some VTI we bough a while ago
2019-07-11 * "Buying some VTI for test purpose"
  Assets:VTI               10 VTI {           152.83 USD}
  Assets:Cash   

; now, what's my current net worth? I.E. what's my PnL?

>bean-price test.beancount -v
INFO    : Using price cache at "/tmp/bean-price.cache" (with indefinite expiration)
INFO    : Processing at date: 2019-11-19
INFO    : Loading "test.beancount"
<unrealized_gains>:0:       A valid price for VTI/USD could not be found

2019-11-19 price VTI                                158.69 USD


How can I get the current price of VTI into beancount/ my fava statements? How to get a PnL based on the current price? Thanks alot!

Justus Pendleton

unread,
Nov 20, 2019, 9:26:36 AM11/20/19
to Beancount
On Wednesday, November 20, 2019 at 4:59:58 AM UTC+7, nug get wrote:
I could not so far figure out how I use bean-price to get current market prices

The screenshot you have shows you getting the current market prices. bean-price fetches the current market prices. It prints them to stdout. You need to them add them to your bean file somehow. Copy & paste or shell redirection, for instance.

and according net worth

Then, after you've added the price statements to your fie, you'd run bean-report test.beancount networth .
Reply all
Reply to author
Forward
Message has been deleted
0 new messages