Documentation ¶
Index ¶
- Constants
- func GetAPIToken() (string, error)
- func TimeSeriesFromJSON(filename string, v interface{}) error
- func TimeSeriesToCSV(timeseries map[string]OHLCV, filename string) error
- type Client
- type DailyAdjustedTimeSeries
- type DailyTimeSeries
- type GlobalQuote
- type IntraDayTimeSeries
- type MetaData
- type MonthlyAdjustedTimeSeries
- type MonthlyTimeSeries
- type OHLCV
- type QueryParams
- type Quote
- type StockAPI
- func (api *StockAPI) Daily(queryParams QueryParams) (*DailyTimeSeries, error)
- func (api *StockAPI) DailyAdjusted(queryParams QueryParams) (*DailyAdjustedTimeSeries, error)
- func (api *StockAPI) GlobalQuote(queryParams QueryParams) (*GlobalQuote, error)
- func (api *StockAPI) IntraDay(queryParams QueryParams) (*IntraDayTimeSeries, error)
- func (api *StockAPI) Monthly(queryParams QueryParams) (*MonthlyTimeSeries, error)
- func (api *StockAPI) MonthlyAdjusted(queryParams QueryParams) (*MonthlyAdjustedTimeSeries, error)
- func (api *StockAPI) TickerSearch(queryParams QueryParams) (*TickerSearchList, error)
- func (api *StockAPI) Weekly(queryParams QueryParams) (*WeeklyTimeSeries, error)
- func (api *StockAPI) WeeklyAdjusted(queryParams QueryParams) (*WeeklyAdjustedTimeSeries, error)
- type TickerSearchList
- type TickerSymbol
- type WeeklyAdjustedTimeSeries
- type WeeklyTimeSeries
Constants ¶
const AVBaseURL = "https://alphavantage.co/query"
const DefaultHTTPTimeout = 80 * time.Second
Variables ¶
This section is empty.
Functions ¶
func GetAPIToken ¶
func TimeSeriesFromJSON ¶
---------------------------------------------------------------------
* Read timeseries data from a local .json file. * This function assumes the filename includes the full path to the * input file. * --------------------------------------------------------------------
func TimeSeriesToCSV ¶
---------------------------------------------------------------------
* Write timeseries data to a local .csv file. * This function assumes the filename includes the full path to the * output file. * -------------------------------------------------------------------
Types ¶
type Client ¶
type Client struct { HTTPClient *http.Client Request *http.Request Query *url.Values // contains filtered or unexported fields }
func (*Client) ExecuteQuery ¶
Execute an existing API query.
func (*Client) NewQuery ¶
func (c *Client) NewQuery(queryParams QueryParams)
Assemble a new API query.
func (*Client) NewRequest ¶
Initialize a new HTTP request
type DailyAdjustedTimeSeries ¶
type DailyTimeSeries ¶
type GlobalQuote ¶
type GlobalQuote struct {
Quote Quote `json:"Global Quote"`
}
type IntraDayTimeSeries ¶
type IntraDayTimeSeries struct { MetaData MetaData `json:"Meta Data"` TimeSeries1Min map[string]OHLCV `json:"Time Series (1min),omitempty"` TimeSeries5Min map[string]OHLCV `json:"Time Series (5min),omitempty"` TimeSeries15Min map[string]OHLCV `json:"Time Series (15min),omitempty"` TimeSeries30Min map[string]OHLCV `json:"Time Series (30min),omitempty"` TimeSeries60Min map[string]OHLCV `json:"Time Series (60min),omitempty"` }
type MetaData ¶
type MetaData struct { Information string `json:"1. Information"` Symbol string `json:"2. Symbol"` LastRefreshed string `json:"3. Last Refreshed"` Interval string `json:"4. Interval,omitempty"` OutputSize string `json:"4. Output Size,5. Output Size,omitempty"` TimeZone string `json:"4. Time Zone,5. Time Zone,6. Time Zone,omitempty"` }
Metadata fields in the AV response can vary depending on the query. Overload the interval, outputsize, and timezone struct tags to capture the variations in the json response.
type MonthlyTimeSeries ¶
type OHLCV ¶
type OHLCV struct { Open string `json:"1. open"` High string `json:"2. high"` Low string `json:"3. low"` Close string `json:"4. close"` AdjustedClose string `json:"5. adjusted close,omitempty"` Volume string `json:"5. volume,6. volume"` DividendAmt string `json:"7. dividend amount,omitempty"` SplitCoefficient string `json:"8. split coefficient,omitempty"` }
Overload the struct tags to account for presence of adjusted close, dividend amount, and split coefficient.
type QueryParams ¶
type QueryParams struct { // Required by all timeseries calls. Function string // Required by all timeseries calls EXCEPT search endpoint. Symbol string // Required by search endpoint. Keywords string // Required by intraday endpoint. Interval string // Optional for all daily timeseries calls. OutputSize string // Optional for all timeseries calls Datatype string }
func (QueryParams) HasDatatype ¶
func (q QueryParams) HasDatatype() bool
func (QueryParams) HasInterval ¶
func (q QueryParams) HasInterval() bool
func (QueryParams) HasKeywords ¶
func (q QueryParams) HasKeywords() bool
func (QueryParams) HasOutputSize ¶
func (q QueryParams) HasOutputSize() bool
func (QueryParams) HasSymbol ¶
func (q QueryParams) HasSymbol() bool
type Quote ¶
type Quote struct { Symbol string `json:"01. symbol"` Open string `json:"02. open"` High string `json:"03. high"` Low string `json:"04. low"` Price string `json:"05. price"` Volume string `json:"06. volume"` LatestTradeDay string `json:"07. latest trading day"` PreviousClose string `json:"08. previous close"` Change string `json:"09. change"` ChangePercent string `json:"10. change percent"` }
* Models for stock quotes.
type StockAPI ¶
type StockAPI struct {
Client *Client
}
func (*StockAPI) Daily ¶
func (api *StockAPI) Daily(queryParams QueryParams) (*DailyTimeSeries, error)
func (*StockAPI) DailyAdjusted ¶
func (api *StockAPI) DailyAdjusted(queryParams QueryParams) (*DailyAdjustedTimeSeries, error)
func (*StockAPI) GlobalQuote ¶
func (api *StockAPI) GlobalQuote(queryParams QueryParams) (*GlobalQuote, error)
func (*StockAPI) IntraDay ¶
func (api *StockAPI) IntraDay(queryParams QueryParams) (*IntraDayTimeSeries, error)
TimeSeries methods
func (*StockAPI) Monthly ¶
func (api *StockAPI) Monthly(queryParams QueryParams) (*MonthlyTimeSeries, error)
func (*StockAPI) MonthlyAdjusted ¶
func (api *StockAPI) MonthlyAdjusted(queryParams QueryParams) (*MonthlyAdjustedTimeSeries, error)
func (*StockAPI) TickerSearch ¶
func (api *StockAPI) TickerSearch(queryParams QueryParams) (*TickerSearchList, error)
func (*StockAPI) Weekly ¶
func (api *StockAPI) Weekly(queryParams QueryParams) (*WeeklyTimeSeries, error)
func (*StockAPI) WeeklyAdjusted ¶
func (api *StockAPI) WeeklyAdjusted(queryParams QueryParams) (*WeeklyAdjustedTimeSeries, error)
type TickerSearchList ¶
type TickerSearchList struct {
BestMatches []TickerSymbol `json:"bestMatches`
}
* Models for ticker search
type TickerSymbol ¶
type TickerSymbol struct { Symbol string `json:"1. symbol"` Name string `json:"2. name"` Equity string `json:"3. type"` Region string `json:"4. region"` MarketOpen string `json:"5. marketOpen"` MarketClose string `json:"6. marketClose"` TimeZone string `json:"7. timezone"` Currency string `json:"8. currency"` MatchScore string `json:"9. matchScore"` }