polygon

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTickerCurrentPrice

func GetTickerCurrentPrice(ctx context.Context, apiKey, ticker string) (float64, error)

func GetTickerYesterdaysClose

func GetTickerYesterdaysClose(ctx context.Context, apiKey, ticker string) (float64, error)

GetTickerYesterdaysClose is the previous days close price. Takes into account weekends, holidays. This should always return a price for a ticker if it has ever traded previously.

Types

type APIResponse

type APIResponse struct {
	Ticker    string `json:"ticker"`
	Status    string `json:"status"`
	RequestID string `json:"request_id"`
}

type Aggregate

type Aggregate struct {
	Ticker    string  `json:"T"`
	Timestamp int64   `json:"t"`
	Volume    float64 `json:"v"`
	Close     float64 `json:"c"`
	Open      float64 `json:"o"`
	High      float64 `json:"h"`
	Low       float64 `json:"l"`
}

Aggregate is a rollup of trades for a specified time window.

type AggsResponse

type AggsResponse struct {
	APIResponse
	Results []*Aggregate `json:"results"`
}

AggsResponse contains multiple Aggregates in the results block.

type Client

type Client struct {
	APIKey       string
	PriceUpdates chan *models.PriceUpdate
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string, perTickUpdate bool) *Client

NewClient creates a new polygon API client.

func (*Client) AddTickerToUpdates

func (c *Client) AddTickerToUpdates(tickers []string) error

AddTickerToUpdates sends a subscribe message to the given tickers.

func (*Client) GetTickerTodayAggs

func (c *Client) GetTickerTodayAggs(ctx context.Context, t time.Time, ticker string, rangeSize int) (results []*models.Agg, err error)

func (*Client) ListenForTickerUpdates

func (c *Client) ListenForTickerUpdates(ctx context.Context, tickers []string) error

ListenForTickerUpdates listens for trades on the given tickers. This will get propogated via the client.PriceUpdates channel.

func (*Client) LoadTickerData

func (c *Client) LoadTickerData(ctx context.Context, tickerSymbol string) (*models.Ticker, error)

type Company

type Company struct {
	CompanyName       string `json:"name"`
	OutstandingShares int64  `json:"outstanding_shares"`
}

Company is the meta data about a company.

func GetCompanyDetails

func GetCompanyDetails(ctx context.Context, apiKey, ticker string) (*Company, error)

type CompanyDetails

type CompanyDetails struct {
	APIResponse
	Results Company `json:"results"`
}

CompanyDetails returns the meta data about this company.

type LastTrade

type LastTrade struct {
	APIResponse
	Results Trade `json:"results"`
}

LastTrade is the last trade that has occurred for this ticker.

type Trade

type Trade struct {
	Price float64 `json:"p"`
}

Trade is an executed trade reported to exchanges or TRFs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL