Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commodity Definition for base currency confuses compute_returns.py #10

Open
cerebore opened this issue Jun 14, 2021 · 1 comment
Open

Comments

@cerebore
Copy link

In my beancount file I have this;

1999-12-31 commodity USD
  export: "CASH"
  name: "United States Dollar"

It causes configure.py to produce

  investment {
    currency: "USD"
    asset_account: "Assets:Coinbase:USD"
    cash_accounts: "Assets::Checking"
  }

This in turn confuses compute returns.py during generate_price_pages because it causes a CurrencyPair to exist ('USD', 'USD'):

$ beangrow/beangrow/compute_returns.py xxxxx.beancount config beangrow_output

Traceback (most recent call last):
  File "beangrow/beangrow/compute_returns.py", line 105, in <module>
    main()
  File "beangrow/beangrow/compute_returns.py", line 94, in main
    reports.generate_price_pages(account_data_map,
  File "xxxxx/beangrow/beangrow/reports.py", line 529, in generate_price_pages
    all_prices = prices.get_all_prices(price_map, base_quote)
  File "/usr/local/lib/python3.8/dist-packages/beancount/core/prices.py", line 197, in get_all_prices
    return _lookup_price_and_inverse(price_map, base_quote)
  File "/usr/local/lib/python3.8/dist-packages/beancount/core/prices.py", line 172, in _lookup_price_and_inverse
    return price_map[base_quote]
KeyError: ('USD', 'USD')
@gety9
Copy link

gety9 commented Sep 13, 2021

config file produced by configure.py is "suggested" based on your beancount file, but it does not mean it's final and you can and often should adjust it.

in your case (since Coinbase is investment account as i can tell) you have 2 options:

  1. remove currency declaration from Assets:Coinbase:USD making it
investment {
    asset_account: "Assets:Coinbase:USD"
    cash_accounts: "Assets::Checking"
  }

(currency is optional parameter https://github.com/beancount/beangrow/blob/master/beangrow/config.proto)

  1. create different commodity USDCOIN and make it
  investment {
    currency: "USDCOIN"
    asset_account: "Assets:Coinbase:USDCOIN"
    cash_accounts: "Assets::Checking"
  }

As a side note i had similar issue, but in my case account wasn't meant for investment purposes at all: i had Assets:Investments:SQ (SQ commodity) and Assets:Business:CompanyName:SQ (Square account for my business) and that account was wrongly picked up by configure.py, renaming it to Assets:Business:CoName:Square solved the configure.py' confusion.

Basically any account ending with declared commodity code will be picked up by configure.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants