From fb9f8b484cac10325c4fa9b02a0246b2d56a0e7d Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 18 Feb 2022 13:57:47 +0800 Subject: [PATCH] max: remove ioc limit type --- pkg/exchange/ftx/convert_test.go | 9 --------- pkg/exchange/max/convert.go | 5 +---- pkg/exchange/max/exchange.go | 7 ++++++- pkg/types/order.go | 1 - 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/pkg/exchange/ftx/convert_test.go b/pkg/exchange/ftx/convert_test.go index e7f25cea0..18766c1df 100644 --- a/pkg/exchange/ftx/convert_test.go +++ b/pkg/exchange/ftx/convert_test.go @@ -131,12 +131,3 @@ func Test_toLocalOrderTypeWithMarket(t *testing.T) { assert.Equal(t, IOC, false) } -func Test_toLocalOrderTypeWithIOCLimit(t *testing.T) { - - orderType, postOnly, IOC, err := toLocalOrderType(types.OrderTypeIOCLimit) - - assert.NoError(t, err) - assert.Equal(t, orderType, OrderTypeLimit) - assert.Equal(t, postOnly, false) - assert.Equal(t, IOC, true) -} diff --git a/pkg/exchange/max/convert.go b/pkg/exchange/max/convert.go index 2c1929aef..a973c49e6 100644 --- a/pkg/exchange/max/convert.go +++ b/pkg/exchange/max/convert.go @@ -121,7 +121,7 @@ func toGlobalOrderType(orderType max.OrderType) types.OrderType { return types.OrderTypeStopMarket case max.OrderTypeIOCLimit: - return types.OrderTypeIOCLimit + return types.OrderTypeLimit case max.OrderTypePostOnly: return types.OrderTypeLimitMaker @@ -149,9 +149,6 @@ func toLocalOrderType(orderType types.OrderType) (max.OrderType, error) { case types.OrderTypeMarket: return max.OrderTypeMarket, nil - - case types.OrderTypeIOCLimit: - return max.OrderTypeIOCLimit, nil } return "", fmt.Errorf("order type %s not supported", orderType) diff --git a/pkg/exchange/max/exchange.go b/pkg/exchange/max/exchange.go index 2eaf9641a..c1d61cfe9 100644 --- a/pkg/exchange/max/exchange.go +++ b/pkg/exchange/max/exchange.go @@ -418,6 +418,11 @@ func toMaxSubmitOrder(o types.SubmitOrder) (*maxapi.Order, error) { return nil, err } + // case IOC type + if orderType == maxapi.OrderTypeLimit && o.TimeInForce == types.TimeInForceIOC { + orderType = maxapi.OrderTypeIOCLimit + } + var quantityString string if o.Market.Symbol != "" { quantityString = o.Market.FormatQuantity(o.Quantity) @@ -443,7 +448,7 @@ func toMaxSubmitOrder(o types.SubmitOrder) (*maxapi.Order, error) { } switch o.Type { - case types.OrderTypeStopLimit, types.OrderTypeLimit, types.OrderTypeLimitMaker, types.OrderTypeIOCLimit: + case types.OrderTypeStopLimit, types.OrderTypeLimit, types.OrderTypeLimitMaker: var priceInString string if o.Market.Symbol != "" { priceInString = o.Market.FormatPrice(o.Price) diff --git a/pkg/types/order.go b/pkg/types/order.go index 8d27f2de5..7b747ab79 100644 --- a/pkg/types/order.go +++ b/pkg/types/order.go @@ -75,7 +75,6 @@ const ( OrderTypeMarket OrderType = "MARKET" OrderTypeStopLimit OrderType = "STOP_LIMIT" OrderTypeStopMarket OrderType = "STOP_MARKET" - OrderTypeIOCLimit OrderType = "IOC_LIMIT" ) /*