Help us shape the future of Go! Take the 2026 Go Developer Survey

alphavantage

package module
v0.0.0-...-23a754c Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 13 Imported by: 0

README

alphavantage

Unofficial Go/Golang www.alphavantage.co API implementation

Disclaimer: This library is not associated with alphavantage or any of its affiliates or subsidiaries. If you use this library, you should contact them to make sure they are okay with how you intend to use it. Use this lib at your own risk.

API doc reference: https://www.alphavantage.co/documentation/

Note: Requests are synchronised and throttled automatically to not flood the API servers. One request every 15 seconds is possible at the moment.

Usage

New client
package main

import (
	"github.com/sklinkert/alphavantage"
	log "github.com/sirupsen/logrus" // optional
)

func main() {
	avClient := alphavantage.New("MYAPIKEY")
 	// ...
}
TimeSeries (prices)
series, err := avClient.TimeSeries("TICKER1", alphavantage.TimeSeriesDaily, alphavantage.OutPutSizeCompact)
if err != nil {
	log.WithError(err).Fatal("TimeSeries() failed")
}
for date, price := range series.TimeSeriesDaily {
	log.Infof("%s: Open=%f High=%f Low=%f Close=%f Volume=%d", date, price.Open, price.High, price.Low, price.Close, price.Volume)
}
Indicator STOCH
indicators, err := avClient.IndicatorStoch("EURUSD", alphavantage.IntervalDaily)
if err != nil {
	log.WithError(err).Fatal("IndicatorStoch() failed")
}

// Loop over all indicators
for date, indicator := range indicators.TechnicalAnalysis {
	log.Infof("%s: SlowK=%f SlowD=%f", date, indicator.SlowK, indicator.SlowD)
}

// Get the most recent one
latestDate, latest := indicators.Latest()
log.Infof("Latest: %s: SlowK=%f SlowD=%f", latestDate, latest.SlowK, latest.SlowD)

// Get today only
today := indicators.Today()
log.Infof("Today: SlowK=%f SlowD=%f", today.SlowK, today.SlowD)

// By specific date
indicator := indicators.ByDate(time.Now())
if indicator != nil {
	log.Infof("SlowK=%f SlowD=%f", indicator.SlowK, indicator.SlowD)
}

Indicator SMA
period := 200
indicators, err := avClient.IndicatorSMA("EURUSD", alphavantage.IntervalDaily, period, alphavantage.SeriesTypeClose)
if err != nil {
	log.WithError(err).Fatal("IndicatorSMA() failed")
}

// See more examples at Indicator STOCH section
Global Quote
globalQuote, err := avClient.GlobalQuote("EURUSD")
if err != nil {
	log.WithError(err).Fatal("GlobalQuote() failed")
}
log.Infof("%s %f", globalQuote.LatestTradingDay, globalQuote.Price)
Analytics
// with date range
analytics, err := avClient.Analytics([]string{"TICKER1", "TICKER2"}, "2023-03-03", "2024-03-01", alphavantage.IntervalDaily)
if err != nil {
	log.WithError(err).Fatal("Analytics() failed")
}
log.Infof("%v", analytics)

// without date range
analytics, err = avClient.Analytics2([]string{"TICKER1", "TICKER2"}, alphavantage.IntervalDaily)
if err != nil {
	log.WithError(err).Fatal("Analytics() failed")
}
log.Infof("%v", analytics)
Balance Sheet
balanceSheet, err := avClient.BalanceSheet("TICKER")
if err != nil {
	log.WithError(err).Fatal("BalanceSheet() failed")
}
log.Infof("%v", balanceSheet)
Cash Flow
cashFlow, err := avClient.CashFlow("TICKER")
if err != nil {
	log.WithError(err).Fatal("CashFlow() failed")
}
log.Infof("%v", cashFlow)
Company Overview
companyOverview, err := avClient.CompanyOverview("TICKER")
if err != nil {
	log.WithError(err).Fatal("CompanyOverview() failed")
}
log.Infof("%v", companyOverview)
Earnings Calendar
// with 3month horizon
earningsCalendar, err := avClient.EarningsCalendar("TICKER", alphavantage.ThreeMonth)
if err != nil {
	log.WithError(err).Fatal("EarningsCalendar() failed")
}
log.Infof("%v", earningsCalendar)

// with 6month horizon
earningsCalendar, err = avClient.EarningsCalendar("TICKER", alphavantage.SixMonth)
if err != nil {
	log.WithError(err).Fatal("EarningsCalendar() failed")
}
log.Infof("%v", earningsCalendar)

// with 12month horizon
earningsCalendar, err = avClient.EarningsCalendar("TICKER", alphavantage.TwelveMonth)
if err != nil {
	log.WithError(err).Fatal("EarningsCalendar() failed")
}
log.Infof("%v", earningsCalendar)
Earnings
earnings, err := avClient.Earnings("TICKER")
if err != nil {
	log.WithError(err).Fatal("Earnings() failed")
}
log.Infof("%v", earnings)
Earnings Call Transcript
transcript, err := avClient.EarningsCallTranscript("TICKER", "2022-03-31")
if err != nil {
	log.WithError(err).Fatal("EarningsCallTranscript() failed")
}
log.Infof("%v", transcript)
ETF Profile
etfProfile, err := avClient.ETFProfileData("VOO")
if err != nil {
	log.WithError(err).Fatal("ETFProfileData() failed")
}
log.Infof("%v", etfProfile)
Historical Options
// with specific date
date := time.Date(2022, 11, 18, 0, 0, 0, 0, time.UTC)
options, err := avClient.HistoricalOptions("TICKER2", &date)
if err != nil {
	log.WithError(err).Fatal("HistoricalOptions() failed")
}
log.Infof("%v", options)

// without specific date
options, err = avClient.HistoricalOptions("TICKER2", nil)
if err != nil {
	log.WithError(err).Fatal("HistoricalOptions() failed")
}
log.Infof("%v", options)
Income Statement
incomeStatement, err := avClient.IncomeStatement("TICKER")
if err != nil {
	log.WithError(err).Fatal("IncomeStatement() failed")
}
log.Infof("%v", incomeStatement)
Indicator EMA
indicatorEMA, err := avClient.IndicatorEMA("EURUSD", alphavantage.IntervalDaily, 200, alphavantage.SeriesTypeClose)
if err != nil {
	log.WithError(err).Fatal("IndicatorEMA() failed")
}
log.Infof("%v", indicatorEMA)
Insider Transactions
insiderTransactions, err := avClient.InsiderTransactions("TICKER")
if err != nil {
	log.WithError(err).Fatal("InsiderTransactions() failed")
}
log.Infof("%v", insiderTransactions)
Listing Status
// for delisted stocks
listingStatus, err := avClient.ListingStatus(true)
if err != nil {
	log.WithError(err).Fatal("ListingStatus() failed")
}
log.Infof("%v", listingStatus)

// for active stocks
listingStatus, err = avClient.ListingStatus(false)
if err != nil {
	log.WithError(err).Fatal("ListingStatus() failed")
}
log.Infof("%v", listingStatus)
News Sentiment
newsSentiment, err := avClient.NewsSentiment("TICKER2", alphavantage.SortLatest, 10, "", "")
if err != nil {
	log.WithError(err).Fatal("NewsSentiment() failed")
}
log.Infof("%v", newsSentiment)
Time Series Adjusted
// with compact output size
timeSeriesAdjusted, err := avClient.TimeSeriesAdjusted("TICKER", alphavantage.TimeSeriesDaily, alphavantage.OutPutSizeCompact)
if err != nil {
	log.WithError(err).Fatal("TimeSeriesAdjusted() failed")
}
log.Infof("%v", timeSeriesAdjusted)

// with full output size
timeSeriesAdjusted, err = avClient.TimeSeriesAdjusted("TICKER", alphavantage.TimeSeriesDaily, alphavantage.OutPutSizeFull)
if err != nil {
	log.WithError(err).Fatal("TimeSeriesAdjusted() failed")
}
log.Infof("%v", timeSeriesAdjusted)

Documentation

Index

Constants

