diff --git a/pkg/exchange/bitget/convert.go b/pkg/exchange/bitget/convert.go index ff5fb6258..c0167d16f 100644 --- a/pkg/exchange/bitget/convert.go +++ b/pkg/exchange/bitget/convert.go @@ -430,6 +430,11 @@ func (o *Order) toGlobalOrder() (types.Order, error) { } } + price := o.Price + if orderType == types.OrderTypeMarket { + price = o.PriceAvg + } + return types.Order{ SubmitOrder: types.SubmitOrder{ ClientOrderID: o.ClientOrderId, @@ -437,7 +442,7 @@ func (o *Order) toGlobalOrder() (types.Order, error) { Side: side, Type: orderType, Quantity: qty, - Price: o.PriceAvg, + Price: price, TimeInForce: timeInForce, }, Exchange: types.ExchangeBitget, diff --git a/pkg/exchange/bitget/convert_test.go b/pkg/exchange/bitget/convert_test.go index da083929f..a0898e21d 100644 --- a/pkg/exchange/bitget/convert_test.go +++ b/pkg/exchange/bitget/convert_test.go @@ -924,6 +924,7 @@ func TestOrder_toGlobalOrder(t *testing.T) { // } t.Run("limit buy", func(t *testing.T) { newO := o + newO.Price = fixedpoint.NewFromFloat(0.49998) newO.OrderType = v2.OrderTypeLimit res, err := newO.toGlobalOrder() @@ -935,7 +936,7 @@ func TestOrder_toGlobalOrder(t *testing.T) { Side: types.SideTypeBuy, Type: types.OrderTypeLimit, Quantity: newO.Size, - Price: newO.PriceAvg, + Price: newO.Price, TimeInForce: types.TimeInForceGTC, }, Exchange: types.ExchangeBitget, @@ -983,6 +984,7 @@ func TestOrder_toGlobalOrder(t *testing.T) { newO := o newO.OrderType = v2.OrderTypeLimit newO.Side = v2.SideTypeSell + newO.Price = fixedpoint.NewFromFloat(0.48710) res, err := newO.toGlobalOrder() assert.NoError(t, err) @@ -993,7 +995,7 @@ func TestOrder_toGlobalOrder(t *testing.T) { Side: types.SideTypeSell, Type: types.OrderTypeLimit, Quantity: newO.Size, - Price: newO.PriceAvg, + Price: newO.Price, TimeInForce: types.TimeInForceGTC, }, Exchange: types.ExchangeBitget, diff --git a/pkg/exchange/bitget/stream_test.go b/pkg/exchange/bitget/stream_test.go index 011210abe..cfe952e6a 100644 --- a/pkg/exchange/bitget/stream_test.go +++ b/pkg/exchange/bitget/stream_test.go @@ -125,6 +125,7 @@ func TestStream(t *testing.T) { }) t.Run("private test", func(t *testing.T) { + s.SetPrivateChannelSymbols([]string{"BTCUSDT"}) err := s.Connect(context.Background()) assert.NoError(t, err) diff --git a/pkg/exchange/bitget/types.go b/pkg/exchange/bitget/types.go index c9c8468f5..163479713 100644 --- a/pkg/exchange/bitget/types.go +++ b/pkg/exchange/bitget/types.go @@ -488,16 +488,18 @@ type Order struct { // Size is base coin when orderType=limit; quote coin when orderType=market Size fixedpoint.Value `json:"size"` // Buy amount, returned when buying at market price - Notional fixedpoint.Value `json:"notional"` - OrderType v2.OrderType `json:"orderType"` - Force v2.OrderForce `json:"force"` - Side v2.SideType `json:"side"` - AccBaseVolume fixedpoint.Value `json:"accBaseVolume"` - PriceAvg fixedpoint.Value `json:"priceAvg"` - Status v2.OrderStatus `json:"status"` - CreatedTime types.MillisecondTimestamp `json:"cTime"` - UpdatedTime types.MillisecondTimestamp `json:"uTime"` - FeeDetail []struct { + Notional fixedpoint.Value `json:"notional"` + OrderType v2.OrderType `json:"orderType"` + Force v2.OrderForce `json:"force"` + Side v2.SideType `json:"side"` + AccBaseVolume fixedpoint.Value `json:"accBaseVolume"` + PriceAvg fixedpoint.Value `json:"priceAvg"` + // The Price field is only applicable to limit orders. + Price fixedpoint.Value `json:"price"` + Status v2.OrderStatus `json:"status"` + CreatedTime types.MillisecondTimestamp `json:"cTime"` + UpdatedTime types.MillisecondTimestamp `json:"uTime"` + FeeDetail []struct { FeeCoin string `json:"feeCoin"` Fee string `json:"fee"` } `json:"feeDetail"`