diff --git a/exchanges/bybit/bybit_test.go b/exchanges/bybit/bybit_test.go index caeea790..18027507 100644 --- a/exchanges/bybit/bybit_test.go +++ b/exchanges/bybit/bybit_test.go @@ -3736,6 +3736,11 @@ func TestGenerateSubscriptions(t *testing.T) { } else { s.Pairs = pairs s.QualifiedChannel = channelName(s) + categoryName := getCategoryName(a) + if isCategorisedChannel(s.QualifiedChannel) && categoryName != "" { + s.QualifiedChannel += "." + categoryName + } + exp = append(exp, s) } } diff --git a/exchanges/bybit/bybit_websocket.go b/exchanges/bybit/bybit_websocket.go index 59803308..63a29fad 100644 --- a/exchanges/bybit/bybit_websocket.go +++ b/exchanges/bybit/bybit_websocket.go @@ -65,7 +65,6 @@ var defaultSubscriptions = subscription.List{ {Enabled: true, Asset: asset.Spot, Authenticated: true, Channel: subscription.MyOrdersChannel}, {Enabled: true, Asset: asset.Spot, Authenticated: true, Channel: subscription.MyWalletChannel}, {Enabled: true, Asset: asset.Spot, Authenticated: true, Channel: subscription.MyTradesChannel}, - {Enabled: true, Asset: asset.Spot, Authenticated: true, Channel: chanPositions}, } var subscriptionNames = map[string]string{ @@ -242,9 +241,11 @@ func (by *Bybit) generateSubscriptions() (subscription.List, error) { // GetSubscriptionTemplate returns a subscription channel template func (by *Bybit) GetSubscriptionTemplate(_ *subscription.Subscription) (*template.Template, error) { return template.New("master.tmpl").Funcs(template.FuncMap{ - "channelName": channelName, - "isSymbolChannel": isSymbolChannel, - "intervalToString": intervalToString, + "channelName": channelName, + "isSymbolChannel": isSymbolChannel, + "intervalToString": intervalToString, + "getCategoryName": getCategoryName, + "isCategorisedChannel": isCategorisedChannel, }).Parse(subTplText) } @@ -759,6 +760,14 @@ func isSymbolChannel(name string) bool { return true } +func isCategorisedChannel(name string) bool { + switch name { + case chanPositions, chanExecution, chanOrder: + return true + } + return false +} + const subTplText = ` {{ with $name := channelName $.S }} {{- range $asset, $pairs := $.AssetPairs }} @@ -772,6 +781,7 @@ const subTplText = ` {{- end }} {{- else }} {{- $name }} + {{- if and (isCategorisedChannel $name) ($categoryName := getCategoryName $asset) -}} . {{- $categoryName -}} {{- end }} {{- end }} {{- end }} {{- $.AssetSeparator }}