View Source
const (
	// Interval1Min represents the 1 minute interval.
	Interval1Min = Interval("1min")
	// Interval5Min represents the 5 minute interval.
	Interval5Min = Interval("5mn")
	// Interval15Min represents the 15 minute interval.
	Interval15Min = Interval("15mn")
	// Interval30Min represents the 30 minute interval.
	Interval30Min = Interval("30mn")
	// Interval60Min represents the 60 minute interval.
	Interval60Min = Interval("60mn")
	// IntervalDaily represents the daily interval.
	IntervalDaily = Interval("daily")
	// IntervalWeekly represents the weekly interval.
	IntervalWeekly = Interval("weekly")
	// IntervalMonthly represents the monthly interval.
	IntervalMonthly = Interval("monthly")

	// DateFormat is the date format used by the API
	DateFormat = "2006-01-02"
	// DateTimeFormat datetime format used by the API
	DateTimeFormat = "2006-01-02 15:04:05"

	// TimeSeriesDaily - Time series for daily prices
	TimeSeriesDaily = TimeSeriesInterval("TIME_SERIES_DAILY")
	// TimeSeriesWeekly - Time series for weekly prices
	TimeSeriesWeekly = TimeSeriesInterval("TIME_SERIES_WEEKLY")
	// TimeSeriesMonthly - Time series for monthly prices
	TimeSeriesMonthly = TimeSeriesInterval("TIME_SERIES_MONTHLY")

	// TimeSeriesDailyAdjusted represents daily adjusted time series data.
	TimeSeriesDailyAdjusted = TimeSeriesIntervalAdjusted("TIME_SERIES_DAILY_ADJUSTED")
	// TimeSeriesWeeklyAdjusted represents weekly adjusted time series data.
	TimeSeriesWeeklyAdjusted = TimeSeriesIntervalAdjusted("TIME_SERIES_WEEKLY_ADJUSTED")
	// TimeSeriesMonthlyAdjusted represents monthly adjusted time series data.
	TimeSeriesMonthlyAdjusted = TimeSeriesIntervalAdjusted("TIME_SERIES_MONTHLY_ADJUSTED")

	// OutputSizeCompact is for the latest 100 items
	OutputSizeCompact = OutputSize("compact")
	// OutputSizeFull is for the full-length time series
	OutputSizeFull = OutputSize("full")

	// SortTypeLatest represents sorting by latest.
	SortTypeLatest = SortType("LATEST")
	// SortTypeEarliest represents sorting by earliest.
	SortTypeEarliest = SortType("EARLIEST")
	// SortTypeRelevance represents sorting by relevance.
	SortTypeRelevance = SortType("RELEVANCE")

	// AnalyticsCalculationMin represents the minimum return calculation.
	AnalyticsCalculationMin = AnalyticsCalculation("MIN")
	// AnalyticsCalculationMax represents the maximum return calculation.
	AnalyticsCalculationMax = AnalyticsCalculation("MAX")
	// AnalyticsCalculationMean represents the mean return calculation.
	AnalyticsCalculationMean = AnalyticsCalculation("MEAN")
	// AnalyticsCalculationMedian represents the median return calculation.
	AnalyticsCalculationMedian = AnalyticsCalculation("MEDIAN")
	// AnalyticsCalculationCumulativeReturn represents the cumulative return calculation.
	AnalyticsCalculationCumulativeReturn = AnalyticsCalculation("CUMULATIVE_RETURN")
	// AnalyticsCalculationVariance represents the variance calculation.
	AnalyticsCalculationVariance = AnalyticsCalculation("VARIANCE")
	// AnalyticsCalculationStdDev represents the standard deviation calculation.
	AnalyticsCalculationStdDev = AnalyticsCalculation("STDDEV")
	// AnalyticsCalculationMaxDrawdown represents the maximum drawdown calculation.
	AnalyticsCalculationMaxDrawdown = AnalyticsCalculation("MAX_DRAWDOWN")
	// AnalyticsCalculationHistogram represents the histogram calculation.
	AnalyticsCalculationHistogram = AnalyticsCalculation("HISTOGRAM")
	// AnalyticsCalculationAutocorrelation represents the autocorrelation calculation.
	AnalyticsCalculationAutocorrelation = AnalyticsCalculation("AUTOCORRELATION")
	// AnalyticsCalculationCovariance represents the covariance calculation.
	AnalyticsCalculationCovariance = AnalyticsCalculation("COVARIANCE")
	// AnalyticsCalculationCorrelation represents the correlation calculation.
	AnalyticsCalculationCorrelation = AnalyticsCalculation("CORRELATION")

	// AnalyticsRangeUnitFull represents the full range unit.
	AnalyticsRangeUnitFull = AnalyticsRangeUnit("full")
	// AnalyticsRangeUnitDay represents the day range unit.
	AnalyticsRangeUnitDay = AnalyticsRangeUnit("day")
	// AnalyticsRangeUnitWeek represents the week range unit.
	AnalyticsRangeUnitWeek = AnalyticsRangeUnit("week")
	// AnalyticsRangeUnitMonth represents the month range unit.
	AnalyticsRangeUnitMonth = AnalyticsRangeUnit("month")
	// AnalyticsRangeUnitYear represents the year range unit.
	AnalyticsRangeUnitYear = AnalyticsRangeUnit("year")
	// AnalyticsRangeUnitMinute represents the minute range unit.
	AnalyticsRangeUnitMinute = AnalyticsRangeUnit("minute")
	// AnalyticsRangeUnitHour represents the hour range unit.
	AnalyticsRangeUnitHour = AnalyticsRangeUnit("hour")

	// AnalyticsOhlcOpen represents the open OHLC data type.
	AnalyticsOhlcOpen = AnalyticsOhlc("open")
	// AnalyticsOhlcHigh represents the high OHLC data type.
	AnalyticsOhlcHigh = AnalyticsOhlc("high")
	// AnalyticsOhlcLow represents the low OHLC data type.
	AnalyticsOhlcLow = AnalyticsOhlc("low")
	// AnalyticsOhlcClose represents the close OHLC data type.
	AnalyticsOhlcClose = AnalyticsOhlc("close")

	// AnalyticsInterval1Min represents the 1 minute interval.
	AnalyticsInterval1Min = AnalyticsInterval("1min")
	// AnalyticsInterval5Min represents the 5 minute interval.
	AnalyticsInterval5Min = AnalyticsInterval("5mn")
	// AnalyticsInterval15Min represents the 15 minute interval.
	AnalyticsInterval15Min = AnalyticsInterval("15mn")
	// AnalyticsInterval30Min represents the 30 minute interval.
	AnalyticsInterval30Min = AnalyticsInterval("30mn")
	// AnalyticsInterval60Min represents the 60 minute interval.
	AnalyticsInterval60Min = AnalyticsInterval("60mn")
	// AnalyticsIntervalDaily represents the daily interval.
	AnalyticsIntervalDaily = AnalyticsInterval("DAILY")
	// AnalyticsIntervalWeekly represents the weekly interval.
	AnalyticsIntervalWeekly = AnalyticsInterval("WEEKLY")
	// AnalyticsIntervalMonthly represents the monthly interval.
	AnalyticsIntervalMonthly = AnalyticsInterval("MONTHLY")

	// SeriesTypeOpen - Series Type Open
	SeriesTypeOpen = SeriesType("open")
	// SeriesTypeHigh - Series Type High
	SeriesTypeHigh = SeriesType("high")
	// SeriesTypeLow - Series Type Low
	SeriesTypeLow = SeriesType("low")
	// SeriesTypeClose - Series Type Close
	SeriesTypeClose = SeriesType("close")
)

Variables

This section is empty.

Functions

func GetPrevYear

func GetPrevYear(dateString string) (int, int, error)

GetPrevYear calculates the previous year and quarter for a given date string.

func GetPrevYearAndQuarter

func GetPrevYearAndQuarter(dateString string) (int, int, error)

GetPrevYearAndQuarter calculates the previous year and quarter for a given date string.

func GetYearAndQuarter

func GetYearAndQuarter(dateString string) (int, int, error)

GetYearAndQuarter extracts the year and quarter from a date string.

func IntervalToExpirationDelay

func IntervalToExpirationDelay(interval Interval) time.Duration

IntervalToExpirationDelay transforms an Interval to a time.Duration

func PrettyPrint

func PrettyPrint(s interface{}) ([]byte, error)

PrettyPrint formats a given data structure into indented JSON.

func PrevQuarter

func PrevQuarter(year int, quarter int) (int, int, error)

PrevQuarter calculates the previous quarter for a given year and quarter.

func TimeSeriesIntervalAdjustedToExpirationDelay

func TimeSeriesIntervalAdjustedToExpirationDelay(interval TimeSeriesIntervalAdjusted) time.Duration

TimeSeriesIntervalAdjustedToExpirationDelay transforms an Interval to a time.Duration

func TimeSeriesIntervalToExpirationDelay

func TimeSeriesIntervalToExpirationDelay(interval TimeSeriesInterval) time.Duration

TimeSeriesIntervalToExpirationDelay transforms an Interval to a time.Duration

Types

type AVFloat64

type AVFloat64 struct {
	Value float64
}

AVFloat64 represents a custom float type to handle "None" value.

func (AVFloat64) MarshalJSON

func (cf AVFloat64) MarshalJSON() ([]byte, error)

MarshalJSON method to handle custom JSON marshaling

func (*AVFloat64) UnmarshalJSON

func (cf *AVFloat64) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller to handle "None" value.

type AVInt

type AVInt struct {
	Value int
}

AVInt represents a custom int type to handle "None" value.

func (AVInt) MarshalCSV

func (cf AVInt) MarshalCSV() ([]byte, error)

MarshalCSV custom marshaller to handle CSV marshaling.

func (AVInt) MarshalJSON

func (cf AVInt) MarshalJSON() ([]byte, error)

MarshalJSON method to handle custom JSON marshaling

func (*AVInt) UnmarshalJSON

func (cf *AVInt) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller to handle "None" value.

type AVPercent

type AVPercent struct {
	Value float64
}

