Merge pull request #1339 from bailantaotao/edwin/support-200-depth

FEATURE: [BYBIT] support order book depth 200 on bybit
This commit is contained in:
bailantaotao 2023-10-12 21:16:56 -05:00 committed by GitHub
commit fb110a1d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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",

View File

@ -525,6 +525,7 @@ const (
DepthLevel5 Depth = "5"
DepthLevel20 Depth = "20"
DepthLevel50 Depth = "50"
DepthLevel200 Depth = "200"
)
type Speed string