twelvedata

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 15 Imported by: 1

README

Twelve data go api client

Go Report Card Tests and linters

Covered:

Reference data

  • Stocks list ✅
  • Forex Pairs List ❌
  • Cryptocurrencies List ❌
  • Etfs ✅
  • Indices ✅
  • Exchanges ✅
  • Cryptocurrency exchanges ❌
  • Technical indicators interface ❌
  • Symbol search ❌
  • Earliest timestamp ❌
  • Market state ✅

Core data

  • Time series ✅
  • Exchange rate ✅
  • Currency conversion ❌
  • Quote ✅
  • Real-time price ❌
  • Edd of day price ❌
  • Market movers ✅

Fundamentals

  • Logo ❌
  • Profile ✅
  • Dividends ✅
  • Splits ❌
  • Earnings ❌
  • Earnings calendar ✅
  • IPO calendar ❌
  • Statistics ✅
  • Insider transactions ✅
  • Income statement ✅
  • Balance sheet ✅
  • Cash flow ✅
  • Options expiration ❌
  • Options chain ❌
  • Key executives ❌
  • Institutional holders ❌
  • Fund holders ❌

WebSocket

  • Price ✅

Advanced

  • Complex Data ❌
  • Usage ✅

Usage

http example

ws example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced struct {
	UsageURL string `default:"/api_usage?apikey={apikey}" json:"usage_url"`
}

type Cli

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

func NewCli

func NewCli(cfg *Conf, httpCli *HTTPCli, logger *zerolog.Logger) *Cli

func (*Cli) CheckErrorInResponse

func (c *Cli) CheckErrorInResponse(resp *fasthttp.Response) (*response.Error, error)

func (*Cli) GetBalanceSheet

