github.com/polygon-io/client-go@v1.16.4/rest/models/quotes.go (about) 1 package models 2 3 import "time" 4 5 // ListQuotesParams is the set of parameters for the ListQuotes method. 6 type ListQuotesParams struct { 7 // The ticker symbol to get quotes for. 8 Ticker string `validate:"required" path:"ticker"` 9 10 // Query by timestamp. To query for a specific day instead of a nanosecond timestamp, 11 // set it via this pattern: params.WithDay(2006, 1, 2) // January 2, 2006. 12 TimestampEQ *Nanos `query:"timestamp"` 13 TimestampLT *Nanos `query:"timestamp.lt"` 14 TimestampLTE *Nanos `query:"timestamp.lte"` 15 TimestampGT *Nanos `query:"timestamp.gt"` 16 TimestampGTE *Nanos `query:"timestamp.gte"` 17 18 // Order results based on the sort field. 19 Order *Order `query:"order"` 20 21 // Limit the number of results returned, default is 10 and max is 50000. 22 Limit *int `query:"limit"` 23 24 // Sort field used for ordering. 25 Sort *Sort `query:"sort"` 26 } 27 28 func (p ListQuotesParams) WithTimestamp(c Comparator, q Nanos) *ListQuotesParams { 29 switch c { 30 case EQ: 31 p.TimestampEQ = &q 32 case LT: 33 p.TimestampLT = &q 34 case LTE: 35 p.TimestampLTE = &q 36 case GT: 37 p.TimestampGT = &q 38 case GTE: 39 p.TimestampGTE = &q 40 } 41 return &p 42 } 43 44 func (p ListQuotesParams) WithDay(year int, month time.Month, day int) *ListQuotesParams { 45 d := Nanos(time.Date(year, month, day, 0, 0, 0, 0, time.UTC)) 46 p.TimestampEQ = &d 47 return &p 48 } 49 50 func (p ListQuotesParams) WithOrder(q Order) *ListQuotesParams { 51 p.Order = &q 52 return &p 53 } 54 55 func (p ListQuotesParams) WithLimit(q int) *ListQuotesParams { 56 p.Limit = &q 57 return &p 58 } 59 60 func (p ListQuotesParams) WithSort(q Sort) *ListQuotesParams { 61 p.Sort = &q 62 return &p 63 } 64 65 // ListQuotesResponse is the response returned by the ListQuotes method. 66 type ListQuotesResponse struct { 67 BaseResponse 68 Results []Quote `json:"results,omitempty"` 69 } 70 71 // GetLastQuoteParams is the set of parameters for the GetLastQuote method. 72 type GetLastQuoteParams struct { 73 // The ticker symbol of the stock/equity. 74 Ticker string `validate:"required" path:"ticker"` 75 } 76 77 // GetLastQuoteResponse is the response returned by the GetLastQuote method. 78 type GetLastQuoteResponse struct { 79 BaseResponse 80 Results LastQuote `json:"results,omitempty"` 81 } 82 83 // GetLastForexQuoteParams is the set of parameters for the GetLastForexQuote method. 84 type GetLastForexQuoteParams struct { 85 // The "from" symbol of the pair. 86 From string `validate:"required" path:"from"` 87 88 // The "to" symbol of the pair. 89 To string `validate:"required" path:"to"` 90 } 91 92 // GetLastForexQuoteResponse is the response returned by the GetLastForexQuote method. 93 type GetLastForexQuoteResponse struct { 94 BaseResponse 95 Symbol string `json:"symbol,omitempty"` 96 Last ForexQuote `json:"last,omitempty"` 97 } 98 99 // GetRealTimeCurrencyConversionParams is the set of parameters for the GetRealTimeCurrencyConversion method. 100 type GetRealTimeCurrencyConversionParams struct { 101 From string `validate:"required" path:"from"` 102 To string `validate:"required" path:"to"` 103 } 104 105 // GetRealTimeCurrencyConversionResponse is the response returned by the GetRealTimeCurrencyConversion method. 106 type GetRealTimeCurrencyConversionResponse struct { 107 BaseResponse 108 InitialAmount float64 `json:"initialAmount,omitempty"` 109 Converted float64 `json:"converted,omitempty"` 110 From string `json:"from,omitempty"` 111 To string `json:"to,omitempty"` 112 LastQuote ForexQuote `json:"last,omitempty"` 113 } 114 115 // Quote is an NBBO for a ticker symbol in a given time range. 116 type Quote struct { 117 AskExchange int `json:"ask_exchange,omitempty"` 118 AskPrice float64 `json:"ask_price,omitempty"` 119 AskSize float64 `json:"ask_size,omitempty"` 120 BidExchange int `json:"bid_exchange,omitempty"` 121 BidPrice float64 `json:"bid_price,omitempty"` 122 BidSize float64 `json:"bid_size,omitempty"` 123 Conditions []int32 `json:"conditions,omitempty"` 124 Indicators []int32 `json:"indicators,omitempty"` 125 ParticipantTimestamp Nanos `json:"participant_timestamp,omitempty"` 126 SequenceNumber int64 `json:"sequence_number,omitempty"` 127 SipTimestamp Nanos `json:"sip_timestamp,omitempty"` 128 Tape int32 `json:"tape,omitempty"` 129 TrfTimestamp Nanos `json:"trf_timestamp,omitempty"` 130 } 131 132 // LastQuote is the most recent NBBO for a ticker symbol. 133 type LastQuote struct { 134 Ticker string `json:"T,omitempty"` 135 TrfTimestamp Nanos `json:"f,omitempty"` 136 SequenceNumber int64 `json:"q,omitempty"` 137 SipTimestamp Nanos `json:"t,omitempty"` 138 ParticipantTimestamp Nanos `json:"y,omitempty"` 139 AskPrice float64 `json:"P,omitempty"` 140 AskSize float64 `json:"S,omitempty"` 141 AskExchange int `json:"X,omitempty"` 142 Conditions []int32 `json:"c,omitempty"` 143 Indicators []int32 `json:"i,omitempty"` 144 BidPrice float64 `json:"p,omitempty"` 145 BidSize float64 `json:"s,omitempty"` 146 BidExchange int `json:"x,omitempty"` 147 Tape int32 `json:"z,omitempty"` 148 } 149 150 // ForexQuote is a BBO for a forex currency pair. 151 type ForexQuote struct { 152 Ask float64 `json:"ask,omitempty"` 153 Bid float64 `json:"bid,omitempty"` 154 Exchange int `json:"exchange,omitempty"` 155 Timestamp Nanos `json:"timestamp,omitempty"` 156 }