backtest: fix backtest fee mode when fee currency is not base or quote

This commit is contained in:
c9s 2022-09-05 17:41:12 +08:00
parent 843b81e132
commit bf4eade604
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -284,6 +284,8 @@ func (m *SimplePriceMatching) executeTrade(trade types.Trade) {
m.account.AddBalance(m.Market.BaseCurrency, trade.Quantity)
case m.Market.BaseCurrency:
m.account.AddBalance(m.Market.BaseCurrency, trade.Quantity.Sub(trade.Fee))
default:
m.account.AddBalance(m.Market.BaseCurrency, trade.Quantity)
}
} else { // sell trade
@ -295,6 +297,8 @@ func (m *SimplePriceMatching) executeTrade(trade types.Trade) {
case m.Market.BaseCurrency:
m.account.AddBalance(m.Market.BaseCurrency, trade.Fee.Neg())
m.account.AddBalance(m.Market.QuoteCurrency, trade.QuoteQuantity)
default:
m.account.AddBalance(m.Market.QuoteCurrency, trade.QuoteQuantity)
}
}