Skip to content

Commit 94ad8a5

Browse files
committed
gross loss and gross profit
1 parent 278a9e9 commit 94ad8a5

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

pkg/types/profit.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,17 @@ type ProfitStats struct {
205205
BaseCurrency string `json:"baseCurrency"`
206206

207207
AccumulatedPnL fixedpoint.Value `json:"accumulatedPnL,omitempty"`
208-
AccumulatedNetProfit fixedpoint.Value `json:"accumulatedNetProfit,omitempty"`
209-
AccumulatedProfit fixedpoint.Value `json:"accumulatedProfit,omitempty"`
210-
AccumulatedLoss fixedpoint.Value `json:"accumulatedLoss,omitempty"`
211-
AccumulatedVolume fixedpoint.Value `json:"accumulatedVolume,omitempty"`
208+
AccumulatedNetProfit fixedpoint.Value `json:"accumulatedNetProfit,omitempty"`
209+
AccumulatedGrossProfit fixedpoint.Value `json:"accumulatedProfit,omitempty"`
210+
AccumulatedGrossLoss fixedpoint.Value `json:"accumulatedLoss,omitempty"`
211+
AccumulatedVolume fixedpoint.Value `json:"accumulatedVolume,omitempty"`
212212
AccumulatedSince int64 `json:"accumulatedSince,omitempty"`
213213

214214
TodayPnL fixedpoint.Value `json:"todayPnL,omitempty"`
215-
TodayNetProfit fixedpoint.Value `json:"todayNetProfit,omitempty"`
216-
TodayProfit fixedpoint.Value `json:"todayProfit,omitempty"`
217-
TodayLoss fixedpoint.Value `json:"todayLoss,omitempty"`
218-
TodaySince int64 `json:"todaySince,omitempty"`
215+
TodayNetProfit fixedpoint.Value `json:"todayNetProfit,omitempty"`
216+
TodayGrossProfit fixedpoint.Value `json:"todayProfit,omitempty"`
217+
TodayGrossLoss fixedpoint.Value `json:"todayLoss,omitempty"`
218+
TodaySince int64 `json:"todaySince,omitempty"`
219219
}
220220

221221
func NewProfitStats(market Market) *ProfitStats {
@@ -244,11 +244,11 @@ func (s *ProfitStats) AddProfit(profit Profit) {
244244
s.TodayNetProfit = s.TodayNetProfit.Add(profit.NetProfit)
245245

246246
if profit.Profit.Sign() < 0 {
247-
s.AccumulatedLoss = s.AccumulatedLoss.Add(profit.Profit)
248-
s.TodayLoss = s.TodayLoss.Add(profit.Profit)
247+
s.AccumulatedGrossLoss = s.AccumulatedGrossLoss.Add(profit.Profit)
248+
s.TodayGrossLoss = s.TodayGrossLoss.Add(profit.Profit)
249249
} else if profit.Profit.Sign() > 0 {
250-
s.AccumulatedProfit = s.AccumulatedLoss.Add(profit.Profit)
251-
s.TodayProfit = s.TodayProfit.Add(profit.Profit)
250+
s.AccumulatedGrossProfit = s.AccumulatedGrossLoss.Add(profit.Profit)
251+
s.TodayGrossProfit = s.TodayGrossProfit.Add(profit.Profit)
252252
}
253253
}
254254

@@ -267,8 +267,8 @@ func (s *ProfitStats) IsOver24Hours() bool {
267267
func (s *ProfitStats) ResetToday() {
268268
s.TodayPnL = fixedpoint.Zero
269269
s.TodayNetProfit = fixedpoint.Zero
270-
s.TodayProfit = fixedpoint.Zero
271-
s.TodayLoss = fixedpoint.Zero
270+
s.TodayGrossProfit = fixedpoint.Zero
271+
s.TodayGrossLoss = fixedpoint.Zero
272272

273273
var beginningOfTheDay = util.BeginningOfTheDay(time.Now().Local())
274274
s.TodaySince = beginningOfTheDay.Unix()
@@ -288,10 +288,10 @@ func (s *ProfitStats) PlainText() string {
288288
s.Symbol,
289289
s.TodayPnL.String(), s.QuoteCurrency,
290290
s.TodayNetProfit.String(), s.QuoteCurrency,
291-
s.TodayLoss.String(), s.QuoteCurrency,
291+
s.TodayGrossLoss.String(), s.QuoteCurrency,
292292
s.AccumulatedPnL.String(), s.QuoteCurrency,
293293
s.AccumulatedNetProfit.String(), s.QuoteCurrency,
294-
s.AccumulatedLoss.String(), s.QuoteCurrency,
294+
s.AccumulatedGrossLoss.String(), s.QuoteCurrency,
295295
since.Format(time.RFC822),
296296
)
297297
}
@@ -313,10 +313,10 @@ func (s *ProfitStats) SlackAttachment() slack.Attachment {
313313
})
314314
}
315315

316-
if !s.TodayProfit.IsZero() {
316+
if !s.TodayGrossProfit.IsZero() {
317317
fields = append(fields, slack.AttachmentField{
318318
Title: "Profit Today",
319-
Value: pnlSignString(s.TodayProfit) + " " + s.QuoteCurrency,
319+
Value: pnlSignString(s.TodayGrossProfit) + " " + s.QuoteCurrency,
320320
Short: true,
321321
})
322322
}
@@ -329,10 +329,10 @@ func (s *ProfitStats) SlackAttachment() slack.Attachment {
329329
})
330330
}
331331

332-
if !s.TodayLoss.IsZero() {
332+
if !s.TodayGrossLoss.IsZero() {
333333
fields = append(fields, slack.AttachmentField{
334334
Title: "Loss Today",
335-
Value: pnlSignString(s.TodayLoss) + " " + s.QuoteCurrency,
335+
Value: pnlSignString(s.TodayGrossLoss) + " " + s.QuoteCurrency,
336336
Short: true,
337337
})
338338
}
@@ -344,10 +344,10 @@ func (s *ProfitStats) SlackAttachment() slack.Attachment {
344344
})
345345
}
346346

347-
if !s.AccumulatedProfit.IsZero() {
347+
if !s.AccumulatedGrossProfit.IsZero() {
348348
fields = append(fields, slack.AttachmentField{
349349
Title: "Accumulated Profit",
350-
Value: pnlSignString(s.AccumulatedProfit) + " " + s.QuoteCurrency,
350+
Value: pnlSignString(s.AccumulatedGrossProfit) + " " + s.QuoteCurrency,
351351
})
352352
}
353353

@@ -358,10 +358,10 @@ func (s *ProfitStats) SlackAttachment() slack.Attachment {
358358
})
359359
}
360360

361-
if !s.AccumulatedLoss.IsZero() {
361+
if !s.AccumulatedGrossLoss.IsZero() {
362362
fields = append(fields, slack.AttachmentField{
363363
Title: "Accumulated Loss",
364-
Value: pnlSignString(s.AccumulatedLoss) + " " + s.QuoteCurrency,
364+
Value: pnlSignString(s.AccumulatedGrossLoss) + " " + s.QuoteCurrency,
365365
})
366366
}
367367

0 commit comments

Comments
 (0)