Documentation ¶
Index ¶
- Variables
- func NewClient(token string, logger *zerolog.Logger) *resty.Client
- type DividendsPeriod
- type HistoricalIntradayPeriod
- type HistoricalPeriod
- type Market
- func (m *Market) UpcomingDividends(ctx context.Context, symbol string) (dividends []market.UpcomingDividend, err error)
- func (m *Market) UpcomingEarnings(ctx context.Context, symbol string) (earnings []market.UpcomingEarning, err error)
- func (m *Market) UpcomingSplits(ctx context.Context, symbol string) (splits []stock.Split, err error)
- type Options
- type Reference
- type SplitsPeriod
- type Stock
- func (s *Stock) Dividends(ctx context.Context, symbol string, period DividendsPeriod) (res []stock.Dividend, err error)
- func (s *Stock) Earnings(ctx context.Context, symbol string, params map[string]string) (earnings []stock.Earning, err error)
- func (s *Stock) Historical(ctx context.Context, symbol string, period HistoricalPeriod, ...) (res []stock.Historical, err error)
- func (s *Stock) HistoricalIntraday(ctx context.Context, symbol string, period HistoricalIntradayPeriod, ...) (res []stock.Intraday, err error)
- func (s *Stock) PreviousDay(ctx context.Context, symbol string) (res *stock.Historical, err error)
- func (s *Stock) PreviousDayMarket(ctx context.Context) (res []stock.Historical, err error)
- func (s *Stock) Splits(ctx context.Context, symbol string, period SplitsPeriod) (res []stock.Split, err error)
Constants ¶
This section is empty.
Variables ¶
var ( APIDomainBase string = "https://cloud.iexapis.com" APIDomainSandbox string = "https://sandbox.iexapis.com" )
These variables correspond to the domains the IEX Cloud API uses to serve content.
var ( APIVersion1 string = "v1" APIVersionBeta string = "beta" APIVersionStable string = "stable" APIVersionLatest string = "latest" )
These variables correspond to the available versions (ie the first path segment) of the IEX Cloud API.
var MaxRetries = 5
MaxRetries is used by NewClient to limit the number of retry attempts
var RequestsPerSecond = 20
RequestsPerSecond is used by NewClient to implement rate limiting The low default is to prevent 429's: 50 RPS had three failures in five requests for a total of eight requests.
Functions ¶
func NewClient ¶
NewClient creates a new go-resty client with some helpful configuration. - The token is set as a query string parameter, and the HostURL (ie domain) is initialized to the regular or sandbox domain accordingly. A "version" path parameter is set to "v1" by default. Both are set from package variables. - Passing a non-nil Logger will set it as the go-resty logger. - It implements rate limiting with an unexported time.Ticker, set at the package level, that is reused for each client via OnBeforeRequest. This RPS limiter is not related to exponential backoff for retries. - The MaxRetries package variable sets the retry count, and a RetryConditionFunc returns true if Response.IsError() with a status code > 404 and not 413 or 451. - If Response.IsError(), an error will be returned that matches the format "invalid response: <code> <response-body>" (eg "invalid response: 404 Unknown Symbol")
Types ¶
type DividendsPeriod ¶
type DividendsPeriod string
var ( DividendsPeriod5y DividendsPeriod = "5y" DividendsPeriod2y DividendsPeriod = "2y" DividendsPeriod1y DividendsPeriod = "1y" DividendsPeriodYTD DividendsPeriod = "ytd" DividendsPeriod6m DividendsPeriod = "6m" DividendsPeriod3m DividendsPeriod = "3m" DividendsPeriod1m DividendsPeriod = "1m" DividendsPeriodNext DividendsPeriod = "next" )
type HistoricalIntradayPeriod ¶
type HistoricalIntradayPeriod string
var ( HistoricalIntradayPeriod1mm HistoricalIntradayPeriod = "1mm" HistoricalIntradayPeriod5dm HistoricalIntradayPeriod = "5dm" HistoricalIntradayPeriodDate HistoricalIntradayPeriod = "date" )
type HistoricalPeriod ¶
type HistoricalPeriod string
var ( HistoricalPeriodMax HistoricalPeriod = "max" HistoricalPeriod5y HistoricalPeriod = "5y" HistoricalPeriod2y HistoricalPeriod = "2y" HistoricalPeriod1y HistoricalPeriod = "1y" HistoricalPeriodYTD HistoricalPeriod = "ytd" HistoricalPeriod6m HistoricalPeriod = "6m" HistoricalPeriod3m HistoricalPeriod = "3m" HistoricalPeriod1m HistoricalPeriod = "1m" HistoricalPeriod5d HistoricalPeriod = "5d" )
type Market ¶
type Market struct {
// contains filtered or unexported fields
}
Market exposes methods for accessing IEX Cloud market information. A list of endpoints can be found at https://iexcloud.io/docs/api/#market-info.
func NewMarket ¶
func NewMarket(client *resty.Client) *Market
NewMarket creates a new Market with the given client
func (*Market) UpcomingDividends ¶
func (m *Market) UpcomingDividends(ctx context.Context, symbol string) (dividends []market.UpcomingDividend, err error)
UpcomingDividends fetches a list of upcoming earnings from the upcoming events endpoint. Pass "market" as the symbol parameter to return data for all symbols. https://iexcloud.io/docs/api/#upcoming-events
func (*Market) UpcomingEarnings ¶
func (m *Market) UpcomingEarnings(ctx context.Context, symbol string) (earnings []market.UpcomingEarning, err error)
UpcomingEarnings fetches a list of upcoming earnings from the upcoming events endpoint. Pass "market" as the symbol parameter to return data for all symbols. https://iexcloud.io/docs/api/#upcoming-events
func (*Market) UpcomingSplits ¶
func (m *Market) UpcomingSplits(ctx context.Context, symbol string) (splits []stock.Split, err error)
UpcomingSplits fetches a list of upcoming earnings from the upcoming events endpoint. Pass "market" as the symbol parameter to return data for all symbols. https://iexcloud.io/docs/api/#upcoming-events
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options exposes methods for calling options endpoints. https://iexcloud.io/docs/api/#options
func NewOptions ¶
func NewOptions(client *resty.Client) *Options
NewOptions creates a new Options with the given client https://iexcloud.io/docs/api/#options
func (*Options) EndOfDay ¶
func (o *Options) EndOfDay(ctx context.Context, symbol, expiration string, side ...string) (res []option.Option, err error)
EndOfDay returns a slice of option.Options for the given symbol and expiration. The expiration is expected to be specified as YYYYMM or YYYYMMDD: the format returned from this same endpoint when an expiration is not specified (see Expiration()) or the analogous Reference endpoint. If a side ("call" or "put") is passed as an optional fourth parameter, the method will return only options for that side. https://iexcloud.io/docs/api/#end-of-day-options
func (*Options) Expiration ¶
Expiration returns a slice of expiration dates for the given symbol. This endpoint is defined as part of the End of Day Options endpoint, and is the result of a call to that endpoint that does not specify an expiration. https://iexcloud.io/docs/api/#end-of-day-options
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference exposes methods for calling Reference endoints. https://iexcloud.io/docs/api/#reference-data
func NewReference ¶
func NewReference(client *resty.Client) *Reference
NewReference creates a new Reference with the given client https://iexcloud.io/docs/api/#reference-data
func (*Reference) OptionsSymbols ¶
OptionsSymbols fetches a list of options symbols/dates that are supported for making API calls. This call returns an object keyed by symbol with the value of each symbol being an array of available contract dates. https://iexcloud.io/docs/api/#options-symbols
type SplitsPeriod ¶
type SplitsPeriod string
var ( SplitsPeriod5y SplitsPeriod = "5y" SplitsPeriod2y SplitsPeriod = "2y" SplitsPeriod1y SplitsPeriod = "1y" SplitsPeriodYTD SplitsPeriod = "ytd" SplitsPeriod6m SplitsPeriod = "6m" SplitsPeriod3m SplitsPeriod = "3m" SplitsPeriod1m SplitsPeriod = "1m" SplitsPeriodNext SplitsPeriod = "next" )
type Stock ¶
type Stock struct {
// contains filtered or unexported fields
}
Stock exposes methods for calling Stock endoints. https://iexcloud.io/docs/api/#stocks-equities
func NewStock ¶
func NewStock(client *resty.Client) *Stock
NewStock creates a new Stock with the given client https://iexcloud.io/docs/api/#stocks-equities
func (*Stock) Dividends ¶
func (s *Stock) Dividends(ctx context.Context, symbol string, period DividendsPeriod) (res []stock.Dividend, err error)
Dividends provides basic dividend data for US equities, ETFs, and Mutual Funds for the last 5 years. https://iexcloud.io/docs/api/#dividends-basic
func (*Stock) Earnings ¶
func (s *Stock) Earnings(ctx context.Context, symbol string, params map[string]string) (earnings []stock.Earning, err error)
Earnings data for a given company including the actual EPS, consensus, and fiscal period. Available quarterly (last 4 quarters) and annually (last 4 years). https://iexcloud.io/docs/api/#earnings
func (*Stock) Historical ¶
func (s *Stock) Historical(ctx context.Context, symbol string, period HistoricalPeriod, params map[string]string) (res []stock.Historical, err error)
Historical returns adjusted and unadjusted historical data for up to 15 years. https://iexcloud.io/docs/api/#historical-prices
func (*Stock) HistoricalIntraday ¶
func (s *Stock) HistoricalIntraday(ctx context.Context, symbol string, period HistoricalIntradayPeriod, params map[string]string) (res []stock.Intraday, err error)
HistoricalIntraday returns historical intraday data. https://iexcloud.io/docs/api/#historical-prices See also https://iexcloud.io/docs/api/#intraday-prices
func (*Stock) PreviousDay ¶
PreviousDay returns previous day adjusted price data for one or more stocks. https://iexcloud.io/docs/api/#previous-day-price
func (*Stock) PreviousDayMarket ¶
PreviousDayMarket returns previous day adjusted price data for all stocks. https://iexcloud.io/docs/api/#previous-day-price