mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
backtest: delay the order update after the balance unlock
This commit is contained in:
parent
3a24a48cde
commit
bd8b362274
|
@ -192,13 +192,6 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (*types.Order, *ty
|
|||
trade := m.newTradeFromOrder(&order2, false, m.LastPrice)
|
||||
m.executeTrade(trade)
|
||||
|
||||
// update the order status
|
||||
order2.Status = types.OrderStatusFilled
|
||||
order2.ExecutedQuantity = order2.Quantity
|
||||
order2.IsWorking = false
|
||||
|
||||
m.EmitOrderUpdate(order2)
|
||||
|
||||
// unlock the rest balances for limit taker
|
||||
if order.Type == types.OrderTypeLimit {
|
||||
if order.AveragePrice.IsZero() {
|
||||
|
@ -226,6 +219,12 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (*types.Order, *ty
|
|||
}
|
||||
}
|
||||
|
||||
// update the order status
|
||||
order2.Status = types.OrderStatusFilled
|
||||
order2.ExecutedQuantity = order2.Quantity
|
||||
order2.IsWorking = false
|
||||
m.EmitOrderUpdate(order2)
|
||||
|
||||
// let the exchange emit the "FILLED" order update (we need the closed order)
|
||||
// m.EmitOrderUpdate(order2)
|
||||
return &order2, &trade, nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user