Skip to content

Commit

Permalink
fix: assetalloc_class fail due to favapricemap vs beancount pricemap (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aldur authored Apr 24, 2024
1 parent 036ed0f commit c202048
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fava_investor/modules/assetalloc_class/libassetalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def ancestors(s):


def bucketize(vbalance, accapi):
price_map = accapi.build_price_map()
f_price_map = accapi.build_price_map()
b_price_map = accapi.build_beancount_price_map()
commodities = accapi.get_commodity_directives()
operating_currencies = accapi.get_operating_currencies()
base_currency = operating_currencies[0]
Expand All @@ -102,13 +103,13 @@ def bucketize(vbalance, accapi):

# what we want is the conversion to be done on the end date, or on a date
# closest to it, either earlier or later. convert_position does this via bisect
amount = accapi.convert_position(pos, base_currency, price_map, date=end_date)
amount = accapi.convert_position(pos, base_currency, f_price_map, date=end_date)
if amount.currency == pos.units.currency and amount.currency != base_currency:
# Ideally, we would automatically figure out the currency to hop via, based on the cost
# currency of the position. However, with vbalance, cost currency info is not
# available. Hence, we hop via any available operating currency specified by the user.
# This is for supporting multi-currency portfolios
amount = convert.convert_amount(pos.units, base_currency, price_map,
amount = convert.convert_amount(pos.units, base_currency, b_price_map,
via=operating_currencies, date=end_date)
if amount.currency != base_currency:
sys.stderr.write("Error: unable to convert {} to base currency {}"
Expand Down

0 comments on commit c202048

Please sign in to comment.