diff --git a/pkg/exchange/binance/convert_futures.go b/pkg/exchange/binance/convert_futures.go index 2f2f547..52ec90a 100644 --- a/pkg/exchange/binance/convert_futures.go +++ b/pkg/exchange/binance/convert_futures.go @@ -93,6 +93,12 @@ func toLocalFuturesOrderType(orderType types.OrderType) (futures.OrderType, erro // case types.OrderTypeStopMarket: // return futures.OrderTypeStopLoss, nil //TODO + case types.OrderTypeStopMarket: + return futures.OrderTypeStopMarket, nil //TODO + + case types.OrderTypeTakeProfitMarket: + return futures.OrderTypeTakeProfitMarket, nil + case types.OrderTypeMarket: return futures.OrderTypeMarket, nil } @@ -211,7 +217,7 @@ func toGlobalFuturesOrderType(orderType futures.OrderType) types.OrderType { return types.OrderTypeStopLimit case futures.OrderTypeTakeProfitMarket: - return types.OrderTypeStopMarket + return types.OrderTypeTakeProfitMarket case futures.OrderTypeStopMarket: return types.OrderTypeStopMarket diff --git a/pkg/exchange/binance/futures.go b/pkg/exchange/binance/futures.go index 40554f7..2614d03 100644 --- a/pkg/exchange/binance/futures.go +++ b/pkg/exchange/binance/futures.go @@ -139,7 +139,8 @@ func (e *Exchange) submitFuturesOrder(ctx context.Context, order types.SubmitOrd req := e.futuresClient.NewCreateOrderService(). Symbol(order.Symbol). Type(orderType). - Side(futures.SideType(order.Side)) + Side(futures.SideType(order.Side)). + PositionSide(futures.PositionSideType(order.PositionSide)) if order.ReduceOnly { req.ReduceOnly(order.ReduceOnly) @@ -178,7 +179,7 @@ func (e *Exchange) submitFuturesOrder(ctx context.Context, order types.SubmitOrd // set stop price switch order.Type { - case types.OrderTypeStopLimit, types.OrderTypeStopMarket: + case types.OrderTypeStopLimit, types.OrderTypeStopMarket, types.OrderTypeTakeProfitMarket: if order.Market.Symbol != "" { req.StopPrice(order.Market.FormatPrice(order.StopPrice)) } else { diff --git a/pkg/types/order.go b/pkg/types/order.go index 253c061..d9c078e 100644 --- a/pkg/types/order.go +++ b/pkg/types/order.go @@ -79,11 +79,12 @@ func (t *MarginOrderSideEffectType) UnmarshalJSON(data []byte) error { type OrderType string const ( - OrderTypeLimit OrderType = "LIMIT" - OrderTypeLimitMaker OrderType = "LIMIT_MAKER" - OrderTypeMarket OrderType = "MARKET" - OrderTypeStopLimit OrderType = "STOP_LIMIT" - OrderTypeStopMarket OrderType = "STOP_MARKET" + OrderTypeLimit OrderType = "LIMIT" + OrderTypeLimitMaker OrderType = "LIMIT_MAKER" + OrderTypeMarket OrderType = "MARKET" + OrderTypeStopLimit OrderType = "STOP_LIMIT" + OrderTypeStopMarket OrderType = "STOP_MARKET" + OrderTypeTakeProfitMarket OrderType = "TAKE_PROFIT_MARKET" ) /* @@ -130,9 +131,10 @@ func (o OrderStatus) Closed() bool { type SubmitOrder struct { ClientOrderID string `json:"clientOrderID,omitempty" db:"client_order_id"` - Symbol string `json:"symbol" db:"symbol"` - Side SideType `json:"side" db:"side"` - Type OrderType `json:"orderType" db:"order_type"` + Symbol string `json:"symbol" db:"symbol"` + Side SideType `json:"side" db:"side"` + PositionSide PositionSideType `json:"positionSide" db:"positionSide"` + Type OrderType `json:"orderType" db:"order_type"` Quantity fixedpoint.Value `json:"quantity" db:"quantity"` Price fixedpoint.Value `json:"price" db:"price"`