AVPercent represents a custom float type to handle percentage values.

func (AVPercent) MarshalJSON

func (cf AVPercent) MarshalJSON() ([]byte, error)

MarshalJSON method to handle custom JSON marshaling

func (*AVPercent) UnmarshalJSON

func (cf *AVPercent) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller to handle "%" value.

type Analytics

type Analytics struct {
	MetaData MetaData                   `json:"meta_data"`
	Payload  map[string]CalculationData `json:"payload"`
}

Analytics represent the Metadata and the Payload

type AnalyticsCalculation

type AnalyticsCalculation string

AnalyticsCalculation represents the type for analytics calculations.

type AnalyticsInterval

type AnalyticsInterval string

AnalyticsInterval represents the interval for analytics data.

type AnalyticsOhlc

type AnalyticsOhlc string

AnalyticsOhlc represents the OHLC (Open, High, Low, Close) data type.

type AnalyticsRangeUnit

type AnalyticsRangeUnit string

AnalyticsRangeUnit represents the range unit for analytics data.

type AnnualEarnings

type AnnualEarnings struct {
	FiscalDateEnding string    `json:"fiscalDateEnding"`
	ReportedEPS      AVFloat64 `json:"reportedEPS"`
}

AnnualEarnings represents the annual earnings data for a company.

func GetEarningsHistoricalAnnualReport

func GetEarningsHistoricalAnnualReport(e *Earnings, year int) (*AnnualEarnings, error)

GetEarningsHistoricalAnnualReport retrieves a specific annual report from an Earnings struct.

func GetEarningsMostRecentAnnualReport

func GetEarningsMostRecentAnnualReport(e *Earnings) (*AnnualEarnings, error)

GetEarningsMostRecentAnnualReport retrieves the most recent annual report from an Earnings struct.

type BalanceSheet

type BalanceSheet struct {
	Symbol           string              `json:"symbol"`
	AnnualReports    []BsAnnualReport    `json:"annualReports"`
	QuarterlyReports []BsQuarterlyReport `json:"quarterlyReports"`
}

BalanceSheet represents the balance sheet data for a company.

type BsAnnualReport

type BsAnnualReport struct {
	FiscalDateEnding                       string `json:"fiscalDateEnding"`
	ReportedCurrency                       string `json:"reportedCurrency"`
	TotalAssets                            AVInt  `json:"totalAssets"`
	TotalCurrentAssets                     AVInt  `json:"totalCurrentAssets"`
	CashAndCashEquivalentsAtCarryingValue  AVInt  `json:"cashAndCashEquivalentsAtCarryingValue"`
	CashAndShortTermInvestments            AVInt  `json:"cashAndShortTermInvestments"`
	Inventory                              AVInt  `json:"inventory"`
	CurrentNetReceivables                  AVInt  `json:"currentNetReceivables"`
	TotalNonCurrentAssets                  AVInt  `json:"totalNonCurrentAssets"`
	PropertyPlantEquipment                 AVInt  `json:"propertyPlantEquipment"`
	AccumulatedDepreciationAmortizationPpe AVInt  `json:"accumulatedDepreciationAmortizationPPE"`
	IntangibleAssets                       AVInt  `json:"intangibleAssets"`
	IntangibleAssetsExcludingGoodwill      AVInt  `json:"intangibleAssetsExcludingGoodwill"`
	Goodwill                               AVInt  `json:"goodwill"`
	Investments                            AVInt  `json:"investments"`
	LongTermInvestments                    AVInt  `json:"longTermInvestments"`
	ShortTermInvestments                   AVInt  `json:"shortTermInvestments"`
	OtherCurrentAssets                     AVInt  `json:"otherCurrentAssets"`
	OtherNonCurrentAssets                  AVInt  `json:"otherNonCurrentAssets"`
	TotalLiabilities                       AVInt  `json:"totalLiabilities"`
	TotalCurrentLiabilities                AVInt  `json:"totalCurrentLiabilities"`
	CurrentAccountsPayable                 AVInt  `json:"currentAccountsPayable"`
	DeferredRevenue                        AVInt  `json:"deferredRevenue"`
	CurrentDebt                            AVInt  `json:"currentDebt"`
	ShortTermDebt                          AVInt  `json:"shortTermDebt"`
	TotalNonCurrentLiabilities             AVInt  `json:"totalNonCurrentLiabilities"`
	CapitalLeaseObligations                AVInt  `json:"capitalLeaseObligations"`
	LongTermDebt                           AVInt  `json:"longTermDebt"`
	CurrentLongTermDebt                    AVInt  `json:"currentLongTermDebt"`
	LongTermDebtNoncurrent                 AVInt  `json:"longTermDebtNoncurrent"`
	ShortLongTermDebtTotal                 AVInt  `json:"shortLongTermDebtTotal"`
	OtherCurrentLiabilities                AVInt  `json:"otherCurrentLiabilities"`
	OtherNonCurrentLiabilities             AVInt  `json:"otherNonCurrentLiabilities"`
	TotalShareholderEquity                 AVInt  `json:"totalShareholderEquity"`
	TreasuryStock                          AVInt  `json:"treasuryStock"`
	RetainedEarnings                       AVInt  `json:"retainedEarnings"`
	CommonStock                            AVInt  `json:"commonStock"`
	CommonStockSharesOutstanding           AVInt  `json:"commonStockSharesOutstanding"`
}

BsAnnualReport represents an annual report in the balance sheet.

func GetBalanceSheetHistoricalAnnualReport

func GetBalanceSheetHistoricalAnnualReport(bs *BalanceSheet, year int) (*BsAnnualReport, error)

GetBalanceSheetHistoricalAnnualReport retrieves a specific annual report from a BalanceSheet struct.

func GetBalanceSheetMostRecentAnnualReport

func GetBalanceSheetMostRecentAnnualReport(bs *BalanceSheet) (*BsAnnualReport, error)

GetBalanceSheetMostRecentAnnualReport retrieves the most recent annual report from a BalanceSheet struct.

type BsQuarterlyReport

type BsQuarterlyReport struct {
	FiscalDateEnding                       string `json:"fiscalDateEnding"`
	ReportedCurrency                       string `json:"reportedCurrency"`
	TotalAssets                            AVInt  `json:"totalAssets"`
	TotalCurrentAssets                     AVInt  `json:"totalCurrentAssets"`
	CashAndCashEquivalentsAtCarryingValue  AVInt  `json:"cashAndCashEquivalentsAtCarryingValue"`
	CashAndShortTermInvestments            AVInt  `json:"cashAndShortTermInvestments"`
	Inventory                              AVInt  `json:"inventory"`
	CurrentNetReceivables                  AVInt  `json:"currentNetReceivables"`
	TotalNonCurrentAssets                  AVInt  `json:"totalNonCurrentAssets"`
	PropertyPlantEquipment                 AVInt  `json:"propertyPlantEquipment"`
	AccumulatedDepreciationAmortizationPpe AVInt  `json:"accumulatedDepreciationAmortizationPPE"`
	IntangibleAssets                       AVInt  `json:"intangibleAssets"`
	IntangibleAssetsExcludingGoodwill      AVInt  `json:"intangibleAssetsExcludingGoodwill"`
	Goodwill                               AVInt  `json:"goodwill"`
	Investments                            AVInt  `json:"investments"`
	LongTermInvestments                    AVInt  `json:"longTermInvestments"`
	ShortTermInvestments                   AVInt  `json:"shortTermInvestments"`
	OtherCurrentAssets                     AVInt  `json:"otherCurrentAssets"`
	OtherNonCurrentAssets                  AVInt  `json:"otherNonCurrentAssets"`
	TotalLiabilities                       AVInt  `json:"totalLiabilities"`
	TotalCurrentLiabilities                AVInt  `json:"totalCurrentLiabilities"`
	CurrentAccountsPayable                 AVInt  `json:"currentAccountsPayable"`
	DeferredRevenue                        AVInt  `json:"deferredRevenue"`
	CurrentDebt                            AVInt  `json:"currentDebt"`
	ShortTermDebt                          AVInt  `json:"shortTermDebt"`
	TotalNonCurrentLiabilities             AVInt  `json:"totalNonCurrentLiabilities"`
	CapitalLeaseObligations                AVInt  `json:"capitalLeaseObligations"`
	LongTermDebt                           AVInt  `json:"longTermDebt"`
	CurrentLongTermDebt                    AVInt  `json:"currentLongTermDebt"`
	LongTermDebtNoncurrent                 AVInt  `json:"longTermDebtNoncurrent"`
	ShortLongTermDebtTotal                 AVInt  `json:"shortLongTermDebtTotal"`
	OtherCurrentLiabilities                AVInt  `json:"otherCurrentLiabilities"`
	OtherNonCurrentLiabilities             AVInt  `json:"otherNonCurrentLiabilities"`
	TotalShareholderEquity                 AVInt  `json:"totalShareholderEquity"`
	TreasuryStock                          AVInt  `json:"treasuryStock"`
	RetainedEarnings                       AVInt  `json:"retainedEarnings"`
	CommonStock                            AVInt  `json:"commonStock"`
	CommonStockSharesOutstanding           AVInt  `json:"commonStockSharesOutstanding"`
}

