Skip to content

Commit

Permalink
show today's portfolio change
Browse files Browse the repository at this point in the history
  • Loading branch information
rrelyea committed Jun 21, 2023
1 parent a4a574d commit e15a893
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Pages/Portfolio.razor
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Portfolio@(stepPath==null?": review":": "+stepPath.Replace('-',' ')) - bogle.too
case "retirement-assets":
<td>
@((MarkupString)bold("Portfolio Size:"))&nbsp;@(formatMoney(familyData.Value))<br/>
&nbsp;&nbsp;<span title='Change: @formatMoney(portfolioChange())'>.</span><br/>
&nbsp;&nbsp;<span>Change: @formatMoney(portfolioChange())</span><br/>
<br/>
@if (familyData.Accounts.Count > 0) {

Expand Down Expand Up @@ -1228,12 +1228,12 @@ Portfolio@(stepPath==null?": review":": "+stepPath.Replace('-',' ')) - bogle.too

private double? portfolioChange()
{
double change = 0.0;
double? change = 0.0;
foreach (var investment in familyData.GroupedInvestments)
{
if (investment.PercentChange != null)
{
change += (investment.Price ?? 0.0 - investment.PreviousClose ?? 0.0) * investment.Shares ?? 0.0;
change += (investment.Price - investment.PreviousClose) * investment.Shares;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Shared/Models/FamilyData/FamilyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public List<Investment> GroupedInvestments {
Investment? matchingInvestment;
if (!_GroupedInvestments.ContainsKey(key))
{
matchingInvestment = new Investment() { Name = investment.Name, Ticker = investment.Ticker, PercentChange = investment.PercentChange, LastUpdated = investment.LastUpdated, Shares = 0.0, Price = investment.Price, Value = 0.0 };
matchingInvestment = new Investment() { Name = investment.Name, Ticker = investment.Ticker, PercentChange = investment.PercentChange, LastUpdated = investment.LastUpdated, Shares = 0.0, Price = investment.Price, PreviousClose = investment.PreviousClose, Value = 0.0 };
_GroupedInvestments.Add(key, matchingInvestment);
}
else
Expand Down

0 comments on commit e15a893

Please sign in to comment.