mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
binance_cfutures: TimeOnForce is an optional order submission field (#867)
Do not add it to the request unless filled out as the API will deny the request otherwise.
This commit is contained in:
@@ -1000,7 +1000,9 @@ func (b *Binance) FuturesNewOrder(ctx context.Context, x *FuturesNewOrderRequest
|
||||
params.Set("positionSide", x.PositionSide)
|
||||
}
|
||||
params.Set("type", x.OrderType)
|
||||
params.Set("timeInForce", x.TimeInForce)
|
||||
if string(x.TimeInForce) != "" {
|
||||
params.Set("timeInForce", string(x.TimeInForce))
|
||||
}
|
||||
if x.ReduceOnly {
|
||||
params.Set("reduceOnly", "true")
|
||||
}
|
||||
|
||||
@@ -923,7 +923,7 @@ func TestFuturesNewOrder(t *testing.T) {
|
||||
Symbol: currency.NewPairWithDelimiter("BTCUSD", "PERP", "_"),
|
||||
Side: "BUY",
|
||||
OrderType: "LIMIT",
|
||||
TimeInForce: "GTC",
|
||||
TimeInForce: BinanceRequestParamsTimeGTC,
|
||||
Quantity: 1,
|
||||
Price: 1,
|
||||
},
|
||||
|
||||
@@ -956,10 +956,15 @@ func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
|
||||
return submitOrderResponse, fmt.Errorf("invalid side")
|
||||
}
|
||||
|
||||
var oType string
|
||||
var (
|
||||
oType string
|
||||
timeInForce RequestParamsTimeForceType
|
||||
)
|
||||
|
||||
switch s.Type {
|
||||
case order.Limit:
|
||||
oType = cfuturesLimit
|
||||
timeInForce = BinanceRequestParamsTimeGTC
|
||||
case order.Market:
|
||||
oType = cfuturesMarket
|
||||
case order.Stop:
|
||||
@@ -975,13 +980,14 @@ func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
|
||||
default:
|
||||
return submitOrderResponse, errors.New("invalid type, check api docs for updates")
|
||||
}
|
||||
|
||||
o, err := b.FuturesNewOrder(
|
||||
ctx,
|
||||
&FuturesNewOrderRequest{
|
||||
Symbol: s.Pair,
|
||||
Side: reqSide,
|
||||
OrderType: oType,
|
||||
TimeInForce: "GTC",
|
||||
TimeInForce: timeInForce,
|
||||
NewClientOrderID: s.ClientOrderID,
|
||||
Quantity: s.Amount,
|
||||
Price: s.Price,
|
||||
|
||||
@@ -212,7 +212,7 @@ type FuturesNewOrderRequest struct {
|
||||
Side string
|
||||
PositionSide string
|
||||
OrderType string
|
||||
TimeInForce string
|
||||
TimeInForce RequestParamsTimeForceType
|
||||
NewClientOrderID string
|
||||
ClosePosition string
|
||||
WorkingType string
|
||||
|
||||
Reference in New Issue
Block a user