mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
bybit: support categorised channel (#1823)
* bybit: support categorised channel Signed-off-by: Ye Sijun <junnplus@gmail.com> * remove comment for private func Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> --------- Signed-off-by: Ye Sijun <junnplus@gmail.com> Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user