BsQuarterlyReport represents a quarterly report in the balance sheet.

func GetBalanceSheetHistoricalQuarterlyReport

func GetBalanceSheetHistoricalQuarterlyReport(bs *BalanceSheet, year int, quarter int) (*BsQuarterlyReport, error)

GetBalanceSheetHistoricalQuarterlyReport retrieves a specific quarterly report from a BalanceSheet struct.

func GetBalanceSheetMostRecentQuarterlyReport

func GetBalanceSheetMostRecentQuarterlyReport(bs *BalanceSheet) (*BsQuarterlyReport, error)

GetBalanceSheetMostRecentQuarterlyReport retrieves the most recent quarterly report from a BalanceSheet struct.

type CalculationData

type CalculationData struct {
	Min              map[string]float64 `json:"MIN"`
	Max              map[string]float64 `json:"MAX"`
	Mean             map[string]float64 `json:"MEAN"`
	Median           map[string]float64 `json:"MEDIAN"`
	CumulativeReturn map[string]float64 `json:"CUMULATIVE_RETURN"`
	Variance         map[string]float64 `json:"VARIANCE"`
	StdDev           map[string]float64 `json:"STDDEV"`
	Drawdown         Drawdown           `json:"MAX_DRAWDOWN"`
	Histogram        Histogram          `json:"HISTOGRAM"`
	Autocorrelation  map[string]float64 `json:"AUTOCORRELATION"`
	Covariance       CorrelationData    `json:"COVARIANCE"`
	Correlation      CorrelationData    `json:"CORRELATION"`
}

CalculationData represents the payload data containing calculation results.

type CashFlow

type CashFlow struct {
	Symbol           string              `json:"symbol"`
	AnnualReports    []CfAnnualReport    `json:"annualReports"`
	QuarterlyReports []CfQuarterlyReport `json:"quarterlyReports"`
}

CashFlow represents the cash flow data for a company.

type CfAnnualReport

type CfAnnualReport struct {
	FiscalDateEnding                                          string `json:"fiscalDateEnding"`
	ReportedCurrency                                          string `json:"reportedCurrency"`
	OperatingCashflow                                         AVInt  `json:"operatingCashflow"`
	PaymentsForOperatingActivities                            AVInt  `json:"paymentsForOperatingActivities"`
	ProceedsFromOperatingActivities                           AVInt  `json:"proceedsFromOperatingActivities"`
	ChangeInOperatingLiabilities                              AVInt  `json:"changeInOperatingLiabilities"`
	ChangeInOperatingAssets                                   AVInt  `json:"changeInOperatingAssets"`
	DepreciationDepletionAndAmortization                      AVInt  `json:"depreciationDepletionAndAmortization"`
	CapitalExpenditures                                       AVInt  `json:"capitalExpenditures"`
	ChangeInReceivables                                       AVInt  `json:"changeInReceivables"`
	ChangeInInventory                                         AVInt  `json:"changeInInventory"`
	ProfitLoss                                                AVInt  `json:"profitLoss"`
	CashflowFromInvestment                                    AVInt  `json:"cashflowFromInvestment"`
	CashflowFromFinancing                                     AVInt  `json:"cashflowFromFinancing"`
	ProceedsFromRepaymentsOfShortTermDebt                     AVInt  `json:"proceedsFromRepaymentsOfShortTermDebt"`
	PaymentsForRepurchaseOfCommonStock                        AVInt  `json:"paymentsForRepurchaseOfCommonStock"`
	PaymentsForRepurchaseOfEquity                             AVInt  `json:"paymentsForRepurchaseOfEquity"`
	PaymentsForRepurchaseOfPreferredStock                     AVInt  `json:"paymentsForRepurchaseOfPreferredStock"`
	DividendPayout                                            AVInt  `json:"dividendPayout"`
	DividendPayoutCommonStock                                 AVInt  `json:"dividendPayoutCommonStock"`
	DividendPayoutPreferredStock                              AVInt  `json:"dividendPayoutPreferredStock"`
	ProceedsFromIssuanceOfCommonStock                         AVInt  `json:"proceedsFromIssuanceOfCommonStock"`
	ProceedsFromIssuanceOfLongTermDebtAndCapitalSecuritiesNet AVInt  `json:"proceedsFromIssuanceOfLongTermDebtAndCapitalSecuritiesNet"`
	ProceedsFromIssuanceOfPreferredStock                      AVInt  `json:"proceedsFromIssuanceOfPreferredStock"`
	ProceedsFromRepurchaseOfEquity                            AVInt  `json:"proceedsFromRepurchaseOfEquity"`
	ProceedsFromSaleOfTreasuryStock                           AVInt  `json:"proceedsFromSaleOfTreasuryStock"`
	ChangeInCashAndCashEquivalents                            AVInt  `json:"changeInCashAndCashEquivalents"`
	ChangeInExchangeRate                                      AVInt  `json:"changeInExchangeRate"`
	NetIncome                                                 AVInt  `json:"netIncome"`
}

CfAnnualReport represents an annual report in the cash flow.

func GetCashFlowHistoricalAnnualReport

func GetCashFlowHistoricalAnnualReport(cf *CashFlow, year int) (*CfAnnualReport, error)

GetCashFlowHistoricalAnnualReport retrieves a specific annual report from a CashFlow struct.

func GetCashFlowMostRecentAnnualReport

func GetCashFlowMostRecentAnnualReport(cf *CashFlow) (*CfAnnualReport, error)

GetCashFlowMostRecentAnnualReport retrieves the most recent annual report from a CashFlow struct.

type CfQuarterlyReport

type CfQuarterlyReport struct {
	FiscalDateEnding                                          string `json:"fiscalDateEnding"`
	ReportedCurrency                                          string `json:"reportedCurrency"`
	OperatingCashflow                                         AVInt  `json:"operatingCashflow"`
	PaymentsForOperatingActivities                            AVInt  `json:"paymentsForOperatingActivities"`
	ProceedsFromOperatingActivities                           AVInt  `json:"proceedsFromOperatingActivities"`
	ChangeInOperatingLiabilities                              AVInt  `json:"changeInOperatingLiabilities"`
	ChangeInOperatingAssets                                   AVInt  `json:"changeInOperatingAssets"`
	DepreciationDepletionAndAmortization                      AVInt  `json:"depreciationDepletionAndAmortization"`
	CapitalExpenditures                                       AVInt  `json:"capitalExpenditures"`
	ChangeInReceivables                                       AVInt  `json:"changeInReceivables"`
	ChangeInInventory                                         AVInt  `json:"changeInInventory"`
	ProfitLoss                                                AVInt  `json:"profitLoss"`
	CashflowFromInvestment                                    AVInt  `json:"cashflowFromInvestment"`
	CashflowFromFinancing                                     AVInt  `json:"cashflowFromFinancing"`
	ProceedsFromRepaymentsOfShortTermDebt                     AVInt  `json:"proceedsFromRepaymentsOfShortTermDebt"`
	PaymentsForRepurchaseOfCommonStock                        AVInt  `json:"paymentsForRepurchaseOfCommonStock"`
	PaymentsForRepurchaseOfEquity                             AVInt  `json:"paymentsForRepurchaseOfEquity"`
	PaymentsForRepurchaseOfPreferredStock                     AVInt  `json:"paymentsForRepurchaseOfPreferredStock"`
	DividendPayout                                            AVInt  `json:"dividendPayout"`
	DividendPayoutCommonStock                                 AVInt  `json:"dividendPayoutCommonStock"`
	DividendPayoutPreferredStock                              AVInt  `json:"dividendPayoutPreferredStock"`
	ProceedsFromIssuanceOfCommonStock                         AVInt  `json:"proceedsFromIssuanceOfCommonStock"`
	ProceedsFromIssuanceOfLongTermDebtAndCapitalSecuritiesNet AVInt  `json:"proceedsFromIssuanceOfLongTermDebtAndCapitalSecuritiesNet"`
	ProceedsFromIssuanceOfPreferredStock                      AVInt  `json:"proceedsFromIssuanceOfPreferredStock"`
	ProceedsFromRepurchaseOfEquity                            AVInt  `json:"proceedsFromRepurchaseOfEquity"`
	ProceedsFromSaleOfTreasuryStock                           AVInt  `json:"proceedsFromSaleOfTreasuryStock"`
	ChangeInCashAndCashEquivalents                            AVInt  `json:"changeInCashAndCashEquivalents"`
	ChangeInExchangeRate                                      AVInt  `json:"changeInExchangeRate"`
	NetIncome                                                 AVInt  `json:"netIncome"`
}

CfQuarterlyReport represents a quarterly report in the cash flow.

func GetCashFlowHistoricalQuarterlyReport

func GetCashFlowHistoricalQuarterlyReport(cf *CashFlow, year int, quarter int) (*CfQuarterlyReport, error)

GetCashFlowHistoricalQuarterlyReport retrieves a specific quarterly report from a CashFlow struct.

