github.com/polygon-io/client-go@v1.16.4/rest/models/aggs.go (about)

     1  package models
     2  
     3  // ListAggsParams is the set of parameters for the ListAggs method.
     4  type ListAggsParams struct {
     5  	// The ticker symbol of the stock/equity.
     6  	Ticker string `validate:"required" path:"ticker"`
     7  
     8  	// The size of the timespan multiplier.
     9  	Multiplier int `validate:"required" path:"multiplier"`
    10  
    11  	// The size of the time window.
    12  	Timespan Timespan `validate:"required" path:"timespan"`
    13  
    14  	// The start of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.
    15  	From Millis `validate:"required" path:"from"`
    16  
    17  	// The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.
    18  	To Millis `validate:"required" path:"to"`
    19  
    20  	// Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get
    21  	// results that are NOT adjusted for splits.
    22  	Adjusted *bool `query:"adjusted"`
    23  
    24  	// Order the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return
    25  	// results in descending order (newest at the top).
    26  	Order *Order `query:"sort"`
    27  
    28  	// Limits the number of base aggregates queried to create the aggregate results. Max 50000 and Default 5000. Read
    29  	// more about how limit is used to calculate aggregate results in our article on Aggregate Data API Improvements:
    30  	// https://polygon.io/blog/aggs-api-updates/.
    31  	Limit *int `query:"limit"`
    32  }
    33  
    34  func (p ListAggsParams) WithAdjusted(q bool) *ListAggsParams {
    35  	p.Adjusted = &q
    36  	return &p
    37  }
    38  
    39  func (p ListAggsParams) WithOrder(q Order) *ListAggsParams {
    40  	p.Order = &q
    41  	return &p
    42  }
    43  
    44  func (p ListAggsParams) WithLimit(q int) *ListAggsParams {
    45  	p.Limit = &q
    46  	return &p
    47  }
    48  
    49  // ListAggsResponse is the response returned by the ListAggs method.
    50  type ListAggsResponse struct {
    51  	BaseResponse
    52  	Ticker       string `json:"ticker,omitempty"`
    53  	QueryCount   int    `json:"queryCount,omitempty"`
    54  	ResultsCount int    `json:"resultsCount,omitempty"`
    55  	Adjusted     bool   `json:"adjusted"`
    56  	Results      []Agg  `json:"results,omitempty"`
    57  }
    58  
    59  // GetAggsParams is the set of parameters for the GetAggs method.
    60  type GetAggsParams struct {
    61  	// The ticker symbol of the stock/equity.
    62  	Ticker string `validate:"required" path:"ticker"`
    63  
    64  	// The size of the timespan multiplier.
    65  	Multiplier int `validate:"required" path:"multiplier"`
    66  
    67  	// The size of the time window.
    68  	Timespan Timespan `validate:"required" path:"timespan"`
    69  
    70  	// The start of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.
    71  	From Millis `validate:"required" path:"from"`
    72  
    73  	// The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.
    74  	To Millis `validate:"required" path:"to"`
    75  
    76  	// Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get
    77  	// results that are NOT adjusted for splits.
    78  	Adjusted *bool `query:"adjusted"`
    79  
    80  	// Order the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return
    81  	// results in descending order (newest at the top).
    82  	Order *Order `query:"sort"`
    83  
    84  	// Limits the number of base aggregates queried to create the aggregate results. Max 50000 and Default 5000. Read
    85  	// more about how limit is used to calculate aggregate results in our article on Aggregate Data API Improvements:
    86  	// https://polygon.io/blog/aggs-api-updates/.
    87  	Limit *int `query:"limit"`
    88  }
    89  
    90  func (p GetAggsParams) WithAdjusted(q bool) *GetAggsParams {
    91  	p.Adjusted = &q
    92  	return &p
    93  }
    94  
    95  func (p GetAggsParams) WithOrder(q Order) *GetAggsParams {
    96  	p.Order = &q
    97  	return &p
    98  }
    99  
   100  func (p GetAggsParams) WithLimit(q int) *GetAggsParams {
   101  	p.Limit = &q
   102  	return &p
   103  }
   104  
   105  // GetAggsResponse is the response returned by the GetAggs method.
   106  type GetAggsResponse struct {
   107  	BaseResponse
   108  	Ticker       string `json:"ticker,omitempty"`
   109  	QueryCount   int    `json:"queryCount,omitempty"`
   110  	ResultsCount int    `json:"resultsCount,omitempty"`
   111  	Adjusted     bool   `json:"adjusted"`
   112  	Results      []Agg  `json:"results,omitempty"`
   113  }
   114  
   115  // GetGroupedDailyAggsParams is the set of parameters for the GetGroupedDailyAggs method.
   116  type GetGroupedDailyAggsParams struct {
   117  	// The locale of the market.
   118  	Locale MarketLocale `validate:"required" path:"locale"`
   119  
   120  	// The type of market to query.
   121  	MarketType MarketType `validate:"required" path:"marketType"`
   122  
   123  	// The beginning date for the aggregate window.
   124  	Date Date `validate:"required" path:"date"`
   125  
   126  	// Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get
   127  	// results that are NOT adjusted for splits.
   128  	Adjusted *bool `query:"adjusted"`
   129  
   130  	// Include OTC securities in the response. Default is false (don't include OTC securities).
   131  	IncludeOTC *bool `query:"include_otc"`
   132  }
   133  
   134  func (p GetGroupedDailyAggsParams) WithAdjusted(q bool) *GetGroupedDailyAggsParams {
   135  	p.Adjusted = &q
   136  	return &p
   137  }
   138  
   139  func (p GetGroupedDailyAggsParams) WithIncludeOTC(q bool) *GetGroupedDailyAggsParams {
   140  	p.IncludeOTC = &q
   141  	return &p
   142  }
   143  
   144  // GetGroupedDailyAggsResponse is the response returned by the GetGroupedDailyAggs method.
   145  type GetGroupedDailyAggsResponse struct {
   146  	BaseResponse
   147  	Ticker       string `json:"ticker,omitempty"`
   148  	QueryCount   int    `json:"queryCount,omitempty"`
   149  	ResultsCount int    `json:"resultsCount,omitempty"`
   150  	Adjusted     bool   `json:"adjusted"`
   151  	Results      []Agg  `json:"results,omitempty"`
   152  }
   153  
   154  // GetDailyOpenCloseAggParams is the set of parameters for the GetDailyOpenCloseAgg method.
   155  type GetDailyOpenCloseAggParams struct {
   156  	// The ticker symbol of the stock/equity.
   157  	Ticker string `validate:"required" path:"ticker"`
   158  
   159  	// The date of the requested open/close in the format YYYY-MM-DD.
   160  	Date Date `validate:"required" path:"date"`
   161  
   162  	// Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get
   163  	// results that are NOT adjusted for splits.
   164  	Adjusted *bool `query:"adjusted"`
   165  }
   166  
   167  func (p GetDailyOpenCloseAggParams) WithAdjusted(q bool) *GetDailyOpenCloseAggParams {
   168  	p.Adjusted = &q
   169  	return &p
   170  }
   171  
   172  // GetDailyOpenCloseAggResponse is the response for the GetDailyOpenCloseAgg method.
   173  type GetDailyOpenCloseAggResponse struct {
   174  	BaseResponse
   175  	Symbol     string  `json:"symbol,omitempty"`
   176  	From       string  `json:"from,omitempty"`
   177  	Open       float64 `json:"open,omitempty"`
   178  	High       float64 `json:"high,omitempty"`
   179  	Low        float64 `json:"low,omitempty"`
   180  	Close      float64 `json:"close,omitempty"`
   181  	Volume     float64 `json:"volume,omitempty"`
   182  	AfterHours float64 `json:"afterHours,omitempty"`
   183  	PreMarket  float64 `json:"preMarket,omitempty"`
   184  	OTC        bool    `json:"otc,omitempty"`
   185  }
   186  
   187  // GetPreviousCloseAggParams is the set of parameters for the GetPreviousCloseAgg method.
   188  type GetPreviousCloseAggParams struct {
   189  	// The ticker symbol of the stock/equity.
   190  	Ticker string `validate:"required" path:"ticker"`
   191  
   192  	// Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get
   193  	// results that are NOT adjusted for splits.
   194  	Adjusted *bool `query:"adjusted"`
   195  }
   196  
   197  func (p GetPreviousCloseAggParams) WithAdjusted(q bool) *GetPreviousCloseAggParams {
   198  	p.Adjusted = &q
   199  	return &p
   200  }
   201  
   202  // GetPreviousCloseAggResponse is the response returned by the GetPreviousCloseAgg method.
   203  type GetPreviousCloseAggResponse struct {
   204  	BaseResponse
   205  	Ticker       string `json:"ticker,omitempty"`
   206  	QueryCount   int    `json:"queryCount,omitempty"`
   207  	ResultsCount int    `json:"resultsCount,omitempty"`
   208  	Adjusted     bool   `json:"adjusted"`
   209  	Results      []Agg  `json:"results,omitempty"`
   210  }
   211  
   212  // Agg is an aggregation of all the activity on a specified ticker between the start and end timestamps.
   213  type Agg struct {
   214  	Ticker       string  `json:"T,omitempty"`
   215  	Close        float64 `json:"c,omitempty"`
   216  	High         float64 `json:"h,omitempty"`
   217  	Low          float64 `json:"l,omitempty"`
   218  	Transactions int64   `json:"n,omitempty"`
   219  	Open         float64 `json:"o,omitempty"`
   220  	Timestamp    Millis  `json:"t,omitempty"`
   221  	Volume       float64 `json:"v,omitempty"`
   222  	VWAP         float64 `json:"vw,omitempty"`
   223  	OTC          bool    `json:"otc,omitempty"`
   224  }