mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
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:
commit
36a79336dd
|
@ -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