mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
pkg/exchange: support order book depth 200 on bybit
This commit is contained in:
parent
d617bf8ae5
commit
ef582f6e52
|
@ -318,8 +318,12 @@ func (s *Stream) convertSubscription(sub types.Subscription) (string, error) {
|
||||||
|
|
||||||
case types.BookChannel:
|
case types.BookChannel:
|
||||||
depth := types.DepthLevel1
|
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
|
return genTopic(TopicTypeOrderBook, depth, sub.Symbol), nil
|
||||||
|
|
||||||
|
|
|
@ -395,6 +395,28 @@ func Test_convertSubscription(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, genTopic(TopicTypeOrderBook, types.DepthLevel1, "BTCUSDT"), res)
|
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) {
|
t.Run("BookChannel. with default depth", func(t *testing.T) {
|
||||||
res, err := s.convertSubscription(types.Subscription{
|
res, err := s.convertSubscription(types.Subscription{
|
||||||
Symbol: "BTCUSDT",
|
Symbol: "BTCUSDT",
|
||||||
|
|
|
@ -521,6 +521,7 @@ const (
|
||||||
DepthLevel5 Depth = "5"
|
DepthLevel5 Depth = "5"
|
||||||
DepthLevel20 Depth = "20"
|
DepthLevel20 Depth = "20"
|
||||||
DepthLevel50 Depth = "50"
|
DepthLevel50 Depth = "50"
|
||||||
|
DepthLevel200 Depth = "200"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Speed string
|
type Speed string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user