func GetCashFlowMostRecentQuarterlyReport

func GetCashFlowMostRecentQuarterlyReport(cf *CashFlow) (*CfQuarterlyReport, error)

GetCashFlowMostRecentQuarterlyReport retrieves the most recent quarterly report from a CashFlow struct.

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client represents a new alphavantage client

func New

func New(apiKey string) *Client

New creates new Client instance

func (*Client) Analytics

func (c *Client) Analytics(symbols []string,
	calculations []string,
	startTime time.Time,
	endTime time.Time,
	ohlc AnalyticsOhlc,
	interval AnalyticsInterval) (*Analytics, error)

Analytics fetches the analytics data for the specified symbols and calculations within the specified time range. It takes a list of symbols, a list of calculations, a start time, an end time, an OHLC data type, and an interval. The time range format depends on the interval.

func (*Client) Analytics2

func (c *Client) Analytics2(symbols []string,
	calculations []string,
	rangeFactor int,
	rangeUnit AnalyticsRangeUnit,
	ohlc AnalyticsOhlc,
	interval AnalyticsInterval) (*Analytics, error)

Analytics2 fetches the analytics data for the specified symbols and calculations using a range unit. It takes a list of symbols, a list of calculations, a range factor, a range unit, an OHLC data type, and an interval.

func (*Client) BalanceSheet

func (c *Client) BalanceSheet(symbol string) (*BalanceSheet, error)

BalanceSheet fetches and returns the balance sheet data for the specified company symbol.

func (*Client) CashFlow

func (c *Client) CashFlow(symbol string) (*CashFlow, error)

CashFlow fetches and returns the cash flow data for the specified company symbol.

func (*Client) CompanyOverview

func (c *Client) CompanyOverview(symbol string) (*CompanyOverview, error)

CompanyOverview fetches and returns the company overview data for the specified company symbol.

func (*Client) CurrencyExchangeRate

func (c *Client) CurrencyExchangeRate(fromCurrency string, toCurrency string) (*CurrencyExchangeRate, error)

CurrencyExchangeRate fetches and returns the Currency Exchange Rate data for the specified fromCurrency and toCurrency.

func (*Client) ETFProfileData

func (c *Client) ETFProfileData(symbol string) (*ETFProfile, error)

ETFProfileData fetches and returns the ETF profile and holdings data for the specified ETF symbol.

func (*Client) Earnings

func (c *Client) Earnings(symbol string) (*Earnings, error)

Earnings fetches and returns the earnings data for the specified company symbol.

func (*Client) EarningsCalendar

func (c *Client) EarningsCalendar(symbol string, horizon Horizon) (*EarningsCalendar, error)

EarningsCalendar fetches the earnings calendar data for the specified parameters

func (*Client) EarningsCallTranscript

func (c *Client) EarningsCallTranscript(symbol string, quarter string) (*EarningsTranscript, error)

EarningsCallTranscript fetches and returns the earnings call transcript data for the specified symbol and quarter.

func (*Client) GlobalQuote

func (c *Client) GlobalQuote(symbol string) (*GlobalQuote, error)

GlobalQuote fetches data from the Global Quote endpoint for the given symbol

func (*Client) HistoricalOptions

func (c *Client) HistoricalOptions(symbol string, date *time.Time) (*HistoricalOptionsData, error)

HistoricalOptions fetches and returns the historical options data for the specified company symbol.

func (*Client) IncomeStatement

func (c *Client) IncomeStatement(symbol string) (*IncomeStatement, error)

IncomeStatement fetches and returns the income statement data for the specified company symbol.

func (*Client) IndicatorEMA

func (c *Client) IndicatorEMA(symbol string, interval Interval, timePeriod int, seriesType SeriesType) (*IndicatorEMA, error)

IndicatorEMA fetches the "EMA" indicators for given symbol from API. The order of dates in TechnicalAnalysis is random because it's a map.

func (*Client) IndicatorSMA

func (c *Client) IndicatorSMA(symbol string, interval Interval, timePeriod int, seriesType SeriesType) (*IndicatorSMA, error)

IndicatorSMA fetches the "SMA" indicators for given symbol from API. The order of dates in TechnicalAnalysis is random because it's a map.

func (*Client) IndicatorStoch

func (c *Client) IndicatorStoch(symbol string, interval Interval) (*IndicatorStoch, error)

IndicatorStoch fetches the "STOCH" indicators for given symbol from API. The order of dates in TechnicalAnalysis is random because it's a map.

func (*Client) InsiderTransactions

func (c *Client) InsiderTransactions(symbol string) (*InsiderTransactions, error)

InsiderTransactions fetches and returns the insider transactions data for the specified symbol.

func (*Client) ListingStatus

func (c *Client) ListingStatus(delisted bool) (*ListingStatus, error)

ListingStatus fetches and returns the listing status data (either active or delisted). if not active will list delisted tickers

func (*Client) NewsSentiment

func (c *Client) NewsSentiment(tickers string, sortType SortType, limit int, timeFrom string, timeTo string) (*NewsSentiment, error)

NewsSentiment fetches and returns the news sentiment data for the specified tickers.

func (*Client) TimeSeries

func (c *Client) TimeSeries(symbol string, interval TimeSeriesInterval, outputSize OutputSize) (*TimeSeries, error)

TimeSeries fetches the time series for given symbol from API. The order of dates in returned object is random because it's a map.

func (*Client) TimeSeriesAdjusted

func (c *Client) TimeSeriesAdjusted(symbol string, interval TimeSeriesIntervalAdjusted, outputSize OutputSize) (*TimeSeriesAdjusted, error)

TimeSeriesAdjusted fetches the time series for given symbol from API. The order of dates in returned object is random because it's a map.

type CompanyOverview

type CompanyOverview struct {
	Symbol                     string    `json:"Symbol"`
	AssetType                  string    `json:"AssetType"`
	Name                       string    `json:"Name"`
	Description                string    `json:"Description"`
	CIK                        string    `json:"CIK"`
	Exchange                   string    `json:"Exchange"`
	Currency                   string    `json:"Currency"`
	Country                    string    `json:"Country"`
	Sector                     string    `json:"Sector"`
	Industry                   string    `json:"Industry"`
	Address                    string    `json:"Address"`
	FiscalYearEnd              string    `json:"FiscalYearEnd"`
	LatestQuarter              string    `json:"LatestQuarter"` // "2023-03-31"
	MarketCapitalization       AVInt     `json:"MarketCapitalization,string"`
	EBITDA                     AVInt     `json:"EBITDA,string"`
	PERatio                    AVFloat64 `json:"PERatio,string"`
	PEGRatio                   AVFloat64 `json:"PEGRatio,string"`
	BookValue                  AVFloat64 `json:"BookValue,string"`
	DividendPerShare           AVFloat64 `json:"DividendPerShare,string"`
	DividendYield              AVFloat64 `json:"DividendYield,string"`
	EPS                        AVFloat64 `json:"EPS,string"`
	RevenuePerShareTTM         AVFloat64 `json:"RevenuePerShareTTM,string"`
	ProfitMargin               AVFloat64 `json:"ProfitMargin,string"`
	OperatingMarginTTM         AVFloat64 `json:"OperatingMarginTTM,string"`
	ReturnOnAssetsTTM          AVFloat64 `json:"ReturnOnAssetsTTM,string"`
	ReturnOnEquityTTM          AVFloat64 `json:"ReturnOnEquityTTM,string"`
	RevenueTTM                 AVInt     `json:"RevenueTTM,string"`
	GrossProfitTTM             AVInt     `json:"GrossProfitTTM,string"`
	DilutedEPSTTM              AVFloat64 `json:"DilutedEPSTTM,string"`
	QuarterlyEarningsGrowthYOY AVFloat64 `json:"QuarterlyEarningsGrowthYOY,string"`
	QuarterlyRevenueGrowthYOY  AVFloat64 `json:"QuarterlyRevenueGrowthYOY,string"`
	AnalystTargetPrice         AVFloat64 `json:"AnalystTargetPrice,string"`
	AnalystRatingStrongBuy     AVInt     `json:"AnalystRatingStrongBuy,string"`
	AnalystRatingBuy           AVInt     `json:"AnalystRatingBuy,string"`
	AnalystRatingHold          AVInt     `json:"AnalystRatingHold,string"`
	AnalystRatingSell          AVInt     `json:"AnalystRatingSell,string"`
	AnalystRatingStrongSell    AVInt     `json:"AnalystRatingStrongSell,string"`
	TrailingPE                 AVFloat64 `json:"TrailingPE,string"`
	ForwardPE                  AVFloat64 `json:"ForwardPE,string"`
	PriceToSalesRatioTTM       AVFloat64 `json:"PriceToSalesRatioTTM,string"`
	PriceToBookRatio           AVFloat64 `json:"PriceToBookRatio,string"`
	EVToRevenue                AVFloat64 `json:"EVToRevenue,string"`
	EVToEBITDA                 AVFloat64 `json:"EVToEBITDA,string"`
	Beta                       AVFloat64 `json:"Beta,string"`
	Week52High                 AVFloat64 `json:"52WeekHigh,string"`
	Week52Low                  AVFloat64 `json:"52WeekLow,string"`
	MovingAverage50Day         AVFloat64 `json:"50DayMovingAverage,string"`
	MovingAverage200Day        AVFloat64 `json:"200DayMovingAverage,string"`
	SharesOutstanding          AVInt     `json:"SharesOutstanding,string"`
	DividendDate               string    `json:"DividendDate"`   //  "2023-06-10"
	ExDividendDate             string    `json:"ExDividendDate"` // "2023-05-09"
}

