github.com/polygon-io/client-go@v1.16.4/rest/models/indicators.go (about) 1 package models 2 3 // GetSMAParams is the set of parameters for the GetSMA method. 4 type GetSMAParams struct { 5 // The ticker symbol of the stock/equity. 6 Ticker string `validate:"required" path:"ticker"` 7 8 // The size of the timespan of the underlying aggregates. 9 Timespan *Timespan `query:"timespan"` 10 11 // Query indicators by timestamp. 12 TimestampEQ *Millis `query:"timestamp"` 13 TimestampLT *Millis `query:"timestamp.lt"` 14 TimestampLTE *Millis `query:"timestamp.lte"` 15 TimestampGT *Millis `query:"timestamp.gt"` 16 TimestampGTE *Millis `query:"timestamp.gte"` 17 18 // The attribute of the underlying aggregate which will be used to calculate the indicator. 19 SeriesType *SeriesType `query:"series_type"` 20 21 // Whether to also return the underlying aggregates used to calculate the indicator. 22 ExpandUnderlying *bool `query:"expand_underlying"` 23 24 // Whether or not the underlying aggregates used to calculate the indicator are adjusted for splits. By default, the aggregates are adjusted. Set this to false to get 25 // results that are NOT adjusted for splits. 26 Adjusted *bool `query:"adjusted"` 27 28 // Order the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return 29 // results in descending order (newest at the top). 30 Order *Order `query:"order"` 31 32 // Limit the number of results returned, default is 10 and max is 5000 33 Limit *int `query:"limit"` 34 35 // The size of the window over which the indicator will be calculated. 36 Window *int `query:"window"` 37 } 38 39 func (p GetSMAParams) WithAdjusted(q bool) *GetSMAParams { 40 p.Adjusted = &q 41 return &p 42 } 43 44 func (p GetSMAParams) WithOrder(q Order) *GetSMAParams { 45 p.Order = &q 46 return &p 47 } 48 49 func (p GetSMAParams) WithLimit(q int) *GetSMAParams { 50 p.Limit = &q 51 return &p 52 } 53 54 func (p GetSMAParams) WithExpandUnderlying(q bool) *GetSMAParams { 55 p.ExpandUnderlying = &q 56 return &p 57 } 58 59 func (p GetSMAParams) WithTimestamp(c Comparator, q Millis) *GetSMAParams { 60 switch c { 61 case EQ: 62 p.TimestampEQ = &q 63 case LT: 64 p.TimestampLT = &q 65 case LTE: 66 p.TimestampLTE = &q 67 case GT: 68 p.TimestampGT = &q 69 case GTE: 70 p.TimestampGTE = &q 71 } 72 return &p 73 } 74 75 func (p GetSMAParams) WithTimespan(q Timespan) *GetSMAParams { 76 p.Timespan = &q 77 return &p 78 } 79 80 func (p GetSMAParams) WithSeriesType(q SeriesType) *GetSMAParams { 81 p.SeriesType = &q 82 return &p 83 } 84 85 func (p GetSMAParams) WithWindow(q int) *GetSMAParams { 86 p.Window = &q 87 return &p 88 } 89 90 // GetEMAParams is the set of parameters for the GetEMA method. 91 type GetEMAParams struct { 92 // The ticker symbol of the stock/equity. 93 Ticker string `validate:"required" path:"ticker"` 94 95 // The size of the timespan of the underlying aggregates. 96 Timespan *Timespan `query:"timespan"` 97 98 // Query indicators by timestamp. 99 TimestampEQ *Millis `query:"timestamp"` 100 TimestampLT *Millis `query:"timestamp.lt"` 101 TimestampLTE *Millis `query:"timestamp.lte"` 102 TimestampGT *Millis `query:"timestamp.gt"` 103 TimestampGTE *Millis `query:"timestamp.gte"` 104 105 // The attribute of the underlying aggregate which will be used to calculate the indicator. 106 SeriesType *SeriesType `query:"series_type"` 107 108 // Whether to also return the underlying aggregates used to calculate the indicator. 109 ExpandUnderlying *bool `query:"expand_underlying"` 110 111 // Whether or not the underlying aggregates used to calculate the indicator are adjusted for splits. By default, the aggregates are adjusted. Set this to false to get 112 // results that are NOT adjusted for splits. 113 Adjusted *bool `query:"adjusted"` 114 115 // Order the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return 116 // results in descending order (newest at the top). 117 Order *Order `query:"order"` 118 119 // Limit the number of results returned, default is 10 and max is 5000 120 Limit *int `query:"limit"` 121 122 // The size of the window over which the indicator will be calculated. 123 Window *int `query:"window"` 124 } 125 126 func (p GetEMAParams) WithAdjusted(q bool) *GetEMAParams { 127 p.Adjusted = &q 128 return &p 129 } 130 131 func (p GetEMAParams) WithOrder(q Order) *GetEMAParams { 132 p.Order = &q 133 return &p 134 } 135 136 func (p GetEMAParams) WithLimit(q int) *GetEMAParams { 137 p.Limit = &q 138 return &p 139 } 140 141 func (p GetEMAParams) WithExpandUnderlying(q bool) *GetEMAParams { 142 p.ExpandUnderlying = &q 143 return &p 144 } 145 146 func (p GetEMAParams) WithTimestamp(c Comparator, q Millis) *GetEMAParams { 147 switch c { 148 case EQ: 149 p.TimestampEQ = &q 150 case LT: 151 p.TimestampLT = &q 152 case LTE: 153 p.TimestampLTE = &q 154 case GT: 155 p.TimestampGT = &q 156 case GTE: 157 p.TimestampGTE = &q 158 } 159 return &p 160 } 161 162 func (p GetEMAParams) WithTimespan(q Timespan) *GetEMAParams { 163 p.Timespan = &q 164 return &p 165 } 166 167 func (p GetEMAParams) WithSeriesType(q SeriesType) *GetEMAParams { 168 p.SeriesType = &q 169 return &p 170 } 171 172 func (p GetEMAParams) WithWindow(q int) *GetEMAParams { 173 p.Window = &q 174 return &p 175 } 176 177 // GetRSIParams is the set of parameters for the GetRSI method. 178 type GetRSIParams struct { 179 // The ticker symbol of the stock/equity. 180 Ticker string `validate:"required" path:"ticker"` 181 182 // The size of the timespan of the underlying aggregates. 183 Timespan *Timespan `query:"timespan"` 184 185 // Query indicators by timestamp. 186 TimestampEQ *Millis `query:"timestamp"` 187 TimestampLT *Millis `query:"timestamp.lt"` 188 TimestampLTE *Millis `query:"timestamp.lte"` 189 TimestampGT *Millis `query:"timestamp.gt"` 190 TimestampGTE *Millis `query:"timestamp.gte"` 191 192 // The attribute of the underlying aggregate which will be used to calculate the indicator. 193 SeriesType *SeriesType `query:"series_type"` 194 195 // Whether to also return the underlying aggregates used to calculate the indicator. 196 ExpandUnderlying *bool `query:"expand_underlying"` 197 198 // Whether or not the underlying aggregates used to calculate the indicator are adjusted for splits. By default, the aggregates are adjusted. Set this to false to get 199 // results that are NOT adjusted for splits. 200 Adjusted *bool `query:"adjusted"` 201 202 // Order the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return 203 // results in descending order (newest at the top). 204 Order *Order `query:"order"` 205 206 // Limit the number of results returned, default is 10 and max is 5000 207 Limit *int `query:"limit"` 208 209 // The size of the window over which the indicator will be calculated. 210 Window *int `query:"window"` 211 } 212 213 func (p GetRSIParams) WithAdjusted(q bool) *GetRSIParams { 214 p.Adjusted = &q 215 return &p 216 } 217 218 func (p GetRSIParams) WithOrder(q Order) *GetRSIParams { 219 p.Order = &q 220 return &p 221 } 222 223 func (p GetRSIParams) WithLimit(q int) *GetRSIParams { 224 p.Limit = &q 225 return &p 226 } 227 228 func (p GetRSIParams) WithExpandUnderlying(q bool) *GetRSIParams { 229 p.ExpandUnderlying = &q 230 return &p 231 } 232 233 func (p GetRSIParams) WithTimestamp(c Comparator, q Millis) *GetRSIParams { 234 switch c { 235 case EQ: 236 p.TimestampEQ = &q 237 case LT: 238 p.TimestampLT = &q 239 case LTE: 240 p.TimestampLTE = &q 241 case GT: 242 p.TimestampGT = &q 243 case GTE: 244 p.TimestampGTE = &q 245 } 246 return &p 247 } 248 249 func (p GetRSIParams) WithTimespan(q Timespan) *GetRSIParams { 250 p.Timespan = &q 251 return &p 252 } 253 254 func (p GetRSIParams) WithSeriesType(q SeriesType) *GetRSIParams { 255 p.SeriesType = &q 256 return &p 257 } 258 259 func (p GetRSIParams) WithWindow(q int) *GetRSIParams { 260 p.Window = &q 261 return &p 262 } 263 264 // GetMACDParams is the set of parameters for the GetMACD method. 265 type GetMACDParams struct { 266 // The ticker symbol of the stock/equity. 267 Ticker string `validate:"required" path:"ticker"` 268 269 // The size of the timespan of the underlying aggregates. 270 Timespan *Timespan `query:"timespan"` 271 272 // Query indicators by timestamp. 273 TimestampEQ *Millis `query:"timestamp"` 274 TimestampLT *Millis `query:"timestamp.lt"` 275 TimestampLTE *Millis `query:"timestamp.lte"` 276 TimestampGT *Millis `query:"timestamp.gt"` 277 TimestampGTE *Millis `query:"timestamp.gte"` 278 279 // The attribute of the underlying aggregate which will be used to calculate the indicator. 280 SeriesType *SeriesType `query:"series_type"` 281 282 // Whether to also return the underlying aggregates used to calculate the indicator. 283 ExpandUnderlying *bool `query:"expand_underlying"` 284 285 // Whether or not the underlying aggregates used to calculate the indicator are adjusted for splits. By default, the aggregates are adjusted. Set this to false to get 286 // results that are NOT adjusted for splits. 287 Adjusted *bool `query:"adjusted"` 288 289 // Order the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return 290 // results in descending order (newest at the top). 291 Order *Order `query:"order"` 292 293 // Limit the number of results returned, default is 10 and max is 5000 294 Limit *int `query:"limit"` 295 296 // The size of the window over which the indicator will be calculated. 297 ShortWindow *int `query:"short_window"` 298 299 // The size of the window over which the indicator will be calculated. 300 LongWindow *int `query:"long_window"` 301 302 // The size of the window over which the indicator will be calculated. 303 SignalWindow *int `query:"signal_window"` 304 } 305 306 func (p GetMACDParams) WithTimestamp(c Comparator, q Millis) *GetMACDParams { 307 switch c { 308 case EQ: 309 p.TimestampEQ = &q 310 case LT: 311 p.TimestampLT = &q 312 case LTE: 313 p.TimestampLTE = &q 314 case GT: 315 p.TimestampGT = &q 316 case GTE: 317 p.TimestampGTE = &q 318 } 319 return &p 320 } 321 322 func (p GetMACDParams) WithTimespan(q Timespan) *GetMACDParams { 323 p.Timespan = &q 324 return &p 325 } 326 327 func (p GetMACDParams) WithSeriesType(q SeriesType) *GetMACDParams { 328 p.SeriesType = &q 329 return &p 330 } 331 332 func (p GetMACDParams) WithAdjusted(q bool) *GetMACDParams { 333 p.Adjusted = &q 334 return &p 335 } 336 337 func (p GetMACDParams) WithOrder(q Order) *GetMACDParams { 338 p.Order = &q 339 return &p 340 } 341 342 func (p GetMACDParams) WithLimit(q int) *GetMACDParams { 343 p.Limit = &q 344 return &p 345 } 346 347 func (p GetMACDParams) WithExpandUnderlying(q bool) *GetMACDParams { 348 p.ExpandUnderlying = &q 349 return &p 350 } 351 352 func (p GetMACDParams) WithShortWindow(q int) *GetMACDParams { 353 p.ShortWindow = &q 354 return &p 355 } 356 357 func (p GetMACDParams) WithLongWindow(q int) *GetMACDParams { 358 p.LongWindow = &q 359 return &p 360 } 361 362 func (p GetMACDParams) WithSignalWindow(q int) *GetMACDParams { 363 p.SignalWindow = &q 364 return &p 365 } 366 367 // Response Models 368 369 // GetAggsResponse is the response returned by the GetAggs method. 370 type GetSMAResponse struct { 371 BaseResponse 372 Results SingleIndicatorResults `json:"results,omitempty"` 373 } 374 375 type GetEMAResponse struct { 376 BaseResponse 377 Results SingleIndicatorResults `json:"results,omitempty"` 378 } 379 380 type GetRSIResponse struct { 381 BaseResponse 382 Results SingleIndicatorResults `json:"results,omitempty"` 383 } 384 385 type SingleIndicatorResults struct { 386 Underlying UnderlyingResults `json:"underlying,omitempty"` 387 Values SingleIndicatorValues `json:"values,omitempty"` 388 } 389 390 type UnderlyingResults struct { 391 Aggregates []Agg `json:"aggregates,omitempty"` 392 URL string `json:"url,omitempty"` 393 } 394 395 type SingleIndicatorValues []SingleIndicatorValue 396 397 type SingleIndicatorValue struct { 398 Timestamp Millis `json:"timestamp,omitempty"` 399 Value float64 `json:"value,omitempty"` 400 } 401 402 type GetMACDResponse struct { 403 BaseResponse 404 Results MACDIndicatorResults `json:"results,omitempty"` 405 } 406 407 type MACDIndicatorResults struct { 408 Underlying UnderlyingResults `json:"underlying,omitempty"` 409 Values MACDIndicatorValues `json:"values,omitempty"` 410 } 411 412 type MACDIndicatorValues []MACDIndicatorValue 413 414 type MACDIndicatorValue struct { 415 Timestamp Millis `json:"timestamp,omitempty"` 416 Value float64 `json:"value,omitempty"` 417 Signal float64 `json:"signal,omitempty"` 418 Histogram float64 `json:"histogram,omitempty"` 419 }