backtest: for types.OrderTypeStopMarket, use stop price to simulate the actual price for balance locking

This commit is contained in:
c9s 2022-07-14 19:26:04 +08:00
parent a370a5e489
commit 26f5f36f7e
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -139,6 +139,11 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (*types.Order, *ty
switch o.Type {
case types.OrderTypeMarket:
price = m.LastPrice
case types.OrderTypeStopMarket:
// the actual price might be different.
price = o.StopPrice
case types.OrderTypeLimit, types.OrderTypeStopLimit, types.OrderTypeLimitMaker:
price = o.Price
}