CompanyOverview represents the company overview data for a company.

type CorrelationData

type CorrelationData struct {
	Index       []string    `json:"index"`
	Correlation [][]float64 `json:"correlation"`
}

CorrelationData represents the correlation data within CalculationData.

type CurrencyExchangeRate

type CurrencyExchangeRate struct {
	FromCurrencyCode string `json:"1. From_Currency Code"`
	FromCurrencyName string `json:"2. From_Currency Name"`
	ToCurrencyCode   string `json:"3. To_Currency Code"`
	ToCurrencyName   string `json:"4. To_Currency Name"`
	ExchangeRate     string `json:"5. Exchange Rate"`
	LastRefreshed    string `json:"6. Last Refreshed"`
	TimeZone         string `json:"7. Time Zone"`
	BidPrice         string `json:"8. Bid Price"`
	AskPrice         string `json:"9. Ask Price"`
}

CurrencyExchangeRate represent a exchange rate between 2 currencies.

type Drawdown

type Drawdown map[string]DrawdownData

Drawdown represents drawdown data for a symbol.

type DrawdownData

type DrawdownData struct {
	MaxDrawdown   float64       `json:"max_drawdown"`
	DrawdownRange DrawdownRange `json:"drawdown_range"`
}

DrawdownData represents the data for a drawdown.

type DrawdownRange

type DrawdownRange struct {
	StartDrawdown string `json:"start_drawdown"`
	EndDrawdown   string `json:"end_drawdown"`
}

DrawdownRange represents the range of a drawdown.

type ETF

type ETF struct {
	Sector string `json:"sector"`
	Weight string `json:"weight"`
}

ETF represents sector weightings in the ETF.

type ETFHolding

type ETFHolding struct {
	Symbol      string `json:"symbol"`
	Description string `json:"description"`
	Weight      string `json:"weight"`
}

ETFHolding represents an individual holding in the ETF.

type ETFProfile

type ETFProfile struct {
	NetAssets         string       `json:"net_assets"`
	NetExpenseRatio   string       `json:"net_expense_ratio"`
	PortfolioTurnover string       `json:"portfolio_turnover"`
	DividendYield     string       `json:"dividend_yield"`
	InceptionDate     string       `json:"inception_date"`
	Leveraged         string       `json:"leveraged"`
	Sectors           []ETF        `json:"sectors"`
	Holdings          []ETFHolding `json:"holdings"`
}

ETFProfile represents the ETF profile and holdings data.

type Earnings

type Earnings struct {
	Symbol            string              `json:"symbol"`
	AnnualEarnings    []AnnualEarnings    `json:"annualEarnings"`
	QuarterlyEarnings []QuarterlyEarnings `json:"quarterlyEarnings"`
}

Earnings represents the earnings data for a company, including both annual and quarterly earnings.

type EarningsCalendar

type EarningsCalendar struct {
	Events []EarningsEvent
}

EarningsCalendar represents the collection of earnings events

type EarningsEvent

type EarningsEvent struct {
	Symbol           string
	Name             string
	ReportDate       time.Time
	FiscalDateEnding time.Time
	Estimate         float64
	Currency         string
}

EarningsEvent represents a single earnings calendar event

type EarningsTranscript

type EarningsTranscript struct {
	Symbol     string              `json:"symbol"`
	Quarter    string              `json:"quarter"`
	Transcript []TranscriptSegment `json:"transcript"`
}

EarningsTranscript represents the earnings call transcript data.

type FeedItem

type FeedItem struct {
	Title                 string            `json:"title"`
	URL                   string            `json:"url"`
	TimePublished         string            `json:"time_published"`
	Authors               []string          `json:"authors"`
	Summary               string            `json:"summary"`
	BannerImage           string            `json:"banner_image"`
	Source                string            `json:"source"`
	CategoryWithinSource  string            `json:"category_within_source"`
	SourceDomain          string            `json:"source_domain"`
	Topics                []Topic           `json:"topics"`
	OverallSentimentScore AVFloat64         `json:"overall_sentiment_score,string"`
	OverallSentimentLabel string            `json:"overall_sentiment_label"`
	TickerSentiment       []TickerSentiment `json:"ticker_sentiment"`
}

FeedItem represents a news feed item with various attributes.

type GlobalQuote

type GlobalQuote struct {
	Symbol           string    `json:"01. symbol" validate:"required"`
	Open             float64   `json:"02. open,string"`
	High             float64   `json:"03. high,string"`
	Low              float64   `json:"04. low,string"`
	Price            float64   `json:"05. price,string"`
	Volume           int       `json:"06. volume,string"`
	LatestTradingDay string    `json:"07. latest trading day"`
	PreviousClose    float64   `json:"08. previous close,string"`
	Change           float64   `json:"09. change,string"`
	ChangePercent    AVPercent `json:"10. change percent"`
}

GlobalQuote - encapsulates global quote

type GlobalQuoteResponse

type GlobalQuoteResponse struct {
	GlobalQuote GlobalQuote `json:"Global Quote"`
}

GlobalQuoteResponse - encapsulates global quote repsonse

type Histogram

type Histogram map[string]HistogramData

Histogram represents a histogram for a symbol.

type HistogramData

type HistogramData struct {
	BinCount []int     `json:"bin_count"`
	BinEdges []float64 `json:"bin_edges"`
}

HistogramData represents the data for a histogram.

type HistoricalOptionsData

type HistoricalOptionsData struct {
	Symbol   string           `json:"symbol"`
	Endpoint string           `json:"endpoint"`
	Message  string           `json:"message"`
	Data     []OptionContract `json:"data"`
}

HistoricalOptionsData represents the full historical options data for a given symbol.

type Horizon

type Horizon string

Horizon represents the time period for earnings calendar lookup

const (
	// ThreeMonth represents 3-month horizon
	ThreeMonth Horizon = "3month"
	// SixMonth represents 6-month horizon
	SixMonth Horizon = "6month"
	// TwelveMonth represents 12-month horizon
	TwelveMonth Horizon = "12month"
)

type IncomeStatement

type IncomeStatement struct {
	Symbol           string              `json:"symbol"`
	AnnualReports    []IsAnnualReport    `json:"annualReports"`
	QuarterlyReports []IsQuarterlyReport `json:"quarterlyReports"`
}

IncomeStatement represents the income statement data for a company.

type IndicatorEMA

type IndicatorEMA struct {
	Metadata          IndicatorEMAMetadata            `json:"Meta Data"`
	TechnicalAnalysis map[string]TechnicalEMAAnalysis `json:"Technical Analysis: EMA"`
}

IndicatorEMA represents the overall struct for stochastics indicator Example https://www.alphavantage.co/query?function=STOCH&symbol=MSFT&interval=daily&apikey=demo

type IndicatorEMAMetadata

type IndicatorEMAMetadata struct {
	Symbol        string `json:"1: Symbol"`
	Indicator     string `json:"2: Indicator"`
	LastRefreshed string `json:"3: Last Refreshed"`
	Interval      string `json:"4: Interval"`
	TimePeriod    int    `json:"5: Time Period"`
	SeriesType    string `json:"6: Series Type"`
	TimeZone      string `json:"7: Time Zone"`
}

IndicatorEMAMetadata is the metadata subset of IndicatorEMA

type IndicatorSMA

type IndicatorSMA struct {
	Metadata          IndicatorSMAMetadata            `json:"Meta Data"`
	TechnicalAnalysis map[string]TechnicalSMAAnalysis `json:"Technical Analysis: SMA"`
}

IndicatorSMA represents the overall struct for stochastics indicator Example https://www.alphavantage.co/query?function=STOCH&symbol=MSFT&interval=daily&apikey=demo

func (*IndicatorSMA) ByDate

func (stoch *IndicatorSMA) ByDate(date time.Time) *TechnicalSMAAnalysis

ByDate returns TechnicalSMAAnalysis for the given date.

func (*IndicatorSMA) Latest

func (stoch *IndicatorSMA) Latest() (date string, latest *TechnicalSMAAnalysis)

Latest returns the most recent TechnicalSMAAnalysis for given stoch.

func (*IndicatorSMA) Today

func (stoch *IndicatorSMA) Today() *TechnicalSMAAnalysis

Today returns TechnicalSMAAnalysis for today.

type IndicatorSMAMetadata

type IndicatorSMAMetadata struct {
	Symbol        string `json:"1: Symbol"`
	Indicator     string `json:"2: Indicator"`
	LastRefreshed string `json:"3: Last Refreshed"`
	Interval      string `json:"4: Interval"`
	TimePeriod    int    `json:"5: Time Period"`
	SeriesType    string `json:"6: Series Type"`
	TimeZone      string `json:"7: Time Zone"`
}

