Skip to content

Commit

Permalink
fix: scaled-navs was ignoring date if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
redstreet committed May 5, 2024
1 parent c202048 commit 4720e50
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fava_investor/util/experimental/scaled_navs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ScaledNAV(RelateTickers):
def __init__(self, cf, prices_file, date=None):
self.cf = cf
self.prices_file = prices_file
self.date = date
entries, _, _ = self.load_file(cf)

# basic databases
Expand Down Expand Up @@ -123,9 +124,10 @@ def estimate_mf_navs(self):
unavailable_etfs.add(etf)

if unavailable_etfs:
print("Today's prices for these ETFs were not found:", ", ".join(sorted(unavailable_etfs)))
print(f"Prices for these ETFs on {self.date} were not found:",
", ".join(sorted(unavailable_etfs)))

self.estimated_price_entries = [Price({}, datetime.datetime.today().date(), mf, amt)
self.estimated_price_entries = [Price({}, self.date, mf, amt)
for mf, (_, _, amt) in scaled_mf.items()]

def show_estimates(self):
Expand Down Expand Up @@ -155,7 +157,9 @@ def scaled_navs(cf, pf, date, write_to_prices_file):
\n$BEAN_COMMODITIES_FILE: file with beancount commodities declarations.
\n$BEAN_PRICES_FILE: file with beancount prices declarations.
"""
s = ScaledNAV(cf, pf)
if isinstance(date, str):
date = datetime.datetime.strptime(date, "%Y-%m-%d").date()
s = ScaledNAV(cf, pf, date=date)
s.show_estimates()
if write_to_prices_file:
s.update_prices_file()
Expand Down

0 comments on commit 4720e50

Please sign in to comment.