backtest: emit balance update if we got some quote back

This commit is contained in:
c9s 2022-08-18 16:09:07 +08:00
parent bd8b362274
commit 4d32a578d7
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -207,6 +207,7 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (*types.Order, *ty
if err := m.Account.UnlockBalance(m.Market.QuoteCurrency, amount); err != nil { if err := m.Account.UnlockBalance(m.Market.QuoteCurrency, amount); err != nil {
return nil, nil, err return nil, nil, err
} }
m.EmitBalanceUpdate(m.Account.Balances())
} }
case types.SideTypeSell: case types.SideTypeSell:
@ -215,6 +216,7 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (*types.Order, *ty
amount := order.AveragePrice.Sub(order.Price).Mul(order.Quantity) amount := order.AveragePrice.Sub(order.Price).Mul(order.Quantity)
if amount.Sign() > 0 { if amount.Sign() > 0 {
m.Account.AddBalance(m.Market.QuoteCurrency, amount) m.Account.AddBalance(m.Market.QuoteCurrency, amount)
m.EmitBalanceUpdate(m.Account.Balances())
} }
} }
} }