IndicatorSMAMetadata is the metadata subset of IndicatorSMA

type IndicatorStoch

type IndicatorStoch struct {
	Metadata          IndicatorStochMetadata            `json:"Meta Data"`
	TechnicalAnalysis map[string]TechnicalStochAnalysis `json:"Technical Analysis: STOCH"`
}

IndicatorStoch represents the overall struct for stochastics indicator Example https://www.alphavantage.co/query?function=STOCH&symbol=MSFT&interval=daily&apikey=demo

func (*IndicatorStoch) ByDate

func (stoch *IndicatorStoch) ByDate(date time.Time) *TechnicalStochAnalysis

ByDate returns TechnicalStochAnalysis for the given date.

func (*IndicatorStoch) Latest

func (stoch *IndicatorStoch) Latest() (date string, latest *TechnicalStochAnalysis)

Latest returns the most recent TechnicalStochAnalysis for given stoch.

func (*IndicatorStoch) Today

func (stoch *IndicatorStoch) Today() *TechnicalStochAnalysis

Today returns TechnicalStochAnalysis for today.

type IndicatorStochMetadata

type IndicatorStochMetadata struct {
	Symbol        string `json:"1: Symbol"`
	Indicator     string `json:"2: Indicator"`
	LastRefreshed string `json:"3: Last Refreshed"`
	Interval      string `json:"4: Interval"`
	FastKPeriod   int    `json:"5.1: FastK Period"`
	SlowKPeriod   int    `json:"5.2: SlowK Period"`
	SlowKMAType   int    `json:"5.3: SlowK MA Type"`
	SlowDPeriod   int    `json:"5.4: SlowD Period"`
	SlowDMAType   int    `json:"5.5: SlowD MA Type"`
	TimeZone      string `json:"6: Time Zone"`
}

IndicatorStochMetadata is the metadata subset of IndicatorStoch

type InsiderTransaction

type InsiderTransaction struct {
	TransactionDate       string `json:"transaction_date"`
	Ticker                string `json:"ticker"`
	Executive             string `json:"executive"`
	ExecutiveTitle        string `json:"executive_title"`
	SecurityType          string `json:"security_type"`
	AcquisitionOrDisposal string `json:"acquisition_or_disposal"`
	Shares                string `json:"shares"`
	SharePrice            string `json:"share_price"`
}

InsiderTransaction represents a single insider transaction record.

type InsiderTransactions

type InsiderTransactions struct {
	Data []InsiderTransaction `json:"data"`
}

InsiderTransactions represents the response from the INSIDER_TRANSACTIONS API endpoint.

type Interval

type Interval string

Interval represents the possible interval types

func TranslateStringToInterval

func TranslateStringToInterval(intervalStr string) (Interval, error)

TranslateStringToInterval translates a string into an av.Interval

type IsAnnualReport

type IsAnnualReport struct {
	FiscalDateEnding                  string `json:"fiscalDateEnding"`
	ReportedCurrency                  string `json:"reportedCurrency"`
	GrossProfit                       AVInt  `json:"grossProfit"`
	TotalRevenue                      AVInt  `json:"totalRevenue"`
	CostOfRevenue                     AVInt  `json:"costOfRevenue"`
	CostOfGoodsAndServicesSold        AVInt  `json:"costofGoodsAndServicesSold"`
	OperatingIncome                   AVInt  `json:"operatingIncome"`
	SellingGeneralAndAdministrative   AVInt  `json:"sellingGeneralAndAdministrative"`
	ResearchAndDevelopment            AVInt  `json:"researchAndDevelopment"`
	OperatingExpenses                 AVInt  `json:"operatingExpenses"`
	InvestmentIncomeNet               AVInt  `json:"investmentIncomeNet"`
	NetInterestIncome                 AVInt  `json:"netInterestIncome"`
	InterestIncome                    AVInt  `json:"interestIncome"`
	InterestExpense                   AVInt  `json:"interestExpense"`
	NonInterestIncome                 AVInt  `json:"nonInterestIncome"`
	OtherNonOperatingIncome           AVInt  `json:"otherNonOperatingIncome"`
	Depreciation                      AVInt  `json:"depreciation"`
	DepreciationAndAmortization       AVInt  `json:"depreciationAndAmortization"`
	IncomeBeforeTax                   AVInt  `json:"incomeBeforeTax"`
	IncomeTaxExpense                  AVInt  `json:"incomeTaxExpense"`
	InterestAndDebtExpense            AVInt  `json:"interestAndDebtExpense"`
	NetIncomeFromContinuingOperations AVInt  `json:"netIncomeFromContinuingOperations"`
	ComprehensiveIncomeNetOfTax       AVInt  `json:"comprehensiveIncomeNetOfTax"`
	Ebit                              AVInt  `json:"ebit"`
	Ebitda                            AVInt  `json:"ebitda"`
	NetIncome                         AVInt  `json:"netIncome"`
}

IsAnnualReport represents an annual report in the income statement.

func GetIncomeStatementHistoricalAnnualReport

func GetIncomeStatementHistoricalAnnualReport(is *IncomeStatement, year int) (*IsAnnualReport, error)

GetIncomeStatementHistoricalAnnualReport retrieves a specific annual report from an IncomeStatement struct.

func GetIncomeStatementMostRecentAnnualReport

func GetIncomeStatementMostRecentAnnualReport(is *IncomeStatement) (*IsAnnualReport, error)

GetIncomeStatementMostRecentAnnualReport retrieves the most recent annual report from an IncomeStatement struct.

type IsQuarterlyReport

type IsQuarterlyReport struct {
	FiscalDateEnding                  string `json:"fiscalDateEnding"`
	ReportedCurrency                  string `json:"reportedCurrency"`
	GrossProfit                       AVInt  `json:"grossProfit"`
	TotalRevenue                      AVInt  `json:"totalRevenue"`
	CostOfRevenue                     AVInt  `json:"costOfRevenue"`
	CostOfGoodsAndServicesSold        AVInt  `json:"costofGoodsAndServicesSold"`
	OperatingIncome                   AVInt  `json:"operatingIncome"`
	SellingGeneralAndAdministrative   AVInt  `json:"sellingGeneralAndAdministrative"`
	ResearchAndDevelopment            AVInt  `json:"researchAndDevelopment"`
	OperatingExpenses                 AVInt  `json:"operatingExpenses"`
	InvestmentIncomeNet               AVInt  `json:"investmentIncomeNet"`
	NetInterestIncome                 AVInt  `json:"netInterestIncome"`
	InterestIncome                    AVInt  `json:"interestIncome"`
	InterestExpense                   AVInt  `json:"interestExpense"`
	NonInterestIncome                 AVInt  `json:"nonInterestIncome"`
	OtherNonOperatingIncome           AVInt  `json:"otherNonOperatingIncome"`
	Depreciation                      AVInt  `json:"depreciation"`
	DepreciationAndAmortization       AVInt  `json:"depreciationAndAmortization"`
	IncomeBeforeTax                   AVInt  `json:"incomeBeforeTax"`
	IncomeTaxExpense                  AVInt  `json:"incomeTaxExpense"`
	InterestAndDebtExpense            AVInt  `json:"interestAndDebtExpense"`
	NetIncomeFromContinuingOperations AVInt  `json:"netIncomeFromContinuingOperations"`
	ComprehensiveIncomeNetOfTax       AVInt  `json:"comprehensiveIncomeNetOfTax"`
	Ebit                              AVInt  `json:"ebit"`
	Ebitda                            AVInt  `json:"ebitda"`
	NetIncome                         AVInt  `json:"netIncome"`
}

IsQuarterlyReport represents a quarterly report in the income statement.

func GetIncomeStatementHistoricalQuarterlyReport

func GetIncomeStatementHistoricalQuarterlyReport(is *IncomeStatement, year int, quarter int) (*IsQuarterlyReport, error)

GetIncomeStatementHistoricalQuarterlyReport retrieves a specific quarterly report from an IncomeStatement struct.

func GetIncomeStatementMostRecentQuarterlyReport

func GetIncomeStatementMostRecentQuarterlyReport(is *IncomeStatement) (*IsQuarterlyReport, error)

GetIncomeStatementMostRecentQuarterlyReport retrieves the most recent quarterly report from an IncomeStatement struct.

type ListingState

type ListingState int

ListingState represents the state of a listing (Delisted or Active).

const (
	// Delisted represents a delisted listing.
	Delisted ListingState = iota
	// Active represents an active listing.
	Active
)

type ListingStatus

type ListingStatus struct {
	SymbolStatuses []SymbolStatus
}

ListingStatus represents the listing status containing multiple symbol statuses.

type ListingType

type ListingType int

ListingType represents the type of a listing (ETF or Stock).

const (
	// Etf represents an Exchange Traded Fund listing.
	Etf ListingType = iota
	// Stock represents a Stock listing.
	Stock
)

type MetaData

