diff --git a/pkg/exchange/bybit/stream.go b/pkg/exchange/bybit/stream.go index 145591cac..c6b42cb9b 100644 --- a/pkg/exchange/bybit/stream.go +++ b/pkg/exchange/bybit/stream.go @@ -318,8 +318,12 @@ func (s *Stream) convertSubscription(sub types.Subscription) (string, error) { case types.BookChannel: depth := types.DepthLevel1 - if len(sub.Options.Depth) > 0 && sub.Options.Depth == types.DepthLevel50 { - depth = types.DepthLevel50 + + switch sub.Options.Depth { + case types.DepthLevel50: + depth = sub.Options.Depth + case types.DepthLevel200: + depth = sub.Options.Depth } return genTopic(TopicTypeOrderBook, depth, sub.Symbol), nil diff --git a/pkg/exchange/bybit/stream_test.go b/pkg/exchange/bybit/stream_test.go index 7cfc4d99b..e1fec2af8 100644 --- a/pkg/exchange/bybit/stream_test.go +++ b/pkg/exchange/bybit/stream_test.go @@ -395,6 +395,28 @@ func Test_convertSubscription(t *testing.T) { assert.NoError(t, err) assert.Equal(t, genTopic(TopicTypeOrderBook, types.DepthLevel1, "BTCUSDT"), res) }) + t.Run("BookChannel.DepthLevel50", func(t *testing.T) { + res, err := s.convertSubscription(types.Subscription{ + Symbol: "BTCUSDT", + Channel: types.BookChannel, + Options: types.SubscribeOptions{ + Depth: types.DepthLevel50, + }, + }) + assert.NoError(t, err) + assert.Equal(t, genTopic(TopicTypeOrderBook, types.DepthLevel50, "BTCUSDT"), res) + }) + t.Run("BookChannel.DepthLevel200", func(t *testing.T) { + res, err := s.convertSubscription(types.Subscription{ + Symbol: "BTCUSDT", + Channel: types.BookChannel, + Options: types.SubscribeOptions{ + Depth: types.DepthLevel200, + }, + }) + assert.NoError(t, err) + assert.Equal(t, genTopic(TopicTypeOrderBook, types.DepthLevel200, "BTCUSDT"), res) + }) t.Run("BookChannel. with default depth", func(t *testing.T) { res, err := s.convertSubscription(types.Subscription{ Symbol: "BTCUSDT", diff --git a/pkg/types/stream.go b/pkg/types/stream.go index 50cbf59a0..9574b2b64 100644 --- a/pkg/types/stream.go +++ b/pkg/types/stream.go @@ -521,6 +521,7 @@ const ( DepthLevel5 Depth = "5" DepthLevel20 Depth = "20" DepthLevel50 Depth = "50" + DepthLevel200 Depth = "200" ) type Speed string