Skip to content

Commit

Permalink
Kraken: Add subscription Pairs support
Browse files Browse the repository at this point in the history
Note: This is a naieve implementation because we want to rebase the
kraken websocket rewrite on top of this
  • Loading branch information
gbjk committed Feb 21, 2024
1 parent fe941ae commit f62e3ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion exchanges/kraken/kraken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ func TestWebsocketSubscribe(t *testing.T) {
err := k.Subscribe([]subscription.Subscription{
{
Channel: defaultSubscribedChannels[0],
Pair: currency.NewPairWithDelimiter("XBT", "USD", "/"),
Pairs: currency.Pairs{currency.NewPairWithDelimiter("XBT", "USD", "/")},
},
})
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions exchanges/kraken/kraken_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ func (k *Kraken) wsProcessOrderBook(channelData *WebsocketChannelData, data map[
}
}(&subscription.Subscription{
Channel: krakenWsOrderbook,
Pair: outbound,
Pairs: currency.Pairs{outbound},
Asset: asset.Spot,
})
return err
Expand Down Expand Up @@ -1221,7 +1221,7 @@ func (k *Kraken) GenerateDefaultSubscriptions() ([]subscription.Subscription, er
enabledPairs[j].Delimiter = "/"
subscriptions = append(subscriptions, subscription.Subscription{
Channel: defaultSubscribedChannels[i],
Pair: enabledPairs[j],
Pairs: currency.Pairs{enabledPairs[j]},
Asset: asset.Spot,
})
}
Expand All @@ -1248,7 +1248,7 @@ channels:
}

for j := range *s {
(*s)[j].Pairs = append((*s)[j].Pairs, channelsToSubscribe[i].Pair.String())
(*s)[j].Pairs = append((*s)[j].Pairs, channelsToSubscribe[i].Pairs[0].String())
(*s)[j].Channels = append((*s)[j].Channels, channelsToSubscribe[i])
continue channels
}
Expand All @@ -1264,8 +1264,8 @@ channels:
if channelsToSubscribe[i].Channel == "book" {
outbound.Subscription.Depth = krakenWsOrderbookDepth
}
if !channelsToSubscribe[i].Pair.IsEmpty() {
outbound.Pairs = []string{channelsToSubscribe[i].Pair.String()}
if !channelsToSubscribe[i].Pairs[0].IsEmpty() {
outbound.Pairs = []string{channelsToSubscribe[i].Pairs[0].String()}
}
if common.StringDataContains(authenticatedChannels, channelsToSubscribe[i].Channel) {
outbound.Subscription.Token = authToken
Expand Down Expand Up @@ -1306,7 +1306,7 @@ channels:
for y := range unsubs {
if unsubs[y].Subscription.Name == channelsToUnsubscribe[x].Channel {
unsubs[y].Pairs = append(unsubs[y].Pairs,
channelsToUnsubscribe[x].Pair.String())
channelsToUnsubscribe[x].Pairs[0].String())
unsubs[y].Channels = append(unsubs[y].Channels,
channelsToUnsubscribe[x])
continue channels
Expand All @@ -1326,7 +1326,7 @@ channels:

unsub := WebsocketSubscriptionEventRequest{
Event: krakenWsUnsubscribe,
Pairs: []string{channelsToUnsubscribe[x].Pair.String()},
Pairs: []string{channelsToUnsubscribe[x].Pairs[0].String()},
Subscription: WebsocketSubscriptionData{
Name: channelsToUnsubscribe[x].Channel,
Depth: depth,
Expand Down

0 comments on commit f62e3ce

Please sign in to comment.