From e7961be86a42e4d7d5d2fbcb92afaf03726c206a Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Tue, 13 Apr 2021 23:18:40 +0800 Subject: [PATCH] binance: set TimeInForce to GTC by default for limit orders Binance does not allow submitting order without TimeInForce set for certain order types. Set TimeInforce to GTC (Good-Til-Cancel) by default. --- pkg/exchange/binance/exchange.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/exchange/binance/exchange.go b/pkg/exchange/binance/exchange.go index 2089a3b8f..379aa0480 100644 --- a/pkg/exchange/binance/exchange.go +++ b/pkg/exchange/binance/exchange.go @@ -538,6 +538,11 @@ func (e *Exchange) submitMarginOrder(ctx context.Context, order types.SubmitOrde if len(order.TimeInForce) > 0 { // TODO: check the TimeInForce value req.TimeInForce(binance.TimeInForceType(order.TimeInForce)) + } else { + switch order.Type { + case types.OrderTypeLimit, types.OrderTypeStopLimit: + req.TimeInForce(binance.TimeInForceTypeGTC) + } } response, err := req.Do(ctx) @@ -614,6 +619,11 @@ func (e *Exchange) submitSpotOrder(ctx context.Context, order types.SubmitOrder) if len(order.TimeInForce) > 0 { // TODO: check the TimeInForce value req.TimeInForce(binance.TimeInForceType(order.TimeInForce)) + } else { + switch order.Type { + case types.OrderTypeLimit, types.OrderTypeStopLimit: + req.TimeInForce(binance.TimeInForceTypeGTC) + } } response, err := req.Do(ctx)