mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
backtest: fix market order fee calculation
This commit is contained in:
parent
20938895a8
commit
ec8129ab87
|
@ -216,6 +216,13 @@ func (m *SimplePriceMatching) newTradeFromOrder(order types.Order, isMaker bool)
|
|||
}
|
||||
}
|
||||
|
||||
price := order.Price
|
||||
switch order.Type {
|
||||
case types.OrderTypeMarket, types.OrderTypeStopMarket:
|
||||
price = m.LastPrice.Float64()
|
||||
|
||||
}
|
||||
|
||||
var fee float64
|
||||
var feeCurrency string
|
||||
|
||||
|
@ -226,17 +233,11 @@ func (m *SimplePriceMatching) newTradeFromOrder(order types.Order, isMaker bool)
|
|||
feeCurrency = m.Market.BaseCurrency
|
||||
|
||||
case types.SideTypeSell:
|
||||
fee = order.Quantity * order.Price * feeRate
|
||||
fee = order.Quantity * price * feeRate
|
||||
feeCurrency = m.Market.QuoteCurrency
|
||||
|
||||
}
|
||||
|
||||
price := order.Price
|
||||
switch order.Type {
|
||||
case types.OrderTypeMarket, types.OrderTypeStopMarket:
|
||||
price = m.LastPrice.Float64()
|
||||
|
||||
}
|
||||
|
||||
var id = incTradeID()
|
||||
return types.Trade{
|
||||
|
|
Loading…
Reference in New Issue
Block a user