pkg/exchange: add comment

This commit is contained in:
Edwin 2024-01-10 14:02:03 +08:00
parent 1dedd32f42
commit a7aa34c396
3 changed files with 8 additions and 3 deletions

View File

@ -97,6 +97,10 @@ func convertSubscription(s types.Subscription) (WebsocketSubscription, error) {
}, nil
case types.BookChannel:
if s.Options.Depth != types.DepthLevel400 {
return WebsocketSubscription{}, fmt.Errorf("%s depth not supported", s.Options.Depth)
}
return WebsocketSubscription{
Channel: ChannelBooks,
InstrumentID: toLocalSymbol(s.Symbol),

View File

@ -48,7 +48,7 @@ func TestStream(t *testing.T) {
t.Run("book test", func(t *testing.T) {
s.Subscribe(types.BookChannel, "BTCUSDT", types.SubscribeOptions{
Depth: types.DepthLevel50,
Depth: types.DepthLevel400,
})
s.SetPublicOnly()
err := s.Connect(context.Background())
@ -97,7 +97,7 @@ func TestStream(t *testing.T) {
t.Run("Subscribe/Unsubscribe test", func(t *testing.T) {
s.Subscribe(types.BookChannel, "BTCUSDT", types.SubscribeOptions{
Depth: types.DepthLevel50,
Depth: types.DepthLevel400,
})
s.SetPublicOnly()
err := s.Connect(context.Background())
@ -119,7 +119,7 @@ func TestStream(t *testing.T) {
t.Run("Resubscribe test", func(t *testing.T) {
s.Subscribe(types.BookChannel, "BTCUSDT", types.SubscribeOptions{
Depth: types.DepthLevel50,
Depth: types.DepthLevel400,
})
s.SetPublicOnly()
err := s.Connect(context.Background())

View File

@ -547,6 +547,7 @@ const (
DepthLevel20 Depth = "20"
DepthLevel50 Depth = "50"
DepthLevel200 Depth = "200"
DepthLevel400 Depth = "400"
)
type Speed string