Documentation
¶
Index ¶
- Variables
- func GetActiveListing(ctx context.Context, opts ...func(*listing.Options) error) (*listing.Data, error)
- func GetDividendData(ctx context.Context, symbol string) (*historic.DividendData, error)
- func GetFX(ctx context.Context, fromCurrency, toCurrency string, ...) (*fx.Data, error)
- func GetHistoricData(ctx context.Context, symbol string, opts ...func(*historic.Options) error) (*historic.Data, error)
- func GetIntradayData(ctx context.Context, symbol string, opts ...func(*intraday.Options) error) (*intraday.Data, error)
- func GetIntradayFX(ctx context.Context, fromCurrency, toCurrency string) (*fx.IntradayData, error)
- func Initialise(ctx context.Context, apiKey string) context.Context
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMissingAPIKey = errors.New("context did not contain a valid api key")
ErrMissingAPIKey returned if the api key has not been found (Initialise() not called)
Functions ¶
func GetActiveListing ¶
func GetActiveListing(ctx context.Context, opts ...func(*listing.Options) error) (*listing.Data, error)
GetActiveListing returns
Example ¶
apiKey := os.Getenv("AV_API_KEY")
ctx := Initialise(context.Background(), apiKey)
if data, err := GetActiveListing(ctx, listing.WithOnlyTypes([]listing.AssetType{listing.ETF})); err == nil {
fmt.Println(len(data.Tradeables) > 0)
} else {
fmt.Println(err)
}
Output: true
func GetDividendData ¶
GetDividendData returns dividend data for the specified symbol, using the api_key stored in the context. Uses DIVIDENDS function - see https://www.alphavantage.co/documentation/
func GetFX ¶
func GetFX(ctx context.Context, fromCurrency, toCurrency string, opts ...func(*fx.Options) error) (*fx.Data, error)
GetFX returns data for the specified currency pair, using the api_key stored in the context. opts allows the behaviour of the call to be varied per the options in https://www.alphavantage.co/documentation/ for FX_DAILY
Example ¶
apiKey := os.Getenv("AV_API_KEY")
ctx := Initialise(context.Background(), apiKey)
if data, err := GetFX(ctx, "EUR", "USD", fx.WithAllAvailableHistory(false)); err == nil {
fmt.Println(len(data.TimeSeries))
} else {
fmt.Println(err)
}
Output: 100
func GetHistoricData ¶
func GetHistoricData(ctx context.Context, symbol string, opts ...func(*historic.Options) error) (*historic.Data, error)
GetIntradayData returns data for the specified symbol, using the api_key stored in the context. opts allows the behaviour of the call to be varied per the options in https://www.alphavantage.co/documentation/ for TIME_SERIES_DAILY_ADJUSTED
Example ¶
apiKey := os.Getenv("AV_API_KEY")
ctx := Initialise(context.Background(), apiKey)
if data, err := GetHistoricData(ctx, "IBM", historic.WithAllAvailableHistory(false)); err == nil {
fmt.Println(len(data.TimeSeries))
} else {
fmt.Println(err)
}
Output: 100
func GetIntradayData ¶
func GetIntradayData(ctx context.Context, symbol string, opts ...func(*intraday.Options) error) (*intraday.Data, error)
GetIntradayData returns data for the specified symbol, using the api_key stored in the context. opts allows the behaviour of the call to be varied per the options in https://www.alphavantage.co/documentation/ for TIME_SERIES_INTRADAY
Example ¶
apiKey := os.Getenv("AV_API_KEY")
ctx := Initialise(context.Background(), apiKey)
if data, err := GetIntradayData(ctx, "IBM", intraday.WithExtendedHours(false)); err == nil {
fmt.Println(len(data.TimeSeries))
} else {
fmt.Println(err)
}
Output: 100
func GetIntradayFX ¶
GetIntradayFX returns data for the specified currency pair, using the api_key stored in the context. This uses CURRENCY_EXCHANGE_RATE from https://www.alphavantage.co/documentation/
Types ¶
This section is empty.