Documentation ¶
Index ¶
- Variables
- func ConvertExchangeCode(exchange int) enum.Exchange
- func ConvertQuoteCondition(condition int) enum.QuoteCondition
- func ConvertTapeCode(tape int) enum.Tape
- func ConvertTradeCondition(condition int) enum.TradeCondition
- func SetAPIKey(key string)
- func SetBaseURL(url string)
- func SetWSServers(serverList string)
- type AggResult
- type GetAggregatesResponse
- type HistoricAggregates
- type HistoricQuotes
- type HistoricTrades
- type ListTickersResponse
- type PolyAggregate
- type PolyQuote
- type PolyTrade
- type PolygonWebSocket
- type Prefix
- type QuoteTick
- type Subscription
- type SubscriptionScope
- type Ticker
- type TradeTick
Constants ¶
This section is empty.
Variables ¶
var (
NY, _ = time.LoadLocation("America/New_York")
CacheDir = ""
FromCache = false
)
var QuoteConditionMapping = map[int]enum.QuoteCondition{ 1: enum.RegularTwoSidedOpen, 3: enum.SlowQuoteOfferSide, 4: enum.SlowQuoteBidSide, 5: enum.SlowQuoteBidAndOfferSide, 6: enum.SlowQuoteLRPBidSide, 7: enum.SlowQuoteLRPOfferSide, 9: enum.SlowQuoteSetSlowList, 10: enum.ManualAskAutomatedBid, 11: enum.ManualBidAutomatedAsk, 12: enum.ManualBidAndAsk, 13: enum.OpeningQuote, 14: enum.ClosingQuote, 15: enum.ClosedQuote, 17: enum.FastTrading, 19: enum.MarketMakerQuotesClosed, 20: enum.NonFirmQuote, 22: enum.OrderInflux, 23: enum.OrderImbalance, 32: enum.NoOpenNoResume, }
var TradeConditionMapping = map[int]enum.TradeCondition{ 0: enum.RegularSale, 1: enum.Acquisition, 2: enum.AveragePriceTrade, 3: enum.AutomaticExecution, 4: enum.BunchedTrade, 5: enum.BunchedSoldTrade, 7: enum.CashSale, 8: enum.ClosingPrints, 9: enum.CrossTrade, 10: enum.DerivativelyPriced, 11: enum.Distribution, 12: enum.FormT, 13: enum.ExtendedHoursTrade, 14: enum.IntermarketSweep, 15: enum.MarketCenterOfficialClose, 16: enum.MarketCenterOfficialOpen, 20: enum.NextDay, 21: enum.PriceVariationTrade, 22: enum.PriorReferencePrice, 23: enum.Rule155Trade, 25: enum.OpeningPrints, 27: enum.StoppedStock, 28: enum.ReopeningPrints, 29: enum.Seller, 30: enum.SoldLast, 33: enum.SoldOutOfSequence, 34: enum.SplitTrade, 36: enum.YellowFlagRegularTrade, 37: enum.OddLotTrade, 38: enum.CorrectedConsolidatedClose, 52: enum.ContingentTrade, 53: enum.QualifiedContingentTrade, }
TradeConditionMapping provides a mapping from Polygon integer format to Marketstore's internal representation
Functions ¶
func ConvertExchangeCode ¶ added in v4.1.0
ConvertExchangeCode converts a Polygon exchange id to the internal representation
func ConvertQuoteCondition ¶ added in v4.1.0
func ConvertQuoteCondition(condition int) enum.QuoteCondition
ConvertQuoteCondition converts between Polygon trade condition format and Marketstore's internal represention
func ConvertTapeCode ¶ added in v4.1.0
ConvertTapeCode converts between Polygons' TapeID and Marketstore's internal representation
func ConvertTradeCondition ¶ added in v4.1.0
func ConvertTradeCondition(condition int) enum.TradeCondition
ConvertTradeCondition converts between Polygon trade condition format and Marketstore's internal represention
func SetBaseURL ¶
func SetBaseURL(url string)
func SetWSServers ¶
func SetWSServers(serverList string)
Types ¶
type AggResult ¶ added in v4.0.1
type AggResult struct { // Volume should be int but json.Decode fails with: "cannot unmarshal number 1.70888e+06 into Go struct" Volume float64 `json:"v"` Open float64 `json:"o"` Close float64 `json:"c"` High float64 `json:"h"` Low float64 `json:"l"` EpochMilliseconds int64 `json:"t"` NumberOfItems int `json:"n"` }
AggResult is the structure that defines the actual Aggregate result
type GetAggregatesResponse ¶
type GetAggregatesResponse struct { Symbol string `json:"symbol"` AggType string `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 []struct { Open float64 `json:"o"` Close float64 `json:"c"` High float64 `json:"h"` Low float64 `json:"l"` Volume int `json:"v"` EpochMillis int64 `json:"d"` } `json:"ticks"` }
type HistoricAggregates ¶
type HistoricAggregates struct { Ticker string `json:"ticker"` Status string `json:"status"` Adjusted bool `json:"adjusted"` QueryCount int `json:"queryCount"` ResultCount int `json:"resultCount"` Results []AggResult `json:"results"` }
HistoricAggregates is the structure that defines aggregate data served through polygon's REST API.
func GetHistoricAggregates ¶
func GetHistoricAggregates( ticker, timespan string, multiplier int, from, to time.Time, limit *int, unadjusted bool) (*HistoricAggregates, error)
GetHistoricAggregates requests polygon's REST API for aggregates for the provided resolution based on the provided parameters.
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, batchSize int) (totalQuotes *HistoricQuotes, err error)
GetHistoricQuotes requests polygon's REST API for historic quotes on the provided date.
type HistoricTrades ¶
type HistoricTrades struct { Ticker string `json:"ticker"` Success bool `json:"success"` ResultsCount int `json:"results_count"` Results []TradeTick `json:"results"` DbLatency int `json:"db_latency"` }
HistoricTrades is the structure that defines trade data served through polygon's REST API.
func GetHistoricTrades ¶
func GetHistoricTrades(symbol, date string, batchSize int) (totalTrades *HistoricTrades, err error)
GetHistoricTrades requests polygon's REST API for historic trades on the provided date .
type ListTickersResponse ¶
type PolyAggregate ¶
type PolyTrade ¶
type PolyTrade struct { Symbol string `json:"sym"` Price float64 `json:"p"` Size int `json:"s"` Timestamp int64 `json:"t"` Conditions []int `json:"c"` // contains filtered or unexported fields }
Streaming Schema from Polygon
// Stocks QUOTE:
{ "ev": "Q", // Event Type "sym": "MSFT", // Symbol Ticker "bx": "4", // Bix Exchange ID "bp": 114.125, // Bid Price "bs": 100, // Bid Size "ax": "7", // Ask Exchange ID "ap": 114.128, // Ask Price "as": 160, // Ask Size "c": 0, // Quote Condition "t": 1536036818784 // Quote Timestamp ( Unix MS ) }
// Stocks Aggregate:
{ "ev": "AM", // Event Type ( A = Second Agg, AM = Minute Agg ) "sym": "MSFT", // Symbol Ticker "v": 10204, // Tick Volume "av": 200304, // Accumlated Volume ( Today ) "op": 114.04, // Todays official opening price "vw": 114.4040, // VWAP (Volume Weighted Average Price) "o": 114.11, // Tick Open Price "c": 114.14, // Tick Close Price "h": 114.19, // Tick High Price "l": 114.09, // Tick Low Price "a": 114.1314, // Tick Average / VWAP Price "s": 1536036818784, // Tick Start Timestamp ( Unix MS ) "e": 1536036818784, // Tick End Timestamp ( Unix MS ) }
Streaming data
type PolygonWebSocket ¶
func NewPolygonWebSocket ¶
func NewPolygonWebSocket(servers, apiKey string, pref Prefix, symbols []string, oChan chan interface{}) *PolygonWebSocket
type QuoteTick ¶
type QuoteTick struct { Timestamp int64 `json:"t"` BidExchange int `json:"bE"` AskExchange int `json:"aE"` BidPrice float64 `json:"bP"` AskPrice float64 `json:"aP"` BidSize int `json:"bS"` AskSize int `json:"aS"` Condition int `json:"c"` Tape int `json:"z"` }
QuoteTick is the structure that contains the actual tick data included in a HistoricQuotes response
type Subscription ¶
type Subscription struct { Incoming chan interface{} sync.Mutex // contains filtered or unexported fields }
func NewSubscription ¶
func NewSubscription(t Prefix, symbols []string) (s *Subscription)
servers := utils.Settings["WS_SERVERS"]
func (*Subscription) GetHandled ¶
func (s *Subscription) GetHandled() int
func (*Subscription) Hangup ¶
func (s *Subscription) Hangup()
func (*Subscription) IncrementHandled ¶
func (s *Subscription) IncrementHandled()
func (*Subscription) IsActive ¶
func (s *Subscription) IsActive() bool
func (*Subscription) ResetHandled ¶
func (s *Subscription) ResetHandled()
func (*Subscription) Subscribe ¶
func (s *Subscription) Subscribe(handler func(msg []byte))
Subscribe to a websocket connection for a given data type by providing a channel that the messages will be written to
type SubscriptionScope ¶
type SubscriptionScope struct {
// contains filtered or unexported fields
}
func NewSubscriptionScope ¶
func NewSubscriptionScope(scope Prefix, symbols []string) *SubscriptionScope
func (SubscriptionScope) GetSubScope ¶
func (s SubscriptionScope) GetSubScope() string
type Ticker ¶ added in v4.0.2
type Ticker struct { Ticker string `json:"ticker"` Name string `json:"name"` Market string `json:"market"` Locale string `json:"locale"` Type string `json:"type"` Currency string `json:"currency"` Active bool `json:"active"` PrimaryExch string `json:"primaryExch"` Updated string `json:"updated"` Codes struct { Cik string `json:"cik"` Figiuid string `json:"figiuid"` Scfigi string `json:"scfigi"` Cfigi string `json:"cfigi"` Figi string `json:"figi"` } `json:"codes"` URL string `json:"url"` }
func ListTickers ¶
func ListTickersPerPage ¶ added in v4.0.2
type TradeTick ¶
type TradeTick struct { ParticipantTimestamp int64 `json:"y"` // Participant/Exchange timestamp TrfTimestamp int64 `json:"f"` SipTimestamp int64 `json:"t"` // Optional Price float64 `json:"p"` Size int `json:"s"` Exchange int `json:"x"` Conditions []int `json:"c"` Id string `json:"i"` Correction int `json:"e"` SequenceNumber int `json:"q"` TrfId int `json:"r"` Tape int `json:"z"` OrigId string `string:"I"` }
TradeTick is the structure that contains the actual tick data included in a HistoricTrades response