Skip to content

Commit

Permalink
mark holdings with no expense ratio or costbasis (when important) wit…
Browse files Browse the repository at this point in the history
…h red # or ~. Fixes #286, #285, #281.
  • Loading branch information
rrelyea committed Jan 29, 2024
1 parent fc87779 commit 3894bdf
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 36 deletions.
10 changes: 10 additions & 0 deletions Pages/AccountView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@
@(investment.Ticker != null ? investment.Ticker : investment.Name)
@if (investment.IsAssetTypeUnknown) { <span style=color:red>*</span> }
@if (investment.IsBalancedFund && !investment.DoesBalancedFundEqual100) { <span style=color:red>^</span> }
@if (account.TaxType == "Taxable" && investment.MissingCostBasis && !investment.IsCash) { <span style=color:red>~</span> }
@if ((investment.IsFund || investment.IsETF) && investment.ExpenseRatio == null) { <span style=color:red>#</span> }
@if (investment.IsIBond) {
<span>&nbsp;</span>@FormatUtilities.formatMonthPlus2DigitYear(investment.PurchaseDate)
}
Expand Down Expand Up @@ -389,6 +391,14 @@
<span><span style=color:red>^</span> - Stock and Bond fund components don't total 100%. Please edit.</span><br/><br/>
}

if (account.TaxType == "Taxable" && investment.MissingCostBasis && !investment.IsCash) {
<span><span style=color:red>~</span> - Missing CostBasis. Please edit.</span><br/><br/>
}

if ((investment.IsFund || investment.IsETF) && investment.ExpenseRatio == null) {
<span><span style=color:red>#</span> - Missing ExpenseRatio. Please edit.</span><br/><br/>
}

switch (investment.SelectedTransaction?.Type) {
case null:
@((MarkupString)FormatUtilities.Bold("Actions:", ShowMarkup))<br/>
Expand Down
4 changes: 3 additions & 1 deletion Pages/Portfolio.razor
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@
@(investment.Ticker != null ? investment.Ticker : investment.Name)
@if (investment.IsAssetTypeUnknown) { <span style=color:red>*</span> }
@if (investment.IsBalancedFund && !investment.DoesBalancedFundEqual100) { <span style=color:red>^</span> }
@if (account.TaxType == "Taxable" && investment.MissingCostBasis && !investment.IsCash) { <span style=color:red>~</span> }
@if ((investment.IsFund || investment.IsETF) && investment.ExpenseRatio == null) { <span style=color:red>#</span> }
@if (investment.IsIBond) {
<span>&nbsp;</span>@FormatUtilities.formatMonthPlus2DigitYear(investment.PurchaseDate)
}
Expand Down Expand Up @@ -806,7 +808,7 @@
<fieldset>
@((MarkupString)FormatUtilities.Bold("Weighted Expense Ratio: ", ShowMarkup))
<span>&nbsp;@FormatUtilities.formatPercent3(appData.FamilyData.OverallER) or @FormatUtilities.formatMoney(appData.FamilyData.ExpensesTotal) /year</span>
@if (appData.FamilyData.InvestmentsMissingER > 0){<br/><span>&nbsp;(@appData.FamilyData.InvestmentsMissingER investment(s) missing ER)</span><br/>}
@if (appData.FamilyData.InvestmentsMissingER > 0){<br/><span>&nbsp;(@appData.FamilyData.InvestmentsMissingER investment(s) missing ER, select holdings marked with <span style=color:red>#</span> in accounts view)</span><br/>}
</fieldset>
}
}
Expand Down
5 changes: 4 additions & 1 deletion Shared/Models/FamilyData/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ public void UpdatePercentages(double totalValue, FamilyData familyData)
familyData.OverallER += investment.Percentage / 100.0 * investment.ExpenseRatio.Value;
familyData.ExpensesTotal += investment.Value.Value * investment.ExpenseRatio.Value / 100.0;
} else {
familyData.InvestmentsMissingER++;
if (investment.IsETF || investment.IsFund)
{
familyData.InvestmentsMissingER++;
}
}
}
}
Expand Down
80 changes: 47 additions & 33 deletions Shared/Models/FamilyData/Investment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public bool DoesBalancedFundEqual100
}
}

