andreasgerstmayr / fava-dashboards

Custom Dashboards for Beancount in Fava
MIT License
169 stars 19 forks source link

feat: make accounts avaiable in ledger variable #31

Closed fengkx closed 7 months ago

fengkx commented 7 months ago

It is useful to be able to access account meta.

For example in the asset classess, I have an account like this:

2023-02-06 open Assets:Funds CNY
    asset_class: "Funds"

2023-02-05 commodity CNY
    asset_class: "Cash"

It is OTC Funds pricing in CNY, though CNY commodity is Cash the Funds should not classify as Cash.

andreasgerstmayr commented 7 months ago

I'm not sure if I follow, shouldn't the fund be declared as a new commodity?

From the docs: https://beancount.github.io/docs/trading_with_beancount.html The IBM stock is traded in USD, but it has its own commodity in beancount.

fengkx commented 7 months ago

You are correct for stock trading. But for some cases I don't care about the price of a fund but only ammount.

For example: Suppose I invest $100 in a certain fund every week. I invest based on the amount, but I don't care about how many units I have obtained and the net value given after the market closes that day.

There are some funds called OTC(Over-the-counter ) funds, which generally trade through distribution agencies and direct sales platforms of fund companies instead of stock exchanges. Usually, it calculates the net asset value of the fund based on the closing price of each trading day. In China, daily and total profit and loss amounts are generally displayed on bank pages, with less attention paid to unit prices. And compared to on-exchange trading of ETF, it is more difficult for us to obtain prices through API(bean-price).

andreasgerstmayr commented 7 months ago

I think the same applies for ETFs/funds as well (new commodity per fund). I agree that the unit price is not really interesting in the case of e.g. an ETF, but imho it's required to accurately track the increase/decrease of the fund over time. I also had the case once that the fund price was not easy to obtain, so I ended up parsing the PDF of my bank 😬.

In any case, I'm not opposed to this change, so I'll merge it. Thanks!

fengkx commented 7 months ago

Thanks, For now I just pad those accounts periodically. :) It is too difficult to calculate the units when I buying it. Not perfect but enough fo me.