diff --git a/pkg/types/position.go b/pkg/types/position.go index d94ea6ad5e..83026b6552 100644 --- a/pkg/types/position.go +++ b/pkg/types/position.go @@ -574,6 +574,7 @@ func (p *Position) AddTrades(trades []Trade) (fixedpoint.Value, fixedpoint.Value } func (p *Position) calculateFeeInQuote(td Trade) fixedpoint.Value { + // assume the fee is not charged either in base currency or quote currency var quoteQuantity = td.QuoteQuantity if cost, ok := p.FeeAverageCosts[td.FeeCurrency]; ok { @@ -758,3 +759,12 @@ func (p *Position) updateMetrics() { positionBaseQuantityMetrics.With(labels).Set(p.Base.Float64()) positionQuoteQuantityMetrics.With(labels).Set(p.Quote.Float64()) } + +func (p *Position) UpdateQuteUsdPrice(kline KLine) { + // assume the symbol of the kline is the quote to USD price (ex: USDTUSD) + p.Lock() + defer p.Unlock() + + cost := fixedpoint.One.Div(kline.Close) + p.FeeAverageCosts["USD"] = cost +}