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

     1  package models
     2  
     3  import "strings"
     4  
     5  // ListTickersParams is the set of parameters for the ListTickers method.
     6  type ListTickersParams struct {
     7  	// Specify a ticker symbol. Defaults to empty string which queries all tickers.
     8  	TickerEQ  *string `query:"ticker"`
     9  	TickerLT  *string `query:"ticker.lt"`
    10  	TickerLTE *string `query:"ticker.lte"`
    11  	TickerGT  *string `query:"ticker.gt"`
    12  	TickerGTE *string `query:"ticker.gte"`
    13  
    14  	// Specify the type of the tickers. Find the types that we support via our Ticker Types API. Defaults to empty
    15  	// string which queries all types.
    16  	Type *string `query:"type"`
    17  
    18  	// Filter by market type. By default all markets are included.
    19  	Market *AssetClass `query:"market"`
    20  
    21  	// Specify the asset's primary exchange Market Identifier Code (MIC) according to ISO 10383. Defaults to empty
    22  	// string which queries all exchanges.
    23  	Exchange *string `query:"exchange"`
    24  
    25  	// Specify the CUSIP code of the asset you want to search for. Find more information about CUSIP codes at their
    26  	// website. Defaults to empty string which queries all CUSIPs.
    27  	//
    28  	// Note: Although you can query by CUSIP, due to legal reasons we do not return the CUSIP in the response.
    29  	CUSIP *int `query:"cusip"`
    30  
    31  	// Specify the CIK of the asset you want to search for. Find more information about CIK codes at their website.
    32  	// Defaults to empty string which queries all CIKs.
    33  	CIK *int `query:"cik"`
    34  
    35  	// Specify a point in time to retrieve tickers available on that date. Defaults to the most recent available date.
    36  	Date *Date `query:"date"`
    37  
    38  	// Specify if the tickers returned should be actively traded on the queried date. Default is true.
    39  	Active *bool `query:"active"`
    40  
    41  	// Search for terms within the ticker and/or company name.
    42  	Search *string `query:"search"`
    43  
    44  	// The field to sort the results on. Default is ticker. If the search query parameter is present, sort is ignored
    45  	// and results are ordered by relevance.
    46  	Sort *Sort `query:"sort"`
    47  
    48  	// The order to sort the results on. Default is asc (ascending).
    49  	Order *Order `query:"order"`
    50  
    51  	// Limit the size of the response, default is 100 and max is 1000.
    52  	Limit *int `query:"limit"`
    53  }
    54  
    55  func (p ListTickersParams) WithTicker(c Comparator, q string) *ListTickersParams {
    56  	switch c {
    57  	case EQ:
    58  		p.TickerEQ = &q
    59  	case LT:
    60  		p.TickerLT = &q
    61  	case LTE:
    62  		p.TickerLTE = &q
    63  	case GT:
    64  		p.TickerGT = &q
    65  	case GTE:
    66  		p.TickerGTE = &q
    67  	}
    68  	return &p
    69  }
    70  
    71  func (p ListTickersParams) WithType(q string) *ListTickersParams {
    72  	p.Type = &q
    73  	return &p
    74  }
    75  
    76  func (p ListTickersParams) WithMarket(q AssetClass) *ListTickersParams {
    77  	p.Market = &q
    78  	return &p
    79  }
    80  
    81  func (p ListTickersParams) WithExchange(q string) *ListTickersParams {
    82  	p.Exchange = &q
    83  	return &p
    84  }
    85  
    86  func (p ListTickersParams) WithCUSIP(q int) *ListTickersParams {
    87  	p.CUSIP = &q
    88  	return &p
    89  }
    90  
    91  func (p ListTickersParams) WithCIK(q int) *ListTickersParams {
    92  	p.CIK = &q
    93  	return &p
    94  }
    95  
    96  func (p ListTickersParams) WithDate(q Date) *ListTickersParams {
    97  	p.Date = &q
    98  	return &p
    99  }
   100  
   101  func (p ListTickersParams) WithActive(q bool) *ListTickersParams {
   102  	p.Active = &q
   103  	return &p
   104  }
   105  
   106  func (p ListTickersParams) WithSearch(q string) *ListTickersParams {
   107  	p.Search = &q
   108  	return &p
   109  }
   110  
   111  func (p ListTickersParams) WithSort(q Sort) *ListTickersParams {
   112  	p.Sort = &q
   113  	return &p
   114  }
   115  
   116  func (p ListTickersParams) WithOrder(q Order) *ListTickersParams {
   117  	p.Order = &q
   118  	return &p
   119  }
   120  
   121  func (p ListTickersParams) WithLimit(q int) *ListTickersParams {
   122  	p.Limit = &q
   123  	return &p
   124  }
   125  
   126  // ListTickersResponse is the response returned by the ListTickers method.
   127  type ListTickersResponse struct {
   128  	BaseResponse
   129  
   130  	// An array of tickers that match your query. Note: Although you can query by CUSIP, due to legal reasons we do not
   131  	// return the CUSIP in the response.
   132  	Results []Ticker `json:"results,omitempty"`
   133  }
   134  
   135  // GetTickerDetailsParams is the set of parameters for the GetTickerDetails method.
   136  type GetTickerDetailsParams struct {
   137  	// The ticker symbol of the asset.
   138  	Ticker string `validate:"required" path:"ticker"`
   139  
   140  	// Specify a point in time to get information about the ticker available on that date. When retrieving information
   141  	// from SEC filings, we compare this date with the period of report date on the SEC filing.
   142  	//
   143  	// For example, consider an SEC filing submitted by AAPL on 2019-07-31, with a period of report date ending on
   144  	// 2019-06-29. That means that the filing was submitted on 2019-07-31, but the filing was created based on
   145  	// information from 2019-06-29. If you were to query for AAPL details on 2019-06-29, the ticker details would
   146  	// include information from the SEC filing.
   147  	//
   148  	// Defaults to the most recent available date.
   149  	Date *Date `query:"date"`
   150  }
   151  
   152  func (p GetTickerDetailsParams) WithDate(q Date) *GetTickerDetailsParams {
   153  	p.Date = &q
   154  	return &p
   155  }
   156  
   157  // GetTickerDetailsResponse is the response returned by the GetTickerDetails method.
   158  type GetTickerDetailsResponse struct {
   159  	BaseResponse
   160  
   161  	// Ticker with details.
   162  	Results Ticker `json:"results,omitempty"`
   163  }
   164  
   165  // ListTickerNewsParams is the set of parameters for the ListTickerNews method.
   166  type ListTickerNewsParams struct {
   167  	// Return results that contain this ticker.
   168  	TickerEQ  *string `query:"ticker"`
   169  	TickerLT  *string `query:"ticker.lt"`
   170  	TickerLTE *string `query:"ticker.lte"`
   171  	TickerGT  *string `query:"ticker.gt"`
   172  	TickerGTE *string `query:"ticker.gte"`
   173  
   174  	// Return results published on, before, or after this date.
   175  	PublishedUtcEQ  *Millis `query:"published_utc"`
   176  	PublishedUtcLT  *Millis `query:"published_utc.lt"`
   177  	PublishedUtcLTE *Millis `query:"published_utc.lte"`
   178  	PublishedUtcGT  *Millis `query:"published_utc.gt"`
   179  	PublishedUtcGTE *Millis `query:"published_utc.gte"`
   180  
   181  	// Sort field used for ordering.
   182  	Sort *Sort `query:"sort"`
   183  
   184  	// Order results based on the sort field.
   185  	Order *Order `query:"order"`
   186  
   187  	// Limit the number of results returned, default is 10 and max is 1000.
   188  	Limit *int `query:"limit"`
   189  }
   190  
   191  func (p ListTickerNewsParams) WithTicker(c Comparator, q string) *ListTickerNewsParams {
   192  	switch c {
   193  	case EQ:
   194  		p.TickerEQ = &q
   195  	case LT:
   196  		p.TickerLT = &q
   197  	case LTE:
   198  		p.TickerLTE = &q
   199  	case GT:
   200  		p.TickerGT = &q
   201  	case GTE:
   202  		p.TickerGTE = &q
   203  	}
   204  	return &p
   205  }
   206  
   207  func (p ListTickerNewsParams) WithPublishedUTC(c Comparator, q Millis) *ListTickerNewsParams {
   208  	switch c {
   209  	case EQ:
   210  		p.PublishedUtcEQ = &q
   211  	case LT:
   212  		p.PublishedUtcLT = &q
   213  	case LTE:
   214  		p.PublishedUtcLTE = &q
   215  	case GT:
   216  		p.PublishedUtcGT = &q
   217  	case GTE:
   218  		p.PublishedUtcGTE = &q
   219  	}
   220  	return &p
   221  }
   222  
   223  func (p ListTickerNewsParams) WithSort(q Sort) *ListTickerNewsParams {
   224  	p.Sort = &q
   225  	return &p
   226  }
   227  
   228  func (p ListTickerNewsParams) WithOrder(q Order) *ListTickerNewsParams {
   229  	p.Order = &q
   230  	return &p
   231  }
   232  
   233  func (p ListTickerNewsParams) WithLimit(q int) *ListTickerNewsParams {
   234  	p.Limit = &q
   235  	return &p
   236  }
   237  
   238  // ListTickerNewsResponse is the response returned by the ListTickerNews method.
   239  type ListTickerNewsResponse struct {
   240  	BaseResponse
   241  
   242  	// Ticker news results.
   243  	Results []TickerNews `json:"results,omitempty"`
   244  }
   245  
   246  // GetTickerTypesParams is the set of parameters for the GetTickerTypes method.
   247  type GetTickerTypesParams struct {
   248  	// Filter by asset class.
   249  	AssetClass *AssetClass `query:"asset_class"`
   250  
   251  	// Filter by locale.
   252  	Locale *MarketLocale `query:"locale"`
   253  }
   254  
   255  func (p GetTickerTypesParams) WithAssetClass(q AssetClass) *GetTickerTypesParams {
   256  	p.AssetClass = &q
   257  	return &p
   258  }
   259  
   260  func (p GetTickerTypesParams) WithLocale(q MarketLocale) *GetTickerTypesParams {
   261  	p.Locale = &q
   262  	return &p
   263  }
   264  
   265  // GetTickerTypesResponse is the response returned by the GetTickerTypes method.
   266  type GetTickerTypesResponse struct {
   267  	BaseResponse
   268  
   269  	// Ticker type results.
   270  	Results []TickerType `json:"results,omitempty"`
   271  }
   272  
   273  // Ticker contains detailed information on a specified ticker symbol.
   274  type Ticker struct {
   275  	Active                      bool           `json:"active"`
   276  	Address                     CompanyAddress `json:"address,omitempty"`
   277  	Branding                    Branding       `json:"branding,omitempty"`
   278  	CIK                         string         `json:"cik,omitempty"`
   279  	CompositeFIGI               string         `json:"composite_figi,omitempty"`
   280  	CurrencyName                string         `json:"currency_name,omitempty"`
   281  	CurrencySymbol              string         `json:"currency_symbol,omitempty"`
   282  	BaseCurrencyName            string         `json:"base_currency_name,omitempty"`
   283  	BaseCurrencySymbol          string         `json:"base_currency_symbol,omitempty"`
   284  	DelistedUTC                 Time           `json:"delisted_utc,omitempty"`
   285  	Description                 string         `json:"description,omitempty"`
   286  	HomepageURL                 string         `json:"homepage_url,omitempty"`
   287  	LastUpdatedUTC              Time           `json:"last_updated_utc,omitempty"`
   288  	ListDate                    Date           `json:"list_date,omitempty"`
   289  	Locale                      string         `json:"locale,omitempty"`
   290  	Market                      string         `json:"market,omitempty"`
   291  	MarketCap                   float64        `json:"market_cap,omitempty"`
   292  	Name                        string         `json:"name,omitempty"`
   293  	PhoneNumber                 string         `json:"phone_number,omitempty"`
   294  	PrimaryExchange             string         `json:"primary_exchange,omitempty"`
   295  	ShareClassFIGI              string         `json:"share_class_figi,omitempty"`
   296  	ShareClassSharesOutstanding int64          `json:"share_class_shares_outstanding,omitempty"`
   297  	SICCode                     string         `json:"sic_code,omitempty"`
   298  	SICDescription              string         `json:"sic_description,omitempty"`
   299  	Ticker                      string         `json:"ticker,omitempty"`
   300  	TickerRoot                  string         `json:"ticker_root,omitempty"`
   301  	TickerSuffix                string         `json:"ticker_suffix,omitempty"`
   302  	TotalEmployees              int32          `json:"total_employees,omitempty"`
   303  	Type                        string         `json:"type,omitempty"`
   304  	WeightedSharesOutstanding   int64          `json:"weighted_shares_outstanding,omitempty"`
   305  	SourceFeed                  string         `json:"source_feed,omitempty"`
   306  }
   307  
   308  // CompanyAddress contains information on the physical address of a company.
   309  type CompanyAddress struct {
   310  	Address1   string `json:"address1,omitempty"`
   311  	Address2   string `json:"address2,omitempty"` // todo: add this to the spec
   312  	City       string `json:"city,omitempty"`
   313  	PostalCode string `json:"postal_code,omitempty"`
   314  	State      string `json:"state,omitempty"`
   315  }
   316  
   317  // Branding contains information related to a company's brand.
   318  type Branding struct {
   319  	LogoURL string `json:"logo_url,omitempty"`
   320  	IconURL string `json:"icon_url,omitempty"`
   321  }
   322  
   323  // TickerNews contains information on a ticker news article.
   324  type TickerNews struct {
   325  	AMPURL       string    `json:"amp_url,omitempty"`
   326  	ArticleURL   string    `json:"article_url,omitempty"`
   327  	Author       string    `json:"author,omitempty"`
   328  	Description  string    `json:"description,omitempty"`
   329  	ID           string    `json:"id,omitempty"`
   330  	ImageURL     string    `json:"image_url,omitempty"`
   331  	Keywords     []string  `json:"keywords,omitempty"`
   332  	PublishedUTC Time      `json:"published_utc,omitempty"`
   333  	Publisher    Publisher `json:"publisher,omitempty"`
   334  	Tickers      []string  `json:"tickers,omitempty"`
   335  	Title        string    `json:"title,omitempty"`
   336  }
   337  
   338  // Publisher contains information on a new article publisher.
   339  type Publisher struct {
   340  	FaviconURL  string `json:"favicon_url,omitempty"`
   341  	HomepageURL string `json:"homepage_url,omitempty"`
   342  	LogoURL     string `json:"logo_url,omitempty"`
   343  	Name        string `json:"name,omitempty"`
   344  }
   345  
   346  // TickerType represents a type of ticker with a code that the API understands.
   347  type TickerType struct {
   348  	AssetClass  string `json:"asset_class,omitempty"`
   349  	Code        string `json:"code,omitempty"`
   350  	Description string `json:"description,omitempty"`
   351  	Locale      string `json:"locale,omitempty"`
   352  }
   353  
   354  // GetTickerEventsParams is the set of parameters for the GetTickerEvents method.
   355  type GetTickerEventsParams struct {
   356  	// ID Identifier of an asset. This can currently be a Ticker, CUSIP, or Composite FIGI.
   357  	// When given a ticker, we return events for the entity currently represented by that ticker.
   358  	// To find events for entities previously associated with a ticker, find the relevant identifier
   359  	// using the Ticker Details Endpoint (https://polygon.io/docs/stocks/get_v3_reference_tickers__ticker).
   360  	ID string `validate:"required" path:"id"`
   361  
   362  	// A comma-separated list of the types of event to include. Currently, ticker_change is the only supported event_type. Leave blank to return all supported event_types.
   363  	Types *string `query:"types"`
   364  }
   365  
   366  func (p GetTickerEventsParams) WithTypes(types ...string) *GetTickerEventsParams {
   367  	q := strings.Join(types, ",")
   368  	p.Types = &q
   369  	return &p
   370  }
   371  
   372  // GetTickerEventsResponse is the response returned by the GetTickerEvents method.
   373  type GetTickerEventsResponse struct {
   374  	BaseResponse
   375  	Results []TickerEventResult `json:"results,omitempty"`
   376  }
   377  
   378  // TickerEventResult is the data for a ticker event.
   379  type TickerEventResult struct {
   380  	// Name is the company name.
   381  	Name   string        `json:"name"`
   382  	Events []TickerEvent `json:"events"`
   383  }
   384  
   385  // TickerEvent contains the data for the different type of ticker events that could occur.
   386  type TickerEvent struct {
   387  	Date         Date               `json:"date"`
   388  	Type         string             `json:"type"`
   389  	TickerChange *TickerChangeEvent `json:"ticker_change,omitempty"`
   390  }
   391  
   392  // TickerChangeEvent represents the data relevant to a ticker_change typed event.
   393  type TickerChangeEvent struct {
   394  	Ticker string `json:"ticker"`
   395  }