github.com/polygon-io/client-go@v1.16.4/websocket/models/models.go (about) 1 package models 2 3 // Action is the set of recognized actions used in control messages. 4 type Action string 5 6 const ( 7 Auth Action = "auth" 8 Subscribe Action = "subscribe" 9 Unsubscribe Action = "unsubscribe" 10 ) 11 12 // EventType is the type of message received. It should be present in every message sent by the server. 13 type EventType struct { 14 EventType string `json:"ev,omitempty"` 15 } 16 17 // ControlMessage is a message to signal status and control events to and from the server. 18 type ControlMessage struct { 19 EventType 20 Status string `json:"status,omitempty"` 21 Message string `json:"message,omitempty"` 22 Action Action `json:"action,omitempty"` 23 Params string `json:"params,omitempty"` 24 } 25 26 // EquityAgg is an aggregate for either stock tickers or option contracts. 27 type EquityAgg struct { 28 // The event type. 29 EventType 30 31 // The ticker symbol for the given stock. 32 Symbol string `json:"sym,omitempty"` 33 34 // The tick volume. 35 Volume float64 `json:"v,omitempty"` 36 37 // Today's accumulated volume. 38 AccumulatedVolume float64 `json:"av,omitempty"` 39 40 // Today's official opening price. 41 OfficialOpenPrice float64 `json:"op,omitempty"` 42 43 // The tick's volume weighted average price. 44 VWAP float64 `json:"vw,omitempty"` 45 46 // The opening tick price for this aggregate window. 47 Open float64 `json:"o,omitempty"` 48 49 // The closing tick price for this aggregate window. 50 Close float64 `json:"c,omitempty"` 51 52 // The highest tick price for this aggregate window. 53 High float64 `json:"h,omitempty"` 54 55 // The lowest tick price for this aggregate window. 56 Low float64 `json:"l,omitempty"` 57 58 // Today's volume weighted average price. 59 AggregateVWAP float64 `json:"a,omitempty"` 60 61 // The average trade size for this aggregate window. 62 AverageSize float64 `json:"z,omitempty"` 63 64 // The timestamp of the starting tick for this aggregate window in Unix Milliseconds. 65 StartTimestamp int64 `json:"s,omitempty"` 66 67 // The timestamp of the ending tick for this aggregate window in Unix Milliseconds. 68 EndTimestamp int64 `json:"e,omitempty"` 69 70 // Whether or not this aggregate is for an OTC ticker. This field will be left off if false. 71 OTC bool `json:"otc,omitempty"` 72 } 73 74 // CurrencyAgg is an aggregate for either forex currency pairs or crypto pairs. 75 type CurrencyAgg struct { 76 // The event type. 77 EventType 78 79 // The currency pair. 80 Pair string `json:"pair,omitempty"` 81 82 // The open price for this aggregate window. 83 Open float64 `json:"o,omitempty"` 84 85 // The close price for this aggregate window. 86 Close float64 `json:"c,omitempty"` 87 88 // The high price for this aggregate window. 89 High float64 `json:"h,omitempty"` 90 91 // The low price for this aggregate window. 92 Low float64 `json:"l,omitempty"` 93 94 // The volume of trades during this aggregate window. 95 Volume float64 `json:"v,omitempty"` 96 97 // The volume weighted average price. 98 VWAP float64 `json:"vw,omitempty"` 99 100 // The start time for this aggregate window in Unix Milliseconds. 101 StartTimestamp int64 `json:"s,omitempty"` 102 103 // The end time for this aggregate window in Unix Milliseconds. 104 EndTimestamp int64 `json:"e,omitempty"` 105 106 // The average trade size for this aggregate window. 107 AVGTradeSize int32 `json:"z,omitempty"` 108 } 109 110 // EquityTrade is trade data for either stock tickers or option contracts. 111 type EquityTrade struct { 112 // The event type. 113 EventType 114 115 // The ticker symbol for the given stock. 116 Symbol string `json:"sym,omitempty"` 117 118 // The exchange ID. 119 Exchange int32 `json:"x,omitempty"` 120 121 // The trade ID. 122 ID string `json:"i,omitempty"` 123 124 // The tape. (1 = NYSE, 2 = AMEX, 3 = Nasdaq). 125 Tape int32 `json:"z,omitempty"` 126 127 // The price. 128 Price float64 `json:"p,omitempty"` 129 130 // The trade size. 131 Size int64 `json:"s,omitempty"` 132 133 // The trade conditions. 134 Conditions []int32 `json:"c,omitempty"` 135 136 // The Timestamp in Unix MS. 137 Timestamp int64 `json:"t,omitempty"` 138 139 // The sequence number represents the sequence in which message events happened. These are increasing and unique per 140 // ticker symbol, but will not always be sequential (e.g., 1, 2, 6, 9, 10, 11). 141 SequenceNumber int64 `json:"q,omitempty"` 142 143 // The ID for the Trade Reporting Facility where the trade took place. 144 TradeReportingFacilityID int64 `json:"trfi,omitempty"` 145 146 // The TRF (Trade Reporting Facility) Timestamp in Unix MS. 147 // This is the timestamp of when the trade reporting facility received this trade. 148 TradeReportingFacilityTimestamp int64 `json:"trft,omitempty"` 149 } 150 151 // CryptoTrade is a trade for a crypto pair. 152 type CryptoTrade struct { 153 // The event type. 154 EventType 155 156 // The crypto pair. 157 Pair string `json:"pair,omitempty"` 158 159 // The crypto exchange ID. 160 Exchange int32 `json:"x,omitempty"` 161 162 // The ID of the trade (optional). 163 ID string `json:"i,omitempty"` 164 165 // The price. 166 Price float64 `json:"p,omitempty"` 167 168 // The size. 169 Size float64 `json:"s,omitempty"` 170 171 // The conditions. 0 (or empty array): empty 1: sellside 2: buyside 172 Conditions []int32 `json:"c,omitempty"` 173 174 // The Timestamp in Unix MS. 175 Timestamp int64 `json:"t,omitempty"` 176 177 // The timestamp that the tick was received by Polygon. 178 ReceivedTimestamp int64 `json:"r,omitempty"` 179 } 180 181 // EquityQuote is a quote for either stock tickers or option contracts. 182 type EquityQuote struct { 183 // The event type. 184 EventType 185 186 // The ticker symbol for the given stock. 187 Symbol string `json:"sym,omitempty"` 188 189 // The bid exchange ID. 190 BidExchangeID int32 `json:"bx,omitempty"` 191 192 // The bid price. 193 BidPrice float64 `json:"bp,omitempty"` 194 195 // The bid size. This represents the number of round lot orders at the given bid price. The normal round lot size is 196 // 100 shares. A bid size of 2 means there are 200 shares for purchase at the given bid price. 197 BidSize int32 `json:"bs,omitempty"` 198 199 // The ask exchange ID. 200 AskExchangeID int32 `json:"ax,omitempty"` 201 202 // The ask price. 203 AskPrice float64 `json:"ap,omitempty"` 204 205 // The ask size. This represents the number of round lot orders at the given ask price. The normal round lot size is 206 // 100 shares. An ask size of 2 means there are 200 shares available to purchase at the given ask price. 207 AskSize int32 `json:"as,omitempty"` 208 209 // The condition. 210 Condition int32 `json:"c,omitempty"` 211 212 // The indicators. For more information, see our glossary: https://polygon.io/glossary/us/stocks/conditions-indicators. 213 Indicators []int32 `json:"i,omitempty"` 214 215 // The Timestamp in Unix MS. 216 Timestamp int64 `json:"t,omitempty"` 217 218 // The tape. (1 = NYSE, 2 = AMEX, 3 = Nasdaq). 219 Tape int32 `json:"z,omitempty"` 220 221 // The sequence number represents the sequence in which message events happened. These are increasing and unique per 222 // ticker symbol, but will not always be sequential (e.g., 1, 2, 6, 9, 10, 11). 223 SequenceNumber int64 `json:"q,omitempty"` 224 } 225 226 // ForexQuote is a quote for a forex currency pair. 227 type ForexQuote struct { 228 // The event type. 229 EventType 230 231 // The current pair. 232 Pair string `json:"p,omitempty"` 233 234 // The exchange ID. 235 ExchangeID int32 `json:"x,omitempty"` 236 237 // The ask price. 238 AskPrice float64 `json:"a,omitempty"` 239 240 // The bid price. 241 BidPrice float64 `json:"b,omitempty"` 242 243 // The Timestamp in Unix MS. 244 Timestamp int64 `json:"t,omitempty"` 245 } 246 247 // CryptoQuote is a quote for a crypto pair. 248 type CryptoQuote struct { 249 // The event type. 250 EventType 251 252 // The crypto pair. 253 Pair string `json:"pair,omitempty"` 254 255 // The bid price. 256 BidPrice float64 `json:"bp,omitempty"` 257 258 // The bid size. 259 BidSize float64 `json:"bs,omitempty"` 260 261 // The ask price. 262 AskPrice float64 `json:"ap,omitempty"` 263 264 // The ask size. 265 AskSize float64 `json:"as,omitempty"` 266 267 // The Timestamp in Unix MS. 268 Timestamp int64 `json:"t,omitempty"` 269 270 // The crypto exchange ID. 271 ExchangeID int32 `json:"x,omitempty"` 272 273 // The timestamp that the tick was received by Polygon. 274 ReceivedTimestamp int64 `json:"r,omitempty"` 275 } 276 277 // Imbalance is an imbalance event for a given stock ticker symbol. 278 type Imbalance struct { 279 // The event type. 280 EventType 281 282 // The ticker symbol for the given stock. 283 Symbol string `json:"T,omitempty"` 284 285 // The Timestamp in Unix MS. 286 Timestamp int64 `json:"t,omitempty"` 287 288 // The time that the auction is planned to take place in the format (hour x 100) + minutes in Eastern Standard Time, 289 // for example 930 would be 9:30 am EST, and 1600 would be 4:00 pm EST. 290 AuctionTime int32 `json:"at,omitempty"` 291 292 // The auction type. O - Early Opening Auction (non-NYSE only) M - Core Opening Auction H - Reopening Auction (Halt 293 // Resume) C - Closing Auction P - Extreme Closing Imbalance (NYSE only) R - Regulatory Closing Imbalance (NYSE 294 // only) 295 AuctionType string `json:"a,omitempty"` 296 297 // The symbol sequence. 298 SymbolSequence int32 `json:"i,omitempty"` 299 300 // The exchange ID. 301 ExchangeID int32 `json:"x,omitempty"` 302 303 // The imbalance quantity. 304 ImbalanceQuantity int32 `json:"o,omitempty"` 305 306 // The paired quantity. 307 PairedQuantity int32 `json:"p,omitempty"` 308 309 // The book clearing price. 310 BookClearingPrice float64 `json:"b,omitempty"` 311 } 312 313 // LimitUpLimitDown is a LULD event for a given stock ticker symbol. 314 type LimitUpLimitDown struct { 315 // The event type. 316 EventType 317 318 // The ticker symbol for the given stock. 319 Symbol string `json:"T,omitempty"` 320 321 // The high price. 322 HighPrice float64 `json:"h,omitempty"` 323 324 // The low price. 325 LowPrice float64 `json:"l,omitempty"` 326 327 // The Indicators. 328 Indicators []int32 `json:"i,omitempty"` 329 330 // The tape. (1 = NYSE, 2 = AMEX, 3 = Nasdaq). 331 Tape int32 `json:"z,omitempty"` 332 333 // The Timestamp in Unix MS. 334 Timestamp int64 `json:"t,omitempty"` 335 336 // The sequence number represents the sequence in which message events happened. These are increasing and unique per ticker symbol, but will not always be sequential (e.g., 1, 2, 6, 9, 10, 11). 337 SequenceNumber int64 `json:"q,omitempty"` 338 } 339 340 // Level2Book is level 2 book data for a given crypto pair. 341 type Level2Book struct { 342 // The event type. 343 EventType 344 345 // The crypto pair. 346 Pair string `json:"pair,omitempty"` 347 348 // An array of bid prices with a maximum depth of 100. 349 BidPrices [][]float64 `json:"b,omitempty"` 350 351 // An array of ask prices with a maximum depth of 100. 352 AskPrices [][]float64 `json:"a,omitempty"` 353 354 // The Timestamp in Unix MS. 355 Timestamp int64 `json:"t,omitempty"` 356 357 // The crypto exchange ID. 358 ExchangeID int32 `json:"x,omitempty"` 359 360 // The timestamp that the tick was received by Polygon. 361 ReceivedTimestamp int64 `json:"r,omitempty"` 362 } 363 364 // IndexValue is value data for either indices. 365 type IndexValue struct { 366 // The event type. 367 EventType 368 369 // The value. 370 Value float64 `json:"val"` 371 372 // The ticker symbol for the given index. 373 Ticker string `json:"T"` 374 375 // The Timestamp in Unix MS. 376 Timestamp int64 `json:"t,omitempty"` 377 } 378 379 type LaunchpadValue struct { 380 // The event type. 381 EventType 382 383 // The value. 384 Value float64 `json:"val"` 385 386 // The ticker symbol for the given security. 387 Ticker string `json:"sym"` 388 389 // The Timestamp in nanoseconds. 390 Timestamp int64 `json:"t,omitempty"` 391 } 392 393 type FairMarketValue struct { 394 // The event type. 395 EventType 396 397 // The value. 398 FMV float64 `json:"fmv"` 399 400 // The ticker symbol for the given security. 401 Ticker string `json:"sym"` 402 403 // The Timestamp in nanoseconds. 404 Timestamp int64 `json:"t,omitempty"` 405 }