diff --git a/examples/crypto-perp-stream/crypto_stream.go b/examples/crypto-perp-stream/crypto_stream.go index a8c0536..d6bf9f2 100644 --- a/examples/crypto-perp-stream/crypto_stream.go +++ b/examples/crypto-perp-stream/crypto_stream.go @@ -14,28 +14,27 @@ func main() { baseURL := "ws://stream.data.alpaca.markets/v1beta1/crypto-perps" - // Creating a client that connects to iex - c := stream.NewCryptoPerpsClient( + c := stream.NewCryptoPerpClient( marketdata.GLOBAL, stream.WithLogger(stream.DefaultLogger()), stream.WithBaseURL(baseURL), // Set the base URL // configuring initial subscriptions and handlers - stream.WithCryptoPerpsTrades(func(ct stream.CryptoPerpsTrade) { + stream.WithCryptoPerpTrades(func(ct stream.CryptoPerpTrade) { fmt.Printf("TRADE: %+v\n", ct) }, "BTC-PERP"), - stream.WithCryptoPerpsQuotes(func(cq stream.CryptoPerpsQuote) { + stream.WithCryptoPerpQuotes(func(cq stream.CryptoPerpQuote) { fmt.Printf("QUOTE: %+v\n", cq) }, "BTC-PERP"), - stream.WithCryptoPerpsOrderbooks(func(cob stream.CryptoPerpsOrderbook) { + stream.WithCryptoPerpOrderbooks(func(cob stream.CryptoPerpOrderbook) { fmt.Printf("ORDERBOOK: %+v\n", cob) }, "BTC-PERP"), - stream.WithCryptoPerpsBars(func(cb stream.CryptoPerpsBar) { + stream.WithCryptoPerpBars(func(cb stream.CryptoPerpBar) { fmt.Printf("BAR: %+v\n", cb) }, "BTC-PERP"), - stream.WithCryptoPerpsUpdatedBars(func(cb stream.CryptoPerpsBar) { + stream.WithCryptoPerpUpdatedBars(func(cb stream.CryptoPerpBar) { fmt.Printf("UPDATED BAR: %+v\n", cb) }, "BTC-PERP"), - stream.WithCryptoPerpsDailyBars(func(cb stream.CryptoPerpsBar) { + stream.WithCryptoPerpDailyBars(func(cb stream.CryptoPerpBar) { fmt.Printf("DAILY BAR: %+v\n", cb) }, "BTC-PERP"), ) diff --git a/examples/marketdata/marketdata.go b/examples/marketdata/marketdata.go index e83c8ab..ad65f92 100644 --- a/examples/marketdata/marketdata.go +++ b/examples/marketdata/marketdata.go @@ -124,8 +124,8 @@ func cryptoQuote() { fmt.Println() } -func cryptoPerpsQuote() { - quote, err := marketdata.GetLatestCryptoPerpsQuote("BTC-PERP", marketdata.GetLatestCryptoQuoteRequest{}) +func cryptoPerpQuote() { + quote, err := marketdata.GetLatestCryptoPerpQuote("BTC-PERP", marketdata.GetLatestCryptoQuoteRequest{}) if err != nil { panic(err) } @@ -133,8 +133,8 @@ func cryptoPerpsQuote() { fmt.Println() } -func cryptoPerpsTrade() { - trade, err := marketdata.GetLatestCryptoPerpsTrade("BTC-PERP", marketdata.GetLatestCryptoTradeRequest{}) +func cryptoPerpTrade() { + trade, err := marketdata.GetLatestCryptoPerpTrade("BTC-PERP", marketdata.GetLatestCryptoTradeRequest{}) if err != nil { panic(err) } @@ -142,8 +142,8 @@ func cryptoPerpsTrade() { fmt.Println() } -func cryptoPerpsBar() { - trade, err := marketdata.GetLatestCryptoPerpsBar("BTC-PERP", marketdata.GetLatestCryptoBarRequest{}) +func cryptoPerpBar() { + trade, err := marketdata.GetLatestCryptoPerpBar("BTC-PERP", marketdata.GetLatestCryptoBarRequest{}) if err != nil { panic(err) } @@ -236,16 +236,16 @@ func main() { {Name: "news", Func: news}, {Name: "auctions", Func: auctions}, {Name: "crypto_quote", Func: cryptoQuote}, - {Name: "crypto_perp_quote", Func: cryptoPerpsQuote}, - {Name: "crypto_perp_trade", Func: cryptoPerpsTrade}, - {Name: "crypto_perp_bar", Func: cryptoPerpsBar}, + {Name: "crypto_perp_quote", Func: cryptoPerpQuote}, + {Name: "crypto_perp_trade", Func: cryptoPerpTrade}, + {Name: "crypto_perp_bar", Func: cryptoPerpBar}, {Name: "option_chain", Func: optionChain}, {Name: "corporate_actions", Func: corporateActions}, } for { fmt.Println("Examples: ") for i, e := range examples { - fmt.Printf("[ %d ] %s\n", i, e.Name) + fmt.Printf("[ %2d ] %s\n", i, e.Name) } fmt.Print("Please type the number of the example you'd like to run or q to exit: ") r := bufio.NewReader(os.Stdin) diff --git a/marketdata/entities.go b/marketdata/entities.go index d7337c2..80c210c 100644 --- a/marketdata/entities.go +++ b/marketdata/entities.go @@ -209,10 +209,10 @@ type CryptoSnapshot struct { PrevDailyBar *CryptoBar `json:"prevDailyBar"` } -type CryptoPerpsTrade CryptoTrade -type CryptoPerpsQuote CryptoQuote -type CryptoPerpsBar CryptoBar -type CryptoPerpsSnapshot CryptoSnapshot +type CryptoPerpTrade CryptoTrade +type CryptoPerpQuote CryptoQuote +type CryptoPerpBar CryptoBar +type CryptoPerpSnapshot CryptoSnapshot // CryptoSnapshots is the snapshots for multiple crypto symbols type CryptoSnapshots struct { diff --git a/marketdata/rest.go b/marketdata/rest.go index eb8d6e4..5428ea6 100644 --- a/marketdata/rest.go +++ b/marketdata/rest.go @@ -44,11 +44,6 @@ type ClientOpts struct { RequestHost string } -type request interface { - cryptoFeed() CryptoFeed - isPerp() bool -} - // Client is the alpaca marketdata Client. type Client struct { opts ClientOpts @@ -777,44 +772,6 @@ func (c *Client) GetCryptoTrades(symbol string, req GetCryptoTradesRequest) ([]C return resp[symbol], nil } -// GetCryptoPerpsTrades returns the trades for the given crypto perpetual futures symbol. -func (c *Client) GetCryptoPerpsTrades(symbol string, req GetCryptoTradesRequest) ([]CryptoPerpsTrade, error) { - req.perpetualFutures = true - - trades, err := c.GetCryptoTrades(symbol, req) - if err != nil { - return nil, err - } - - perpsTrades := make([]CryptoPerpsTrade, len(trades)) - for i, trade := range trades { - perpsTrades[i] = CryptoPerpsTrade(trade) - } - - return perpsTrades, nil -} - -// GetCryptoPerpsMultiTrades returns trades for the given crypto perpetual futures symbols. -func (c *Client) GetCryptoPerpsMultiTrades(symbols []string, req GetCryptoTradesRequest) (map[string][]CryptoPerpsTrade, error) { - req.perpetualFutures = true - - trades, err := c.GetCryptoMultiTrades(symbols, req) - if err != nil { - return nil, err - } - - perpsTrades := make(map[string][]CryptoPerpsTrade, len(trades)) - for symbol, tradeList := range trades { - perpsTradeList := make([]CryptoPerpsTrade, len(tradeList)) - for i, trade := range tradeList { - perpsTradeList[i] = CryptoPerpsTrade(trade) - } - perpsTrades[symbol] = perpsTradeList - } - - return perpsTrades, nil -} - // GetCryptoMultiTrades returns trades for the given crypto symbols. func (c *Client) GetCryptoMultiTrades(symbols []string, req GetCryptoTradesRequest) (map[string][]CryptoTrade, error) { u, err := url.Parse(fmt.Sprintf("%s/trades", c.cryptoURL(req))) @@ -889,43 +846,6 @@ func (c *Client) GetCryptoQuotes(symbol string, req GetCryptoQuotesRequest) ([]C return resp[symbol], nil } -// GetCryptoPerpsQuotes returns the trades for the given crypto perps symbol. -func (c *Client) GetCryptoPerpsQuotes(symbol string, req GetCryptoQuotesRequest) ([]CryptoPerpsQuote, error) { - req.perpetualFutures = true - quotes, err := c.GetCryptoQuotes(symbol, req) - if err != nil { - return nil, err - } - - perpsQuotes := make([]CryptoPerpsQuote, len(quotes)) - for i, quote := range quotes { - perpsQuotes[i] = CryptoPerpsQuote(quote) - } - - return perpsQuotes, nil -} - -// GetCryptoPerpsMultiQuotes returns quotes for the given crypto perps symbols. -func (c *Client) GetCryptoPerpsMultiQuotes(symbols []string, req GetCryptoQuotesRequest) (map[string][]CryptoPerpsQuote, error) { - req.perpetualFutures = true - - quotes, err := c.GetCryptoMultiQuotes(symbols, req) - if err != nil { - return nil, err - } - - perpsQuotes := make(map[string][]CryptoPerpsQuote, len(quotes)) - for symbol, quoteList := range quotes { - perpsQuoteList := make([]CryptoPerpsQuote, len(quoteList)) - for i, quote := range quoteList { - perpsQuoteList[i] = CryptoPerpsQuote(quote) - } - perpsQuotes[symbol] = perpsQuoteList - } - - return perpsQuotes, nil -} - // GetCryptoMultiQuotes returns quotes for the given crypto symbols. func (c *Client) GetCryptoMultiQuotes(symbols []string, req GetCryptoQuotesRequest) (map[string][]CryptoQuote, error) { u, err := url.Parse(fmt.Sprintf("%s/quotes", c.cryptoURL(req))) @@ -1084,24 +1004,25 @@ func (c *Client) cryptoFeed(fromReq string) string { return "us" } -func (c *Client) cryptoURL(fromReq request) string { - return fmt.Sprintf("%s/%s/%s", c.opts.BaseURL, func(p bool) string { - if !p { - return cryptoPrefix - } - return cryptoPerpPrefix - }(fromReq.isPerp()), func(fromReq request) string { - if fromReq.cryptoFeed() != "" { - return fromReq.cryptoFeed() - } - if c.opts.CryptoFeed != "" { - return c.opts.CryptoFeed - } +type cryptoRequest interface { + cryptoFeed() CryptoFeed + isPerp() bool +} + +func (c *Client) cryptoURL(fromReq cryptoRequest) string { + prefix := cryptoPrefix + if fromReq.isPerp() { + prefix = cryptoPerpPrefix + } + feed := fromReq.cryptoFeed() + if feed == "" { if fromReq.isPerp() { - return "global" + feed = GLOBAL + } else { + feed = US } - return "us" - }(fromReq)) + } + return fmt.Sprintf("%s/%s/%s", c.opts.BaseURL, prefix, feed) } // GetLatestCryptoBar returns the latest bar for a given crypto symbol @@ -1117,8 +1038,8 @@ func (c *Client) GetLatestCryptoBar(symbol string, req GetLatestCryptoBarRequest return &bar, nil } -// GetLatestCryptoPerpsBar returns the latest bar for a given crypto symbol -func (c *Client) GetLatestCryptoPerpsBar(symbol string, req GetLatestCryptoBarRequest) (*CryptoPerpsBar, error) { +// GetLatestCryptoPerpBar returns the latest bar for a given crypto perpetual future +func (c *Client) GetLatestCryptoPerpBar(symbol string, req GetLatestCryptoBarRequest) (*CryptoPerpBar, error) { req.perpetualFutures = true latestBar, err := c.GetLatestCryptoBars([]string{symbol}, req) @@ -1129,10 +1050,28 @@ func (c *Client) GetLatestCryptoPerpsBar(symbol string, req GetLatestCryptoBarRe if !ok { return nil, nil } - perpsBar := CryptoPerpsBar(bar) + perpsBar := CryptoPerpBar(bar) return &perpsBar, nil } +// GetLatestCryptoPerpBars returns the latest bars for the given crypto perpetual futures +func (c *Client) GetLatestCryptoPerpBars( + symbols []string, req GetLatestCryptoBarRequest, +) (map[string]CryptoPerpBar, error) { + req.perpetualFutures = true + + bars, err := c.GetLatestCryptoBars(symbols, req) + if err != nil { + return nil, err + } + perpsBars := make(map[string]CryptoPerpBar, len(bars)) + for symbol, bar := range perpsBars { + perpsBars[symbol] = CryptoPerpBar(bar) + } + + return perpsBars, nil +} + // GetLatestCryptoBars returns the latest bars for the given crypto symbols func (c *Client) GetLatestCryptoBars(symbols []string, req GetLatestCryptoBarRequest) (map[string]CryptoBar, error) { u, err := url.Parse(fmt.Sprintf("%s/latest/bars", c.cryptoURL(req))) @@ -1178,8 +1117,8 @@ func (c *Client) GetLatestCryptoTrade(symbol string, req GetLatestCryptoTradeReq return &trade, nil } -// GetLatestCryptoPerpsTrade returns the latest trade for a given crypto perp symbol -func (c *Client) GetLatestCryptoPerpsTrade(symbol string, req GetLatestCryptoTradeRequest) (*CryptoPerpsTrade, error) { +// GetLatestCryptoPerpTrade returns the latest trade for a given crypto perp symbol +func (c *Client) GetLatestCryptoPerpTrade(symbol string, req GetLatestCryptoTradeRequest) (*CryptoPerpTrade, error) { req.perpetualFutures = true latestTrade, err := c.GetLatestCryptoTrade(symbol, req) @@ -1187,14 +1126,14 @@ func (c *Client) GetLatestCryptoPerpsTrade(symbol string, req GetLatestCryptoTra return nil, err } - perpsTrade := CryptoPerpsTrade(*latestTrade) + perpsTrade := CryptoPerpTrade(*latestTrade) return &perpsTrade, nil } -// GetLatestCryptoPerpsTrades returns the latest trades for the given crypto perp symbols -func (c *Client) GetLatestCryptoPerpsTrades( +// GetLatestCryptoPerpTrades returns the latest trades for the given crypto perpetual futures +func (c *Client) GetLatestCryptoPerpTrades( symbols []string, req GetLatestCryptoTradeRequest, -) (map[string]CryptoPerpsTrade, error) { +) (map[string]CryptoPerpTrade, error) { req.perpetualFutures = true trades, err := c.GetLatestCryptoTrades(symbols, req) @@ -1202,9 +1141,9 @@ func (c *Client) GetLatestCryptoPerpsTrades( return nil, err } - perpsTrades := make(map[string]CryptoPerpsTrade, len(trades)) + perpsTrades := make(map[string]CryptoPerpTrade, len(trades)) for symbol, trade := range trades { - perpsTrades[symbol] = CryptoPerpsTrade(trade) + perpsTrades[symbol] = CryptoPerpTrade(trade) } return perpsTrades, nil @@ -1257,8 +1196,8 @@ func (c *Client) GetLatestCryptoQuote(symbol string, req GetLatestCryptoQuoteReq return "e, nil } -// GetLatestCryptoPerpsQuote returns the latest quote for a given crypto perp symbol -func (c *Client) GetLatestCryptoPerpsQuote(symbol string, req GetLatestCryptoQuoteRequest) (*CryptoPerpsQuote, error) { +// GetLatestCryptoPerpQuote returns the latest quote for a given crypto perp symbol +func (c *Client) GetLatestCryptoPerpQuote(symbol string, req GetLatestCryptoQuoteRequest) (*CryptoPerpQuote, error) { req.perpetualFutures = true latestQuote, err := c.GetLatestCryptoQuote(symbol, req) @@ -1266,14 +1205,14 @@ func (c *Client) GetLatestCryptoPerpsQuote(symbol string, req GetLatestCryptoQuo return nil, err } - perpsQuote := CryptoPerpsQuote(*latestQuote) + perpsQuote := CryptoPerpQuote(*latestQuote) return &perpsQuote, nil } -// GetLatestCryptoPerpsQuotes returns the latest quotes for the given crypto perps symbols -func (c *Client) GetLatestCryptoPerpsQuotes( +// GetLatestCryptoPerpQuotes returns the latest quotes for the given crypto perpetual futures +func (c *Client) GetLatestCryptoPerpQuotes( symbols []string, req GetLatestCryptoQuoteRequest, -) (map[string]CryptoPerpsQuote, error) { +) (map[string]CryptoPerpQuote, error) { req.perpetualFutures = true quotes, err := c.GetLatestCryptoQuotes(symbols, req) @@ -1281,9 +1220,9 @@ func (c *Client) GetLatestCryptoPerpsQuotes( return nil, err } - perpsQuotes := make(map[string]CryptoPerpsQuote, len(quotes)) + perpsQuotes := make(map[string]CryptoPerpQuote, len(quotes)) for symbol, quote := range quotes { - perpsQuotes[symbol] = CryptoPerpsQuote(quote) + perpsQuotes[symbol] = CryptoPerpQuote(quote) } return perpsQuotes, nil @@ -1337,36 +1276,6 @@ func (c *Client) GetCryptoSnapshot(symbol string, req GetCryptoSnapshotRequest) return &snapshot, nil } -// GetCryptoPerpsSnapshot returns the snapshot for a given crypto perps symbol -func (c *Client) GetCryptoPerpsSnapshot(symbol string, req GetCryptoSnapshotRequest) (*CryptoPerpsSnapshot, error) { - req.perpetualFutures = true - - snapshot, err := c.GetCryptoSnapshot(symbol, req) - if err != nil { - return nil, err - } - - perpsSnapshot := CryptoPerpsSnapshot(*snapshot) - return &perpsSnapshot, nil -} - -// GetCryptoPerpsSnapshots returns the snapshots for the given crypto perps symbols -func (c *Client) GetCryptoPerpsSnapshots(symbols []string, req GetCryptoSnapshotRequest) (map[string]CryptoPerpsSnapshot, error) { - req.perpetualFutures = true - - snapshots, err := c.GetCryptoSnapshots(symbols, req) - if err != nil { - return nil, err - } - - perpsSnapshots := make(map[string]CryptoPerpsSnapshot, len(snapshots)) - for symbol, snapshot := range snapshots { - perpsSnapshots[symbol] = CryptoPerpsSnapshot(snapshot) - } - - return perpsSnapshots, nil -} - // GetCryptoSnapshots returns the snapshots for the given crypto symbols func (c *Client) GetCryptoSnapshots(symbols []string, req GetCryptoSnapshotRequest) (map[string]CryptoSnapshot, error) { u, err := url.Parse(fmt.Sprintf("%s/snapshots", c.cryptoURL(req))) @@ -1754,39 +1663,29 @@ func GetCryptoSnapshots(symbols []string, req GetCryptoSnapshotRequest) (map[str return DefaultClient.GetCryptoSnapshots(symbols, req) } -// GetLatestCryptoPerpsTrade returns the latest trade for a given crypto perp symbol -func GetLatestCryptoPerpsTrade(symbol string, req GetLatestCryptoTradeRequest) (*CryptoPerpsTrade, error) { - return DefaultClient.GetLatestCryptoPerpsTrade(symbol, req) -} - -// GetLatestCryptoPerpsTrades returns the latest trades for the given crypto perps symbols -func GetLatestCryptoPerpsTrades(symbols []string, req GetLatestCryptoTradeRequest) (map[string]CryptoPerpsTrade, error) { - return DefaultClient.GetLatestCryptoPerpsTrades(symbols, req) -} - -// GetLatestCryptoPerpsQuote returns the latest quote for a given crypto perps symbol -func GetLatestCryptoPerpsQuote(symbol string, req GetLatestCryptoQuoteRequest) (*CryptoPerpsQuote, error) { - return DefaultClient.GetLatestCryptoPerpsQuote(symbol, req) +// GetLatestCryptoPerpTrade returns the latest trade for a given crypto perp symbol +func GetLatestCryptoPerpTrade(symbol string, req GetLatestCryptoTradeRequest) (*CryptoPerpTrade, error) { + return DefaultClient.GetLatestCryptoPerpTrade(symbol, req) } -// GetLatestCryptoPerpsBar returns the latest bar for a given crypto perps symbol -func GetLatestCryptoPerpsBar(symbol string, req GetLatestCryptoBarRequest) (*CryptoPerpsBar, error) { - return DefaultClient.GetLatestCryptoPerpsBar(symbol, req) +// GetLatestCryptoPerpTrades returns the latest trades for the given crypto perpetual futures +func GetLatestCryptoPerpTrades(symbols []string, req GetLatestCryptoTradeRequest) (map[string]CryptoPerpTrade, error) { + return DefaultClient.GetLatestCryptoPerpTrades(symbols, req) } -// GetLatestCryptoPerpsQuotes returns the latest quotes for the given crypto perps symbols -func GetLatestCryptoPerpsQuotes(symbols []string, req GetLatestCryptoQuoteRequest) (map[string]CryptoPerpsQuote, error) { - return DefaultClient.GetLatestCryptoPerpsQuotes(symbols, req) +// GetLatestCryptoPerpQuote returns the latest quote for a given crypto perpetual future +func GetLatestCryptoPerpQuote(symbol string, req GetLatestCryptoQuoteRequest) (*CryptoPerpQuote, error) { + return DefaultClient.GetLatestCryptoPerpQuote(symbol, req) } -// GetCryptoPerpsSnapshot returns the snapshot for a given crypto symbol -func GetCryptoPerpsSnapshot(symbol string, req GetCryptoSnapshotRequest) (*CryptoPerpsSnapshot, error) { - return DefaultClient.GetCryptoPerpsSnapshot(symbol, req) +// GetLatestCryptoPerpBar returns the latest bar for a given crypto perpetual future +func GetLatestCryptoPerpBar(symbol string, req GetLatestCryptoBarRequest) (*CryptoPerpBar, error) { + return DefaultClient.GetLatestCryptoPerpBar(symbol, req) } -// GetCryptoPerpsSnapshots returns the snapshots for the given crypto symbols -func GetCryptoPerpsSnapshots(symbols []string, req GetCryptoSnapshotRequest) (map[string]CryptoPerpsSnapshot, error) { - return DefaultClient.GetCryptoPerpsSnapshots(symbols, req) +// GetLatestCryptoPerpQuotes returns the latest quotes for the given crypto perpetual futures +func GetLatestCryptoPerpQuotes(symbols []string, req GetLatestCryptoQuoteRequest) (map[string]CryptoPerpQuote, error) { + return DefaultClient.GetLatestCryptoPerpQuotes(symbols, req) } // GetNews returns the news articles based on the given req. diff --git a/marketdata/stream/client.go b/marketdata/stream/client.go index 8bd7623..cf8fd53 100644 --- a/marketdata/stream/client.go +++ b/marketdata/stream/client.go @@ -222,19 +222,15 @@ func (cc *CryptoClient) constructURL() (url.URL, error) { } // This will create a crytpo perpetual futures subscriptions to the Alpaca market data services -type CryptoPerpsClient struct { +type CryptoPerpClient struct { CryptoClient } -// NewCryptoPerpsClient returns a new CryptoPerpsClient that will connect to the crypto perpetual futures feed +// NewCryptoPerpClient returns a new CryptoPerpClient that will connect to the crypto perpetual futures feed // Currently only the marketdata.GLOBAL is supported. // Base URL will be modified to reflect the perpetual endpoint with respect to the crypto endpoint -func NewCryptoPerpsClient(feed marketdata.CryptoFeed, opts ...CryptoOption) *CryptoPerpsClient { - if feed != marketdata.GLOBAL { - return nil - } - - cc := CryptoPerpsClient{} +func NewCryptoPerpClient(feed marketdata.CryptoFeed, opts ...CryptoOption) *CryptoPerpClient { + cc := CryptoPerpClient{} cc.init(feed, opts...) return &cc } diff --git a/marketdata/stream/entities.go b/marketdata/stream/entities.go index 6de7db0..0b09ef5 100644 --- a/marketdata/stream/entities.go +++ b/marketdata/stream/entities.go @@ -142,10 +142,10 @@ type CryptoOrderbookEntry struct { Size float64 } -type CryptoPerpsTrade CryptoTrade -type CryptoPerpsQuote CryptoQuote -type CryptoPerpsBar CryptoBar -type CryptoPerpsOrderbook CryptoOrderbook +type CryptoPerpTrade CryptoTrade +type CryptoPerpQuote CryptoQuote +type CryptoPerpBar CryptoBar +type CryptoPerpOrderbook CryptoOrderbook // OptionTrade is an option trade that happened on the market type OptionTrade struct { diff --git a/marketdata/stream/options.go b/marketdata/stream/options.go index 681215d..c1e74a0 100644 --- a/marketdata/stream/options.go +++ b/marketdata/stream/options.go @@ -434,62 +434,62 @@ func WithCryptoOrderbooks(handler func(CryptoOrderbook), symbols ...string) Cryp }) } -// WithCryptoPerpsTrades configures initial perp trade symbols to subscribe to and the handler -func WithCryptoPerpsTrades(handler func(CryptoPerpsTrade), symbols ...string) CryptoOption { +// WithCryptoPerpTrades configures initial perp trade symbols to subscribe to and the handler +func WithCryptoPerpTrades(handler func(CryptoPerpTrade), symbols ...string) CryptoOption { return newFuncCryptoOption(func(o *cryptoOptions) { o.sub.trades = symbols o.tradeHandler = func(trade CryptoTrade) { - handler(CryptoPerpsTrade(trade)) + handler(CryptoPerpTrade(trade)) } }) } -// WithCryptoPerpsQuotes configures initial perp quote symbols to subscribe to and the handler -func WithCryptoPerpsQuotes(handler func(CryptoPerpsQuote), symbols ...string) CryptoOption { +// WithCryptoPerpQuotes configures initial perp quote symbols to subscribe to and the handler +func WithCryptoPerpQuotes(handler func(CryptoPerpQuote), symbols ...string) CryptoOption { return newFuncCryptoOption(func(o *cryptoOptions) { o.sub.quotes = symbols o.quoteHandler = func(quote CryptoQuote) { - handler(CryptoPerpsQuote(quote)) + handler(CryptoPerpQuote(quote)) } }) } -// WithCryptoPerpsBars configures initial perp bar symbols to subscribe to and the handler -func WithCryptoPerpsBars(handler func(CryptoPerpsBar), symbols ...string) CryptoOption { +// WithCryptoPerpBars configures initial perp bar symbols to subscribe to and the handler +func WithCryptoPerpBars(handler func(CryptoPerpBar), symbols ...string) CryptoOption { return newFuncCryptoOption(func(o *cryptoOptions) { o.sub.bars = symbols o.barHandler = func(bar CryptoBar) { - handler(CryptoPerpsBar(bar)) + handler(CryptoPerpBar(bar)) } }) } -// WithCryptoPerpsUpdatedBars configures updated perp bar symbols to subscribe to and the handler -func WithCryptoPerpsUpdatedBars(handler func(CryptoPerpsBar), symbols ...string) CryptoOption { +// WithCryptoPerpUpdatedBars configures updated perp bar symbols to subscribe to and the handler +func WithCryptoPerpUpdatedBars(handler func(CryptoPerpBar), symbols ...string) CryptoOption { return newFuncCryptoOption(func(o *cryptoOptions) { o.sub.updatedBars = symbols o.updatedBarHandler = func(bar CryptoBar) { - handler(CryptoPerpsBar(bar)) + handler(CryptoPerpBar(bar)) } }) } -// WithCryptoPerpsDailyBars configures daily perp bar symbols to subscribe to and the handler -func WithCryptoPerpsDailyBars(handler func(CryptoPerpsBar), symbols ...string) CryptoOption { +// WithCryptoPerpDailyBars configures daily perp bar symbols to subscribe to and the handler +func WithCryptoPerpDailyBars(handler func(CryptoPerpBar), symbols ...string) CryptoOption { return newFuncCryptoOption(func(o *cryptoOptions) { o.sub.dailyBars = symbols o.dailyBarHandler = func(bar CryptoBar) { - handler(CryptoPerpsBar(bar)) + handler(CryptoPerpBar(bar)) } }) } -// WithCryptoPerpsOrderbooks configures initial perp orderbook symbols to subscribe to and the handler -func WithCryptoPerpsOrderbooks(handler func(CryptoPerpsOrderbook), symbols ...string) CryptoOption { +// WithCryptoPerpOrderbooks configures initial perp orderbook symbols to subscribe to and the handler +func WithCryptoPerpOrderbooks(handler func(CryptoPerpOrderbook), symbols ...string) CryptoOption { return newFuncCryptoOption(func(o *cryptoOptions) { o.sub.orderbooks = symbols o.orderbookHandler = func(ob CryptoOrderbook) { - handler(CryptoPerpsOrderbook(ob)) + handler(CryptoPerpOrderbook(ob)) } }) }