mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #1339 from bailantaotao/edwin/support-200-depth
FEATURE: [BYBIT] support order book depth 200 on bybit
This commit is contained in:
commit
fb110a1d5b
|
@ -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
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -525,6 +525,7 @@ const (
|
|||
DepthLevel5 Depth = "5"
|
||||
DepthLevel20 Depth = "20"
|
||||
DepthLevel50 Depth = "50"
|
||||
DepthLevel200 Depth = "200"
|
||||
)
|
||||
|
||||
type Speed string
|
||||
|
|
Loading…
Reference in New Issue
Block a user