type MetaData struct {
	Symbols  string `json:"symbols"`
	MinDt    string `json:"min_dt"`
	MaxDt    string `json:"max_dt"`
	OHLC     string `json:"ohlc"`
	Interval string `json:"interval"`
}

MetaData represents the metadata in the API response.

type NewsSentiment

type NewsSentiment struct {
	Items                    string     `json:"items"`
	SentimentScoreDefinition string     `json:"sentiment_score_definition"`
	RelevanceScoreDefinition string     `json:"relevance_score_definition"`
	Feed                     []FeedItem `json:"feed"`
}

NewsSentiment represents the sentiment analysis of news items.

type OptionContract

type OptionContract struct {
	ContractID        string    `json:"contractID"`
	Symbol            string    `json:"symbol"`
	Expiration        string    `json:"expiration"`
	Strike            AVFloat64 `json:"strike"`
	Type              string    `json:"type"` // "call" or "put"
	Last              AVFloat64 `json:"last"`
	Mark              AVFloat64 `json:"mark"`
	Bid               AVFloat64 `json:"bid"`
	BidSize           AVInt     `json:"bid_size"`
	Ask               AVFloat64 `json:"ask"`
	AskSize           AVInt     `json:"ask_size"`
	Volume            AVInt     `json:"volume"`
	OpenInterest      AVInt     `json:"open_interest"`
	Date              string    `json:"date"`
	ImpliedVolatility AVFloat64 `json:"implied_volatility"`
	Delta             AVFloat64 `json:"delta"`
	Gamma             AVFloat64 `json:"gamma"`
	Theta             AVFloat64 `json:"theta"`
	Vega              AVFloat64 `json:"vega"`
	Rho               AVFloat64 `json:"rho"`
}

OptionContract represents a single option contract (either call or put) with detailed option Greeks and other metrics.

type OutputSize

type OutputSize string

OutputSize is the type for data output

func TranslateStringToOutputSize

func TranslateStringToOutputSize(outputSizeStr string) (OutputSize, error)

TranslateStringToOutputSize translates a string into an av.TimeSeriesIntervalAdjusted

type QuarterlyEarnings

type QuarterlyEarnings struct {
	FiscalDateEnding   string    `json:"fiscalDateEnding"`
	ReportedDate       string    `json:"reportedDate"`
	ReportedEPS        AVFloat64 `json:"reportedEPS"`
	EstimatedEPS       AVFloat64 `json:"estimatedEPS"`
	Surprise           AVFloat64 `json:"surprise"`
	SurprisePercentage AVFloat64 `json:"surprisePercentage"`
}

QuarterlyEarnings represents the quarterly earnings data for a company.

func GetEarningsHistoricalQuarterlyReport

func GetEarningsHistoricalQuarterlyReport(e *Earnings, year int, quarter int) (*QuarterlyEarnings, error)

GetEarningsHistoricalQuarterlyReport retrieves a specific quarterly report from an Earnings struct.

func GetEarningsMostRecentQuarterlyReport

func GetEarningsMostRecentQuarterlyReport(e *Earnings) (*QuarterlyEarnings, error)

GetEarningsMostRecentQuarterlyReport retrieves the most recent quarterly report from an Earnings struct.

type SeriesType

type SeriesType string

SeriesType type of series for indicators

type SortType

type SortType string

SortType represents the type for sorting data.

type SymbolStatus

type SymbolStatus struct {
	Symbol       string
	Name         string
	Exchange     string
	Type         ListingType
	ActiveSince  time.Time
	DelistedFrom time.Time
	Status       ListingState
}

SymbolStatus represents the status of a symbol.

type TechnicalEMAAnalysis

type TechnicalEMAAnalysis struct {
	EMA float64 `json:",string"`
}

TechnicalEMAAnalysis is the EMA indicator subset of IndicatorEMA

type TechnicalSMAAnalysis

type TechnicalSMAAnalysis struct {
	SMA float64 `json:",string"`
}

TechnicalSMAAnalysis is the SMA indicator subset of IndicatorSMA

type TechnicalStochAnalysis

type TechnicalStochAnalysis struct {
	SlowK float64 `json:",string"`
	SlowD float64 `json:",string"`
}

TechnicalStochAnalysis is the stoch indicator subset of IndicatorStoch

type TickerSentiment

type TickerSentiment struct {
	Ticker               string  `json:"ticker"`
	RelevanceScore       float64 `json:"relevance_score,string"`
	TickerSentimentScore float64 `json:"ticker_sentiment_score,string"`
	TickerSentimentLabel string  `json:"ticker_sentiment_label"`
}

TickerSentiment represents the sentiment of a ticker in a news item.

type TimeSeries

type TimeSeries struct {
	Metadata          TimeSeriesMetadata        `json:"Meta Data"`
	TimeSeriesDaily   map[string]TimeSeriesData `json:"Time Series (Daily)"`
	TimeSeriesWeekly  map[string]TimeSeriesData `json:"Weekly Time Series"`
	TimeSeriesMonthly map[string]TimeSeriesData `json:"Monthly Time Series"`
}

TimeSeries represents the overall struct for time series

func (*TimeSeries) ByDate

func (ts *TimeSeries) ByDate(date time.Time) *TimeSeriesData

ByDate returns the dataset for the given date.

func (*TimeSeries) Latest

func (ts *TimeSeries) Latest() (date string, latest *TimeSeriesData)

Latest returns the most recent item

func (*TimeSeries) Len

func (ts *TimeSeries) Len() int

Len returns the number of data items

func (*TimeSeries) Today

func (ts *TimeSeries) Today() *TimeSeriesData

Today returns dataset for today.

type TimeSeriesAdjusted

type TimeSeriesAdjusted struct {
	Metadata          TimeSeriesMetadata                `json:"Meta Data"`
	TimeSeriesDaily   map[string]TimeSeriesAdjustedData `json:"Time Series (Daily)"`
	TimeSeriesWeekly  map[string]TimeSeriesAdjustedData `json:"Weekly Adjusted Time Series"`
	TimeSeriesMonthly map[string]TimeSeriesAdjustedData `json:"Monthly Adjusted Time Series"`
}

TimeSeriesAdjusted - like TimeSeries, but inclused dividends and adjusted close

type TimeSeriesAdjustedData

type TimeSeriesAdjustedData struct {
	Open             float64 `json:"1. open,string"`
	High             float64 `json:"2. high,string"`
	Low              float64 `json:"3. low,string"`
	Close            float64 `json:"4. close,string"`
	AdjustedClose    float64 `json:"5. adjusted close,string"`
	Volume           uint64  `json:"6. volume,string"`
	DividendAmount   float64 `json:"7. dividend amount,string"`
	SplitCoefficient float64 `json:"8. split coefficient,string"`
}

TimeSeriesAdjustedData - like TimeSeries, but inclused dividends and adjusted close

type TimeSeriesData

type TimeSeriesData struct {
	Open   float64 `json:"1. open,string"`
	High   float64 `json:"2. high,string"`
	Low    float64 `json:"3. low,string"`
	Close  float64 `json:"4. close,string"`
	Volume uint64  `json:"5. volume,string"`
}

TimeSeriesData is a subset of TimeSeries

func GetTimeSeriesMonthlyData

func GetTimeSeriesMonthlyData(ts *TimeSeries, year int, quarter int) (*TimeSeriesData, string, error)

GetTimeSeriesMonthlyData retrieves the monthly data from a TimeSeries struct for a specific year and quarter.

type TimeSeriesInterval

type TimeSeriesInterval string

TimeSeriesInterval is the type for time series data

func TranslateStringToTimeSeriesInterval

func TranslateStringToTimeSeriesInterval(intervalStr string) (TimeSeriesInterval, error)

TranslateStringToTimeSeriesInterval translates a string into an av.TimeSeriesInterval

type TimeSeriesIntervalAdjusted

type TimeSeriesIntervalAdjusted string

TimeSeriesIntervalAdjusted is the type for adjusted time series data

func TranslateStringToTimeSeriesIntervalAdjusted

func TranslateStringToTimeSeriesIntervalAdjusted(intervalStr string) (TimeSeriesIntervalAdjusted, error)

TranslateStringToTimeSeriesIntervalAdjusted translates a string into an av.TimeSeriesIntervalAdjusted

type TimeSeriesMetadata

type TimeSeriesMetadata struct {
	Information   string `json:"1. Information"`
	Symbol        string `json:"2. Symbol"`
	LastRefreshed string `json:"3. Last Refreshed"`
	TimeZone      string `json:"4. Time Zone"`
}

TimeSeriesMetadata is the metadata subset of TimeSeries

type Topic

type Topic struct {
	Topic          string  `json:"topic"`
	RelevanceScore float64 `json:"relevance_score,string"`
}

Topic represents a topic related to a news item.

type TranscriptSegment

type TranscriptSegment struct {
	Speaker   string `json:"speaker"`
	Title     string `json:"title"`
	Content   string `json:"content"`
	Sentiment string `json:"sentiment"`
}

TranscriptSegment represents an individual segment of the earnings call transcript.

Jump to

Keyboard shortcuts

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