[JsonIgnore]
public bool MissingCostBasis
{
get {
return CostBasis == null;
}
}

public double? GetPercentage(AssetType? assetType) {
if (assetType == null) { return 100.0 / 100.0; }
else {
Expand Down Expand Up @@ -473,44 +481,50 @@ public async Task CalculateIBondValue()
var nowYear = DateTime.Now.Year;
decimal value = CostBasis == null ? 0.0m : (decimal)CostBasis;
decimal bondQuantity = (value / 25.0m);
double currentRate = 0.0;
var monthsLeft = GetTotalMonths(PurchaseDate.Value, DateTime.Now);
var i = rates.Count - 1;
int monthsToCompoundThisRound = 6;
while (monthsLeft > 0)
{
monthsToCompoundThisRound = monthsLeft >= 6 ? 6 : monthsLeft;
currentRate = rates[i];
var price = Math.Round(value/bondQuantity*(decimal)Math.Pow((1.0+currentRate/2.0),((double)monthsToCompoundThisRound/6.0)),2, MidpointRounding.AwayFromZero);
value = bondQuantity * price;
monthsLeft -= monthsToCompoundThisRound;
i--;
}

InterestRate = rates[0];
CurrentRate = monthsToCompoundThisRound != 6 ? currentRate : rates[i];
if (monthsToCompoundThisRound != 6 && i > 0)
if (bondQuantity != 0m)
{
NextRate = rates[i];
var nextMonthStart = nowMonth + 6 - monthsToCompoundThisRound + 1;
var nextYearStart = nowYear;
if (nextMonthStart > 12)
double currentRate = 0.0;
var monthsLeft = GetTotalMonths(PurchaseDate.Value, DateTime.Now);
var i = rates.Count - 1;
int monthsToCompoundThisRound = 6;
while (monthsLeft > 0)
{
monthsToCompoundThisRound = monthsLeft >= 6 ? 6 : monthsLeft;
currentRate = rates[i];
var price = Math.Round(value/bondQuantity*(decimal)Math.Pow((1.0+currentRate/2.0),((double)monthsToCompoundThisRound/6.0)),2, MidpointRounding.AwayFromZero);
value = bondQuantity * price;
monthsLeft -= monthsToCompoundThisRound;
i--;
}

InterestRate = rates[0];
CurrentRate = monthsToCompoundThisRound != 6 ? currentRate : rates[i];
if (monthsToCompoundThisRound != 6 && i > 0)
{
nextMonthStart -= 12;
nextYearStart++;
NextRate = rates[i];
var nextMonthStart = nowMonth + 6 - monthsToCompoundThisRound + 1;
var nextYearStart = nowYear;
if (nextMonthStart > 12)
{
nextMonthStart -= 12;
nextYearStart++;
}
NextRateStart = new DateOnly(nextYearStart, nextMonthStart, 1);
} else {
NextRate = null;
NextRateStart = null;
}

if (PurchaseDate <= DateOnly.FromDateTime(DateTime.Now))
{
ValuePIN = (int)value;
}
else
{
ValuePIN = null;
}
NextRateStart = new DateOnly(nextYearStart, nextMonthStart, 1);
} else {
NextRate = null;
NextRateStart = null;
}

if (PurchaseDate <= DateOnly.FromDateTime(DateTime.Now))
{
ValuePIN = (int)value;
}
else
{
ValuePIN = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion wwwroot/cache.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CACHE MANIFEST

# Version 1.0136
# Version 1.0137

NETWORK:
*

0 comments on commit 3894bdf

Please sign in to comment.