alphavantage

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Example
package main

import (
	"fmt"
	"github.com/SimpleApplicationsOrg/stock/alphavantage"
)

func main() {
	avClient, err := alphavantage.NewAVClient()
	if err != nil {
		fmt.Printf("error getting client: %s", err.Error())
		return
	}

	response, err := avClient.TimeSeriesIntraday("GOOGL", "1min")
	if err != nil {
		fmt.Printf("error calling api: %s", err.Error())
		return
	}

	metaData := *response.MetaData
	fmt.Println(metaData.Information(), metaData.OutputSize())
	fmt.Println(metaData.LastRefreshed(), metaData.TimeZone())
	fmt.Println(metaData.Interval())

	timeSeries := *response.TimeSeries
	for _, timeStamp := range timeSeries.TimeStamps() {
		value := (timeSeries)[timeStamp]
		fmt.Println(timeStamp, value.Open(), value.High(), value.Low(), value.Close(), value.Volume())
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// Intraday function
	Intraday = "TIME_SERIES_INTRADAY"
	// Daily function
	Daily = "TIME_SERIES_DAILY"
	// DailyAdjusted function
	DailyAdjusted = "TIME_SERIES_DAILY_ADJUSTED"
	// Weekly function
	Weekly = "TIME_SERIES_WEEKLY"
	// Monthly function
	Monthly = "TIME_SERIES_MONTHLY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AVClient

type AVClient struct {
	// contains filtered or unexported fields
}

AVClient is the client for the Alpha Vantage API

func NewAVClient

func NewAVClient() (*AVClient, error)

NewAVClient gives a specific Alpha Vantage API client

func (*AVClient) TimeSeries

func (api *AVClient) TimeSeries(function, symbol string) (*TimeSeriesData, error)

TimeSeries gets daily, weekly and monthly series

func (*AVClient) TimeSeriesIntraday

func (api *AVClient) TimeSeriesIntraday(symbol, interval string) (*TimeSeriesData, error)

TimeSeriesIntraday returns intraday time series (timestamp, open, high, low, close, volume) of the equity specified, updated realtime.

type MetaData

type MetaData map[string]string

MetaData about the time series data

func (MetaData) Information

func (m MetaData) Information() string

Information gives the metadata value

func (MetaData) Interval

func (m MetaData) Interval() string

Interval gives the value for that metadata

func (MetaData) LastRefreshed

func (m MetaData) LastRefreshed() string

LastRefreshed gives the value for that metadata

func (MetaData) OutputSize

func (m MetaData) OutputSize() string

OutputSize give the value for that metadata

func (MetaData) Symbol

func (m MetaData) Symbol() string

Symbol gives the values for that metadata

func (MetaData) TimeZone

func (m MetaData) TimeZone() string

TimeZone give the value for that metadata

type Series

type Series map[string]string

Series is a map containing the open, high, low, close, volume values

func (Series) Close

func (s Series) Close() string

Close gives the value of the "4. close"

func (Series) High

func (s Series) High() string

High gives the value of the "2. high"

func (Series) Low

func (s Series) Low() string

Low gives the value of the "3. low"

func (Series) Open

func (s Series) Open() string

Open gives the value of the "1. open"

func (Series) Volume

func (s Series) Volume() string

Volume gives the value of the "5. volume"

type TimeSeries

type TimeSeries map[string]Series

TimeSeries temporal resolution with the timestamp as the keys

func (TimeSeries) TimeStamps

func (t TimeSeries) TimeStamps() []string

TimeStamps gives an array with all the value keys from the time series

type TimeSeriesData

type TimeSeriesData struct {
	MetaData   *MetaData
	TimeSeries *TimeSeries
}

TimeSeriesData contains realtime and historical equity data in 4 different temporal resolutions: (1) intraday, (2) daily, (3) weekly, and (4) monthly. Daily, weekly, and monthly time series contain up to 20 years of historical data. Intraday time series typically span the past 10 to 15 active trading days.

Jump to

Keyboard shortcuts

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