mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
backtest: fix backtest fee mode when fee currency is not base or quote
This commit is contained in:
parent
843b81e132
commit
bf4eade604
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user