github.com/polygon-io/client-go@v1.16.4/rest/vx.go (about) 1 package polygon 2 3 import ( 4 "context" 5 "net/http" 6 7 "github.com/polygon-io/client-go/rest/client" 8 "github.com/polygon-io/client-go/rest/iter" 9 "github.com/polygon-io/client-go/rest/models" 10 ) 11 12 const ( 13 ListFinancialsPath = "/vX/reference/financials" 14 GetTickerEventsPath = "/vX/reference/tickers/{id}/events" 15 ) 16 17 // VXClient defines a REST client for the Polygon VX (experimental) API. 18 type VXClient struct { 19 client.Client 20 } 21 22 // ListStockFinancials retrieves historical financial data for a stock ticker. The financials data is extracted from XBRL from company SEC filings 23 // using the methodology outlined here: http://xbrl.squarespace.com/understanding-sec-xbrl-financi/. 24 // 25 // Note: this method utilizes an experimental API and could experience breaking changes or deprecation. 26 // 27 // This method returns an iterator that should be used to access the results via this pattern: 28 // 29 // iter := c.ListStockFinancials(context.TODO(), params, opts...) 30 // for iter.Next() { 31 // log.Print(iter.Item()) // do something with the current value 32 // } 33 // if iter.Err() != nil { 34 // return iter.Err() 35 // } 36 func (c *VXClient) ListStockFinancials(ctx context.Context, params *models.ListStockFinancialsParams, options ...models.RequestOption) *iter.Iter[models.StockFinancial] { 37 return iter.NewIter(ctx, ListFinancialsPath, params, func(uri string) (iter.ListResponse, []models.StockFinancial, error) { 38 res := &models.ListStockFinancialsResponse{} 39 err := c.CallURL(ctx, http.MethodGet, uri, res, options...) 40 return res, res.Results, err 41 }) 42 } 43 44 // GetTickerEvents retrieves a timeline of events for the entity associated with the given ticker, CUSIP, or Composite FIGI. 45 // // For more details see https://polygon.io/docs/stocks/get_vx_reference_tickers__id__events. 46 func (c *VXClient) GetTickerEvents(ctx context.Context, params *models.GetTickerEventsParams, options ...models.RequestOption) (*models.GetTickerEventsResponse, error) { 47 res := &models.GetTickerEventsResponse{} 48 err := c.Call(ctx, http.MethodGet, GetTickerEventsPath, params, res, options...) 49 return res, err 50 }