fix stop price formating

This commit is contained in:
c9s 2020-12-03 09:25:47 +08:00
parent b75ebf2f0f
commit 4f399ebb9f
3 changed files with 24 additions and 0 deletions

View File

@ -266,6 +266,12 @@ func formatOrder(session *ExchangeSession, order types.SubmitOrder) (types.Submi
order.Market = market order.Market = market
switch order.Type {
case types.OrderTypeStopMarket, types.OrderTypeStopLimit:
order.StopPriceString = market.FormatPrice(order.StopPrice)
}
switch order.Type { switch order.Type {
case types.OrderTypeMarket, types.OrderTypeStopMarket: case types.OrderTypeMarket, types.OrderTypeStopMarket:
order.Price = 0.0 order.Price = 0.0

View File

@ -373,6 +373,15 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
req.Price(order.PriceString) req.Price(order.PriceString)
} }
switch order.Type {
case types.OrderTypeStopLimit, types.OrderTypeStopMarket:
if len(order.StopPriceString) == 0 {
return createdOrders, fmt.Errorf("stop price string can not be empty")
}
req.StopPrice(order.StopPriceString)
}
if len(order.TimeInForce) > 0 { if len(order.TimeInForce) > 0 {
// TODO: check the TimeInForce value // TODO: check the TimeInForce value
req.TimeInForce(binance.TimeInForceType(order.TimeInForce)) req.TimeInForce(binance.TimeInForceType(order.TimeInForce))

View File

@ -181,6 +181,15 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
req.ClientOrderID(clientOrderID) req.ClientOrderID(clientOrderID)
} }
switch order.Type {
case types.OrderTypeStopLimit, types.OrderTypeStopMarket:
if len(order.StopPriceString) == 0 {
return createdOrders, fmt.Errorf("stop price string can not be empty")
}
req.StopPrice(order.StopPriceString)
}
if len(order.PriceString) > 0 { if len(order.PriceString) > 0 {
req.Price(order.PriceString) req.Price(order.PriceString)
} }