Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type AggTick
- type AggType
- type Client
- func (c *Client) GetHistoricAggregates(symbol string, resolution AggType, from, to *time.Time, limit *int) (*HistoricAggregates, error)
- func (c *Client) GetHistoricAggregatesV2(symbol string, multiplier int, resolution AggType, from, to *time.Time, ...) (*HistoricAggregatesV2, error)
- func (c *Client) GetHistoricQuotes(symbol, date string) (totalQuotes *HistoricQuotes, err error)deprecated
- func (c *Client) GetHistoricQuotesV2(ticker string, date string, opts *HistoricTicksV2Params) (*HistoricQuotesV2, error)
- func (c *Client) GetHistoricTrades(symbol string, date string, opts *GetHistoricTradesParams) (totalTrades *HistoricTrades, err error)deprecated
- func (c *Client) GetHistoricTradesV2(ticker string, date string, opts *HistoricTicksV2Params) (*HistoricTradesV2, error)
- func (c *Client) GetStockExchanges() ([]StockExchange, error)
- type GetHistoricTradesParams
- type HistoricAggregates
- type HistoricAggregatesV2
- type HistoricQuotes
- type HistoricQuotesV2
- type HistoricTicksV2Params
- type HistoricTrades
- type HistoricTradesV2
- type MapItem
- type PolgyonServerMsg
- type PolygonAuthMsg
- type PolygonClientMsg
- type QuoteTick
- type QuoteTickV2
- type StockExchange
- type Stream
- type StreamAggregate
- type StreamQuote
- type StreamTrade
- type SymbolsMetadata
- type TradeTick
- type TradeTickV2
Constants ¶
const ( MinuteAggs = "AM" SecondAggs = "A" Trades = "T" Quotes = "Q" )
const (
MaxConnectionAttempts = 3
)
Variables ¶
var ( // DefaultClient is the default Polygon client using the // environment variable set credentials DefaultClient = NewClient(common.Credentials()) )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError wraps the detailed code and message supplied by Polygon's API for debugging purposes
type AggTick ¶
type AggTick struct { Open float64 `json:"o"` High float64 `json:"h"` Low float64 `json:"l"` Close float64 `json:"c"` Volume float64 `json:"v"` EpochMilliseconds int64 `json:"t"` Items int64 `json:"n"` // v2 response only }
AggTick is the structure that contains the actual tick data included in a HistoricAggregates response
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Polygon REST API client
func (*Client) GetHistoricAggregates ¶
func (c *Client) GetHistoricAggregates( symbol string, resolution AggType, from, to *time.Time, limit *int) (*HistoricAggregates, error)
GetHistoricAggregates requests Polygon's v1 REST API for historic aggregates for the provided resolution based on the provided query parameters.
func (*Client) GetHistoricAggregatesV2 ¶
func (c *Client) GetHistoricAggregatesV2( symbol string, multiplier int, resolution AggType, from, to *time.Time, unadjusted *bool) (*HistoricAggregatesV2, error)
GetHistoricAggregates requests Polygon's v2 REST API for historic aggregates for the provided resolution based on the provided query parameters.
func (*Client) GetHistoricQuotes
deprecated
func (c *Client) GetHistoricQuotes(symbol, date string) (totalQuotes *HistoricQuotes, err error)
GetHistoricQuotes requests polygon's REST API for historic quotes on the provided date.
Deprecated: This v1 endpoint should no longer be used, as it will be removed from the Polygon API in the future. Please use GetHistoricQuotesV2 instead.
func (*Client) GetHistoricQuotesV2 ¶
func (c *Client) GetHistoricQuotesV2(ticker string, date string, opts *HistoricTicksV2Params) (*HistoricQuotesV2, error)
GetHistoricQuotesV2 requests polygon's REST API for historic trades on the provided date.
func (*Client) GetHistoricTrades
deprecated
func (c *Client) GetHistoricTrades( symbol string, date string, opts *GetHistoricTradesParams) (totalTrades *HistoricTrades, err error)
GetHistoricTrades requests polygon's REST API for historic trades on the provided date.
Deprecated: This v1 endpoint should no longer be used, as it will be removed from the Polygon API in the future. Please use GetHistoricTradesV2 instead.
func (*Client) GetHistoricTradesV2 ¶
func (c *Client) GetHistoricTradesV2(ticker string, date string, opts *HistoricTicksV2Params) (*HistoricTradesV2, error)
GetHistoricTradesV2 requests polygon's REST API for historic trades on the provided date.
func (*Client) GetStockExchanges ¶
func (c *Client) GetStockExchanges() ([]StockExchange, error)
GetStockExchanges requests available stock and equity exchanges on polygon.io
type GetHistoricTradesParams ¶
type HistoricAggregates ¶
type HistoricAggregates struct { Symbol string `json:"symbol"` AggregateType AggType `json:"aggType"` Map struct { O string `json:"o"` C string `json:"c"` H string `json:"h"` L string `json:"l"` V string `json:"v"` D string `json:"d"` } `json:"map"` Ticks []AggTick `json:"ticks"` }
HistoricAggregates is the structure that defines aggregate data served through Polygon's v1 REST API.
func GetHistoricAggregates ¶
func GetHistoricAggregates( symbol string, resolution AggType, from, to *time.Time, limit *int) (*HistoricAggregates, error)
GetHistoricAggregates requests polygon's REST API for historic aggregates for the provided resolution based on the provided query parameters using the default Polygon client.
type HistoricAggregatesV2 ¶
type HistoricAggregatesV2 struct { Symbol string `json:"ticker"` Adjusted bool `json:"adjusted"` QueryCount int `json:"queryCount"` ResultsCount int `json:"resultsCount"` Ticks []AggTick `json:"results"` }
HistoricAggregatesV2 is the structure that defines aggregate data served through Polygon's v2 REST API.
type HistoricQuotes ¶
type HistoricQuotes struct { Day string `json:"day"` Map struct { AE string `json:"aE"` AP string `json:"aP"` AS string `json:"aS"` BE string `json:"bE"` BP string `json:"bP"` BS string `json:"bS"` C string `json:"c"` T string `json:"t"` } `json:"map"` MsLatency int `json:"msLatency"` Status string `json:"status"` Symbol string `json:"symbol"` Ticks []QuoteTick `json:"ticks"` Type string `json:"type"` }
HistoricQuotes is the structure that defines quote data served through polygon's REST API.
func GetHistoricQuotes ¶
func GetHistoricQuotes(symbol, date string) (totalQuotes *HistoricQuotes, err error)
GetHistoricQuotes requests polygon's REST API for historic quotes on the provided date using the default Polygon client.
type HistoricQuotesV2 ¶
type HistoricQuotesV2 struct { ResultsCount int64 `json:"results_count"` Ticker string `json:"ticker"` Results []QuoteTickV2 `json:"results"` Map map[string]MapItem `json:"map"` }
HistoricQuotesV2 is the structure that defines trade data served through polygon's REST API.
type HistoricTicksV2Params ¶
type HistoricTrades ¶
type HistoricTrades struct { Day string `json:"day"` Map struct { C1 string `json:"c1"` C2 string `json:"c2"` C3 string `json:"c3"` C4 string `json:"c4"` E string `json:"e"` P string `json:"p"` S string `json:"s"` T string `json:"t"` } `json:"map"` MsLatency int `json:"msLatency"` Status string `json:"status"` Symbol string `json:"symbol"` Ticks []TradeTick `json:"ticks"` Type string `json:"type"` }
HistoricTrades is the structure that defines trade data served through polygon's REST API.
func GetHistoricTrades ¶
func GetHistoricTrades( symbol string, date string, opts *GetHistoricTradesParams) (totalTrades *HistoricTrades, err error)
GetHistoricTrades requests polygon's REST API for historic trades on the provided date using the default Polygon client.
type HistoricTradesV2 ¶
type HistoricTradesV2 struct { ResultsCount int64 `json:"results_count"` Ticker string `json:"ticker"` Results []TradeTickV2 `json:"results"` Map map[string]MapItem `json:"map"` }
HistoricTradesV2 is the structure that defines trade data served through polygon's REST API.
type PolgyonServerMsg ¶
type PolgyonServerMsg struct {
Event string `json:"ev"`
}
PolygonServerMsg contains the field that is present in all responses to identify their type
type PolygonAuthMsg ¶
type PolygonClientMsg ¶
PolygonClientMsg is the standard message sent by clients of the stream interface
type QuoteTick ¶
type QuoteTick struct { Timestamp int64 `json:"t"` BidExchange string `json:"bE"` AskExchange string `json:"aE"` BidPrice float64 `json:"bP"` AskPrice float64 `json:"aP"` BidSize int `json:"bS"` AskSize int `json:"aS"` Condition int `json:"c"` }
QuoteTick is the structure that contains the actual tick data included in a HistoricQuotes response
type QuoteTickV2 ¶
type QuoteTickV2 struct { SIPTimestamp *int64 `json:"t"` ParticipantTimestamp *int64 `json:"y"` TRFTimestamp *int64 `json:"f"` SequenceNumber *int `json:"q"` Indicators *[]int `json:"i"` BidExchange *int `json:"x"` AskExchange *int `json:"X"` TRFID *int `json:"r"` Size *int `json:"s"` Conditions *[]int `json:"c"` BidPrice *float64 `json:"p"` AskPrice *float64 `json:"P"` BidSize *int `json:"s"` AskSize *int `json:"S"` Tape *int `json:"z"` }
QuoteTickV2 is the structure that contains the actual tick data included in a HistoricQuotesV2 response
type StockExchange ¶
type StockExchange struct { Id int64 `json:"id"` Type string `json:"type"` Market string `json:"market"` Mic string `json:"mic"` Name string `json:"name"` Tape string `json:"tape"` }
Exchange defines the Stocks / Equities "Exchange" endpoint response
func GetStockExchanges ¶
func GetStockExchanges() ([]StockExchange, error)
GetStockExchanges queries Polygon.io REST API for information on available stock and equities exchanges
type Stream ¶
func (*Stream) Unsubscribe ¶
Unsubscribe the specified Polygon stream channel.
type StreamAggregate ¶
type StreamAggregate struct { Event string `json:"ev"` Symbol string `json:"sym"` Volume int `json:"v"` AccumulatedVolume int `json:"av"` OpeningPrice float64 `json:"op"` VWAP float64 `json:"vw"` OpenPrice float64 `json:"o"` ClosePrice float64 `json:"c"` HighPrice float64 `json:"h"` LowPrice float64 `json:"l"` Average float64 `json:"a"` StartTimestamp int64 `json:"s"` EndTimestamp int64 `json:"e"` }
StreamAggregate is the structure that defines an aggregate that polygon transmits via websocket protocol.
type StreamQuote ¶
type StreamQuote struct { Symbol string `json:"sym"` Condition int `json:"c"` BidExchange int `json:"bx"` AskExchange int `json:"ax"` BidPrice float64 `json:"bp"` AskPrice float64 `json:"ap"` BidSize int64 `json:"bs"` AskSize int64 `json:"as"` Timestamp int64 `json:"t"` }
StreamQuote is the structure that defines a quote that polygon transmits via websocket protocol.
type StreamTrade ¶
type StreamTrade struct { Symbol string `json:"sym"` Exchange int `json:"x"` TradeID string `json:"i"` Price float64 `json:"p"` Size int64 `json:"s"` Timestamp int64 `json:"t"` Conditions []int `json:"c"` }
StreamTrade is the structure that defines a trade that polygon transmits via websocket protocol.
type SymbolsMetadata ¶
type SymbolsMetadata struct { Symbols []struct { Symbol string `json:"symbol"` Name string `json:"name"` Type string `json:"type"` Updated time.Time `json:"updated"` IsOTC bool `json:"isOTC"` URL string `json:"url"` } `json:"symbols"` }
SymbolsMetadata is the structure that defines symbol metadata served through polygon's REST API.
type TradeTick ¶
type TradeTick struct { Timestamp int64 `json:"t"` Price float64 `json:"p"` Size int `json:"s"` Exchange string `json:"e"` Condition1 int `json:"c1"` Condition2 int `json:"c2"` Condition3 int `json:"c3"` Condition4 int `json:"c4"` }
TradeTick is the structure that contains the actual tick data included in a HistoricTrades response
type TradeTickV2 ¶
type TradeTickV2 struct { SIPTimestamp *int64 `json:"t"` ParticipantTimestamp *int64 `json:"y"` TRFTimestamp *int64 `json:"f"` SequenceNumber *int `json:"q"` ID *string `json:"i"` OrigID *string `json:"I"` Exchange *int `json:"x"` TRFID *int `json:"r"` Size *int `json:"s"` Conditions *[]int `json:"c"` Price *float64 `json:"p"` Tape *int `json:"z"` Correction *int `json:"e"` }
TradeTickV2 is the structure that contains the actual tick data included in a HistoricTradesV2 response