From 3d8eec1878a17dca849dedd8dc344f643b77d4fc Mon Sep 17 00:00:00 2001 From: Chathumi Kumarapeli Date: Wed, 8 Jan 2025 16:00:59 +0530 Subject: [PATCH] Fixed PR feedback --- examples/crypto-perp-stream/crypto_stream.go | 2 +- marketdata/entities.go | 2 +- marketdata/entities_easyjson.go | 4 +-- marketdata/stream/client_test.go | 14 ++++----- marketdata/stream/options.go | 2 +- marketdata/stream/subscription.go | 32 ++++++++++---------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/crypto-perp-stream/crypto_stream.go b/examples/crypto-perp-stream/crypto_stream.go index b0fd50a..261bc86 100644 --- a/examples/crypto-perp-stream/crypto_stream.go +++ b/examples/crypto-perp-stream/crypto_stream.go @@ -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"), ) diff --git a/marketdata/entities.go b/marketdata/entities.go index 496cf8a..466b926 100644 --- a/marketdata/entities.go +++ b/marketdata/entities.go @@ -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 { diff --git a/marketdata/entities_easyjson.go b/marketdata/entities_easyjson.go index 4289df1..bed65fc 100644 --- a/marketdata/entities_easyjson.go +++ b/marketdata/entities_easyjson.go @@ -1803,7 +1803,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(in *j continue } switch key { - case "futuresPricing": + case "pricing": if in.IsNull() { in.Skip() } else { @@ -1834,7 +1834,7 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(out * first := true _ = first { - const prefix string = ",\"futuresPricing\":" + const prefix string = ",\"pricing\":" out.RawString(prefix[1:]) if in.Pricing == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) diff --git a/marketdata/stream/client_test.go b/marketdata/stream/client_test.go index 91d9249..34b87a8 100644 --- a/marketdata/stream/client_test.go +++ b/marketdata/stream/client_test.go @@ -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) diff --git a/marketdata/stream/options.go b/marketdata/stream/options.go index cda96d7..938c6b1 100644 --- a/marketdata/stream/options.go +++ b/marketdata/stream/options.go @@ -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 }) } diff --git a/marketdata/stream/subscription.go b/marketdata/stream/subscription.go index 338fbd5..bc574d6 100644 --- a/marketdata/stream/subscription.go +++ b/marketdata/stream/subscription.go @@ -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 { @@ -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 { @@ -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 @@ -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. }) }