From b36dcba3c31f755c6a1fca02b7adff3d5a5d081b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20Nov=C3=A1k?= Date: Tue, 12 Mar 2024 08:20:07 +0100 Subject: [PATCH] Add marketdata for options (#271) * Add marketdata for options * fix typo and remove unused methods --- examples/marketdata/marketdata.go | 50 + marketdata/entities.go | 67 + marketdata/entities_easyjson.go | 2515 +++++++++++++++++------- marketdata/options.go | 346 ++++ marketdata/options_test.go | 157 ++ marketdata/stream/client.go | 65 +- marketdata/stream/client_test.go | 73 + marketdata/stream/entities.go | 23 + marketdata/stream/entities_easyjson.go | 323 ++- marketdata/stream/message.go | 127 ++ marketdata/stream/message_test.go | 25 + marketdata/stream/options.go | 85 + marketdata/stream/subscription.go | 22 + 13 files changed, 3075 insertions(+), 803 deletions(-) create mode 100644 marketdata/options.go create mode 100644 marketdata/options_test.go diff --git a/examples/marketdata/marketdata.go b/examples/marketdata/marketdata.go index b197428..a6ed22d 100644 --- a/examples/marketdata/marketdata.go +++ b/examples/marketdata/marketdata.go @@ -4,8 +4,10 @@ import ( "bufio" "fmt" "os" + "sort" "strconv" "strings" + "text/tabwriter" "time" "github.com/alpacahq/alpaca-trade-api-go/v3/marketdata" @@ -120,6 +122,53 @@ func cryptoQuote() { fmt.Println() } +func optionChain() { + chain, err := marketdata.GetOptionChain("AAPL", marketdata.GetOptionSnapshotRequest{}) + if err != nil { + panic(err) + } + type snap struct { + marketdata.OptionSnapshot + Symbol string + } + calls, puts := []snap{}, []snap{} + for symbol, snapshot := range chain { + if strings.Contains(symbol, "C") { + calls = append(calls, snap{OptionSnapshot: snapshot, Symbol: symbol}) + } else { + puts = append(puts, snap{OptionSnapshot: snapshot, Symbol: symbol}) + } + } + sort.Slice(calls, func(i, j int) bool { return calls[i].Symbol < calls[j].Symbol }) + sort.Slice(puts, func(i, j int) bool { return puts[i].Symbol < puts[j].Symbol }) + printSnaps := func(snaps []snap) { + tw := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0) + fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n", "Contract name", "Last trade time", "Price", "Bid", "Ask") + for _, s := range snaps { + ts := "" + if s.LatestTrade != nil { + ts = s.LatestTrade.Timestamp.Format(time.RFC3339) + } + price := float64(0) + if s.LatestTrade != nil { + price = s.LatestTrade.Price + } + bid, ask := float64(0), float64(0) + if s.LatestQuote != nil { + bid = s.LatestQuote.BidPrice + ask = s.LatestQuote.AskPrice + } + fmt.Fprintf(tw, "%s\t%s\t%g\t%g\t%g\n", s.Symbol, ts, price, bid, ask) + } + tw.Flush() + } + fmt.Println("CALLS") + printSnaps(calls) + fmt.Println() + fmt.Println("PUTS") + printSnaps(puts) +} + type example struct { Name string Func func() @@ -134,6 +183,7 @@ func main() { {Name: "news", Func: news}, {Name: "auctions", Func: auctions}, {Name: "crypto_quote", Func: cryptoQuote}, + {Name: "option_chain", Func: optionChain}, } for { fmt.Println("Examples: ") diff --git a/marketdata/entities.go b/marketdata/entities.go index 9b097f7..ba7bb8b 100644 --- a/marketdata/entities.go +++ b/marketdata/entities.go @@ -33,6 +33,14 @@ const ( US CryptoFeed = "us" ) +// OptionFeed defines the source feed of option data. +type OptionFeed = string + +const ( + OPRA Feed = "opra" + Indicative Feed = "indicative" +) + // TakerSide is the taker's side: one of B, S or -. B is buy, S is sell and - is unknown. type TakerSide = string @@ -219,6 +227,43 @@ type News struct { Symbols []string `json:"symbols"` } +// OptionTrade is an option trade that happened on the market +type OptionTrade struct { + Timestamp time.Time `json:"t"` + Price float64 `json:"p"` + Size uint32 `json:"s"` + Exchange string `json:"x"` + Condition string `json:"c"` +} + +// OptionBar is an aggregate of option trades +type OptionBar struct { + Timestamp time.Time `json:"t"` + Open float64 `json:"o"` + High float64 `json:"h"` + Low float64 `json:"l"` + Close float64 `json:"c"` + Volume uint64 `json:"v"` + TradeCount uint64 `json:"n"` + VWAP float64 `json:"vw"` +} + +// OptionQuote is an option NBBO (National Best Bid and Offer) +type OptionQuote struct { + Timestamp time.Time `json:"t"` + BidPrice float64 `json:"bp"` + BidSize uint32 `json:"bs"` + BidExchange string `json:"bx"` + AskPrice float64 `json:"ap"` + AskSize uint32 `json:"as"` + AskExchange string `json:"ax"` + Condition string `json:"c"` +} + +type OptionSnapshot struct { + LatestTrade *OptionTrade `json:"latestTrade"` + LatestQuote *OptionQuote `json:"latestQuote"` +} type multiTradeResponse struct { NextPageToken *string `json:"next_page_token"` Trades map[string][]Trade `json:"trades"` @@ -282,3 +327,25 @@ type newsResponse struct { NextPageToken *string `json:"next_page_token"` News []News `json:"news"` } + +type multiOptionTradeResponse struct { + NextPageToken *string `json:"next_page_token"` + Trades map[string][]OptionTrade `json:"trades"` +} + +type multiOptionBarResponse struct { + NextPageToken *string `json:"next_page_token"` + Bars map[string][]OptionBar `json:"bars"` +} + +type latestOptionTradesResponse struct { + Trades map[string]OptionTrade `json:"trades"` +} + +type latestOptionQuotesResponse struct { + Quotes map[string]OptionQuote `json:"quotes"` +} + +type optionSnapshotsResponse struct { + Snapshots map[string]OptionSnapshot `json:"snapshots"` +} diff --git a/marketdata/entities_easyjson.go b/marketdata/entities_easyjson.go index 49fe8b0..76b84b6 100644 --- a/marketdata/entities_easyjson.go +++ b/marketdata/entities_easyjson.go @@ -93,7 +93,103 @@ func (v *snapshotsResponse) UnmarshalJSON(data []byte) error { func (v *snapshotsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(in *jlexer.Lexer, out *newsResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(in *jlexer.Lexer, out *optionSnapshotsResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "snapshots": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Snapshots = make(map[string]OptionSnapshot) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v3 OptionSnapshot + (v3).UnmarshalEasyJSON(in) + (out.Snapshots)[key] = v3 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(out *jwriter.Writer, in optionSnapshotsResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"snapshots\":" + out.RawString(prefix[1:]) + if in.Snapshots == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v4First := true + for v4Name, v4Value := range in.Snapshots { + if v4First { + v4First = false + } else { + out.RawByte(',') + } + out.String(string(v4Name)) + out.RawByte(':') + (v4Value).MarshalEasyJSON(out) + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v optionSnapshotsResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v optionSnapshotsResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *optionSnapshotsResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *optionSnapshotsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(in *jlexer.Lexer, out *newsResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -138,9 +234,9 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(in *jl out.News = (out.News)[:0] } for !in.IsDelim(']') { - var v3 News - (v3).UnmarshalEasyJSON(in) - out.News = append(out.News, v3) + var v5 News + (v5).UnmarshalEasyJSON(in) + out.News = append(out.News, v5) in.WantComma() } in.Delim(']') @@ -155,7 +251,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(out *jwriter.Writer, in newsResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(out *jwriter.Writer, in newsResponse) { out.RawByte('{') first := true _ = first @@ -175,11 +271,11 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(out *j out.RawString("null") } else { out.RawByte('[') - for v4, v5 := range in.News { - if v4 > 0 { + for v6, v7 := range in.News { + if v6 > 0 { out.RawByte(',') } - (v5).MarshalEasyJSON(out) + (v7).MarshalEasyJSON(out) } out.RawByte(']') } @@ -190,27 +286,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(out *j // MarshalJSON supports json.Marshaler interface func (v newsResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v newsResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *newsResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *newsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata1(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(in *jlexer.Lexer, out *multiTradeResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(in *jlexer.Lexer, out *multiTradeResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -248,30 +344,30 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(in *jl for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v6 []Trade + var v8 []Trade if in.IsNull() { in.Skip() - v6 = nil + v8 = nil } else { in.Delim('[') - if v6 == nil { + if v8 == nil { if !in.IsDelim(']') { - v6 = make([]Trade, 0, 0) + v8 = make([]Trade, 0, 0) } else { - v6 = []Trade{} + v8 = []Trade{} } } else { - v6 = (v6)[:0] + v8 = (v8)[:0] } for !in.IsDelim(']') { - var v7 Trade - (v7).UnmarshalEasyJSON(in) - v6 = append(v6, v7) + var v9 Trade + (v9).UnmarshalEasyJSON(in) + v8 = append(v8, v9) in.WantComma() } in.Delim(']') } - (out.Trades)[key] = v6 + (out.Trades)[key] = v8 in.WantComma() } in.Delim('}') @@ -286,7 +382,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(out *jwriter.Writer, in multiTradeResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(out *jwriter.Writer, in multiTradeResponse) { out.RawByte('{') first := true _ = first @@ -306,24 +402,24 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(out *j out.RawString(`null`) } else { out.RawByte('{') - v8First := true - for v8Name, v8Value := range in.Trades { - if v8First { - v8First = false + v10First := true + for v10Name, v10Value := range in.Trades { + if v10First { + v10First = false } else { out.RawByte(',') } - out.String(string(v8Name)) + out.String(string(v10Name)) out.RawByte(':') - if v8Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + if v10Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { out.RawString("null") } else { out.RawByte('[') - for v9, v10 := range v8Value { - if v9 > 0 { + for v11, v12 := range v10Value { + if v11 > 0 { out.RawByte(',') } - (v10).MarshalEasyJSON(out) + (v12).MarshalEasyJSON(out) } out.RawByte(']') } @@ -337,27 +433,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(out *j // MarshalJSON supports json.Marshaler interface func (v multiTradeResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v multiTradeResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *multiTradeResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *multiTradeResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata2(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(in *jlexer.Lexer, out *multiQuoteResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(in *jlexer.Lexer, out *multiQuoteResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -395,30 +491,30 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(in *jl for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v11 []Quote + var v13 []Quote if in.IsNull() { in.Skip() - v11 = nil + v13 = nil } else { in.Delim('[') - if v11 == nil { + if v13 == nil { if !in.IsDelim(']') { - v11 = make([]Quote, 0, 0) + v13 = make([]Quote, 0, 0) } else { - v11 = []Quote{} + v13 = []Quote{} } } else { - v11 = (v11)[:0] + v13 = (v13)[:0] } for !in.IsDelim(']') { - var v12 Quote - (v12).UnmarshalEasyJSON(in) - v11 = append(v11, v12) + var v14 Quote + (v14).UnmarshalEasyJSON(in) + v13 = append(v13, v14) in.WantComma() } in.Delim(']') } - (out.Quotes)[key] = v11 + (out.Quotes)[key] = v13 in.WantComma() } in.Delim('}') @@ -433,7 +529,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(out *jwriter.Writer, in multiQuoteResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(out *jwriter.Writer, in multiQuoteResponse) { out.RawByte('{') first := true _ = first @@ -453,24 +549,24 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(out *j out.RawString(`null`) } else { out.RawByte('{') - v13First := true - for v13Name, v13Value := range in.Quotes { - if v13First { - v13First = false + v15First := true + for v15Name, v15Value := range in.Quotes { + if v15First { + v15First = false } else { out.RawByte(',') } - out.String(string(v13Name)) + out.String(string(v15Name)) out.RawByte(':') - if v13Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + if v15Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { out.RawString("null") } else { out.RawByte('[') - for v14, v15 := range v13Value { - if v14 > 0 { + for v16, v17 := range v15Value { + if v16 > 0 { out.RawByte(',') } - (v15).MarshalEasyJSON(out) + (v17).MarshalEasyJSON(out) } out.RawByte(']') } @@ -484,27 +580,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(out *j // MarshalJSON supports json.Marshaler interface func (v multiQuoteResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v multiQuoteResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *multiQuoteResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *multiQuoteResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata3(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(in *jlexer.Lexer, out *multiBarResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(in *jlexer.Lexer, out *multiOptionTradeResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -533,39 +629,39 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(in *jl } *out.NextPageToken = string(in.String()) } - case "bars": + case "trades": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Bars = make(map[string][]Bar) + out.Trades = make(map[string][]OptionTrade) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v16 []Bar + var v18 []OptionTrade if in.IsNull() { in.Skip() - v16 = nil + v18 = nil } else { in.Delim('[') - if v16 == nil { + if v18 == nil { if !in.IsDelim(']') { - v16 = make([]Bar, 0, 0) + v18 = make([]OptionTrade, 0, 0) } else { - v16 = []Bar{} + v18 = []OptionTrade{} } } else { - v16 = (v16)[:0] + v18 = (v18)[:0] } for !in.IsDelim(']') { - var v17 Bar - (v17).UnmarshalEasyJSON(in) - v16 = append(v16, v17) + var v19 OptionTrade + (v19).UnmarshalEasyJSON(in) + v18 = append(v18, v19) in.WantComma() } in.Delim(']') } - (out.Bars)[key] = v16 + (out.Trades)[key] = v18 in.WantComma() } in.Delim('}') @@ -580,7 +676,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(out *jwriter.Writer, in multiBarResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(out *jwriter.Writer, in multiOptionTradeResponse) { out.RawByte('{') first := true _ = first @@ -594,30 +690,30 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(out *j } } { - const prefix string = ",\"bars\":" + const prefix string = ",\"trades\":" out.RawString(prefix) - if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if in.Trades == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v18First := true - for v18Name, v18Value := range in.Bars { - if v18First { - v18First = false + v20First := true + for v20Name, v20Value := range in.Trades { + if v20First { + v20First = false } else { out.RawByte(',') } - out.String(string(v18Name)) + out.String(string(v20Name)) out.RawByte(':') - if v18Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + if v20Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { out.RawString("null") } else { out.RawByte('[') - for v19, v20 := range v18Value { - if v19 > 0 { + for v21, v22 := range v20Value { + if v21 > 0 { out.RawByte(',') } - (v20).MarshalEasyJSON(out) + (v22).MarshalEasyJSON(out) } out.RawByte(']') } @@ -629,29 +725,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(out *j } // MarshalJSON supports json.Marshaler interface -func (v multiBarResponse) MarshalJSON() ([]byte, error) { +func (v multiOptionTradeResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v multiBarResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(w, v) +func (v multiOptionTradeResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *multiBarResponse) UnmarshalJSON(data []byte) error { +func (v *multiOptionTradeResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *multiBarResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata4(l, v) +func (v *multiOptionTradeResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(in *jlexer.Lexer, out *multiAuctionsResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(in *jlexer.Lexer, out *multiOptionBarResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -680,39 +776,39 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(in *jl } *out.NextPageToken = string(in.String()) } - case "auctions": + case "bars": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Auctions = make(map[string][]DailyAuctions) + out.Bars = make(map[string][]OptionBar) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v21 []DailyAuctions + var v23 []OptionBar if in.IsNull() { in.Skip() - v21 = nil + v23 = nil } else { in.Delim('[') - if v21 == nil { + if v23 == nil { if !in.IsDelim(']') { - v21 = make([]DailyAuctions, 0, 0) + v23 = make([]OptionBar, 0, 0) } else { - v21 = []DailyAuctions{} + v23 = []OptionBar{} } } else { - v21 = (v21)[:0] + v23 = (v23)[:0] } for !in.IsDelim(']') { - var v22 DailyAuctions - (v22).UnmarshalEasyJSON(in) - v21 = append(v21, v22) + var v24 OptionBar + (v24).UnmarshalEasyJSON(in) + v23 = append(v23, v24) in.WantComma() } in.Delim(']') } - (out.Auctions)[key] = v21 + (out.Bars)[key] = v23 in.WantComma() } in.Delim('}') @@ -727,7 +823,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(out *jwriter.Writer, in multiAuctionsResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(out *jwriter.Writer, in multiOptionBarResponse) { out.RawByte('{') first := true _ = first @@ -741,30 +837,30 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(out *j } } { - const prefix string = ",\"auctions\":" + const prefix string = ",\"bars\":" out.RawString(prefix) - if in.Auctions == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v23First := true - for v23Name, v23Value := range in.Auctions { - if v23First { - v23First = false + v25First := true + for v25Name, v25Value := range in.Bars { + if v25First { + v25First = false } else { out.RawByte(',') } - out.String(string(v23Name)) + out.String(string(v25Name)) out.RawByte(':') - if v23Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + if v25Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { out.RawString("null") } else { out.RawByte('[') - for v24, v25 := range v23Value { - if v24 > 0 { + for v26, v27 := range v25Value { + if v26 > 0 { out.RawByte(',') } - (v25).MarshalEasyJSON(out) + (v27).MarshalEasyJSON(out) } out.RawByte(']') } @@ -776,29 +872,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(out *j } // MarshalJSON supports json.Marshaler interface -func (v multiAuctionsResponse) MarshalJSON() ([]byte, error) { +func (v multiOptionBarResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v multiAuctionsResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(w, v) +func (v multiOptionBarResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *multiAuctionsResponse) UnmarshalJSON(data []byte) error { +func (v *multiOptionBarResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *multiAuctionsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata5(l, v) +func (v *multiOptionBarResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(in *jlexer.Lexer, out *latestTradesResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(in *jlexer.Lexer, out *multiBarResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -817,18 +913,49 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(in *jl continue } switch key { - case "trades": + case "next_page_token": + if in.IsNull() { + in.Skip() + out.NextPageToken = nil + } else { + if out.NextPageToken == nil { + out.NextPageToken = new(string) + } + *out.NextPageToken = string(in.String()) + } + case "bars": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Trades = make(map[string]Trade) + out.Bars = make(map[string][]Bar) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v26 Trade - (v26).UnmarshalEasyJSON(in) - (out.Trades)[key] = v26 + var v28 []Bar + if in.IsNull() { + in.Skip() + v28 = nil + } else { + in.Delim('[') + if v28 == nil { + if !in.IsDelim(']') { + v28 = make([]Bar, 0, 0) + } else { + v28 = []Bar{} + } + } else { + v28 = (v28)[:0] + } + for !in.IsDelim(']') { + var v29 Bar + (v29).UnmarshalEasyJSON(in) + v28 = append(v28, v29) + in.WantComma() + } + in.Delim(']') + } + (out.Bars)[key] = v28 in.WantComma() } in.Delim('}') @@ -843,27 +970,47 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(out *jwriter.Writer, in latestTradesResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(out *jwriter.Writer, in multiBarResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"trades\":" + const prefix string = ",\"next_page_token\":" out.RawString(prefix[1:]) - if in.Trades == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if in.NextPageToken == nil { + out.RawString("null") + } else { + out.String(string(*in.NextPageToken)) + } + } + { + const prefix string = ",\"bars\":" + out.RawString(prefix) + if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v27First := true - for v27Name, v27Value := range in.Trades { - if v27First { - v27First = false + v30First := true + for v30Name, v30Value := range in.Bars { + if v30First { + v30First = false } else { out.RawByte(',') } - out.String(string(v27Name)) + out.String(string(v30Name)) out.RawByte(':') - (v27Value).MarshalEasyJSON(out) + if v30Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v31, v32 := range v30Value { + if v31 > 0 { + out.RawByte(',') + } + (v32).MarshalEasyJSON(out) + } + out.RawByte(']') + } } out.RawByte('}') } @@ -872,29 +1019,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(out *j } // MarshalJSON supports json.Marshaler interface -func (v latestTradesResponse) MarshalJSON() ([]byte, error) { +func (v multiBarResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v latestTradesResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(w, v) +func (v multiBarResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *latestTradesResponse) UnmarshalJSON(data []byte) error { +func (v *multiBarResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *latestTradesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata6(l, v) +func (v *multiBarResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(in *jlexer.Lexer, out *latestQuotesResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(in *jlexer.Lexer, out *multiAuctionsResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -913,18 +1060,49 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(in *jl continue } switch key { - case "quotes": + case "next_page_token": + if in.IsNull() { + in.Skip() + out.NextPageToken = nil + } else { + if out.NextPageToken == nil { + out.NextPageToken = new(string) + } + *out.NextPageToken = string(in.String()) + } + case "auctions": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Quotes = make(map[string]Quote) + out.Auctions = make(map[string][]DailyAuctions) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v28 Quote - (v28).UnmarshalEasyJSON(in) - (out.Quotes)[key] = v28 + var v33 []DailyAuctions + if in.IsNull() { + in.Skip() + v33 = nil + } else { + in.Delim('[') + if v33 == nil { + if !in.IsDelim(']') { + v33 = make([]DailyAuctions, 0, 0) + } else { + v33 = []DailyAuctions{} + } + } else { + v33 = (v33)[:0] + } + for !in.IsDelim(']') { + var v34 DailyAuctions + (v34).UnmarshalEasyJSON(in) + v33 = append(v33, v34) + in.WantComma() + } + in.Delim(']') + } + (out.Auctions)[key] = v33 in.WantComma() } in.Delim('}') @@ -939,58 +1117,78 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(out *jwriter.Writer, in latestQuotesResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(out *jwriter.Writer, in multiAuctionsResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"quotes\":" + const prefix string = ",\"next_page_token\":" out.RawString(prefix[1:]) - if in.Quotes == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if in.NextPageToken == nil { + out.RawString("null") + } else { + out.String(string(*in.NextPageToken)) + } + } + { + const prefix string = ",\"auctions\":" + out.RawString(prefix) + if in.Auctions == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v29First := true - for v29Name, v29Value := range in.Quotes { - if v29First { - v29First = false + v35First := true + for v35Name, v35Value := range in.Auctions { + if v35First { + v35First = false } else { out.RawByte(',') } - out.String(string(v29Name)) + out.String(string(v35Name)) out.RawByte(':') - (v29Value).MarshalEasyJSON(out) - } - out.RawByte('}') + if v35Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v36, v37 := range v35Value { + if v36 > 0 { + out.RawByte(',') + } + (v37).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') } } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v latestQuotesResponse) MarshalJSON() ([]byte, error) { +func (v multiAuctionsResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v latestQuotesResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(w, v) +func (v multiAuctionsResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *latestQuotesResponse) UnmarshalJSON(data []byte) error { +func (v *multiAuctionsResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *latestQuotesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata7(l, v) +func (v *multiAuctionsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(in *jlexer.Lexer, out *latestCryptoTradesResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(in *jlexer.Lexer, out *latestTradesResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1014,13 +1212,13 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(in *jl in.Skip() } else { in.Delim('{') - out.Trades = make(map[string]CryptoTrade) + out.Trades = make(map[string]Trade) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v30 CryptoTrade - (v30).UnmarshalEasyJSON(in) - (out.Trades)[key] = v30 + var v38 Trade + (v38).UnmarshalEasyJSON(in) + (out.Trades)[key] = v38 in.WantComma() } in.Delim('}') @@ -1035,7 +1233,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(out *jwriter.Writer, in latestCryptoTradesResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(out *jwriter.Writer, in latestTradesResponse) { out.RawByte('{') first := true _ = first @@ -1046,16 +1244,16 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(out *j out.RawString(`null`) } else { out.RawByte('{') - v31First := true - for v31Name, v31Value := range in.Trades { - if v31First { - v31First = false + v39First := true + for v39Name, v39Value := range in.Trades { + if v39First { + v39First = false } else { out.RawByte(',') } - out.String(string(v31Name)) + out.String(string(v39Name)) out.RawByte(':') - (v31Value).MarshalEasyJSON(out) + (v39Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -1064,29 +1262,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(out *j } // MarshalJSON supports json.Marshaler interface -func (v latestCryptoTradesResponse) MarshalJSON() ([]byte, error) { +func (v latestTradesResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v latestCryptoTradesResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(w, v) +func (v latestTradesResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *latestCryptoTradesResponse) UnmarshalJSON(data []byte) error { +func (v *latestTradesResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *latestCryptoTradesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata8(l, v) +func (v *latestTradesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(in *jlexer.Lexer, out *latestCryptoQuotesResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(in *jlexer.Lexer, out *latestQuotesResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1110,13 +1308,13 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(in *jl in.Skip() } else { in.Delim('{') - out.Quotes = make(map[string]CryptoQuote) + out.Quotes = make(map[string]Quote) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v32 CryptoQuote - (v32).UnmarshalEasyJSON(in) - (out.Quotes)[key] = v32 + var v40 Quote + (v40).UnmarshalEasyJSON(in) + (out.Quotes)[key] = v40 in.WantComma() } in.Delim('}') @@ -1131,7 +1329,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(in *jl in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(out *jwriter.Writer, in latestCryptoQuotesResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(out *jwriter.Writer, in latestQuotesResponse) { out.RawByte('{') first := true _ = first @@ -1142,16 +1340,16 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(out *j out.RawString(`null`) } else { out.RawByte('{') - v33First := true - for v33Name, v33Value := range in.Quotes { - if v33First { - v33First = false + v41First := true + for v41Name, v41Value := range in.Quotes { + if v41First { + v41First = false } else { out.RawByte(',') } - out.String(string(v33Name)) + out.String(string(v41Name)) out.RawByte(':') - (v33Value).MarshalEasyJSON(out) + (v41Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -1160,29 +1358,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(out *j } // MarshalJSON supports json.Marshaler interface -func (v latestCryptoQuotesResponse) MarshalJSON() ([]byte, error) { +func (v latestQuotesResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v latestCryptoQuotesResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(w, v) +func (v latestQuotesResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *latestCryptoQuotesResponse) UnmarshalJSON(data []byte) error { +func (v *latestQuotesResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *latestCryptoQuotesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata9(l, v) +func (v *latestQuotesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(in *jlexer.Lexer, out *latestCryptoBarsResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(in *jlexer.Lexer, out *latestOptionTradesResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1201,18 +1399,18 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(in *j continue } switch key { - case "bars": + case "trades": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Bars = make(map[string]CryptoBar) + out.Trades = make(map[string]OptionTrade) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v34 CryptoBar - (v34).UnmarshalEasyJSON(in) - (out.Bars)[key] = v34 + var v42 OptionTrade + (v42).UnmarshalEasyJSON(in) + (out.Trades)[key] = v42 in.WantComma() } in.Delim('}') @@ -1227,27 +1425,27 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(out *jwriter.Writer, in latestCryptoBarsResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(out *jwriter.Writer, in latestOptionTradesResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"bars\":" + const prefix string = ",\"trades\":" out.RawString(prefix[1:]) - if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if in.Trades == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v35First := true - for v35Name, v35Value := range in.Bars { - if v35First { - v35First = false + v43First := true + for v43Name, v43Value := range in.Trades { + if v43First { + v43First = false } else { out.RawByte(',') } - out.String(string(v35Name)) + out.String(string(v43Name)) out.RawByte(':') - (v35Value).MarshalEasyJSON(out) + (v43Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -1256,29 +1454,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(out * } // MarshalJSON supports json.Marshaler interface -func (v latestCryptoBarsResponse) MarshalJSON() ([]byte, error) { +func (v latestOptionTradesResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v latestCryptoBarsResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(w, v) +func (v latestOptionTradesResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *latestCryptoBarsResponse) UnmarshalJSON(data []byte) error { +func (v *latestOptionTradesResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *latestCryptoBarsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata10(l, v) +func (v *latestOptionTradesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(in *jlexer.Lexer, out *latestBarsResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(in *jlexer.Lexer, out *latestOptionQuotesResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1297,18 +1495,18 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(in *j continue } switch key { - case "bars": + case "quotes": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Bars = make(map[string]Bar) + out.Quotes = make(map[string]OptionQuote) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v36 Bar - (v36).UnmarshalEasyJSON(in) - (out.Bars)[key] = v36 + var v44 OptionQuote + (v44).UnmarshalEasyJSON(in) + (out.Quotes)[key] = v44 in.WantComma() } in.Delim('}') @@ -1323,27 +1521,27 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(out *jwriter.Writer, in latestBarsResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(out *jwriter.Writer, in latestOptionQuotesResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"bars\":" + const prefix string = ",\"quotes\":" out.RawString(prefix[1:]) - if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if in.Quotes == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v37First := true - for v37Name, v37Value := range in.Bars { - if v37First { - v37First = false + v45First := true + for v45Name, v45Value := range in.Quotes { + if v45First { + v45First = false } else { out.RawByte(',') } - out.String(string(v37Name)) + out.String(string(v45Name)) out.RawByte(':') - (v37Value).MarshalEasyJSON(out) + (v45Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -1352,29 +1550,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(out * } // MarshalJSON supports json.Marshaler interface -func (v latestBarsResponse) MarshalJSON() ([]byte, error) { +func (v latestOptionQuotesResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v latestBarsResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(w, v) +func (v latestOptionQuotesResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *latestBarsResponse) UnmarshalJSON(data []byte) error { +func (v *latestOptionQuotesResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *latestBarsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata11(l, v) +func (v *latestOptionQuotesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(in *jlexer.Lexer, out *cryptoMultiTradeResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(in *jlexer.Lexer, out *latestCryptoTradesResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1393,49 +1591,18 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(in *j continue } switch key { - case "next_page_token": - if in.IsNull() { - in.Skip() - out.NextPageToken = nil - } else { - if out.NextPageToken == nil { - out.NextPageToken = new(string) - } - *out.NextPageToken = string(in.String()) - } case "trades": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Trades = make(map[string][]CryptoTrade) + out.Trades = make(map[string]CryptoTrade) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v38 []CryptoTrade - if in.IsNull() { - in.Skip() - v38 = nil - } else { - in.Delim('[') - if v38 == nil { - if !in.IsDelim(']') { - v38 = make([]CryptoTrade, 0, 1) - } else { - v38 = []CryptoTrade{} - } - } else { - v38 = (v38)[:0] - } - for !in.IsDelim(']') { - var v39 CryptoTrade - (v39).UnmarshalEasyJSON(in) - v38 = append(v38, v39) - in.WantComma() - } - in.Delim(']') - } - (out.Trades)[key] = v38 + var v46 CryptoTrade + (v46).UnmarshalEasyJSON(in) + (out.Trades)[key] = v46 in.WantComma() } in.Delim('}') @@ -1450,47 +1617,27 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(out *jwriter.Writer, in cryptoMultiTradeResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(out *jwriter.Writer, in latestCryptoTradesResponse) { out.RawByte('{') first := true _ = first - { - const prefix string = ",\"next_page_token\":" - out.RawString(prefix[1:]) - if in.NextPageToken == nil { - out.RawString("null") - } else { - out.String(string(*in.NextPageToken)) - } - } { const prefix string = ",\"trades\":" - out.RawString(prefix) + out.RawString(prefix[1:]) if in.Trades == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v40First := true - for v40Name, v40Value := range in.Trades { - if v40First { - v40First = false + v47First := true + for v47Name, v47Value := range in.Trades { + if v47First { + v47First = false } else { out.RawByte(',') } - out.String(string(v40Name)) + out.String(string(v47Name)) out.RawByte(':') - if v40Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v41, v42 := range v40Value { - if v41 > 0 { - out.RawByte(',') - } - (v42).MarshalEasyJSON(out) - } - out.RawByte(']') - } + (v47Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -1499,29 +1646,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(out * } // MarshalJSON supports json.Marshaler interface -func (v cryptoMultiTradeResponse) MarshalJSON() ([]byte, error) { +func (v latestCryptoTradesResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v cryptoMultiTradeResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(w, v) +func (v latestCryptoTradesResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *cryptoMultiTradeResponse) UnmarshalJSON(data []byte) error { +func (v *latestCryptoTradesResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *cryptoMultiTradeResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata12(l, v) +func (v *latestCryptoTradesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(in *jlexer.Lexer, out *cryptoMultiQuoteResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(in *jlexer.Lexer, out *latestCryptoQuotesResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1540,49 +1687,18 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(in *j continue } switch key { - case "next_page_token": - if in.IsNull() { - in.Skip() - out.NextPageToken = nil - } else { - if out.NextPageToken == nil { - out.NextPageToken = new(string) - } - *out.NextPageToken = string(in.String()) - } case "quotes": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Quotes = make(map[string][]CryptoQuote) + out.Quotes = make(map[string]CryptoQuote) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v43 []CryptoQuote - if in.IsNull() { - in.Skip() - v43 = nil - } else { - in.Delim('[') - if v43 == nil { - if !in.IsDelim(']') { - v43 = make([]CryptoQuote, 0, 1) - } else { - v43 = []CryptoQuote{} - } - } else { - v43 = (v43)[:0] - } - for !in.IsDelim(']') { - var v44 CryptoQuote - (v44).UnmarshalEasyJSON(in) - v43 = append(v43, v44) - in.WantComma() - } - in.Delim(']') - } - (out.Quotes)[key] = v43 + var v48 CryptoQuote + (v48).UnmarshalEasyJSON(in) + (out.Quotes)[key] = v48 in.WantComma() } in.Delim('}') @@ -1597,47 +1713,27 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(out *jwriter.Writer, in cryptoMultiQuoteResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(out *jwriter.Writer, in latestCryptoQuotesResponse) { out.RawByte('{') first := true _ = first - { - const prefix string = ",\"next_page_token\":" - out.RawString(prefix[1:]) - if in.NextPageToken == nil { - out.RawString("null") - } else { - out.String(string(*in.NextPageToken)) - } - } { const prefix string = ",\"quotes\":" - out.RawString(prefix) + out.RawString(prefix[1:]) if in.Quotes == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v45First := true - for v45Name, v45Value := range in.Quotes { - if v45First { - v45First = false + v49First := true + for v49Name, v49Value := range in.Quotes { + if v49First { + v49First = false } else { out.RawByte(',') } - out.String(string(v45Name)) + out.String(string(v49Name)) out.RawByte(':') - if v45Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v46, v47 := range v45Value { - if v46 > 0 { - out.RawByte(',') - } - (v47).MarshalEasyJSON(out) - } - out.RawByte(']') - } + (v49Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -1646,29 +1742,29 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(out * } // MarshalJSON supports json.Marshaler interface -func (v cryptoMultiQuoteResponse) MarshalJSON() ([]byte, error) { +func (v latestCryptoQuotesResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v cryptoMultiQuoteResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(w, v) +func (v latestCryptoQuotesResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *cryptoMultiQuoteResponse) UnmarshalJSON(data []byte) error { +func (v *latestCryptoQuotesResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *cryptoMultiQuoteResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata13(l, v) +func (v *latestCryptoQuotesResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(in *jlexer.Lexer, out *cryptoMultiBarResponse) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(in *jlexer.Lexer, out *latestCryptoBarsResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1687,52 +1783,910 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(in *j continue } switch key { - case "next_page_token": - if in.IsNull() { - in.Skip() - out.NextPageToken = nil - } else { - if out.NextPageToken == nil { - out.NextPageToken = new(string) - } - *out.NextPageToken = string(in.String()) - } case "bars": if in.IsNull() { in.Skip() } else { in.Delim('{') - out.Bars = make(map[string][]CryptoBar) + out.Bars = make(map[string]CryptoBar) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v48 []CryptoBar - if in.IsNull() { - in.Skip() - v48 = nil - } else { - in.Delim('[') - if v48 == nil { - if !in.IsDelim(']') { - v48 = make([]CryptoBar, 0, 0) - } else { - v48 = []CryptoBar{} + var v50 CryptoBar + (v50).UnmarshalEasyJSON(in) + (out.Bars)[key] = v50 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(out *jwriter.Writer, in latestCryptoBarsResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"bars\":" + out.RawString(prefix[1:]) + if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v51First := true + for v51Name, v51Value := range in.Bars { + if v51First { + v51First = false + } else { + out.RawByte(',') + } + out.String(string(v51Name)) + out.RawByte(':') + (v51Value).MarshalEasyJSON(out) + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v latestCryptoBarsResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v latestCryptoBarsResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *latestCryptoBarsResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *latestCryptoBarsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(in *jlexer.Lexer, out *latestBarsResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "bars": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Bars = make(map[string]Bar) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v52 Bar + (v52).UnmarshalEasyJSON(in) + (out.Bars)[key] = v52 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(out *jwriter.Writer, in latestBarsResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"bars\":" + out.RawString(prefix[1:]) + if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v53First := true + for v53Name, v53Value := range in.Bars { + if v53First { + v53First = false + } else { + out.RawByte(',') + } + out.String(string(v53Name)) + out.RawByte(':') + (v53Value).MarshalEasyJSON(out) + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v latestBarsResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v latestBarsResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *latestBarsResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *latestBarsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(in *jlexer.Lexer, out *cryptoMultiTradeResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "next_page_token": + if in.IsNull() { + in.Skip() + out.NextPageToken = nil + } else { + if out.NextPageToken == nil { + out.NextPageToken = new(string) + } + *out.NextPageToken = string(in.String()) + } + case "trades": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Trades = make(map[string][]CryptoTrade) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v54 []CryptoTrade + if in.IsNull() { + in.Skip() + v54 = nil + } else { + in.Delim('[') + if v54 == nil { + if !in.IsDelim(']') { + v54 = make([]CryptoTrade, 0, 1) + } else { + v54 = []CryptoTrade{} } } else { - v48 = (v48)[:0] + v54 = (v54)[:0] } for !in.IsDelim(']') { - var v49 CryptoBar - (v49).UnmarshalEasyJSON(in) - v48 = append(v48, v49) + var v55 CryptoTrade + (v55).UnmarshalEasyJSON(in) + v54 = append(v54, v55) in.WantComma() } in.Delim(']') } - (out.Bars)[key] = v48 + (out.Trades)[key] = v54 in.WantComma() } - in.Delim('}') + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(out *jwriter.Writer, in cryptoMultiTradeResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"next_page_token\":" + out.RawString(prefix[1:]) + if in.NextPageToken == nil { + out.RawString("null") + } else { + out.String(string(*in.NextPageToken)) + } + } + { + const prefix string = ",\"trades\":" + out.RawString(prefix) + if in.Trades == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v56First := true + for v56Name, v56Value := range in.Trades { + if v56First { + v56First = false + } else { + out.RawByte(',') + } + out.String(string(v56Name)) + out.RawByte(':') + if v56Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v57, v58 := range v56Value { + if v57 > 0 { + out.RawByte(',') + } + (v58).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v cryptoMultiTradeResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v cryptoMultiTradeResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *cryptoMultiTradeResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *cryptoMultiTradeResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(in *jlexer.Lexer, out *cryptoMultiQuoteResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "next_page_token": + if in.IsNull() { + in.Skip() + out.NextPageToken = nil + } else { + if out.NextPageToken == nil { + out.NextPageToken = new(string) + } + *out.NextPageToken = string(in.String()) + } + case "quotes": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Quotes = make(map[string][]CryptoQuote) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v59 []CryptoQuote + if in.IsNull() { + in.Skip() + v59 = nil + } else { + in.Delim('[') + if v59 == nil { + if !in.IsDelim(']') { + v59 = make([]CryptoQuote, 0, 1) + } else { + v59 = []CryptoQuote{} + } + } else { + v59 = (v59)[:0] + } + for !in.IsDelim(']') { + var v60 CryptoQuote + (v60).UnmarshalEasyJSON(in) + v59 = append(v59, v60) + in.WantComma() + } + in.Delim(']') + } + (out.Quotes)[key] = v59 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(out *jwriter.Writer, in cryptoMultiQuoteResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"next_page_token\":" + out.RawString(prefix[1:]) + if in.NextPageToken == nil { + out.RawString("null") + } else { + out.String(string(*in.NextPageToken)) + } + } + { + const prefix string = ",\"quotes\":" + out.RawString(prefix) + if in.Quotes == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v61First := true + for v61Name, v61Value := range in.Quotes { + if v61First { + v61First = false + } else { + out.RawByte(',') + } + out.String(string(v61Name)) + out.RawByte(':') + if v61Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v62, v63 := range v61Value { + if v62 > 0 { + out.RawByte(',') + } + (v63).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v cryptoMultiQuoteResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v cryptoMultiQuoteResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *cryptoMultiQuoteResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *cryptoMultiQuoteResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(in *jlexer.Lexer, out *cryptoMultiBarResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "next_page_token": + if in.IsNull() { + in.Skip() + out.NextPageToken = nil + } else { + if out.NextPageToken == nil { + out.NextPageToken = new(string) + } + *out.NextPageToken = string(in.String()) + } + case "bars": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Bars = make(map[string][]CryptoBar) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v64 []CryptoBar + if in.IsNull() { + in.Skip() + v64 = nil + } else { + in.Delim('[') + if v64 == nil { + if !in.IsDelim(']') { + v64 = make([]CryptoBar, 0, 0) + } else { + v64 = []CryptoBar{} + } + } else { + v64 = (v64)[:0] + } + for !in.IsDelim(']') { + var v65 CryptoBar + (v65).UnmarshalEasyJSON(in) + v64 = append(v64, v65) + in.WantComma() + } + in.Delim(']') + } + (out.Bars)[key] = v64 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(out *jwriter.Writer, in cryptoMultiBarResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"next_page_token\":" + out.RawString(prefix[1:]) + if in.NextPageToken == nil { + out.RawString("null") + } else { + out.String(string(*in.NextPageToken)) + } + } + { + const prefix string = ",\"bars\":" + out.RawString(prefix) + if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v66First := true + for v66Name, v66Value := range in.Bars { + if v66First { + v66First = false + } else { + out.RawByte(',') + } + out.String(string(v66Name)) + out.RawByte(':') + if v66Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v67, v68 := range v66Value { + if v67 > 0 { + out.RawByte(',') + } + (v68).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v cryptoMultiBarResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v cryptoMultiBarResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *cryptoMultiBarResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *cryptoMultiBarResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(in *jlexer.Lexer, out *Trade) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "t": + if data := in.Raw(); in.Ok() { + in.AddError((out.Timestamp).UnmarshalJSON(data)) + } + case "p": + out.Price = float64(in.Float64()) + case "s": + out.Size = uint32(in.Uint32()) + case "x": + out.Exchange = string(in.String()) + case "i": + out.ID = int64(in.Int64()) + case "c": + if in.IsNull() { + in.Skip() + out.Conditions = nil + } else { + in.Delim('[') + if out.Conditions == nil { + if !in.IsDelim(']') { + out.Conditions = make([]string, 0, 4) + } else { + out.Conditions = []string{} + } + } else { + out.Conditions = (out.Conditions)[:0] + } + for !in.IsDelim(']') { + var v69 string + v69 = string(in.String()) + out.Conditions = append(out.Conditions, v69) + in.WantComma() + } + in.Delim(']') + } + case "z": + out.Tape = string(in.String()) + case "u": + out.Update = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(out *jwriter.Writer, in Trade) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"t\":" + out.RawString(prefix[1:]) + out.Raw((in.Timestamp).MarshalJSON()) + } + { + const prefix string = ",\"p\":" + out.RawString(prefix) + out.Float64(float64(in.Price)) + } + { + const prefix string = ",\"s\":" + out.RawString(prefix) + out.Uint32(uint32(in.Size)) + } + { + const prefix string = ",\"x\":" + out.RawString(prefix) + out.String(string(in.Exchange)) + } + { + const prefix string = ",\"i\":" + out.RawString(prefix) + out.Int64(int64(in.ID)) + } + { + const prefix string = ",\"c\":" + out.RawString(prefix) + if in.Conditions == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v70, v71 := range in.Conditions { + if v70 > 0 { + out.RawByte(',') + } + out.String(string(v71)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"z\":" + out.RawString(prefix) + out.String(string(in.Tape)) + } + { + const prefix string = ",\"u\":" + out.RawString(prefix) + out.String(string(in.Update)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Trade) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Trade) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Trade) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Trade) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(in *jlexer.Lexer, out *TimeFrame) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "n": + out.N = int(in.Int()) + case "unit": + out.Unit = TimeFrameUnit(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(out *jwriter.Writer, in TimeFrame) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"n\":" + out.RawString(prefix[1:]) + out.Int(int(in.N)) + } + { + const prefix string = ",\"unit\":" + out.RawString(prefix) + out.String(string(in.Unit)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v TimeFrame) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v TimeFrame) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *TimeFrame) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *TimeFrame) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(in *jlexer.Lexer, out *Snapshot) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "latestTrade": + if in.IsNull() { + in.Skip() + out.LatestTrade = nil + } else { + if out.LatestTrade == nil { + out.LatestTrade = new(Trade) + } + (*out.LatestTrade).UnmarshalEasyJSON(in) + } + case "latestQuote": + if in.IsNull() { + in.Skip() + out.LatestQuote = nil + } else { + if out.LatestQuote == nil { + out.LatestQuote = new(Quote) + } + (*out.LatestQuote).UnmarshalEasyJSON(in) + } + case "minuteBar": + if in.IsNull() { + in.Skip() + out.MinuteBar = nil + } else { + if out.MinuteBar == nil { + out.MinuteBar = new(Bar) + } + (*out.MinuteBar).UnmarshalEasyJSON(in) + } + case "dailyBar": + if in.IsNull() { + in.Skip() + out.DailyBar = nil + } else { + if out.DailyBar == nil { + out.DailyBar = new(Bar) + } + (*out.DailyBar).UnmarshalEasyJSON(in) + } + case "prevDailyBar": + if in.IsNull() { + in.Skip() + out.PrevDailyBar = nil + } else { + if out.PrevDailyBar == nil { + out.PrevDailyBar = new(Bar) + } + (*out.PrevDailyBar).UnmarshalEasyJSON(in) } default: in.SkipRecursive() @@ -1744,78 +2698,82 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(out *jwriter.Writer, in cryptoMultiBarResponse) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(out *jwriter.Writer, in Snapshot) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"next_page_token\":" + const prefix string = ",\"latestTrade\":" out.RawString(prefix[1:]) - if in.NextPageToken == nil { + if in.LatestTrade == nil { out.RawString("null") } else { - out.String(string(*in.NextPageToken)) + (*in.LatestTrade).MarshalEasyJSON(out) } } { - const prefix string = ",\"bars\":" + const prefix string = ",\"latestQuote\":" out.RawString(prefix) - if in.Bars == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { - out.RawString(`null`) + if in.LatestQuote == nil { + out.RawString("null") } else { - out.RawByte('{') - v50First := true - for v50Name, v50Value := range in.Bars { - if v50First { - v50First = false - } else { - out.RawByte(',') - } - out.String(string(v50Name)) - out.RawByte(':') - if v50Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v51, v52 := range v50Value { - if v51 > 0 { - out.RawByte(',') - } - (v52).MarshalEasyJSON(out) - } - out.RawByte(']') - } - } - out.RawByte('}') + (*in.LatestQuote).MarshalEasyJSON(out) + } + } + { + const prefix string = ",\"minuteBar\":" + out.RawString(prefix) + if in.MinuteBar == nil { + out.RawString("null") + } else { + (*in.MinuteBar).MarshalEasyJSON(out) + } + } + { + const prefix string = ",\"dailyBar\":" + out.RawString(prefix) + if in.DailyBar == nil { + out.RawString("null") + } else { + (*in.DailyBar).MarshalEasyJSON(out) + } + } + { + const prefix string = ",\"prevDailyBar\":" + out.RawString(prefix) + if in.PrevDailyBar == nil { + out.RawString("null") + } else { + (*in.PrevDailyBar).MarshalEasyJSON(out) } } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v cryptoMultiBarResponse) MarshalJSON() ([]byte, error) { +func (v Snapshot) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v cryptoMultiBarResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(w, v) +func (v Snapshot) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *cryptoMultiBarResponse) UnmarshalJSON(data []byte) error { +func (v *Snapshot) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *cryptoMultiBarResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata14(l, v) +func (v *Snapshot) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(in *jlexer.Lexer, out *Trade) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(in *jlexer.Lexer, out *Quote) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1838,14 +2796,18 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(in *j if data := in.Raw(); in.Ok() { in.AddError((out.Timestamp).UnmarshalJSON(data)) } - case "p": - out.Price = float64(in.Float64()) - case "s": - out.Size = uint32(in.Uint32()) - case "x": - out.Exchange = string(in.String()) - case "i": - out.ID = int64(in.Int64()) + case "bp": + out.BidPrice = float64(in.Float64()) + case "bs": + out.BidSize = uint32(in.Uint32()) + case "bx": + out.BidExchange = string(in.String()) + case "ap": + out.AskPrice = float64(in.Float64()) + case "as": + out.AskSize = uint32(in.Uint32()) + case "ax": + out.AskExchange = string(in.String()) case "c": if in.IsNull() { in.Skip() @@ -1862,17 +2824,15 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(in *j out.Conditions = (out.Conditions)[:0] } for !in.IsDelim(']') { - var v53 string - v53 = string(in.String()) - out.Conditions = append(out.Conditions, v53) + var v72 string + v72 = string(in.String()) + out.Conditions = append(out.Conditions, v72) in.WantComma() } in.Delim(']') } case "z": out.Tape = string(in.String()) - case "u": - out.Update = string(in.String()) default: in.SkipRecursive() } @@ -1883,7 +2843,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(out *jwriter.Writer, in Trade) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(out *jwriter.Writer, in Quote) { out.RawByte('{') first := true _ = first @@ -1893,24 +2853,34 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(out * out.Raw((in.Timestamp).MarshalJSON()) } { - const prefix string = ",\"p\":" + const prefix string = ",\"bp\":" out.RawString(prefix) - out.Float64(float64(in.Price)) + out.Float64(float64(in.BidPrice)) } { - const prefix string = ",\"s\":" + const prefix string = ",\"bs\":" out.RawString(prefix) - out.Uint32(uint32(in.Size)) + out.Uint32(uint32(in.BidSize)) } { - const prefix string = ",\"x\":" + const prefix string = ",\"bx\":" out.RawString(prefix) - out.String(string(in.Exchange)) + out.String(string(in.BidExchange)) } { - const prefix string = ",\"i\":" + const prefix string = ",\"ap\":" out.RawString(prefix) - out.Int64(int64(in.ID)) + out.Float64(float64(in.AskPrice)) + } + { + const prefix string = ",\"as\":" + out.RawString(prefix) + out.Uint32(uint32(in.AskSize)) + } + { + const prefix string = ",\"ax\":" + out.RawString(prefix) + out.String(string(in.AskExchange)) } { const prefix string = ",\"c\":" @@ -1919,11 +2889,11 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(out * out.RawString("null") } else { out.RawByte('[') - for v54, v55 := range in.Conditions { - if v54 > 0 { + for v73, v74 := range in.Conditions { + if v73 > 0 { out.RawByte(',') } - out.String(string(v55)) + out.String(string(v74)) } out.RawByte(']') } @@ -1933,38 +2903,33 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(out * out.RawString(prefix) out.String(string(in.Tape)) } - { - const prefix string = ",\"u\":" - out.RawString(prefix) - out.String(string(in.Update)) - } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Trade) MarshalJSON() ([]byte, error) { +func (v Quote) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Trade) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(w, v) +func (v Quote) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Trade) UnmarshalJSON(data []byte) error { +func (v *Quote) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Trade) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata15(l, v) +func (v *Quote) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(in *jlexer.Lexer, out *TimeFrame) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(in *jlexer.Lexer, out *OptionTrade) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1983,10 +2948,18 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(in *j continue } switch key { - case "n": - out.N = int(in.Int()) - case "unit": - out.Unit = TimeFrameUnit(in.String()) + case "t": + if data := in.Raw(); in.Ok() { + in.AddError((out.Timestamp).UnmarshalJSON(data)) + } + case "p": + out.Price = float64(in.Float64()) + case "s": + out.Size = uint32(in.Uint32()) + case "x": + out.Exchange = string(in.String()) + case "c": + out.Condition = string(in.String()) default: in.SkipRecursive() } @@ -1997,47 +2970,62 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(out *jwriter.Writer, in TimeFrame) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(out *jwriter.Writer, in OptionTrade) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"n\":" + const prefix string = ",\"t\":" out.RawString(prefix[1:]) - out.Int(int(in.N)) + out.Raw((in.Timestamp).MarshalJSON()) } { - const prefix string = ",\"unit\":" + const prefix string = ",\"p\":" out.RawString(prefix) - out.String(string(in.Unit)) + out.Float64(float64(in.Price)) + } + { + const prefix string = ",\"s\":" + out.RawString(prefix) + out.Uint32(uint32(in.Size)) + } + { + const prefix string = ",\"x\":" + out.RawString(prefix) + out.String(string(in.Exchange)) + } + { + const prefix string = ",\"c\":" + out.RawString(prefix) + out.String(string(in.Condition)) } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v TimeFrame) MarshalJSON() ([]byte, error) { +func (v OptionTrade) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v TimeFrame) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(w, v) +func (v OptionTrade) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *TimeFrame) UnmarshalJSON(data []byte) error { +func (v *OptionTrade) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *TimeFrame) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata16(l, v) +func (v *OptionTrade) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(in *jlexer.Lexer, out *Snapshot) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(in *jlexer.Lexer, out *OptionSnapshot) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2050,61 +3038,31 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(in *j for !in.IsDelim('}') { key := in.UnsafeFieldName(false) in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "latestTrade": - if in.IsNull() { - in.Skip() - out.LatestTrade = nil - } else { - if out.LatestTrade == nil { - out.LatestTrade = new(Trade) - } - (*out.LatestTrade).UnmarshalEasyJSON(in) - } - case "latestQuote": - if in.IsNull() { - in.Skip() - out.LatestQuote = nil - } else { - if out.LatestQuote == nil { - out.LatestQuote = new(Quote) - } - (*out.LatestQuote).UnmarshalEasyJSON(in) - } - case "minuteBar": - if in.IsNull() { - in.Skip() - out.MinuteBar = nil - } else { - if out.MinuteBar == nil { - out.MinuteBar = new(Bar) - } - (*out.MinuteBar).UnmarshalEasyJSON(in) - } - case "dailyBar": + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "latestTrade": if in.IsNull() { in.Skip() - out.DailyBar = nil + out.LatestTrade = nil } else { - if out.DailyBar == nil { - out.DailyBar = new(Bar) + if out.LatestTrade == nil { + out.LatestTrade = new(OptionTrade) } - (*out.DailyBar).UnmarshalEasyJSON(in) + (*out.LatestTrade).UnmarshalEasyJSON(in) } - case "prevDailyBar": + case "latestQuote": if in.IsNull() { in.Skip() - out.PrevDailyBar = nil + out.LatestQuote = nil } else { - if out.PrevDailyBar == nil { - out.PrevDailyBar = new(Bar) + if out.LatestQuote == nil { + out.LatestQuote = new(OptionQuote) } - (*out.PrevDailyBar).UnmarshalEasyJSON(in) + (*out.LatestQuote).UnmarshalEasyJSON(in) } default: in.SkipRecursive() @@ -2116,7 +3074,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(out *jwriter.Writer, in Snapshot) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(out *jwriter.Writer, in OptionSnapshot) { out.RawByte('{') first := true _ = first @@ -2138,60 +3096,33 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(out * (*in.LatestQuote).MarshalEasyJSON(out) } } - { - const prefix string = ",\"minuteBar\":" - out.RawString(prefix) - if in.MinuteBar == nil { - out.RawString("null") - } else { - (*in.MinuteBar).MarshalEasyJSON(out) - } - } - { - const prefix string = ",\"dailyBar\":" - out.RawString(prefix) - if in.DailyBar == nil { - out.RawString("null") - } else { - (*in.DailyBar).MarshalEasyJSON(out) - } - } - { - const prefix string = ",\"prevDailyBar\":" - out.RawString(prefix) - if in.PrevDailyBar == nil { - out.RawString("null") - } else { - (*in.PrevDailyBar).MarshalEasyJSON(out) - } - } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Snapshot) MarshalJSON() ([]byte, error) { +func (v OptionSnapshot) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Snapshot) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(w, v) +func (v OptionSnapshot) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Snapshot) UnmarshalJSON(data []byte) error { +func (v *OptionSnapshot) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Snapshot) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata17(l, v) +func (v *OptionSnapshot) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(in *jlexer.Lexer, out *Quote) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(in *jlexer.Lexer, out *OptionQuote) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2227,30 +3158,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(in *j case "ax": out.AskExchange = string(in.String()) case "c": - if in.IsNull() { - in.Skip() - out.Conditions = nil - } else { - in.Delim('[') - if out.Conditions == nil { - if !in.IsDelim(']') { - out.Conditions = make([]string, 0, 4) - } else { - out.Conditions = []string{} - } - } else { - out.Conditions = (out.Conditions)[:0] - } - for !in.IsDelim(']') { - var v56 string - v56 = string(in.String()) - out.Conditions = append(out.Conditions, v56) - in.WantComma() - } - in.Delim(']') - } - case "z": - out.Tape = string(in.String()) + out.Condition = string(in.String()) default: in.SkipRecursive() } @@ -2261,7 +3169,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(out *jwriter.Writer, in Quote) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(out *jwriter.Writer, in OptionQuote) { out.RawByte('{') first := true _ = first @@ -2303,51 +3211,152 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(out * { const prefix string = ",\"c\":" out.RawString(prefix) - if in.Conditions == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v57, v58 := range in.Conditions { - if v57 > 0 { - out.RawByte(',') - } - out.String(string(v58)) + out.String(string(in.Condition)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v OptionQuote) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v OptionQuote) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *OptionQuote) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *OptionQuote) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(in *jlexer.Lexer, out *OptionBar) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "t": + if data := in.Raw(); in.Ok() { + in.AddError((out.Timestamp).UnmarshalJSON(data)) } - out.RawByte(']') + case "o": + out.Open = float64(in.Float64()) + case "h": + out.High = float64(in.Float64()) + case "l": + out.Low = float64(in.Float64()) + case "c": + out.Close = float64(in.Float64()) + case "v": + out.Volume = uint64(in.Uint64()) + case "n": + out.TradeCount = uint64(in.Uint64()) + case "vw": + out.VWAP = float64(in.Float64()) + default: + in.SkipRecursive() } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(out *jwriter.Writer, in OptionBar) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"t\":" + out.RawString(prefix[1:]) + out.Raw((in.Timestamp).MarshalJSON()) } { - const prefix string = ",\"z\":" + const prefix string = ",\"o\":" out.RawString(prefix) - out.String(string(in.Tape)) + out.Float64(float64(in.Open)) + } + { + const prefix string = ",\"h\":" + out.RawString(prefix) + out.Float64(float64(in.High)) + } + { + const prefix string = ",\"l\":" + out.RawString(prefix) + out.Float64(float64(in.Low)) + } + { + const prefix string = ",\"c\":" + out.RawString(prefix) + out.Float64(float64(in.Close)) + } + { + const prefix string = ",\"v\":" + out.RawString(prefix) + out.Uint64(uint64(in.Volume)) + } + { + const prefix string = ",\"n\":" + out.RawString(prefix) + out.Uint64(uint64(in.TradeCount)) + } + { + const prefix string = ",\"vw\":" + out.RawString(prefix) + out.Float64(float64(in.VWAP)) } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Quote) MarshalJSON() ([]byte, error) { +func (v OptionBar) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Quote) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(w, v) +func (v OptionBar) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Quote) UnmarshalJSON(data []byte) error { +func (v *OptionBar) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Quote) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata18(l, v) +func (v *OptionBar) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(in *jlexer.Lexer, out *NewsImage) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(in *jlexer.Lexer, out *NewsImage) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2380,7 +3389,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(out *jwriter.Writer, in NewsImage) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(out *jwriter.Writer, in NewsImage) { out.RawByte('{') first := true _ = first @@ -2400,27 +3409,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(out * // MarshalJSON supports json.Marshaler interface func (v NewsImage) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v NewsImage) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *NewsImage) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *NewsImage) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata19(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(in *jlexer.Lexer, out *News) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata29(in *jlexer.Lexer, out *News) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2473,9 +3482,9 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(in *j out.Images = (out.Images)[:0] } for !in.IsDelim(']') { - var v59 NewsImage - (v59).UnmarshalEasyJSON(in) - out.Images = append(out.Images, v59) + var v75 NewsImage + (v75).UnmarshalEasyJSON(in) + out.Images = append(out.Images, v75) in.WantComma() } in.Delim(']') @@ -2498,9 +3507,9 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(in *j out.Symbols = (out.Symbols)[:0] } for !in.IsDelim(']') { - var v60 string - v60 = string(in.String()) - out.Symbols = append(out.Symbols, v60) + var v76 string + v76 = string(in.String()) + out.Symbols = append(out.Symbols, v76) in.WantComma() } in.Delim(']') @@ -2515,7 +3524,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(out *jwriter.Writer, in News) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata29(out *jwriter.Writer, in News) { out.RawByte('{') first := true _ = first @@ -2561,11 +3570,11 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(out * out.RawString("null") } else { out.RawByte('[') - for v61, v62 := range in.Images { - if v61 > 0 { + for v77, v78 := range in.Images { + if v77 > 0 { out.RawByte(',') } - (v62).MarshalEasyJSON(out) + (v78).MarshalEasyJSON(out) } out.RawByte(']') } @@ -2582,11 +3591,11 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(out * out.RawString("null") } else { out.RawByte('[') - for v63, v64 := range in.Symbols { - if v63 > 0 { + for v79, v80 := range in.Symbols { + if v79 > 0 { out.RawByte(',') } - out.String(string(v64)) + out.String(string(v80)) } out.RawByte(']') } @@ -2597,27 +3606,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(out * // MarshalJSON supports json.Marshaler interface func (v News) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata29(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v News) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata29(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *News) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata29(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *News) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata20(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata29(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(in *jlexer.Lexer, out *DailyAuctions) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata30(in *jlexer.Lexer, out *DailyAuctions) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2656,9 +3665,9 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(in *j out.Opening = (out.Opening)[:0] } for !in.IsDelim(']') { - var v65 Auction - (v65).UnmarshalEasyJSON(in) - out.Opening = append(out.Opening, v65) + var v81 Auction + (v81).UnmarshalEasyJSON(in) + out.Opening = append(out.Opening, v81) in.WantComma() } in.Delim(']') @@ -2679,9 +3688,9 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(in *j out.Closing = (out.Closing)[:0] } for !in.IsDelim(']') { - var v66 Auction - (v66).UnmarshalEasyJSON(in) - out.Closing = append(out.Closing, v66) + var v82 Auction + (v82).UnmarshalEasyJSON(in) + out.Closing = append(out.Closing, v82) in.WantComma() } in.Delim(']') @@ -2696,7 +3705,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(out *jwriter.Writer, in DailyAuctions) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata30(out *jwriter.Writer, in DailyAuctions) { out.RawByte('{') first := true _ = first @@ -2712,11 +3721,11 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(out * out.RawString("null") } else { out.RawByte('[') - for v67, v68 := range in.Opening { - if v67 > 0 { + for v83, v84 := range in.Opening { + if v83 > 0 { out.RawByte(',') } - (v68).MarshalEasyJSON(out) + (v84).MarshalEasyJSON(out) } out.RawByte(']') } @@ -2728,11 +3737,11 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(out * out.RawString("null") } else { out.RawByte('[') - for v69, v70 := range in.Closing { - if v69 > 0 { + for v85, v86 := range in.Closing { + if v85 > 0 { out.RawByte(',') } - (v70).MarshalEasyJSON(out) + (v86).MarshalEasyJSON(out) } out.RawByte(']') } @@ -2743,27 +3752,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(out * // MarshalJSON supports json.Marshaler interface func (v DailyAuctions) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata30(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DailyAuctions) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata30(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DailyAuctions) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata30(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DailyAuctions) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata21(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata30(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(in *jlexer.Lexer, out *CryptoTrade) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata31(in *jlexer.Lexer, out *CryptoTrade) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2804,7 +3813,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(out *jwriter.Writer, in CryptoTrade) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata31(out *jwriter.Writer, in CryptoTrade) { out.RawByte('{') first := true _ = first @@ -2839,27 +3848,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(out * // MarshalJSON supports json.Marshaler interface func (v CryptoTrade) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata31(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoTrade) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata31(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoTrade) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata31(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoTrade) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata22(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata31(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(in *jlexer.Lexer, out *CryptoSnapshots) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata32(in *jlexer.Lexer, out *CryptoSnapshots) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2887,9 +3896,9 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(in *j for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v71 CryptoSnapshot - (v71).UnmarshalEasyJSON(in) - (out.Snapshots)[key] = v71 + var v87 CryptoSnapshot + (v87).UnmarshalEasyJSON(in) + (out.Snapshots)[key] = v87 in.WantComma() } in.Delim('}') @@ -2904,7 +3913,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(out *jwriter.Writer, in CryptoSnapshots) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata32(out *jwriter.Writer, in CryptoSnapshots) { out.RawByte('{') first := true _ = first @@ -2915,16 +3924,16 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(out * out.RawString(`null`) } else { out.RawByte('{') - v72First := true - for v72Name, v72Value := range in.Snapshots { - if v72First { - v72First = false + v88First := true + for v88Name, v88Value := range in.Snapshots { + if v88First { + v88First = false } else { out.RawByte(',') } - out.String(string(v72Name)) + out.String(string(v88Name)) out.RawByte(':') - (v72Value).MarshalEasyJSON(out) + (v88Value).MarshalEasyJSON(out) } out.RawByte('}') } @@ -2935,27 +3944,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(out * // MarshalJSON supports json.Marshaler interface func (v CryptoSnapshots) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata32(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoSnapshots) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata32(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoSnapshots) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata32(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoSnapshots) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata23(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata32(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(in *jlexer.Lexer, out *CryptoSnapshot) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata33(in *jlexer.Lexer, out *CryptoSnapshot) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3034,7 +4043,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(out *jwriter.Writer, in CryptoSnapshot) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata33(out *jwriter.Writer, in CryptoSnapshot) { out.RawByte('{') first := true _ = first @@ -3089,27 +4098,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(out * // MarshalJSON supports json.Marshaler interface func (v CryptoSnapshot) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata33(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoSnapshot) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata33(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoSnapshot) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata33(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoSnapshot) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata24(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata33(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(in *jlexer.Lexer, out *CryptoQuote) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata34(in *jlexer.Lexer, out *CryptoQuote) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3150,7 +4159,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(out *jwriter.Writer, in CryptoQuote) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata34(out *jwriter.Writer, in CryptoQuote) { out.RawByte('{') first := true _ = first @@ -3185,27 +4194,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(out * // MarshalJSON supports json.Marshaler interface func (v CryptoQuote) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata34(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoQuote) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata34(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoQuote) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata34(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoQuote) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata25(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata34(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(in *jlexer.Lexer, out *CryptoBar) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata35(in *jlexer.Lexer, out *CryptoBar) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3252,7 +4261,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(out *jwriter.Writer, in CryptoBar) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata35(out *jwriter.Writer, in CryptoBar) { out.RawByte('{') first := true _ = first @@ -3302,27 +4311,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(out * // MarshalJSON supports json.Marshaler interface func (v CryptoBar) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata35(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoBar) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata35(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoBar) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata35(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoBar) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata26(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata35(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(in *jlexer.Lexer, out *Bar) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata36(in *jlexer.Lexer, out *Bar) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3369,7 +4378,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(out *jwriter.Writer, in Bar) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata36(out *jwriter.Writer, in Bar) { out.RawByte('{') first := true _ = first @@ -3419,27 +4428,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(out * // MarshalJSON supports json.Marshaler interface func (v Bar) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata36(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Bar) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata36(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Bar) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata36(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Bar) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata27(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata36(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(in *jlexer.Lexer, out *Auction) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata37(in *jlexer.Lexer, out *Auction) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3480,7 +4489,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(in *j in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(out *jwriter.Writer, in Auction) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata37(out *jwriter.Writer, in Auction) { out.RawByte('{') first := true _ = first @@ -3515,23 +4524,23 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(out * // MarshalJSON supports json.Marshaler interface func (v Auction) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata37(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Auction) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata37(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Auction) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata37(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Auction) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata28(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3Marketdata37(l, v) } diff --git a/marketdata/options.go b/marketdata/options.go new file mode 100644 index 0000000..795e8bf --- /dev/null +++ b/marketdata/options.go @@ -0,0 +1,346 @@ +package marketdata + +import ( + "fmt" + "net/url" + "time" +) + +const optionPrefix = "v1beta1/options" + +// GetOptionTradesRequest contains optional parameters for getting option trades. +type GetOptionTradesRequest struct { + // Start is the inclusive beginning of the interval + Start time.Time + // End is the inclusive end of the interval + End time.Time + // TotalLimit is the limit of the total number of the returned trades. + // If missing, all trades between start end end will be returned. + TotalLimit int + // PageLimit is the pagination size. If empty, the default page size will be used. + PageLimit int + // Sort is the sort direction of the data + Sort Sort +} + +// GetOptionTrades returns the option trades for the given symbol. +func (c *Client) GetOptionTrades(symbol string, req GetOptionTradesRequest) ([]OptionTrade, error) { + resp, err := c.GetOptionMultiTrades([]string{symbol}, req) + if err != nil { + return nil, err + } + return resp[symbol], nil +} + +// GetOptionMultiTrades returns option trades for the given symbols. +func (c *Client) GetOptionMultiTrades(symbols []string, req GetOptionTradesRequest) (map[string][]OptionTrade, error) { + u, err := url.Parse(fmt.Sprintf("%s/%s/trades", c.opts.BaseURL, optionPrefix)) + if err != nil { + return nil, err + } + + q := u.Query() + c.setBaseQuery(q, baseRequest{ + Symbols: symbols, + Start: req.Start, + End: req.End, + Sort: req.Sort, + }) + + trades := make(map[string][]OptionTrade, len(symbols)) + received := 0 + for req.TotalLimit == 0 || received < req.TotalLimit { + setQueryLimit(q, req.TotalLimit, req.PageLimit, received, v2MaxLimit) + u.RawQuery = q.Encode() + + resp, err := c.get(u) + if err != nil { + return nil, err + } + + var tradeResp multiOptionTradeResponse + if err = unmarshal(resp, &tradeResp); err != nil { + return nil, err + } + + for symbol, t := range tradeResp.Trades { + trades[symbol] = append(trades[symbol], t...) + received += len(t) + } + if tradeResp.NextPageToken == nil { + break + } + q.Set("page_token", *tradeResp.NextPageToken) + } + return trades, nil +} + +// GetOptionBarsRequest contains optional parameters for getting bars +type GetOptionBarsRequest struct { + // TimeFrame is the aggregation size of the bars + TimeFrame TimeFrame + // Start is the inclusive beginning of the interval + Start time.Time + // End is the inclusive end of the interval + End time.Time + // TotalLimit is the limit of the total number of the returned bars. + // If missing, all bars between start end end will be returned. + TotalLimit int + // PageLimit is the pagination size. If empty, the default page size will be used. + PageLimit int + // Sort is the sort direction of the data + Sort Sort +} + +// GetOptionBars returns a slice of bars for the given symbol. +func (c *Client) GetOptionBars(symbol string, req GetOptionBarsRequest) ([]OptionBar, error) { + resp, err := c.GetMultiOptionBars([]string{symbol}, req) + if err != nil { + return nil, err + } + return resp[symbol], nil +} + +// GetMultiOptionBars returns bars for the given symbols. +func (c *Client) GetMultiOptionBars(symbols []string, req GetOptionBarsRequest) (map[string][]OptionBar, error) { + bars := make(map[string][]OptionBar, len(symbols)) + + u, err := url.Parse(fmt.Sprintf("%s/%s/bars", c.opts.BaseURL, optionPrefix)) + if err != nil { + return nil, err + } + + q := u.Query() + c.setBaseQuery(q, baseRequest{ + Symbols: symbols, + Start: req.Start, + End: req.End, + Sort: req.Sort, + }) + timeframe := OneDay + if req.TimeFrame.N != 0 { + timeframe = req.TimeFrame + } + q.Set("timeframe", timeframe.String()) + + received := 0 + for req.TotalLimit == 0 || received < req.TotalLimit { + setQueryLimit(q, req.TotalLimit, req.PageLimit, received, v2MaxLimit) + u.RawQuery = q.Encode() + + resp, err := c.get(u) + if err != nil { + return nil, err + } + + var barResp multiOptionBarResponse + if err = unmarshal(resp, &barResp); err != nil { + return nil, err + } + + for symbol, b := range barResp.Bars { + bars[symbol] = append(bars[symbol], b...) + received += len(b) + } + if barResp.NextPageToken == nil { + break + } + q.Set("page_token", *barResp.NextPageToken) + } + return bars, nil +} + +type GetLatestOptionTradeRequest struct { + Feed OptionFeed +} + +// GetLatestOptionTrade returns the latest option trade for a given symbol +func (c *Client) GetLatestOptionTrade(symbol string, req GetLatestOptionTradeRequest) (*OptionTrade, error) { + resp, err := c.GetLatestOptionTrades([]string{symbol}, req) + if err != nil { + return nil, err + } + trade, ok := resp[symbol] + if !ok { + return nil, nil + } + return &trade, nil +} + +// GetLatestOptionTrades returns the latest option trades for the given symbols +func (c *Client) GetLatestOptionTrades(symbols []string, req GetLatestOptionTradeRequest) (map[string]OptionTrade, error) { + u, err := url.Parse(fmt.Sprintf("%s/%s/trades/latest", c.opts.BaseURL, optionPrefix)) + if err != nil { + return nil, err + } + c.setLatestQueryRequest(u, baseLatestRequest{ + Symbols: symbols, + Feed: req.Feed, + }) + + resp, err := c.get(u) + if err != nil { + return nil, err + } + + var latestTradesResp latestOptionTradesResponse + if err = unmarshal(resp, &latestTradesResp); err != nil { + return nil, err + } + return latestTradesResp.Trades, nil +} + +type GetLatestOptionQuoteRequest struct { + Feed OptionFeed +} + +// GetLatestOptionQuote returns the latest option quote for a given symbol +func (c *Client) GetLatestOptionQuote(symbol string, req GetLatestOptionQuoteRequest) (*OptionQuote, error) { + resp, err := c.GetLatestOptionQuotes([]string{symbol}, req) + if err != nil { + return nil, err + } + quote, ok := resp[symbol] + if !ok { + return nil, nil + } + return "e, nil +} + +// GetLatestOptionQuotes returns the latest option quotes for the given symbols +func (c *Client) GetLatestOptionQuotes(symbols []string, req GetLatestOptionQuoteRequest) (map[string]OptionQuote, error) { + u, err := url.Parse(fmt.Sprintf("%s/%s/quotes/latest", c.opts.BaseURL, optionPrefix)) + if err != nil { + return nil, err + } + c.setLatestQueryRequest(u, baseLatestRequest{ + Symbols: symbols, + Feed: req.Feed, + }) + + resp, err := c.get(u) + if err != nil { + return nil, err + } + + var latestQuotesResp latestOptionQuotesResponse + if err = unmarshal(resp, &latestQuotesResp); err != nil { + return nil, err + } + return latestQuotesResp.Quotes, nil +} + +type GetOptionSnapshotRequest struct { + Feed OptionFeed +} + +// GetOptionSnapshot returns the snapshot for a given symbol +func (c *Client) GetOptionSnapshot(symbol string, req GetOptionSnapshotRequest) (*OptionSnapshot, error) { + resp, err := c.GetOptionSnapshots([]string{symbol}, req) + if err != nil { + return nil, err + } + snapshot, ok := resp[symbol] + if !ok { + return nil, nil + } + return &snapshot, nil +} + +// GetOptionSnapshots returns the snapshots for multiple symbols +func (c *Client) GetOptionSnapshots(symbols []string, req GetOptionSnapshotRequest) (map[string]OptionSnapshot, error) { + u, err := url.Parse(fmt.Sprintf("%s/%s/snapshots", c.opts.BaseURL, optionPrefix)) + if err != nil { + return nil, err + } + c.setLatestQueryRequest(u, baseLatestRequest{ + Symbols: symbols, + Feed: req.Feed, + }) + + resp, err := c.get(u) + if err != nil { + return nil, err + } + + var snapshots optionSnapshotsResponse + if err = unmarshal(resp, &snapshots); err != nil { + return nil, err + } + return snapshots.Snapshots, nil +} + +// GetOptionChain returns the snapshot chain for an underlying symbol (e.g. AAPL) +func (c *Client) GetOptionChain(underlyingSymbol string, req GetOptionSnapshotRequest) (map[string]OptionSnapshot, error) { + u, err := url.Parse(fmt.Sprintf("%s/%s/snapshots/%s", c.opts.BaseURL, optionPrefix, underlyingSymbol)) + if err != nil { + return nil, err + } + c.setLatestQueryRequest(u, baseLatestRequest{Feed: req.Feed}) + + resp, err := c.get(u) + if err != nil { + return nil, err + } + + var snapshots optionSnapshotsResponse + if err = unmarshal(resp, &snapshots); err != nil { + return nil, err + } + return snapshots.Snapshots, nil +} + +// GetOptionTrades returns the option trades for the given symbol. +func GetOptionTrades(symbol string, req GetOptionTradesRequest) ([]OptionTrade, error) { + return DefaultClient.GetOptionTrades(symbol, req) +} + +// GetOptionMultiTrades returns option trades for the given symbols. +func GetOptionMultiTrades(symbols []string, req GetOptionTradesRequest) (map[string][]OptionTrade, error) { + return DefaultClient.GetOptionMultiTrades(symbols, req) +} + +// GetOptionBars returns a slice of bars for the given symbol. +func GetOptionBars(symbol string, req GetOptionBarsRequest) ([]OptionBar, error) { + return DefaultClient.GetOptionBars(symbol, req) +} + +// GetMultiOptionBars returns bars for the given symbols. +func GetMultiOptionBars(symbols []string, req GetOptionBarsRequest) (map[string][]OptionBar, error) { + return DefaultClient.GetMultiOptionBars(symbols, req) +} + +// GetLatestOptionTrade returns the latest option trade for a given symbol +func GetLatestOptionTrade(symbol string, req GetLatestOptionTradeRequest) (*OptionTrade, error) { + return DefaultClient.GetLatestOptionTrade(symbol, req) +} + +// GetLatestOptionTrades returns the latest option trades for the given symbols +func GetLatestOptionTrades(symbols []string, req GetLatestOptionTradeRequest) (map[string]OptionTrade, error) { + return DefaultClient.GetLatestOptionTrades(symbols, req) +} + +// GetLatestOptionQuote returns the latest option quote for a given symbol +func GetLatestOptionQuote(symbol string, req GetLatestOptionQuoteRequest) (*OptionQuote, error) { + return DefaultClient.GetLatestOptionQuote(symbol, req) +} + +// GetLatestOptionQuotes returns the latest option quotes for the given symbols +func GetLatestOptionQuotes(symbols []string, req GetLatestOptionQuoteRequest) (map[string]OptionQuote, error) { + return DefaultClient.GetLatestOptionQuotes(symbols, req) +} + +// GetOptionSnapshot returns the snapshot for a given symbol +func GetOptionSnapshot(symbol string, req GetOptionSnapshotRequest) (*OptionSnapshot, error) { + return DefaultClient.GetOptionSnapshot(symbol, req) +} + +// GetOptionSnapshots returns the snapshots for multiple symbols +func GetOptionSnapshots(symbols []string, req GetOptionSnapshotRequest) (map[string]OptionSnapshot, error) { + return DefaultClient.GetOptionSnapshots(symbols, req) +} + +// GetOptionChain returns the snapshot chain for an underlying symbol (e.g. AAPL) +func GetOptionChain(underlyingSymbol string, req GetOptionSnapshotRequest) (map[string]OptionSnapshot, error) { + return DefaultClient.GetOptionChain(underlyingSymbol, req) +} diff --git a/marketdata/options_test.go b/marketdata/options_test.go new file mode 100644 index 0000000..f4ef4ca --- /dev/null +++ b/marketdata/options_test.go @@ -0,0 +1,157 @@ +package marketdata + +import ( + "fmt" + "io" + "net/http" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestGetOptionTrades(t *testing.T) { + c := DefaultClient + c.do = func(c *Client, req *http.Request) (*http.Response, error) { + resp := `{"next_page_token":"QUFQTDI0MDMwOEMwMDE3MjUwMHwxNzA5NjU3OTk5MTA5MzE5NDI0fFU=","trades":{"AAPL240308C00172500":[{"c":"g","p":0.98,"s":4,"t":"2024-03-05T16:59:59.816906752Z","x":"C"},{"c":"I","p":0.99,"s":1,"t":"2024-03-05T16:59:59.109319424Z","x":"U"}]}}` //nolint:lll + return &http.Response{ + Body: io.NopCloser(strings.NewReader(resp)), + }, nil + } + got, err := c.GetOptionTrades("AAPL240308C00172500", GetOptionTradesRequest{ + Start: time.Date(2024, 3, 5, 16, 0, 0, 0, time.UTC), + End: time.Date(2024, 3, 5, 17, 0, 0, 0, time.UTC), + TotalLimit: 2, + Sort: SortDesc, + }) + require.NoError(t, err) + require.Len(t, got, 2) + assert.Equal(t, OptionTrade{ + Timestamp: time.Date(2024, 3, 5, 16, 59, 59, 816906752, time.UTC), + Price: 0.98, + Size: 4, + Exchange: "C", + Condition: "g", + }, got[0]) + assert.Equal(t, OptionTrade{ + Timestamp: time.Date(2024, 3, 5, 16, 59, 59, 109319424, time.UTC), + Price: 0.99, + Size: 1, + Exchange: "U", + Condition: "I", + }, got[1]) +} + +func TestGetOptionBars(t *testing.T) { + c := DefaultClient + resp := `{"bars":{"AAPL240308C00172500":[{"c":1.1,"h":1.26,"l":1.1,"n":15,"o":1.23,"t":"2024-03-05T14:00:00Z","v":82,"vw":1.187683},{"c":0.99,"h":1.14,"l":0.83,"n":1545,"o":1,"t":"2024-03-05T15:00:00Z","v":9959,"vw":0.959978},{"c":0.98,"h":1.15,"l":0.85,"n":1075,"o":0.93,"t":"2024-03-05T16:00:00Z","v":7637,"vw":0.965448},{"c":0.97,"h":1.15,"l":0.93,"n":1096,"o":0.99,"t":"2024-03-05T17:00:00Z","v":8483,"vw":1.028201},{"c":0.91,"h":1.1,"l":0.88,"n":903,"o":0.96,"t":"2024-03-05T18:00:00Z","v":7925,"vw":0.96723},{"c":0.9,"h":1,"l":0.88,"n":423,"o":0.9,"t":"2024-03-05T19:00:00Z","v":2895,"vw":0.931516},{"c":0.97,"h":1,"l":0.87,"n":543,"o":0.92,"t":"2024-03-05T20:00:00Z","v":5669,"vw":0.9383}]},"next_page_token":null}` //nolint:lll + c.do = func(c *Client, req *http.Request) (*http.Response, error) { + assert.Equal(t, "/v1beta1/options/bars", req.URL.Path) + assert.Equal(t, "AAPL240308C00172500", req.URL.Query().Get("symbols")) + assert.Equal(t, "2024-03-05T00:00:00Z", req.URL.Query().Get("start")) + assert.Equal(t, "2024-03-06T00:00:00Z", req.URL.Query().Get("end")) + return &http.Response{ + Body: io.NopCloser(strings.NewReader(resp)), + }, nil + } + + got, err := c.GetOptionBars("AAPL240308C00172500", GetOptionBarsRequest{ + TimeFrame: OneDay, + Start: time.Date(2024, 3, 5, 0, 0, 0, 0, time.UTC), + End: time.Date(2024, 3, 6, 0, 0, 0, 0, time.UTC), + }) + require.NoError(t, err) + require.Len(t, got, 7) + for i := 0; i < 7; i++ { + assert.Equal(t, fmt.Sprintf("2024-03-05T%d:00:00Z", 14+i), got[i].Timestamp.Format(time.RFC3339)) + } + assert.EqualValues(t, 1.23, got[0].Open) + assert.EqualValues(t, 1.26, got[0].High) + assert.EqualValues(t, 1.1, got[0].Low) + assert.EqualValues(t, 1.1, got[0].Close) + assert.EqualValues(t, 82, got[0].Volume) + assert.EqualValues(t, 15, got[0].TradeCount) + assert.EqualValues(t, 1.187683, got[0].VWAP) +} + +func TestGetLatestOptionTrade(t *testing.T) { + c := DefaultClient + c.do = mockResp(`{"trades":{"BABA260116P00125000":{"c":"f","p":49.61,"s":1,"t":"2024-02-26T18:23:18.79373184Z","x":"D"}}}`) + got, err := c.GetLatestOptionTrade("BABA260116P00125000", GetLatestOptionTradeRequest{}) + require.NoError(t, err) + require.NotNil(t, got) + assert.Equal(t, OptionTrade{ + Exchange: "D", + Price: 49.61, + Size: 1, + Timestamp: time.Date(2024, 2, 26, 18, 23, 18, 793731840, time.UTC), + Condition: "f", + }, *got) + + c.do = mockResp(`{"trades":{}}`) + got, err = c.GetLatestOptionTrade("BABA260116P00125000", GetLatestOptionTradeRequest{ + Feed: Indicative, + }) + require.NoError(t, err) + assert.Nil(t, got) +} + +func TestGetLatestOptionQuote(t *testing.T) { + c := DefaultClient + c.do = mockResp(`{"quotes":{"SPXW240327P04925000":{"ap":11.7,"as":103,"ax":"C","bp":11.4,"bs":172,"bx":"C","c":"A","t":"2024-03-07T13:54:51.985563136Z"}}}`) + got, err := c.GetLatestOptionQuote("SPXW240327P04925000", GetLatestOptionQuoteRequest{}) + require.NoError(t, err) + require.NotNil(t, got) + assert.Equal(t, OptionQuote{ + BidExchange: "C", + BidPrice: 11.4, + BidSize: 172, + AskExchange: "C", + AskPrice: 11.7, + AskSize: 103, + Timestamp: time.Date(2024, 3, 7, 13, 54, 51, 985563136, time.UTC), + Condition: "A", + }, *got) +} + +func TestGetOptionSnapshot(t *testing.T) { + c := DefaultClient + c.do = mockResp(`{"snapshots":{"SPXW240327P04925000":{"latestQuote":{"ap":11.6,"as":59,"ax":"C","bp":11.3,"bs":180,"bx":"C","c":"A","t":"2024-03-07T13:56:22.278961408Z"},"latestTrade":{"c":"g","p":14.85,"s":2,"t":"2024-03-05T16:36:57.709309696Z","x":"C"}}}}`) + got, err := c.GetOptionSnapshot("SPXW240327P04925000", GetOptionSnapshotRequest{}) + require.NoError(t, err) + require.NotNil(t, got) + assert.Equal(t, OptionQuote{ + BidExchange: "C", + BidPrice: 11.3, + BidSize: 180, + AskExchange: "C", + AskPrice: 11.6, + AskSize: 59, + Timestamp: time.Date(2024, 3, 7, 13, 56, 22, 278961408, time.UTC), + Condition: "A", + }, *got.LatestQuote) + assert.Equal(t, OptionTrade{ + Timestamp: time.Date(2024, 3, 5, 16, 36, 57, 709309696, time.UTC), + Price: 14.85, + Size: 2, + Exchange: "C", + Condition: "g", + }, *got.LatestTrade) +} + +func TestGetOptionChain(t *testing.T) { + defer func() { + DefaultClient = NewClient(ClientOpts{}) + }() + DefaultClient.do = mockResp(`{"snapshots":{"NIO240719P00002000":{"latestQuote":{"ap":1.24,"as":2183,"ax":"A","bp":0.03,"bs":1143,"bx":"A","c":"A","t":"2024-03-06T20:59:05.378523136Z"}},"NIO240405P00004000":{"latestQuote":{"ap":0.05,"as":3041,"ax":"D","bp":0.03,"bs":1726,"bx":"D","c":"C","t":"2024-03-06T20:59:59.678798848Z"},"latestTrade":{"c":"f","p":0.05,"s":17,"t":"2024-03-07T15:53:37.134486784Z","x":"I"}}}}`) //nolint:lll + got, err := GetOptionChain("NIO", GetOptionSnapshotRequest{}) + require.NoError(t, err) + require.NotNil(t, got) + assert.Len(t, got, 2) + assert.Nil(t, got["NIO240719P00002000"].LatestTrade) + assert.Equal(t, 1.24, got["NIO240719P00002000"].LatestQuote.AskPrice) + assert.EqualValues(t, 1726, got["NIO240405P00004000"].LatestQuote.BidSize) + assert.EqualValues(t, 17, got["NIO240405P00004000"].LatestTrade.Size) +} diff --git a/marketdata/stream/client.go b/marketdata/stream/client.go index b7a1bb5..d097ab7 100644 --- a/marketdata/stream/client.go +++ b/marketdata/stream/client.go @@ -65,7 +65,7 @@ func (c *client) configure(o options) { c.connCreator = o.connCreator } -// StocksClient is a client that connects to an Alpaca Data V2 stream server +// StocksClient is a client that connects to the Alpaca stream server // and handles communication both ways. // // After constructing, Connect() must be called before any subscription changes @@ -146,7 +146,7 @@ func constructURL(base, feed string) (url.URL, error) { return url.URL{Scheme: scheme, Host: ub.Host, Path: ub.Path}, nil } -// CryptoClient is a client that connects to an Alpaca Data V2 stream server +// CryptoClient is a client that connects to an Alpaca stream server // and handles communication both ways. // // After constructing, Connect() must be called before any subscription changes @@ -211,6 +211,67 @@ func (cc *CryptoClient) constructURL() (url.URL, error) { return constructURL(cc.baseURL, cc.feed) } +// OptionClient is a client that connects to an Alpaca stream server +// and handles communication both ways. +// +// After constructing, Connect() must be called before any subscription changes +// are called. Connect keeps the connection alive and reestablishes it until +// a configured number of retries has not been exceeded. +// +// Terminated() returns a channel that the client sends an error to when it has terminated. +// A client can not be reused once it has terminated! +// +// SubscribeTo... and UnsubscribeFrom... can be used to modify subscriptions and +// the handler used to process incoming trades/quotes/bars. These block until an +// irrecoverable error occurs or if they succeed. +// +// Note that subscription changes can not be called concurrently. +type OptionClient struct { + *client + + feed marketdata.OptionFeed + handler *optionsMsgHandler +} + +// NewOptionClient returns a new OptionClient that will connect to the option feed +// and whose default configurations are modified by opts. +func NewOptionClient(feed marketdata.OptionFeed, opts ...OptionOption) *OptionClient { + cc := OptionClient{ + client: newClient(), + feed: feed, + handler: &optionsMsgHandler{}, + } + cc.client.handler = cc.handler + o := defaultOptionOptions() + o.applyOption(opts...) + cc.configure(*o) + return &cc +} + +func (cc *OptionClient) configure(o optionOptions) { + cc.client.configure(o.options) + cc.handler.tradeHandler = o.tradeHandler + cc.handler.quoteHandler = o.quoteHandler +} + +// Connect establishes a connection and **reestablishes it when errors occur** +// as long as the configured number of retries has not been exceeded. +// +// It blocks until the connection has been established for the first time (or it failed to do so). +// +// **Should only be called once!** +func (cc *OptionClient) Connect(ctx context.Context) error { + u, err := cc.constructURL() + if err != nil { + return err + } + return cc.connect(ctx, u) +} + +func (cc *OptionClient) constructURL() (url.URL, error) { + return constructURL(cc.baseURL, cc.feed) +} + type NewsClient struct { *client diff --git a/marketdata/stream/client_test.go b/marketdata/stream/client_test.go index f2d533e..3741bcc 100644 --- a/marketdata/stream/client_test.go +++ b/marketdata/stream/client_test.go @@ -1114,6 +1114,79 @@ func TestCoreFunctionalityCrypto(t *testing.T) { } } +func TestCoreFunctionalityOption(t *testing.T) { + connection := newMockConn() + defer connection.close() + const spx1 = "SPXW240308P05120000" + const spx2 = "SPXW240308P05075000" + writeInitialFlowMessagesToConn(t, connection, subscriptions{ + trades: []string{spx1}, + quotes: []string{spx2}, + }) + + trades := make(chan OptionTrade, 10) + quotes := make(chan OptionQuote, 10) + c := NewOptionClient(marketdata.US, + WithOptionTrades(func(t OptionTrade) { trades <- t }, spx1), + WithOptionQuotes(func(q OptionQuote) { quotes <- q }, spx2), + withConnCreator(func(ctx context.Context, u url.URL) (conn, error) { + return connection, nil + })) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + // connecting with the client + err := c.Connect(ctx) + require.NoError(t, err) + + connection.readCh <- serializeToMsgpack(t, []interface{}{ + optionTradeWithT{ + Type: "t", + Symbol: spx1, + Exchange: "C", + Price: 5.06, + Size: 1, + Timestamp: time.Date(2024, 3, 8, 11, 41, 24, 727071744, time.UTC), + Condition: "I", + }, + optionQuoteWithT{ + Type: "q", + Symbol: spx2, + BidExchange: "C", + BidPrice: 0.7, + BidSize: 476, + AskExchange: "C", + AskPrice: 0.8, + AskSize: 921, + Timestamp: time.Date(2024, 3, 8, 12, 3, 19, 245168896, time.UTC), + Condition: "B", + }, + }) + + // checking contents + select { + case trade := <-trades: + assert.Equal(t, spx1, trade.Symbol) + assert.Equal(t, "C", trade.Exchange) + assert.Equal(t, 5.06, trade.Price) + assert.Equal(t, "I", trade.Condition) + case <-time.After(time.Second): + require.Fail(t, "no trade received in time") + } + + select { + case quote := <-quotes: + assert.Equal(t, spx2, quote.Symbol) + assert.EqualValues(t, 0.8, quote.AskPrice) + assert.EqualValues(t, 921, quote.AskSize) + assert.EqualValues(t, 0.7, quote.BidPrice) + assert.EqualValues(t, "C", quote.BidExchange) + assert.Equal(t, "B", quote.Condition) + case <-time.After(time.Second): + require.Fail(t, "no quote received in time") + } +} + func TestCoreFunctionalityNews(t *testing.T) { connection := newMockConn() defer connection.close() diff --git a/marketdata/stream/entities.go b/marketdata/stream/entities.go index f1ca4e8..5845cf3 100644 --- a/marketdata/stream/entities.go +++ b/marketdata/stream/entities.go @@ -166,6 +166,29 @@ type CryptoOrderbookEntry struct { Size float64 } +// OptionTrade is an option trade that happened on the market +type OptionTrade struct { + Symbol string + Exchange string + Price float64 + Size uint32 + Timestamp time.Time + Condition string +} + +// OptionQuote is an option quote from the market +type OptionQuote struct { + Symbol string + BidExchange string + BidPrice float64 + BidSize uint32 + AskExchange string + AskPrice float64 + AskSize uint32 + Timestamp time.Time + Condition string +} + type News struct { ID int Author string diff --git a/marketdata/stream/entities_easyjson.go b/marketdata/stream/entities_easyjson.go index 03fe3a1..370198a 100644 --- a/marketdata/stream/entities_easyjson.go +++ b/marketdata/stream/entities_easyjson.go @@ -960,7 +960,234 @@ func (v *Quote) UnmarshalJSON(data []byte) error { func (v *Quote) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream7(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(in *jlexer.Lexer, out *News) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(in *jlexer.Lexer, out *OptionTrade) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "symbol": + out.Symbol = string(in.String()) + case "exchange": + out.Exchange = string(in.String()) + case "price": + out.Price = float64(in.Float64()) + case "size": + out.Size = uint32(in.Uint32()) + case "timestamp": + if data := in.Raw(); in.Ok() { + in.AddError((out.Timestamp).UnmarshalJSON(data)) + } + case "condition": + out.Condition = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(out *jwriter.Writer, in OptionTrade) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"symbol\":" + out.RawString(prefix[1:]) + out.String(string(in.Symbol)) + } + { + const prefix string = ",\"exchange\":" + out.RawString(prefix) + out.String(string(in.Exchange)) + } + { + const prefix string = ",\"price\":" + out.RawString(prefix) + out.Float64(float64(in.Price)) + } + { + const prefix string = ",\"size\":" + out.RawString(prefix) + out.Uint32(uint32(in.Size)) + } + { + const prefix string = ",\"timestamp\":" + out.RawString(prefix) + out.Raw((in.Timestamp).MarshalJSON()) + } + { + const prefix string = ",\"condition\":" + out.RawString(prefix) + out.String(string(in.Condition)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v OptionTrade) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v OptionTrade) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *OptionTrade) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *OptionTrade) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(in *jlexer.Lexer, out *OptionQuote) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "symbol": + out.Symbol = string(in.String()) + case "bid_exchange": + out.BidExchange = string(in.String()) + case "bid_price": + out.BidPrice = float64(in.Float64()) + case "bid_size": + out.BidSize = uint32(in.Uint32()) + case "ask_exchange": + out.AskExchange = string(in.String()) + case "ask_price": + out.AskPrice = float64(in.Float64()) + case "ask_size": + out.AskSize = uint32(in.Uint32()) + case "timestamp": + if data := in.Raw(); in.Ok() { + in.AddError((out.Timestamp).UnmarshalJSON(data)) + } + case "condition": + out.Condition = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(out *jwriter.Writer, in OptionQuote) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"symbol\":" + out.RawString(prefix[1:]) + out.String(string(in.Symbol)) + } + { + const prefix string = ",\"bid_exchange\":" + out.RawString(prefix) + out.String(string(in.BidExchange)) + } + { + const prefix string = ",\"bid_price\":" + out.RawString(prefix) + out.Float64(float64(in.BidPrice)) + } + { + const prefix string = ",\"bid_size\":" + out.RawString(prefix) + out.Uint32(uint32(in.BidSize)) + } + { + const prefix string = ",\"ask_exchange\":" + out.RawString(prefix) + out.String(string(in.AskExchange)) + } + { + const prefix string = ",\"ask_price\":" + out.RawString(prefix) + out.Float64(float64(in.AskPrice)) + } + { + const prefix string = ",\"ask_size\":" + out.RawString(prefix) + out.Uint32(uint32(in.AskSize)) + } + { + const prefix string = ",\"timestamp\":" + out.RawString(prefix) + out.Raw((in.Timestamp).MarshalJSON()) + } + { + const prefix string = ",\"condition\":" + out.RawString(prefix) + out.String(string(in.Condition)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v OptionQuote) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v OptionQuote) MarshalEasyJSON(w *jwriter.Writer) { + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *OptionQuote) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *OptionQuote) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(l, v) +} +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(in *jlexer.Lexer, out *News) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1032,7 +1259,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8( in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(out *jwriter.Writer, in News) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(out *jwriter.Writer, in News) { out.RawByte('{') first := true _ = first @@ -1098,27 +1325,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8( // MarshalJSON supports json.Marshaler interface func (v News) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v News) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *News) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *News) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream8(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(in *jlexer.Lexer, out *LULD) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(in *jlexer.Lexer, out *LULD) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1161,7 +1388,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9( in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(out *jwriter.Writer, in LULD) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(out *jwriter.Writer, in LULD) { out.RawByte('{') first := true _ = first @@ -1201,27 +1428,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9( // MarshalJSON supports json.Marshaler interface func (v LULD) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v LULD) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *LULD) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *LULD) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream9(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(in *jlexer.Lexer, out *CryptoTrade) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(in *jlexer.Lexer, out *CryptoTrade) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1266,7 +1493,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10 in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(out *jwriter.Writer, in CryptoTrade) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(out *jwriter.Writer, in CryptoTrade) { out.RawByte('{') first := true _ = first @@ -1311,27 +1538,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10 // MarshalJSON supports json.Marshaler interface func (v CryptoTrade) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoTrade) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoTrade) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoTrade) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream10(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(in *jlexer.Lexer, out *CryptoQuote) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(in *jlexer.Lexer, out *CryptoQuote) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1376,7 +1603,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11 in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(out *jwriter.Writer, in CryptoQuote) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(out *jwriter.Writer, in CryptoQuote) { out.RawByte('{') first := true _ = first @@ -1421,27 +1648,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11 // MarshalJSON supports json.Marshaler interface func (v CryptoQuote) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoQuote) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoQuote) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoQuote) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream11(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(in *jlexer.Lexer, out *CryptoOrderbookEntry) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(in *jlexer.Lexer, out *CryptoOrderbookEntry) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1474,7 +1701,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12 in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(out *jwriter.Writer, in CryptoOrderbookEntry) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(out *jwriter.Writer, in CryptoOrderbookEntry) { out.RawByte('{') first := true _ = first @@ -1494,27 +1721,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12 // MarshalJSON supports json.Marshaler interface func (v CryptoOrderbookEntry) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoOrderbookEntry) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoOrderbookEntry) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoOrderbookEntry) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream12(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(in *jlexer.Lexer, out *CryptoOrderbook) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(in *jlexer.Lexer, out *CryptoOrderbook) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1599,7 +1826,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13 in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(out *jwriter.Writer, in CryptoOrderbook) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(out *jwriter.Writer, in CryptoOrderbook) { out.RawByte('{') first := true _ = first @@ -1661,27 +1888,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13 // MarshalJSON supports json.Marshaler interface func (v CryptoOrderbook) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoOrderbook) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoOrderbook) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoOrderbook) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream13(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(in *jlexer.Lexer, out *CryptoBar) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream16(in *jlexer.Lexer, out *CryptoBar) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1732,7 +1959,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14 in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(out *jwriter.Writer, in CryptoBar) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream16(out *jwriter.Writer, in CryptoBar) { out.RawByte('{') first := true _ = first @@ -1792,27 +2019,27 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14 // MarshalJSON supports json.Marshaler interface func (v CryptoBar) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream16(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CryptoBar) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream16(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CryptoBar) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream16(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CryptoBar) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream14(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream16(l, v) } -func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(in *jlexer.Lexer, out *Bar) { +func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream17(in *jlexer.Lexer, out *Bar) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1861,7 +2088,7 @@ func easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15 in.Consumed() } } -func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(out *jwriter.Writer, in Bar) { +func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream17(out *jwriter.Writer, in Bar) { out.RawByte('{') first := true _ = first @@ -1916,23 +2143,23 @@ func easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15 // MarshalJSON supports json.Marshaler interface func (v Bar) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(&w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream17(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Bar) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(w, v) + easyjson3e8ab7adEncodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream17(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Bar) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(&r, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream17(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Bar) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream15(l, v) + easyjson3e8ab7adDecodeGithubComAlpacahqAlpacaTradeApiGoV3MarketdataStream17(l, v) } diff --git a/marketdata/stream/message.go b/marketdata/stream/message.go index a7fb934..9745a6d 100644 --- a/marketdata/stream/message.go +++ b/marketdata/stream/message.go @@ -647,6 +647,133 @@ func (h *cryptoMsgHandler) handleNews(d *msgpack.Decoder, n int) error { return discardMapContents(d, n) } +type optionsMsgHandler struct { + mu sync.RWMutex + tradeHandler func(trade OptionTrade) + quoteHandler func(quote OptionQuote) +} + +var _ msgHandler = (*optionsMsgHandler)(nil) + +func (h *optionsMsgHandler) handleTrade(d *msgpack.Decoder, n int) error { + trade := OptionTrade{} + for i := 0; i < n; i++ { + key, err := d.DecodeString() + if err != nil { + return err + } + switch key { + case "S": + trade.Symbol, err = d.DecodeString() + case "x": + trade.Exchange, err = d.DecodeString() + case "p": + trade.Price, err = d.DecodeFloat64() + case "s": + trade.Size, err = d.DecodeUint32() + case "t": + trade.Timestamp, err = d.DecodeTime() + case "c": + trade.Condition, err = d.DecodeString() + default: + err = d.Skip() + } + if err != nil { + return err + } + } + h.mu.RLock() + tradeHandler := h.tradeHandler + h.mu.RUnlock() + tradeHandler(trade) + return nil +} + +func (h *optionsMsgHandler) handleQuote(d *msgpack.Decoder, n int) error { + quote := OptionQuote{} + for i := 0; i < n; i++ { + key, err := d.DecodeString() + if err != nil { + return err + } + switch key { + case "S": + quote.Symbol, err = d.DecodeString() + case "bx": + quote.BidExchange, err = d.DecodeString() + case "bp": + quote.BidPrice, err = d.DecodeFloat64() + case "bs": + quote.BidSize, err = d.DecodeUint32() + case "ax": + quote.AskExchange, err = d.DecodeString() + case "ap": + quote.AskPrice, err = d.DecodeFloat64() + case "as": + quote.AskSize, err = d.DecodeUint32() + case "t": + quote.Timestamp, err = d.DecodeTime() + case "c": + quote.Condition, err = d.DecodeString() + default: + err = d.Skip() + } + if err != nil { + return err + } + } + h.mu.RLock() + quoteHandler := h.quoteHandler + h.mu.RUnlock() + quoteHandler(quote) + return nil +} + +func (h *optionsMsgHandler) handleBar(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleUpdatedBar(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleDailyBar(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleTradingStatus(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleLULD(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleCancelError(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleCorrection(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleOrderbook(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + +func (h *optionsMsgHandler) handleNews(d *msgpack.Decoder, n int) error { + // should not happen! + return discardMapContents(d, n) +} + type newsMsgHandler struct { mu sync.RWMutex newsHandler func(news News) diff --git a/marketdata/stream/message_test.go b/marketdata/stream/message_test.go index 8021e0c..4dc614a 100644 --- a/marketdata/stream/message_test.go +++ b/marketdata/stream/message_test.go @@ -183,6 +183,31 @@ type cryptoOrderbookEntry struct { Size float64 `msgpack:"s"` } +// optionTradeWithT is the incoming option trade message that also contains the T type key +type optionTradeWithT struct { + Type string `msgpack:"T"` + Symbol string `msgpack:"S"` + Exchange string `msgpack:"x"` + Price float64 `msgpack:"p"` + Size uint32 `msgpack:"s"` + Timestamp time.Time `msgpack:"t"` + Condition string `msgpack:"c"` +} + +// optionQuoteWithT is the incoming option quote message that also contains the T type key +type optionQuoteWithT struct { + Type string `msgpack:"T"` + Symbol string `msgpack:"S"` + BidExchange string `msgpack:"bx"` + BidPrice float64 `msgpack:"bp"` + BidSize uint32 `msgpack:"bs"` + AskExchange string `msgpack:"ax"` + AskPrice float64 `msgpack:"ap"` + AskSize uint32 `msgpack:"as"` + Timestamp time.Time `msgpack:"t"` + Condition string `msgpack:"c"` +} + type newsWithT struct { Type string `msgpack:"T"` ID int `msgpack:"id"` diff --git a/marketdata/stream/options.go b/marketdata/stream/options.go index 56b188b..3839a92 100644 --- a/marketdata/stream/options.go +++ b/marketdata/stream/options.go @@ -17,6 +17,10 @@ type CryptoOption interface { applyCrypto(*cryptoOptions) } +type OptionOption interface { + applyOption(*optionOptions) +} + type NewsOption interface { applyNews(*newsOptions) } @@ -25,6 +29,7 @@ type NewsOption interface { type Option interface { StockOption CryptoOption + OptionOption NewsOption } @@ -57,6 +62,10 @@ func (fo *funcOption) applyStock(o *stockOptions) { fo.f(&o.options) } +func (fo *funcOption) applyOption(o *optionOptions) { + fo.f(&o.options) +} + func (fo *funcOption) applyNews(o *newsOptions) { fo.f(&o.options) } @@ -413,6 +422,82 @@ func WithCryptoOrderbooks(handler func(CryptoOrderbook), symbols ...string) Cryp }) } +type optionOptions struct { + options + tradeHandler func(OptionTrade) + quoteHandler func(OptionQuote) +} + +// defaultOptionOptions are the default options for a client. +// Don't change this in a backward incompatible way! +func defaultOptionOptions() *optionOptions { + // Note that this will probably change to stream.data.alpaca.markets shortly! + baseURL := "https://stream-options.data.alpaca.markets/v1beta1" + // Should this override option be removed? + if s := os.Getenv("DATA_PROXY_WS"); s != "" { + baseURL = s + } + + return &optionOptions{ + options: options{ + logger: DefaultLogger(), + baseURL: baseURL, + key: os.Getenv("APCA_API_KEY_ID"), + secret: os.Getenv("APCA_API_SECRET_KEY"), + reconnectLimit: 20, + reconnectDelay: 150 * time.Millisecond, + processorCount: 1, + bufferSize: 100000, + sub: subscriptions{ + trades: []string{}, + quotes: []string{}, + bars: []string{}, + updatedBars: []string{}, + dailyBars: []string{}, + }, + connCreator: newNhooyrWebsocketConn, + }, + tradeHandler: func(t OptionTrade) {}, + quoteHandler: func(q OptionQuote) {}, + } +} + +func (o *optionOptions) applyOption(opts ...OptionOption) { + for _, opt := range opts { + opt.applyOption(o) + } +} + +type funcOptionOption struct { + f func(*optionOptions) +} + +func (fo *funcOptionOption) applyOption(o *optionOptions) { + fo.f(o) +} + +func newFuncOptionOption(f func(*optionOptions)) *funcOptionOption { + return &funcOptionOption{ + f: f, + } +} + +// WithOptionTrades configures initial trade symbols to subscribe to and the handler +func WithOptionTrades(handler func(OptionTrade), symbols ...string) OptionOption { + return newFuncOptionOption(func(o *optionOptions) { + o.sub.trades = symbols + o.tradeHandler = handler + }) +} + +// WithOptionQuotes configures initial quote symbols to subscribe to and the handler +func WithOptionQuotes(handler func(OptionQuote), symbols ...string) OptionOption { + return newFuncOptionOption(func(o *optionOptions) { + o.sub.quotes = symbols + o.quoteHandler = handler + }) +} + type newsOptions struct { options newsHandler func(News) diff --git a/marketdata/stream/subscription.go b/marketdata/stream/subscription.go index e9fcd7e..5b42634 100644 --- a/marketdata/stream/subscription.go +++ b/marketdata/stream/subscription.go @@ -178,6 +178,28 @@ func (cc *CryptoClient) UnsubscribeFromOrderbooks(symbols ...string) error { return cc.handleSubChange(false, subscriptions{orderbooks: symbols}) } +func (cc *OptionClient) SubscribeToTrades(handler func(OptionTrade), symbols ...string) error { + cc.handler.mu.Lock() + cc.handler.tradeHandler = handler + cc.handler.mu.Unlock() + return cc.client.handleSubChange(true, subscriptions{trades: symbols}) +} + +func (cc *OptionClient) SubscribeToQuotes(handler func(OptionQuote), symbols ...string) error { + cc.handler.mu.Lock() + cc.handler.quoteHandler = handler + cc.handler.mu.Unlock() + return cc.client.handleSubChange(true, subscriptions{quotes: symbols}) +} + +func (cc *OptionClient) UnsubscribeFromTrades(symbols ...string) error { + return cc.handleSubChange(false, subscriptions{trades: symbols}) +} + +func (cc *OptionClient) UnsubscribeFromQuotes(symbols ...string) error { + return cc.handleSubChange(false, subscriptions{quotes: symbols}) +} + func (nc *NewsClient) SubscribeToNews(handler func(News), symbols ...string) error { nc.handler.mu.Lock() nc.handler.newsHandler = handler