Documentation
¶
Index ¶
- Constants
- func CheckResponse(res *http.Response) error
- func DecodeResponseCSV(target interface{}, res *http.Response) error
- func DecodeResponseJSON(target interface{}, res *http.Response) error
- func GetClient(key string) *http.Client
- func JSONReader(v interface{}) (io.Reader, error)
- func ResolveRelative(basePath string, elem ...string) string
- func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- type DefaultCall
- type DigitalCryptoCurrenciesService
- type Error
- type ForeignExchangeService
- type Percent
- type Quote
- type SearchResult
- type SearchResultList
- type SectorPerformancesService
- type ServerResponse
- type Service
- type TechnicalIndicatorsService
- type Time
- type TimeSeries
- type TimeSeriesDailyAdjCall
- type TimeSeriesDailyCall
- type TimeSeriesIntradayCall
- type TimeSeriesList
- type TimeSeriesMonthlyAdjCall
- type TimeSeriesMonthlyCall
- type TimeSeriesQuoteEndpointCall
- type TimeSeriesSearchEndpointCall
- type TimeSeriesService
- func (r *TimeSeriesService) Daily(symbol string) *TimeSeriesDailyCall
- func (r *TimeSeriesService) DailyAdj(symbol string) *TimeSeriesDailyAdjCall
- func (r *TimeSeriesService) Intraday(symbol, interval string) *TimeSeriesIntradayCall
- func (r *TimeSeriesService) Monthly(symbol string) *TimeSeriesMonthlyCall
- func (r *TimeSeriesService) MonthlyAdj(symbol string) *TimeSeriesMonthlyAdjCall
- func (r *TimeSeriesService) QuoteEndpoint(symbol string) *TimeSeriesQuoteEndpointCall
- func (r *TimeSeriesService) SearchEndpoint(keywords string) *TimeSeriesSearchEndpointCall
- func (r *TimeSeriesService) Weekly(symbol string) *TimeSeriesWeeklyCall
- func (r *TimeSeriesService) WeeklyAdj(symbol string) *TimeSeriesWeeklyAdjCall
- type TimeSeriesWeeklyAdjCall
- type TimeSeriesWeeklyCall
- type Transport
Examples ¶
Constants ¶
const ( // Version defines the gax version being used. This is typically sent // in an HTTP header to services. Version = "0.5" // UserAgent is the header string used to identify this package. UserAgent = "alphavantage-api-go-client/" + Version )
const ( TimeSeriesIntervalOneMinute = "1min" TimeSeriesIntervalFiveMinute = "5min" TimeSeriesIntervalFifteenMinute = "15min" TimeSeriesIntervalThirtyMinute = "30min" TimeSeriesIntervalOneHour = "60min" OutputSizeFull = "full" OutputsizeCompact = "compact" )
Stock Time Series
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse returns an error (of type *Error) if the response status code is not 2xx.
func DecodeResponseCSV ¶
DecodeResponseCSV decodes the body of res into target. If there is no body, target is unchanged.
func DecodeResponseJSON ¶
DecodeResponseJSON decodes the body of res into target. If there is no body, target is unchanged.
func JSONReader ¶
JSONReader convert struct to reader for json request
func ResolveRelative ¶
ResolveRelative join path
Types ¶
type DefaultCall ¶
type DefaultCall struct {
// contains filtered or unexported fields
}
DefaultCall DefaultCall function
func (*DefaultCall) Context ¶
func (c *DefaultCall) Context(ctx context.Context) *DefaultCall
Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.
func (*DefaultCall) Header ¶
func (c *DefaultCall) Header() http.Header
Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.
type DigitalCryptoCurrenciesService ¶
type DigitalCryptoCurrenciesService struct {
// contains filtered or unexported fields
}
DigitalCryptoCurrenciesService https://www.alphavantage.co/documentation/#digital-currency APIs under this section provide a wide range of data feed for digital and crypto currencies such as Bitcoin.
func NewDigitalCryptoCurrenciesService ¶
func NewDigitalCryptoCurrenciesService(s *Service) *DigitalCryptoCurrenciesService
NewDigitalCryptoCurrenciesService https://www.alphavantage.co/documentation/#digital-currency APIs under this section provide a wide range of data feed for digital and crypto currencies such as Bitcoin.
type Error ¶
type Error struct { // Code is the HTTP response status code and will always be populated. Code int `json:"code,omitempty"` // Message is the server response message and is only populated when // explicitly referenced by the JSON server response. Message string `json:"message,omitempty"` // Body is the raw response returned by the server. // It is often but not always JSON, depending on how the request fails. Body string // Header contains the response header fields from the server. Header http.Header }
Error contains an error response from the server.
type ForeignExchangeService ¶
type ForeignExchangeService struct {
// contains filtered or unexported fields
}
ForeignExchangeService https://www.alphavantage.co/documentation/#symbolsearch APIs under this section provide a wide range of data feed for realtime and historical forex (FX) rates.
func NewForeignExchangeService ¶
func NewForeignExchangeService(s *Service) *ForeignExchangeService
NewForeignExchangeService https://www.alphavantage.co/documentation/#symbolsearch APIs under this section provide a wide range of data feed for realtime and historical forex (FX) rates.
type Percent ¶
type Percent float64
Percent redefine for percent value
func (*Percent) UnmarshalCSV ¶
UnmarshalCSV parse data
type Quote ¶
type Quote struct { // ServerResponse contains the HTTP response code and headers from the // server. ServerResponse `csv:"-"` Symbol string `csv:"symbol"` Open float64 `csv:"open"` High float64 `csv:"high"` Low float64 `csv:"low"` Price float64 `csv:"price"` Volume float64 `csv:"volume"` LatestDay Time `csv:"latestDay"` PreviousClose float64 `csv:"previousClose"` Change float64 `csv:"change"` ChangePercent Percent `csv:"changePercent"` }
Quote Quote
type SearchResult ¶
type SearchResult struct { Symbol string `csv:"symbol"` Name string `csv:"name"` Type string `csv:"type"` Region string `csv:"region"` MarketOpen string `csv:"marketOpen"` MarketClose string `csv:"marketClose"` Timezone string `csv:"timezone"` Currency string `csv:"currency"` MatchScore float64 `csv:"matchScore"` }
SearchResult SearchResult
type SearchResultList ¶
type SearchResultList struct { // ServerResponse contains the HTTP response code and headers from the // server. ServerResponse `csv:"-"` SearchResults []*SearchResult }
SearchResultList Search Result List
type SectorPerformancesService ¶
type SectorPerformancesService struct {
// contains filtered or unexported fields
}
SectorPerformancesService https://www.alphavantage.co/documentation/#sector-information This API returns the realtime and historical sector performances calculated from S&P500 incumbents.
func NewSectorPerformancesService ¶
func NewSectorPerformancesService(s *Service) *SectorPerformancesService
NewSectorPerformancesService https://www.alphavantage.co/documentation/#sector-information This API returns the realtime and historical sector performances calculated from S&P500 incumbents.
type ServerResponse ¶
type ServerResponse struct { // HTTPStatusCode is the server's response status code. When using a // resource method's Do call, this will always be in the 2xx range. HTTPStatusCode int // Header contains the response header fields from the server. Header http.Header }
ServerResponse is embedded in each Do response and provides the HTTP status code and header sent by the server.
type Service ¶
type Service struct { BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment TimeSeries *TimeSeriesService ForeignExchange *ForeignExchangeService DigitalCryptoCurrencies *DigitalCryptoCurrenciesService TechnicalIndicators *TechnicalIndicatorsService SectorPerformances *SectorPerformancesService // contains filtered or unexported fields }
Service Alpha Vantage api
type TechnicalIndicatorsService ¶
type TechnicalIndicatorsService struct {
// contains filtered or unexported fields
}
TechnicalIndicatorsService https://www.alphavantage.co/documentation/#technical-indicators Technical indicator values are updated realtime: the latest data point is derived from the current trading day of a given equity or currency exchange pair.
func NewTechnicalIndicatorsService ¶
func NewTechnicalIndicatorsService(s *Service) *TechnicalIndicatorsService
NewTechnicalIndicatorsService https://www.alphavantage.co/documentation/#technical-indicators Technical indicator values are updated realtime: the latest data point is derived from the current trading day of a given equity or currency exchange pair.
type Time ¶
Time redefine time.time for Unmarshal
func (*Time) UnmarshalCSV ¶
UnmarshalCSV process Date
type TimeSeries ¶
type TimeSeries struct { Time Time `csv:"timestamp"` Open float64 `csv:"open"` High float64 `csv:"high"` Low float64 `csv:"low"` Close float64 `csv:"close"` Volume float64 `csv:"volume"` // adj AdjustedClose float64 `csv:"adjusted_close,omitempty"` DividendAmount float64 `csv:"dividend_amount,omitempty"` SplitCoefficient float64 `csv:"split_coefficient,omitempty"` }
TimeSeries time series
type TimeSeriesDailyAdjCall ¶
type TimeSeriesDailyAdjCall struct {
DefaultCall
}
TimeSeriesDailyAdjCall https://www.alphavantage.co/documentation/#DailyAdj This API returns daily time series (date, daily open, daily high, daily low, daily close, daily volume, daily adjusted close, and split/dividend events) of the global equity specified, covering 20+ years of historical data. The most recent data point is the prices and volume information of the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesDailyAdjCall) Do ¶
func (c *TimeSeriesDailyAdjCall) Do() (*TimeSeriesList, error)
Do send request
func (*TimeSeriesDailyAdjCall) Outputsize ¶
func (c *TimeSeriesDailyAdjCall) Outputsize(outputsize string) *TimeSeriesDailyAdjCall
Outputsize By default, outputsize=compact. Strings compact and full are accepted with the following specifications: compact returns only the latest 100 data points; full returns the full-length time series of 20+ years of historical data. The "compact" option is recommended if you would like to reduce the data size of each API call.
type TimeSeriesDailyCall ¶
type TimeSeriesDailyCall struct {
DefaultCall
}
TimeSeriesDailyCall https://www.alphavantage.co/documentation/#daily This API returns daily time series (date, daily open, daily high, daily low, daily close, daily volume) of the global equity specified, covering 20+ years of historical data. The most recent data point is the prices and volume information of the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesDailyCall) Do ¶
func (c *TimeSeriesDailyCall) Do() (*TimeSeriesList, error)
Do send request
func (*TimeSeriesDailyCall) Outputsize ¶
func (c *TimeSeriesDailyCall) Outputsize(outputsize string) *TimeSeriesDailyCall
Outputsize By default, outputsize=compact. Strings compact and full are accepted with the following specifications: compact returns only the latest 100 data points; full returns the full-length time series of 20+ years of historical data. The "compact" option is recommended if you would like to reduce the data size of each API call.
type TimeSeriesIntradayCall ¶
type TimeSeriesIntradayCall struct {
DefaultCall
}
TimeSeriesIntradayCall https://www.alphavantage.co/documentation/#intraday This API returns intraday time series (timestamp, open, high, low, close, volume) of the equity specified. datatype fixed to csv
func (*TimeSeriesIntradayCall) Do ¶
func (c *TimeSeriesIntradayCall) Do() (*TimeSeriesList, error)
Do send request
func (*TimeSeriesIntradayCall) Outputsize ¶
func (c *TimeSeriesIntradayCall) Outputsize(outputsize string) *TimeSeriesIntradayCall
Outputsize By default, outputsize=compact. Strings compact and full are accepted with the following specifications: compact returns only the latest 100 data points; full returns the full-length time series of 20+ years of historical data. The "compact" option is recommended if you would like to reduce the data size of each API call.
type TimeSeriesList ¶
type TimeSeriesList struct { // ServerResponse contains the HTTP response code and headers from the // server. ServerResponse `csv:"-"` TimeSeries []*TimeSeries }
TimeSeriesList TimeSeries List
type TimeSeriesMonthlyAdjCall ¶
type TimeSeriesMonthlyAdjCall struct {
DefaultCall
}
TimeSeriesMonthlyAdjCall https://www.alphavantage.co/documentation/#monthlyadj This API returns monthly adjusted time series (last trading day of each month, monthly open, monthly high, monthly low, monthly close, monthly adjusted close, monthly volume, monthly dividend) of the equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the month (or partial month) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesMonthlyAdjCall) Do ¶
func (c *TimeSeriesMonthlyAdjCall) Do() (*TimeSeriesList, error)
Do send request
type TimeSeriesMonthlyCall ¶
type TimeSeriesMonthlyCall struct {
DefaultCall
}
TimeSeriesMonthlyCall https://www.alphavantage.co/documentation/#monthly This API returns monthly time series (last trading day of each month, monthly open, monthly high, monthly low, monthly close, monthly volume) of the global equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the month (or partial month) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesMonthlyCall) Do ¶
func (c *TimeSeriesMonthlyCall) Do() (*TimeSeriesList, error)
Do send request
type TimeSeriesQuoteEndpointCall ¶
type TimeSeriesQuoteEndpointCall struct { DefaultCall // contains filtered or unexported fields }
TimeSeriesQuoteEndpointCall https://www.alphavantage.co/documentation/#latestprice A lightweight alternative to the time series APIs, this service returns the latest price and volume information for a security of your choice. datatype fixed to csv
func (*TimeSeriesQuoteEndpointCall) Do ¶
func (c *TimeSeriesQuoteEndpointCall) Do() (*Quote, error)
Do send request
type TimeSeriesSearchEndpointCall ¶
type TimeSeriesSearchEndpointCall struct {
DefaultCall
}
TimeSeriesSearchEndpointCall https://www.alphavantage.co/documentation/#symbolsearch We've got you covered! The Search Endpoint returns the best-matching symbols and market information based on keywords of your choice. The search results also contain match scores that provide you with the full flexibility to develop your own search and filtering logic. datatype fixed to csv
func (*TimeSeriesSearchEndpointCall) Do ¶
func (c *TimeSeriesSearchEndpointCall) Do() (*SearchResultList, error)
Do send request
type TimeSeriesService ¶
type TimeSeriesService struct {
// contains filtered or unexported fields
}
TimeSeriesService https://www.alphavantage.co/documentation/#time-series-data This suite of APIs provide realtime and historical global equity data in 4 different temporal resolutions: (1) daily, (2) weekly, (3) monthly, and (4) intraday. Daily, weekly, and monthly time series contain 20+ years of historical data.
func NewTimeSeriesService ¶
func NewTimeSeriesService(s *Service) *TimeSeriesService
NewTimeSeriesService https://www.alphavantage.co/documentation/#time-series-data This suite of APIs provide realtime and historical global equity data in 4 different temporal resolutions: (1) daily, (2) weekly, (3) monthly, and (4) intraday. Daily, weekly, and monthly time series contain 20+ years of historical data.
func (*TimeSeriesService) Daily ¶
func (r *TimeSeriesService) Daily(symbol string) *TimeSeriesDailyCall
Daily https://www.alphavantage.co/documentation/#daily This API returns daily time series (date, daily open, daily high, daily low, daily close, daily volume) of the global equity specified, covering 20+ years of historical data. The most recent data point is the prices and volume information of the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesService) DailyAdj ¶
func (r *TimeSeriesService) DailyAdj(symbol string) *TimeSeriesDailyAdjCall
DailyAdj https://www.alphavantage.co/documentation/#dailyadj This API returns daily time series (date, daily open, daily high, daily low, daily close, daily volume, daily adjusted close, and split/dividend events) of the global equity specified, covering 20+ years of historical data. The most recent data point is the prices and volume information of the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesService) Intraday ¶
func (r *TimeSeriesService) Intraday(symbol, interval string) *TimeSeriesIntradayCall
Intraday https://www.alphavantage.co/documentation/#intraday This API returns intraday time series (timestamp, open, high, low, close, volume) of the equity specified. datatype fixed to csv
Example ¶
client := GetClient(randkey(keyLen)) var err error avReal, err = New(client) if err != nil { log.Fatal(err) } IntradayCall := avReal.TimeSeries.Intraday("VTI", TimeSeriesIntervalOneMinute) timeSeriesList, err := IntradayCall.Do() if err != nil { log.Fatal(err) } fmt.Printf("%v", timeSeriesList.TimeSeries)
Output:
func (*TimeSeriesService) Monthly ¶
func (r *TimeSeriesService) Monthly(symbol string) *TimeSeriesMonthlyCall
Monthly https://www.alphavantage.co/documentation/#monthly This API returns monthly time series (last trading day of each month, monthly open, monthly high, monthly low, monthly close, monthly volume) of the global equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the month (or partial month) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesService) MonthlyAdj ¶
func (r *TimeSeriesService) MonthlyAdj(symbol string) *TimeSeriesMonthlyAdjCall
MonthlyAdj https://www.alphavantage.co/documentation/#monthlyadj This API returns monthly adjusted time series (last trading day of each month, monthly open, monthly high, monthly low, monthly close, monthly adjusted close, monthly volume, monthly dividend) of the equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the month (or partial month) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesService) QuoteEndpoint ¶
func (r *TimeSeriesService) QuoteEndpoint(symbol string) *TimeSeriesQuoteEndpointCall
QuoteEndpoint https://www.alphavantage.co/documentation/#latestprice A lightweight alternative to the time series APIs, this service returns the latest price and volume information for a security of your choice. datatype fixed to csv
func (*TimeSeriesService) SearchEndpoint ¶
func (r *TimeSeriesService) SearchEndpoint(keywords string) *TimeSeriesSearchEndpointCall
SearchEndpoint https://www.alphavantage.co/documentation/#symbolsearch We've got you covered! The Search Endpoint returns the best-matching symbols and market information based on keywords of your choice. The search results also contain match scores that provide you with the full flexibility to develop your own search and filtering logic. datatype fixed to csv
func (*TimeSeriesService) Weekly ¶
func (r *TimeSeriesService) Weekly(symbol string) *TimeSeriesWeeklyCall
Weekly https://www.alphavantage.co/documentation/#weekly This API returns weekly time series (last trading day of each week, weekly open, weekly high, weekly low, weekly close, weekly volume) of the global equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the week (or partial week) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesService) WeeklyAdj ¶
func (r *TimeSeriesService) WeeklyAdj(symbol string) *TimeSeriesWeeklyAdjCall
WeeklyAdj https://www.alphavantage.co/documentation/#weeklyadj This API returns weekly adjusted time series (last trading day of each week, weekly open, weekly high, weekly low, weekly close, weekly adjusted close, weekly volume, weekly dividend) of the global equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the week (or partial week) that contains the current trading day, updated realtime. datatype fixed to csv
type TimeSeriesWeeklyAdjCall ¶
type TimeSeriesWeeklyAdjCall struct {
DefaultCall
}
TimeSeriesWeeklyAdjCall https://www.alphavantage.co/documentation/#weeklyadj This API returns weekly adjusted time series (last trading day of each week, weekly open, weekly high, weekly low, weekly close, weekly adjusted close, weekly volume, weekly dividend) of the global equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the week (or partial week) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesWeeklyAdjCall) Do ¶
func (c *TimeSeriesWeeklyAdjCall) Do() (*TimeSeriesList, error)
Do send request
type TimeSeriesWeeklyCall ¶
type TimeSeriesWeeklyCall struct {
DefaultCall
}
TimeSeriesWeeklyCall https://www.alphavantage.co/documentation/#weekly This API returns weekly time series (last trading day of each week, weekly open, weekly high, weekly low, weekly close, weekly volume) of the global equity specified, covering 20+ years of historical data. The latest data point is the prices and volume information for the week (or partial week) that contains the current trading day, updated realtime. datatype fixed to csv
func (*TimeSeriesWeeklyCall) Do ¶
func (c *TimeSeriesWeeklyCall) Do() (*TimeSeriesList, error)
Do send request