Documentation ¶
Overview ¶
Package polygon defines a REST client for the Polygon API.
Index ¶
- Constants
- type AggsClient
- func (ac *AggsClient) GetAggs(ctx context.Context, params *models.GetAggsParams, ...) (*models.GetAggsResponse, error)
- func (ac *AggsClient) GetDailyOpenCloseAgg(ctx context.Context, params *models.GetDailyOpenCloseAggParams, ...) (*models.GetDailyOpenCloseAggResponse, error)
- func (ac *AggsClient) GetGroupedDailyAggs(ctx context.Context, params *models.GetGroupedDailyAggsParams, ...) (*models.GetGroupedDailyAggsResponse, error)
- func (ac *AggsClient) GetPreviousCloseAgg(ctx context.Context, params *models.GetPreviousCloseAggParams, ...) (*models.GetPreviousCloseAggResponse, error)
- type Client
- type QuotesClient
- func (c *QuotesClient) GetLastForexQuote(ctx context.Context, params *models.GetLastForexQuoteParams, ...) (*models.GetLastForexQuoteResponse, error)
- func (c *QuotesClient) GetLastQuote(ctx context.Context, params *models.GetLastQuoteParams, ...) (*models.GetLastQuoteResponse, error)
- func (c *QuotesClient) GetRealTimeCurrencyConversion(ctx context.Context, params *models.GetRealTimeCurrencyConversionParams, ...) (*models.GetRealTimeCurrencyConversionResponse, error)
- func (c *QuotesClient) ListQuotes(ctx context.Context, params *models.ListQuotesParams, ...) *iter.Iter[models.Quote]
- type ReferenceClient
- func (c *ReferenceClient) GetExchanges(ctx context.Context, params *models.GetExchangesParams, ...) (*models.GetExchangesResponse, error)
- func (c *ReferenceClient) GetMarketHolidays(ctx context.Context, options ...models.RequestOption) (*models.GetMarketHolidaysResponse, error)
- func (c *ReferenceClient) GetMarketStatus(ctx context.Context, options ...models.RequestOption) (*models.GetMarketStatusResponse, error)
- func (c *ReferenceClient) GetOptionsContract(ctx context.Context, params *models.GetOptionsContractParams, ...) (*models.GetOptionsContractResponse, error)
- func (c *ReferenceClient) GetTickerDetails(ctx context.Context, params *models.GetTickerDetailsParams, ...) (*models.GetTickerDetailsResponse, error)
- func (c *ReferenceClient) GetTickerTypes(ctx context.Context, params *models.GetTickerTypesParams, ...) (*models.GetTickerTypesResponse, error)
- func (c *ReferenceClient) ListConditions(ctx context.Context, params *models.ListConditionsParams, ...) *iter.Iter[models.Condition]
- func (c *ReferenceClient) ListDividends(ctx context.Context, params *models.ListDividendsParams, ...) *iter.Iter[models.Dividend]
- func (c *ReferenceClient) ListOptionsContracts(ctx context.Context, params *models.ListOptionsContractsParams, ...) *iter.Iter[models.OptionsContract]
- func (c *ReferenceClient) ListSplits(ctx context.Context, params *models.ListSplitsParams, ...) *iter.Iter[models.Split]
- func (c *ReferenceClient) ListTickerNews(ctx context.Context, params *models.ListTickerNewsParams, ...) *iter.Iter[models.TickerNews]
- func (c *ReferenceClient) ListTickers(ctx context.Context, params *models.ListTickersParams, ...) *iter.Iter[models.Ticker]
- type SnapshotClient
- func (ac *SnapshotClient) GetAllTickersSnapshot(ctx context.Context, params *models.GetAllTickersSnapshotParams, ...) (*models.GetAllTickersSnapshotResponse, error)
- func (ac *SnapshotClient) GetCryptoFullBookSnapshot(ctx context.Context, params *models.GetCryptoFullBookSnapshotParams, ...) (*models.GetCryptoFullBookSnapshotResponse, error)
- func (ac *SnapshotClient) GetGainersLosersSnapshot(ctx context.Context, params *models.GetGainersLosersSnapshotParams, ...) (*models.GetGainersLosersSnapshotResponse, error)
- func (ac *SnapshotClient) GetOptionContractSnapshot(ctx context.Context, params *models.GetOptionContractSnapshotParams, ...) (*models.GetOptionContractSnapshotResponse, error)
- func (ac *SnapshotClient) GetTickerSnapshot(ctx context.Context, params *models.GetTickerSnapshotParams, ...) (*models.GetTickerSnapshotResponse, error)
- type TradesClient
- func (c *TradesClient) GetLastCryptoTrade(ctx context.Context, params *models.GetLastCryptoTradeParams, ...) (*models.GetLastCryptoTradeResponse, error)
- func (c *TradesClient) GetLastTrade(ctx context.Context, params *models.GetLastTradeParams, ...) (*models.GetLastTradeResponse, error)
- func (c *TradesClient) ListTrades(ctx context.Context, params *models.ListTradesParams, ...) *iter.Iter[models.Trade]
- type VXClient
Constants ¶
const ( GetAggsPath = "/v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}" GetGroupedDailyAggsPath = "/v2/aggs/grouped/locale/{locale}/market/{marketType}/{date}" GetDailyOpenCloseAggPath = "/v1/open-close/{ticker}/{date}" GetPreviousCloseAggPath = "/v2/aggs/ticker/{ticker}/prev" )
const ( ListQuotesPath = "/v3/quotes/{ticker}" GetLastQuotePath = "/v2/last/nbbo/{ticker}" GetLastForexQuotePath = "/v1/last_quote/currencies/{from}/{to}" GetRealTimeCurrencyConversionPath = "/v1/conversion/{from}/{to}" )
const ( ListTickersPath = "/v3/reference/tickers" GetTickerDetailsPath = "/v3/reference/tickers/{ticker}" ListTickerNewsPath = "/v2/reference/news" GetTickerTypesPath = "/v3/reference/tickers/types" GetMarketHolidaysPath = "/v1/marketstatus/upcoming" GetMarketStatusPath = "/v1/marketstatus/now" ListSplitsPath = "/v3/reference/splits" ListDividendsPath = "/v3/reference/dividends" ListConditionsPath = "/v3/reference/conditions" GetExchangesPath = "/v3/reference/exchanges" GetOptionsContractPath = "/v3/reference/options/contracts/{ticker}" ListOptionsContractsPath = "/v3/reference/options/contracts" )
const ( GetAllTickersSnapshotPath = "/v2/snapshot/locale/{locale}/markets/{marketType}/tickers" GetTickerSnapshotPath = "/v2/snapshot/locale/{locale}/markets/{marketType}/tickers/{ticker}" GetGainersLosersSnapshotPath = "/v2/snapshot/locale/{locale}/markets/{marketType}/{direction}" GetOptionContractSnapshotPath = "/v3/snapshot/options/{underlyingAsset}/{optionContract}" GetCryptoFullBookSnapshotPath = "/v2/snapshot/locale/global/markets/crypto/tickers/{ticker}/book" )
const ( ListTradesPath = "/v3/trades/{ticker}" GetLastTradePath = "/v2/last/trade/{ticker}" GetLastCryptoTradePath = "/v1/last/crypto/{from}/{to}" )
const (
ListFinancialsPath = "/vX/reference/financials"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggsClient ¶
AggsClient defines a REST client for the Polygon aggs API.
func (*AggsClient) GetAggs ¶
func (ac *AggsClient) GetAggs(ctx context.Context, params *models.GetAggsParams, opts ...models.RequestOption) (*models.GetAggsResponse, error)
GetAggs retrieves aggregate bars for a specified ticker over a given date range in custom time window sizes. For example, if timespan = ‘minute’ and multiplier = ‘5’ then 5-minute bars will be returned. For more details see https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to.
func (*AggsClient) GetDailyOpenCloseAgg ¶
func (ac *AggsClient) GetDailyOpenCloseAgg(ctx context.Context, params *models.GetDailyOpenCloseAggParams, opts ...models.RequestOption) (*models.GetDailyOpenCloseAggResponse, error)
GetDailyOpenCloseAgg retrieves the open, close and afterhours prices of a specific symbol on a certain date. For more details see https://polygon.io/docs/stocks/get_v1_open-close__stocksticker___date.
func (*AggsClient) GetGroupedDailyAggs ¶
func (ac *AggsClient) GetGroupedDailyAggs(ctx context.Context, params *models.GetGroupedDailyAggsParams, opts ...models.RequestOption) (*models.GetGroupedDailyAggsResponse, error)
GetGroupedDailyAggs retrieves the daily open, high, low, and close (OHLC) for the specified market type. For more details see https://polygon.io/docs/stocks/get_v2_aggs_grouped_locale_us_market_stocks__date.
func (*AggsClient) GetPreviousCloseAgg ¶
func (ac *AggsClient) GetPreviousCloseAgg(ctx context.Context, params *models.GetPreviousCloseAggParams, opts ...models.RequestOption) (*models.GetPreviousCloseAggResponse, error)
GetPreviousCloseAgg retrieves the previous day's open, high, low, and close (OHLC) for the specified ticker. For more details see https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__prev.
type Client ¶ added in v0.4.0
type Client struct { client.Client AggsClient QuotesClient ReferenceClient TradesClient SnapshotClient VX VXClient }
Client defines a client to the Polygon REST API.
type QuotesClient ¶
QuotesClient defines a REST client for the Polygon quotes API.
func (*QuotesClient) GetLastForexQuote ¶
func (c *QuotesClient) GetLastForexQuote(ctx context.Context, params *models.GetLastForexQuoteParams, options ...models.RequestOption) (*models.GetLastForexQuoteResponse, error)
GetLastForexQuote retrieves the last quote (BBO) for a forex currency pair. For more details see https://polygon.io/docs/forex/get_v1_last_quote_currencies__from___to.
func (*QuotesClient) GetLastQuote ¶
func (c *QuotesClient) GetLastQuote(ctx context.Context, params *models.GetLastQuoteParams, options ...models.RequestOption) (*models.GetLastQuoteResponse, error)
GetLastQuote retrieves the last quote (NBBO) for a specified ticker. For more details see https://polygon.io/docs/stocks/get_v2_last_nbbo__stocksticker.
func (*QuotesClient) GetRealTimeCurrencyConversion ¶ added in v0.5.0
func (c *QuotesClient) GetRealTimeCurrencyConversion(ctx context.Context, params *models.GetRealTimeCurrencyConversionParams, options ...models.RequestOption) (*models.GetRealTimeCurrencyConversionResponse, error)
GetRealTimeCurrencyConversion retrieves retrieves currency conversion using the latest market conversion rates. Note that you can convert in both directions. For more details see https://polygon.io/docs/forex/get_v1_conversion__from___to.
func (*QuotesClient) ListQuotes ¶
func (c *QuotesClient) ListQuotes(ctx context.Context, params *models.ListQuotesParams, options ...models.RequestOption) *iter.Iter[models.Quote]
ListQuotes retrieves quotes for a specified ticker. For more details see https://polygon.io/docs/stocks/get_v3_quotes__stockticker.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListQuotes(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
type ReferenceClient ¶
ReferenceClient defines a REST client for the Polygon reference API.
func (*ReferenceClient) GetExchanges ¶
func (c *ReferenceClient) GetExchanges(ctx context.Context, params *models.GetExchangesParams, options ...models.RequestOption) (*models.GetExchangesResponse, error)
GetExchanges lists all exchanges that Polygon knows about. For more details see https://polygon.io/docs/stocks/get_v3_reference_exchanges.
func (*ReferenceClient) GetMarketHolidays ¶
func (c *ReferenceClient) GetMarketHolidays(ctx context.Context, options ...models.RequestOption) (*models.GetMarketHolidaysResponse, error)
GetMarketHolidays retrieves upcoming market holidays and their open/close times. For more details see https://polygon.io/docs/stocks/get_v1_marketstatus_upcoming.
func (*ReferenceClient) GetMarketStatus ¶
func (c *ReferenceClient) GetMarketStatus(ctx context.Context, options ...models.RequestOption) (*models.GetMarketStatusResponse, error)
GetMarketStatus retrieves the current trading status of the exchanges and overall financial markets. For more details see https://polygon.io/docs/stocks/get_v1_marketstatus_now.
func (*ReferenceClient) GetOptionsContract ¶ added in v0.10.0
func (c *ReferenceClient) GetOptionsContract(ctx context.Context, params *models.GetOptionsContractParams, options ...models.RequestOption) (*models.GetOptionsContractResponse, error)
GetOptionsContract retrieves a historical options contract. For more details see https://polygon.io/docs/options/get_v3_reference_options_contracts__options_ticker.
func (*ReferenceClient) GetTickerDetails ¶
func (c *ReferenceClient) GetTickerDetails(ctx context.Context, params *models.GetTickerDetailsParams, options ...models.RequestOption) (*models.GetTickerDetailsResponse, error)
GetTickerDetails retrieves details for a specified ticker. For more details see https://polygon.io/docs/stocks/get_v3_reference_tickers__ticker.
func (*ReferenceClient) GetTickerTypes ¶
func (c *ReferenceClient) GetTickerTypes(ctx context.Context, params *models.GetTickerTypesParams, options ...models.RequestOption) (*models.GetTickerTypesResponse, error)
GetTickerTypes retrieves all the possible ticker types that can be queried. For more details see https://polygon.io/docs/stocks/get_v3_reference_tickers_types.
func (*ReferenceClient) ListConditions ¶
func (c *ReferenceClient) ListConditions(ctx context.Context, params *models.ListConditionsParams, options ...models.RequestOption) *iter.Iter[models.Condition]
ListConditions retrieves reference conditions. For more details see https://polygon.io/docs/stocks/get_v3_reference_conditions.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListConditions(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
func (*ReferenceClient) ListDividends ¶
func (c *ReferenceClient) ListDividends(ctx context.Context, params *models.ListDividendsParams, options ...models.RequestOption) *iter.Iter[models.Dividend]
ListDividends retrieves reference dividends. For more details see https://polygon.io/docs/stocks/get_v3_reference_dividends.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListDividends(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
func (*ReferenceClient) ListOptionsContracts ¶ added in v0.10.0
func (c *ReferenceClient) ListOptionsContracts(ctx context.Context, params *models.ListOptionsContractsParams, options ...models.RequestOption) *iter.Iter[models.OptionsContract]
ListOptionsContracts lists historical options contracts. For more details see https://polygon.io/docs/options/get_v3_reference_options_contracts.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListConditions(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
func (*ReferenceClient) ListSplits ¶
func (c *ReferenceClient) ListSplits(ctx context.Context, params *models.ListSplitsParams, options ...models.RequestOption) *iter.Iter[models.Split]
ListSplits retrieves reference splits. For more details see https://polygon.io/docs/stocks/get_v3_reference_splits.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListSplits(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
func (*ReferenceClient) ListTickerNews ¶ added in v0.4.0
func (c *ReferenceClient) ListTickerNews(ctx context.Context, params *models.ListTickerNewsParams, options ...models.RequestOption) *iter.Iter[models.TickerNews]
ListTickerNews retrieves news articles for a specified ticker. For more details see https://polygon.io/docs/stocks/get_v2_reference_news.
func (*ReferenceClient) ListTickers ¶
func (c *ReferenceClient) ListTickers(ctx context.Context, params *models.ListTickersParams, options ...models.RequestOption) *iter.Iter[models.Ticker]
ListTickers retrieves reference tickers. For more details see https://polygon.io/docs/stocks/get_v3_reference_tickers__ticker.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListTickers(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
type SnapshotClient ¶
SnapshotClient defines a REST client for the Polygon snapshot API.
func (*SnapshotClient) GetAllTickersSnapshot ¶
func (ac *SnapshotClient) GetAllTickersSnapshot(ctx context.Context, params *models.GetAllTickersSnapshotParams, opts ...models.RequestOption) (*models.GetAllTickersSnapshotResponse, error)
GetAllTickersSnapshot gets the current minute, day, and previous day’s aggregate, as well as the last trade and quote for all symbols of a specified market type.
Note: Snapshot data is cleared at 12am EST and gets populated as data is received from the exchanges. This can happen as early as 4am EST.
For more details see https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers.
func (*SnapshotClient) GetCryptoFullBookSnapshot ¶
func (ac *SnapshotClient) GetCryptoFullBookSnapshot(ctx context.Context, params *models.GetCryptoFullBookSnapshotParams, opts ...models.RequestOption) (*models.GetCryptoFullBookSnapshotResponse, error)
GetCryptoFullBookSnapshot gets the current level 2 book of a single cryptocurrency ticker. This is the combined book from all of the exchanges.
Note: Snapshot data is cleared at 12am EST and gets populated as data is received from the exchanges.
For more details see https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker__book.
func (*SnapshotClient) GetGainersLosersSnapshot ¶
func (ac *SnapshotClient) GetGainersLosersSnapshot(ctx context.Context, params *models.GetGainersLosersSnapshotParams, opts ...models.RequestOption) (*models.GetGainersLosersSnapshotResponse, error)
GetGainersLosersSnapshot gets the current top 20 gainers or losers of the day in a specific market type.
Top gainers are those tickers whose price has increased by the highest percentage since the previous day's close. Top losers are those tickers whose price has decreased by the highest percentage since the previous day's close.
Note: Snapshot data is cleared at 12am EST and gets populated as data is received from the exchanges.
For more details see https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks__direction.
func (*SnapshotClient) GetOptionContractSnapshot ¶
func (ac *SnapshotClient) GetOptionContractSnapshot(ctx context.Context, params *models.GetOptionContractSnapshotParams, opts ...models.RequestOption) (*models.GetOptionContractSnapshotResponse, error)
GetOptionContractSnapshot gets the snapshot of an option contract for a stock equity. For more details see https://polygon.io/docs/options/get_v3_snapshot_options__underlyingasset___optioncontract.
func (*SnapshotClient) GetTickerSnapshot ¶
func (ac *SnapshotClient) GetTickerSnapshot(ctx context.Context, params *models.GetTickerSnapshotParams, opts ...models.RequestOption) (*models.GetTickerSnapshotResponse, error)
GetTickerSnapshot gets the current minute, day, and previous day’s aggregate, as well as the last trade and quote for a single traded symbol of a specified market type.
Note: Snapshot data is cleared at 12am EST and gets populated as data is received from the exchanges. This can happen as early as 4am EST.
For more details see https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers__stocksticker.
type TradesClient ¶
TradesClient defines a REST client for the Polygon trades API.
func (*TradesClient) GetLastCryptoTrade ¶
func (c *TradesClient) GetLastCryptoTrade(ctx context.Context, params *models.GetLastCryptoTradeParams, options ...models.RequestOption) (*models.GetLastCryptoTradeResponse, error)
GetLastCryptoTrade retrieves the last trade for a crypto pair. For more details see https://polygon.io/docs/crypto/get_v1_last_crypto__from___to.
func (*TradesClient) GetLastTrade ¶
func (c *TradesClient) GetLastTrade(ctx context.Context, params *models.GetLastTradeParams, options ...models.RequestOption) (*models.GetLastTradeResponse, error)
GetLastTrade retrieves the last trade for a specified ticker. For more details see https://polygon.io/docs/stocks/get_v2_last_trade__stocksticker.
func (*TradesClient) ListTrades ¶
func (c *TradesClient) ListTrades(ctx context.Context, params *models.ListTradesParams, options ...models.RequestOption) *iter.Iter[models.Trade]
ListTrades retrieves trades for a specified ticker. For more details see https://polygon.io/docs/stocks/get_v3_trades__stockticker.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListTrades(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }
type VXClient ¶ added in v0.7.0
VXClient defines a REST client for the Polygon VX (experimental) API.
func (*VXClient) ListStockFinancials ¶ added in v0.7.0
func (c *VXClient) ListStockFinancials(ctx context.Context, params *models.ListStockFinancialsParams, options ...models.RequestOption) *iter.Iter[models.StockFinancial]
Get historical financial data for a stock ticker. The financials data is extracted from XBRL from company SEC filings using the methodology outlined here: http://xbrl.squarespace.com/understanding-sec-xbrl-financi/.
Note: this method utilizes an experimental API and could experience breaking changes or deprecation.
This method returns an iterator that should be used to access the results via this pattern:
iter, err := c.ListStockFinancials(context.TODO(), params, opts...) for iter.Next() { log.Print(iter.Item()) // do something with the current value } if iter.Err() != nil { return err }