Skip to content

Commit

Permalink
Fixed PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chathumi-k committed Jan 8, 2025
1 parent cf969f6 commit 3d8eec1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/crypto-perp-stream/crypto_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
fmt.Printf("DAILY BAR: %+v\n", cb)
}, "BTC-PERP"),
stream.WithCryptoPerpPricing(func(fp stream.CryptoPerpPricing) {
fmt.Printf("FUTURES PRICING: %+v\n", fp)
fmt.Printf("PRICING: %+v\n", fp)
}, "BTC-PERP"),
)

Expand Down
2 changes: 1 addition & 1 deletion marketdata/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ type latestCryptoTradesResponse struct {
}

type latestCryptoPerpPricingResponse struct {
Pricing map[string]CryptoPerpPricing `json:"futuresPricing"`
Pricing map[string]CryptoPerpPricing `json:"pricing"`
}

type latestCryptoQuotesResponse struct {
Expand Down
4 changes: 2 additions & 2 deletions marketdata/entities_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions marketdata/stream/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1782,13 +1782,13 @@ func TestCoreFunctionalityCryptoPerp(t *testing.T) {
connection := newMockConn()
defer connection.close()
writeInitialFlowMessagesToConn(t, connection, subscriptions{
trades: []string{"BTC-PERP"},
quotes: []string{"BTC-PERP"},
bars: []string{"BTC-PERP"},
updatedBars: []string{"BTC-PERP"},
dailyBars: []string{"BTC-PERP"},
orderbooks: []string{"BTC-PERP"},
futuresPricing: []string{"BTC-PERP"},
trades: []string{"BTC-PERP"},
quotes: []string{"BTC-PERP"},
bars: []string{"BTC-PERP"},
updatedBars: []string{"BTC-PERP"},
dailyBars: []string{"BTC-PERP"},
orderbooks: []string{"BTC-PERP"},
pricing: []string{"BTC-PERP"},
})

trades := make(chan CryptoTrade, 10)
Expand Down
2 changes: 1 addition & 1 deletion marketdata/stream/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func WithCryptoTrades(handler func(CryptoTrade), symbols ...string) CryptoOption
// WithCryptoPerpPricing configures initial pricing symbols to subscribe to and the handler
func WithCryptoPerpPricing(handler func(CryptoPerpPricing), symbols ...string) CryptoOption {
return newFuncCryptoOption(func(o *cryptoOptions) {
o.sub.futuresPricing = symbols
o.sub.pricing = symbols
o.pricingHandler = handler
})
}
Expand Down
32 changes: 16 additions & 16 deletions marketdata/stream/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (cc *CryptoClient) SubscribeToPerpPricing(handler func(pricing CryptoPerpPr
cc.handler.mu.Lock()
cc.handler.futuresPricingHandler = handler
cc.handler.mu.Unlock()
return cc.client.handleSubChange(true, subscriptions{futuresPricing: symbols})
return cc.client.handleSubChange(true, subscriptions{pricing: symbols})
}

func (cc *CryptoClient) UnsubscribeFromTrades(symbols ...string) error {
Expand Down Expand Up @@ -186,7 +186,7 @@ func (cc *CryptoClient) UnsubscribeFromOrderbooks(symbols ...string) error {
}

func (cc *CryptoClient) UnsubscribeFromPerpPricing(symbols ...string) error {
return cc.handleSubChange(false, subscriptions{futuresPricing: symbols})
return cc.handleSubChange(false, subscriptions{pricing: symbols})
}

func (cc *OptionClient) SubscribeToTrades(handler func(OptionTrade), symbols ...string) error {
Expand Down Expand Up @@ -223,24 +223,24 @@ func (nc *NewsClient) UnsubscribeFromNews(symbols ...string) error {
}

type subscriptions struct {
trades []string
quotes []string
bars []string
updatedBars []string
dailyBars []string
statuses []string
lulds []string
cancelErrors []string // Subscribed automatically.
corrections []string // Subscribed automatically.
orderbooks []string
news []string
futuresPricing []string
trades []string
quotes []string
bars []string
updatedBars []string
dailyBars []string
statuses []string
lulds []string
cancelErrors []string // Subscribed automatically.
corrections []string // Subscribed automatically.
orderbooks []string
news []string
pricing []string
}

func (s subscriptions) noSubscribeCallNecessary() bool {
return len(s.trades) == 0 && len(s.quotes) == 0 && len(s.bars) == 0 && len(s.updatedBars) == 0 &&
len(s.dailyBars) == 0 && len(s.statuses) == 0 && len(s.lulds) == 0 &&
len(s.orderbooks) == 0 && len(s.news) == 0 && len(s.futuresPricing) == 0
len(s.orderbooks) == 0 && len(s.news) == 0 && len(s.pricing) == 0
}

var timeAfter = time.After
Expand Down Expand Up @@ -316,7 +316,7 @@ func getSubChangeMessage(subscribe bool, changes subscriptions) ([]byte, error)
"lulds": changes.lulds,
"orderbooks": changes.orderbooks,
"news": changes.news,
"pricing": changes.futuresPricing,
"pricing": changes.pricing,
// No need to subscribe to cancel errors or corrections explicitly.
})
}

0 comments on commit 3d8eec1

Please sign in to comment.