Skip to content

Commit

Permalink
Fix: spread data parsing and re-subscribing to private channels
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Oct 14, 2021
1 parent 38db2c0 commit e50843a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion websocket/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type Spread struct {

// UnmarshalJSON - unmarshal candle update
func (s *Spread) UnmarshalJSON(data []byte) error {
raw := []interface{}{&s.Ask, &s.Bid, &s.Time, &s.AskVolume, &s.BidVolume, &s.Time}
raw := []interface{}{&s.Bid, &s.Ask, &s.Time, &s.AskVolume, &s.BidVolume, &s.Time}
return json.Unmarshal(data, &raw)
}

Expand Down
18 changes: 12 additions & 6 deletions websocket/kraken.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,18 @@ func (k *Kraken) managerThread() {

func (k *Kraken) resubscribe() error {
for _, sub := range k.subscriptions {
if err := k.send(SubscriptionRequest{
Event: EventSubscribe,
Pairs: []string{sub.Pair},
Subscription: sub.Subscription,
}); err != nil {
return err
switch sub.Subscription.Name {
// Private Channels
case ChanOwnTrades, ChanOpenOrders:
return k.subscribeToPrivate(sub.Subscription.Name)
default:
if err := k.send(SubscriptionRequest{
Event: EventSubscribe,
Pairs: []string{sub.Pair},
Subscription: sub.Subscription,
}); err != nil {
return err
}
}
}
return nil
Expand Down

0 comments on commit e50843a

Please sign in to comment.