6
6
@using CryptoStatsSource .model
7
7
@inject Microsoft .AspNetCore .Components .NavigationManager NavigationManager
8
8
@inject IMatDialogService MatDialogService
9
+ @inject IMatToaster Toaster
9
10
@inject IPortfolioService PortfolioService
10
11
@inject IPortfolioEntryService PortfolioEntryService
11
12
@inject IMarketOrderService MarketOrderService
71
72
</div >
72
73
73
74
<MatBody2 class =" demo-mat-card-content clear-margin" >
74
- < div class = " mat-layout-grid " >
75
- < div class = " mat-layout-grid-inner " style = " align-items : center " >
76
- @if ( entrySummary != null )
77
- {
78
- <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6 " >
79
- <MatH4 Class = " clear-margin " > @( CurrencyUtils .Format (entrySummary .MarketValue , ActivePortfolio .Currency )) </ MatH4 >
75
+ @if ( EntrySummary != null )
76
+ {
77
+ < div class = " mat-layout-grid " >
78
+ < div class = " mat-layout-grid-inner " style = " align-items : center " >
79
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-4 " >
80
+ <LabelDecimalValue Value = " @(CurrencyUtils.Format(EntrySummary .MarketValue, ActivePortfolio.Currency))" Label = " Market Value " ></ LabelDecimalValue >
80
81
</div >
81
- <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6 " style = " text-align : end " >
82
- @( entrySummary . RelativeChange * 100 m ) %
82
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-4 " >
83
+ < LabelDecimalValue Value = " @(DecimalUtils.FormatTrimZeros(TotalHoldings)) " Label = " Holdings " ></ LabelDecimalValue >
83
84
</div >
84
- }
85
- else
86
- {
87
- <MatProgressCircle Indeterminate =" true" />
88
- }
85
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-4" style =" text-align : end " >
86
+ <LabelDecimalValue Positive =" @(EntrySummary.AbsoluteChange >= 0)" ValueColorBasedOnValue =" true" Value =" @(CurrencyUtils.FormatWithPlusSign(EntrySummary.AbsoluteChange, ActivePortfolio.Currency))" Label =" Profit/Loss" ></LabelDecimalValue >
87
+ </div >
88
+ </div >
89
89
</div >
90
- </div >
90
+ <div class =" mat-layout-grid" >
91
+ <div class =" mat-layout-grid-inner" style =" align-items : center " >
92
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-4" >
93
+ <LabelDecimalValue Value =" @(CurrencyUtils.Format(EntrySummary.Cost, ActivePortfolio.Currency))" Label =" Net Cost" ></LabelDecimalValue >
94
+ </div >
95
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-4" >
96
+ <LabelDecimalValue Value =" @(CurrencyUtils.Format(TotalHoldings > 0 ? (EntrySummary.Cost / TotalHoldings) : 0, ActivePortfolio.Currency))" Label =" Avg Net Cost" ></LabelDecimalValue >
97
+ </div >
98
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-4" style =" text-align : end " >
99
+ <LabelDecimalValue Positive =" @(EntrySummary.RelativeChange >= 0)" ValueColorBasedOnValue =" true" Value =" @(DecimalUtils.FormatTwoDecimalPlacesWithPlusSign(EntrySummary.RelativeChange * 100) + " % " )" Label =" Percent Change" ></LabelDecimalValue >
100
+ </div >
101
+ </div >
102
+ </div >
103
+ }
104
+ else
105
+ {
106
+ <MatProgressCircle Indeterminate =" true" />
107
+ }
108
+
91
109
</MatBody2 >
92
110
}
93
111
else
125
143
</td >
126
144
<td >@CurrencyUtils.Format(context.Item2.MarketValue , ActivePortfolio .Currency )</td >
127
145
<td style =' color : @(context.Item2.RelativeChange >= 0 ? " #17a104" : " #FF0000" )' >
128
- <div style =" min-width : 9rem " >@CurrencyUtils.Format(context.Item2.AbsoluteChange , ActivePortfolio .Currency ) (@(context .Item2 .RelativeChange * 100 )% )</div >
146
+ <div style =" min-width : 9rem " >@CurrencyUtils.Format(context.Item2.AbsoluteChange , ActivePortfolio .Currency ) (@(DecimalUtils . FormatTwoDecimalPlaces ( context .Item2 .RelativeChange * 100 ) )% )</div >
129
147
</td >
130
148
<td >@CurrencyUtils.Format(context.Item2.Cost , ActivePortfolio .Currency )</td >
131
149
<td >@CurrencyUtils.Format(context.Item1.Fee , ActivePortfolio .Currency )</td >
152
170
protected PortfolioEntry ActivePortfolioEntry ;
153
171
protected MarketEntry CurrentEntryAssetMarketEntry ;
154
172
protected string portfolioEntryName = " Bitcoin" ;
155
- protected ISummaryService .Summary entrySummary = new (523 m , 0 . 719 m , 1268 . 89 m , 745 . 58 m );
173
+ protected ISummaryService .Summary EntrySummary = new (523 m , 0 . 719 m , 1268 . 89 m , 745 . 58 m );
174
+ protected decimal TotalHoldings = 0 ;
156
175
157
176
protected List <Tuple <MarketOrder, ISummaryService.Summary >> tableRowsItems = new ()
158
177
{
184
203
{
185
204
CurrentEntryAssetMarketEntry = null ;
186
205
tableRowsItems = null ;
187
- entrySummary = null ;
206
+ EntrySummary = null ;
188
207
StateHasChanged ();
189
208
}
190
209
205
224
var entrySummaries = entryOrders .Select (order =>
206
225
SummaryService .GetMarketOrderSummary (order , CurrentEntryAssetMarketEntry .CurrentPrice ));
207
226
227
+ TotalHoldings = entryOrders .Sum (order => order .Size * (order .Buy ? 1 : - 1 ));
228
+
208
229
// zip entry orders and summaries into a table rows
209
230
tableRowsItems = entryOrders .Zip (entrySummaries )
210
231
.Select (tuple => new Tuple <MarketOrder , ISummaryService .Summary >(tuple .First , tuple .Second )).ToList ();
211
232
212
233
// compute suummary of this entry
213
- entrySummary = SummaryService .GetPortfolioEntrySummary (entryOrders , CurrentEntryAssetMarketEntry .CurrentPrice );
234
+ EntrySummary = SummaryService .GetPortfolioEntrySummary (entryOrders , CurrentEntryAssetMarketEntry .CurrentPrice );
214
235
}
215
236
216
237
public void EditMarketOrder (MouseEventArgs e )
227
248
SetEntryLoading ();
228
249
await UpdateEntrySummary ();
229
250
StateHasChanged ();
251
+ Toaster .Add (" Order successfully deleted" , MatToastType .Success , " " , " " );
230
252
}
231
253
}
232
254
}
0 commit comments