Skip to content

Commit

Permalink
fix: scaled_navs now only considers last 10 most recent ratios
Browse files Browse the repository at this point in the history
VINIX vs VOO is an example of how related MF/ETFs diverge in NAV across
time, because of the difference in how each pays out dividends and
capital gains. Thus, recent prices are the most relevant ones
  • Loading branch information
redstreet committed Nov 26, 2024
1 parent 4720e50 commit 66eafa0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fava_investor/util/experimental/scaled_navs.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ def estimate_mf_navs(self):
etf_price = etf_prices[0].amount.number
ratio = mf_price / etf_price
# print(" ", p.date, mf_price, etf_price, ratio)
ratios.append(ratio)
ratios.append((p.date, ratio))
if ratios:
if etf in self.latest_prices:
# consider only the most recent 10 values, because some ETFs and MFs that are
# not share classes of each other can diverge due to how they pay dividends and
# capgain distributions (eg: VINIX vs VOO)
ratios.sort(key=lambda x: x[0])
ratios = ratios[-10:]
ratios = [i[1] for i in ratios]
median_ratio = statistics.median(ratios)
scaled_number = round(self.latest_prices[etf].number * median_ratio, 2)
scaled_mf[mf] = (etf, median_ratio, Amount(scaled_number, self.latest_prices[etf].currency))
Expand Down

0 comments on commit 66eafa0

Please sign in to comment.