show net profit margin percentage

This commit is contained in:
c9s 2021-05-23 01:17:20 +08:00
parent de768296f1
commit 117b26840e

View File

@ -546,18 +546,20 @@ func (s *Strategy) handleTradeUpdate(trade types.Trade) {
} }
profitMargin := profit.DivFloat64(trade.QuoteQuantity) profitMargin := profit.DivFloat64(trade.QuoteQuantity)
netProfitMargin := netProfit.DivFloat64(trade.QuoteQuantity)
var since time.Time var since time.Time
if s.state.AccumulatedSince > 0 { if s.state.AccumulatedSince > 0 {
since = time.Unix(s.state.AccumulatedSince, 0).In(localTimeZone) since = time.Unix(s.state.AccumulatedSince, 0).In(localTimeZone)
} }
s.Notify("%s trade profit %s %f %s (%.3f%%), net profit =~ %f %s, since %s accumulated net profit %f %s, accumulated loss %f %s", s.Notify("%s trade profit %s %f %s (%.2f%%), net profit =~ %f %s (%.2f%%), since %s accumulated net profit %f %s, accumulated loss %f %s",
s.Symbol, s.Symbol,
pnlEmoji(profit), pnlEmoji(profit),
profit.Float64(), s.state.Position.QuoteCurrency, profit.Float64(), s.state.Position.QuoteCurrency,
profitMargin.Float64()*100.0, profitMargin.Float64()*100.0,
netProfit.Float64(), s.state.Position.QuoteCurrency, netProfit.Float64(), s.state.Position.QuoteCurrency,
netProfitMargin.Float64()*100.0,
since.Format(time.RFC822), since.Format(time.RFC822),
s.state.AccumulatedPnL.Float64(), s.state.Position.QuoteCurrency, s.state.AccumulatedPnL.Float64(), s.state.Position.QuoteCurrency,
s.state.AccumulatedLoss.Float64(), s.state.Position.QuoteCurrency) s.state.AccumulatedLoss.Float64(), s.state.Position.QuoteCurrency)