mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
backtest: emit balance update if we got some quote back
This commit is contained in:
parent
bd8b362274
commit
4d32a578d7
|
@ -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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user