func (c *Cli) GetBalanceSheet(symbol, exchange, micCode, country, period, startDate, endDate string) (
	balanceSheetResp *response.BalanceSheets,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetCashFlow

func (c *Cli) GetCashFlow(symbol, exchange, micCode, country, startDate, endDate, period string) (
	cashFlowResp *response.CashFlows,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetDividends

func (c *Cli) GetDividends(symbol, exchange, micCode, country, r, startDate, endDate string) (
	dividendsResp *response.Dividends,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

nolint: varnamelen

func (*Cli) GetEarningsCalendar

func (c *Cli) GetEarningsCalendar(exchange, micCode, country string, decimalPlaces int, startDate, endDate string) (
	earningsResp *response.Earnings,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetEtfs

func (c *Cli) GetEtfs(symbol, exchange, micCode, country string, showPlan, includeDelisted bool) (
	etfsResp *response.Etfs,
	creditsLeft, creditsUsed int64,
	err error,
)

func (*Cli) GetExchangeRate

func (c *Cli) GetExchangeRate(
	symbol, date, timeZone string, decimalPlaces int,
) (
	exchangeRate *response.ExchangeRate,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetExchanges

func (c *Cli) GetExchanges(instrumentType, name, code, country string, showPlan bool) (
	exchangesResp *response.Exchanges,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetIncomeStatement

func (c *Cli) GetIncomeStatement(symbol, exchange, micCode, country, period, startDate, endDate string) (
	incomeStatementResp *response.IncomeStatements,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetIndices

func (c *Cli) GetIndices(symbol, country string, showPlan, includeDelisted bool) (
	indicesResp *response.Indices,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetInsiderTransactions

func (c *Cli) GetInsiderTransactions(symbol, exchange, micCode, country string) (
	insiderTransactionsResp *response.InsiderTransactions,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetMarketMovers

func (c *Cli) GetMarketMovers(instrument, direction string, outputSize int, country string, decimalPlaces int) (
	marketMoversResp *response.MarketMovers,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetMarketState

func (c *Cli) GetMarketState(exchange, code, country string) (
	marketStateResp []response.MarketState,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetProfile

func (c *Cli) GetProfile(symbol, exchange, micCode, country string) (
	profileResp *response.Profile,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetQuote added in v0.1.4

func (c *Cli) GetQuote(
	symbol, interval, exchange, micCode, country, volumeTimePeriod, instrumentType, prepost string,
	eod bool,
	rollingPeriod, decimalPlaces int,
	timezone string,
) (
	quotes *response.Quotes,
	creditsLeft, creditsUsed int64,
	err error,
)

func (*Cli) GetStatistics

func (c *Cli) GetStatistics(symbol, exchange, micCode, country string) (
	statisticsResp *response.Statistics,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetStocks

func (c *Cli) GetStocks(symbol, exchange, micCode, country, instrumentType string, showPlan, includeDelisted bool) (
	stocksResp *response.Stocks,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

func (*Cli) GetTimeSeries

func (c *Cli) GetTimeSeries(
	symbol, interval, exchange, micCode, country, instrumentType string,
	outputSize int,
	prePost string,
	decimalPlaces int,
	order, timezone, date, startDate, endDate string,
	previousClose bool,
) (seriesResp *response.TimeSeries, creditsLeft int64, creditsUsed int64, err error)

nolint: cyclop

func (*Cli) GetUsage

func (c *Cli) GetUsage() (
	usageResp *response.Usage,
	creditsLeft int64,
	creditsUsed int64,
	err error,
)

type Conf

type Conf struct {
	BaseURL   string `default:"https://api.twelvedata.com" json:"base_url"`
	BaseWSURL string `default:"ws.twelvedata.com"          json:"base_ws_url"`

	ReferenceData ReferenceData `json:"reference_data"`
	CoreData      CoreData      `json:"core_data"`
	Fundamentals  Fundamentals  `json:"fundamentals"`
	WebSocket     WebSocket     `json:"web_socket"`
	Advanced      Advanced      `json:"advanced"`

	APIKey  string `default:"demo" json:"api_key"`
	Timeout int    `default:"15"   json:"timeout"`
}

type CoreData

type CoreData struct {
	TimeSeriesURL string `` /* 339-byte string literal not displayed */
	QuotesURL     string `` /* 334-byte string literal not displayed */

	ExchangeRateURL string `` /* 150-byte string literal not displayed */
	MarketMoversURL string `` /* 150-byte string literal not displayed */
}

nolint: lll

type Fundamentals

type Fundamentals struct {
	EarningsCalendarURL    string `` /* 206-byte string literal not displayed */
	ProfileURL             string `` /* 196-byte string literal not displayed */
	InsiderTransactionsURL string `` /* 209-byte string literal not displayed */
	IncomeStatementURL     string `` /* 205-byte string literal not displayed */
	BalanceSheetURL        string `` /* 202-byte string literal not displayed */
	CashFlowURL            string `` /* 198-byte string literal not displayed */
	DividendsURL           string `` /* 198-byte string literal not displayed */
	StatisticsURL          string `` /* 199-byte string literal not displayed */
}

nolint: lll

type HTTPCli

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

func NewHTTPCli

func NewHTTPCli(transport *fasthttp.Client, cfg *Conf, logger *zerolog.Logger) *HTTPCli

type ReferenceData

type ReferenceData struct {
	StocksURL      string `` /* 195-byte string literal not displayed */
	ExchangesURL   string `` /* 197-byte string literal not displayed */
	IndicesURL     string `` /* 196-byte string literal not displayed */
	EtfsURL        string `` /* 193-byte string literal not displayed */
	MarketStateURL string `` /* 201-byte string literal not displayed */
}

nolint: lll

type WS

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

func NewWS

func NewWS(cfg *Conf, logger *zerolog.Logger, dialer *websocket.Dialer) *WS

func (*WS) Consume

func (ws *WS) Consume() <-chan response.PriceEvent

func (*WS) Subscribe

func (ws *WS) Subscribe(ctx context.Context, symbols []string) error

type WebSocket

type WebSocket struct {
	PriceURL string `default:"/v1/quotes/price" json:"ws_price_url"`
}

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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