Merge pull request #917 from c9s/fix/backtest-fee-mode

backtest: fix backtest fee mode when fee currency is not base or quote
This commit is contained in:
Yo-An Lin 2022-09-05 17:49:45 +08:00 committed by GitHub
commit 36a79336dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)
}
}