Documentation
¶
Index ¶
- func AddBoolParam(params map[string]string, key string, value *bool)
- func AddDateParam(params map[string]string, key string, value *time.Time, format string)
- func AddIntParam(params map[string]string, key string, value *int)
- func AddStringParam(params map[string]string, key string, value *string)
- type APIClient
- func (c *APIClient) GetCryptocurrencies() (cryptoResponse *CryptoResponse, err error)
- func (c *APIClient) GetLogo(req LogoRequest) (logo *Logo, err error)
- func (c *APIClient) GetQuote(req QuoteRequest) (quote *Quote, err error)
- func (c *APIClient) GetStocks() (stocksResponse *StocksResponse, err error)
- func (c *APIClient) GetTimeSeries(req TimeSeriesRequest) (candles *TimeSeriesResponse, err error)
- type APIUrl
- type Config
- type Crypto
- type CryptoResponse
- type HTTPClient
- type Logo
- type LogoMeta
- type LogoRequest
- type Quote
- type QuoteFiftyTwoWeek
- type QuoteInterval
- type QuoteRequest
- type Stocks
- type StocksResponse
- type TDTime
- type TDZonedTime
- type TimeSeriesCandle
- type TimeSeriesInterval
- type TimeSeriesRequest
- type TimeSeriesResponse
- type TimeSeriesResponseMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDateParam ¶
Types ¶
type APIClient ¶
type APIClient struct { Logger *zap.Logger Debug bool Client *HTTPClient }
func NewAPIClient ¶
NewAPIClient creates a new API client
func (*APIClient) GetCryptocurrencies ¶ added in v0.1.3
func (c *APIClient) GetCryptocurrencies() (cryptoResponse *CryptoResponse, err error)
func (*APIClient) GetLogo ¶ added in v0.1.2
func (c *APIClient) GetLogo(req LogoRequest) (logo *Logo, err error)
func (*APIClient) GetQuote ¶
func (c *APIClient) GetQuote(req QuoteRequest) (quote *Quote, err error)
func (*APIClient) GetStocks ¶ added in v0.1.3
func (c *APIClient) GetStocks() (stocksResponse *StocksResponse, err error)
func (*APIClient) GetTimeSeries ¶
func (c *APIClient) GetTimeSeries(req TimeSeriesRequest) (candles *TimeSeriesResponse, err error)
type Crypto ¶ added in v0.1.3
type Crypto struct { Symbol string `json:"symbol"` // Cryptocurrency symbol (e.g. "BTC/USD", "ETH/EUR") AvailableExchanges []string `json:"available_exchanges"` // List of exchanges where the cryptocurrency is available (e.g. ["Binance", "Coinbase"]) CurrencyBase string `json:"currency_base"` // Base currency of the cryptocurrency (e.g. "BTC", "ETH") CurrencyQuote string `json:"currency_quote"` // Quote currency of the cryptocurrency (e.g. "USD", "EUR") }
type CryptoResponse ¶ added in v0.1.3
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
type Logo ¶ added in v0.1.2
type Logo struct { Meta LogoMeta `json:"meta"` URL string `json:"url"` // URL of the logo image (for stocks only) LogoBase string `json:"logo_base"` // URL of the logo of the base currency (for crypto and forex only) LogoQuote string `json:"logo_quote"` // URL of the logo of the quote currency (for crypto and forex only) }
type LogoRequest ¶ added in v0.1.2
type Quote ¶ added in v0.1.1
type Quote struct { Symbol string `json:"symbol"` Name string `json:"name"` Exchange string `json:"exchange"` MicCode string `json:"mic_code"` Currency string `json:"currency"` DateTime TDTime `json:"datetime"` Timestamp TDTime `json:"timestamp"` LastQuoteAt TDTime `json:"last_quote_at"` Open float64 `json:"open,string"` High float64 `json:"high,string"` Low float64 `json:"low,string"` Close float64 `json:"close,string"` Volume float64 `json:"volume,string"` PreviousClose float64 `json:"previous_close,string"` Change float64 `json:"change,string"` PercentChange float64 `json:"percent_change,string"` AverageVolume float64 `json:"average_volume,string"` Rolling1DayChange float64 `json:"rolling_1day_change,string"` Rolling7DayChange float64 `json:"rolling_7day_change,string"` RollingPeriodChange float64 `json:"rolling_period_change,string"` IsMarketOpen bool `json:"is_market_open"` FiftyTwoWeek QuoteFiftyTwoWeek `json:"fifty_two_week"` ExtendedChange float64 `json:"extended_change,string"` ExtendedPercentChange float64 `json:"extended_percent_change,string"` ExtendedPrice float64 `json:"extended_price,string"` ExtendedTimestamp int64 `json:"extended_timestamp"` }
type QuoteFiftyTwoWeek ¶
type QuoteFiftyTwoWeek struct { Low float64 `json:"low,string"` High float64 `json:"high,string"` LowChange float64 `json:"low_change,string"` HighChange float64 `json:"high_change,string"` LowChangePercent float64 `json:"low_change_percent,string"` HighChangePercent float64 `json:"high_change_percent,string"` Range string `json:"range"` }
type QuoteInterval ¶
type QuoteInterval string
const ( QuoteInterval1Min QuoteInterval = "1min" QuoteInterval5Min QuoteInterval = "5min" QuoteInterval15Min QuoteInterval = "15min" QuoteInterval30Min QuoteInterval = "30min" QuoteInterval45Min QuoteInterval = "45min" QuoteInterval1Hour QuoteInterval = "1h" QuoteInterval2Hour QuoteInterval = "2h" QuoteInterval4Hour QuoteInterval = "4h" QuoteInterval1Day QuoteInterval = "1day" QuoteInterval1Week QuoteInterval = "1week" QuoteInterval1Month QuoteInterval = "1month" )
type QuoteRequest ¶
type QuoteRequest struct { Symbol *string // Required: Symbol of the asset (e.g. "AAPL", "BTC/USD") FIGI *string // Financial Instrument Global Identifier ISIN *string // International Securities Identification Number CUSIP *string // Committee on Uniform Securities Identification Procedures Interval *QuoteInterval // Time interval for the quotes (e.g. "1min", "1week") defaults to "1day" Exchange *string // Exchange code (e.g. "NASDAQ", "Binance") MicCode *string // Market Identifier Code (e.g. "XNAS" for NASDAQ) Country *string // Country code (e.g. "US" or "United States") VolumeTimePeriod *int // Number of periods for Average Volume Type *string // Type of asset (e.g. "Digital currency", "Common stock") PrePost *bool // Include pre/post market data (default is false) EOD *bool // If true, then return data for closed day RollingPeriod *int // Number of hours for calculate rolling change at period DP *int // Number of decimal places for float values. Supports 0-11, default is 5 TimeZone *string // Timezone for the response (e.g. "America/New_York", "UTC"). Defaults to "Exchange" }
QuoteRequest is the available parameters for a quote request
type Stocks ¶ added in v0.1.3
type Stocks struct { Symbol string `json:"symbol"` // Stock symbol (e.g. "AAPL") Name string `json:"name"` // Full name of the stock (e.g. "Apple Inc.") Currency string `json:"currency"` // Currency code (e.g. "USD") Exchange string `json:"exchange"` // Exchange code (e.g. "NASDAQ") MicCode string `json:"mic_code"` // Market Identifier Code (e.g. "XNAS" for NASDAQ) Country string `json:"country"` // Country code (e.g. "US") Type string `json:"type"` // Type of the stock (e.g. "Common Stock", "ETF") FigiCode string `json:"figi_code"` // Financial Instrument Global Identifier CfiCode string `json:"cfi_code"` // Classification of Financial Instruments code ISIN string `json:"isin"` // International Securities Identification Number CUSIP string `json:"cusip"` // Committee on Uniform Securities Identification Procedures }
type StocksResponse ¶ added in v0.1.3
type TDTime ¶
TDTime handles the datetime format used by TwelveData API
func (*TDTime) UnmarshalJSON ¶
type TDZonedTime ¶
type TimeSeriesCandle ¶
type TimeSeriesInterval ¶
type TimeSeriesInterval string
const ( TimeSeriesInterval1Min TimeSeriesInterval = "1min" TimeSeriesInterval5Min TimeSeriesInterval = "5min" TimeSeriesInterval15Min TimeSeriesInterval = "15min" TimeSeriesInterval30Min TimeSeriesInterval = "30min" TimeSeriesInterval45Min TimeSeriesInterval = "45min" TimeSeriesInterval1Hour TimeSeriesInterval = "1h" TimeSeriesInterval2Hour TimeSeriesInterval = "2h" TimeSeriesInterval4Hour TimeSeriesInterval = "4h" TimeSeriesInterval5Hour TimeSeriesInterval = "5h" TimeSeriesInterval1Day TimeSeriesInterval = "1day" TimeSeriesInterval1Week TimeSeriesInterval = "1week" TimeSeriesInterval1Month TimeSeriesInterval = "1month" )
type TimeSeriesRequest ¶
type TimeSeriesRequest struct { Symbol *string // Required: Symbol of the asset (e.g. "AAPL", "BTC/USD") FIGI *string // Financial Instrument Global Identifier ISIN *string // International Securities Identification Number CUSIP *string // Committee on Uniform Securities Identification Procedures Interval *TimeSeriesInterval // Required: Time interval for the candles (e.g. "1min", "1day") Exchange *string // Exchange code (e.g. "NASDAQ", "Binance") MicCode *string // Market Identifier Code (e.g. "XNAS" for NASDAQ) Country *string // Country code (e.g. "US" or "United States") Type *string // Type of asset (e.g. "Digital currency", "Common stock") OutputSize *int // Number of candles to return (default is 30, max is 5000) PrePost *bool // Include pre/post market data (default is false) DP *int // Number of decimal places for float values. Supports 0-11, default is -1 (API automatically determines precision) Order *string // Sorting order for the results "asc" and "desc" (default is "desc") TimeZone *string // Timezone for the response (e.g. "America/New_York", "UTC"). Defaults to "Exchange" Date *time.Time // Specific day to fetch data for (time is ignored) StartDate *time.Time // Time when the series starts EndDate *time.Time // Time when the series ends PreviousClose *bool // Include previous close price in the response (default is false) Adjust *string // Adjusting mode for prices ("none", "dividends", "splits", "all"). Default is "none" }
TimeSeriesRequest is the available parameters for a time series request
type TimeSeriesResponse ¶
type TimeSeriesResponse struct { Meta TimeSeriesResponseMeta `json:"meta"` Candles []TimeSeriesCandle `json:"values"` }
func (*TimeSeriesResponse) UnmarshalJSON ¶
func (r *TimeSeriesResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON Parses JSON response, first taking the exchange timezone from the meta field (if present) and then parsing each candle's datetime in the correct timezone.
type TimeSeriesResponseMeta ¶
type TimeSeriesResponseMeta struct { Symbol string `json:"symbol"` Interval string `json:"interval"` Currency string `json:"currency"` CurrencyBase string `json:"currency_base"` CurrencyQuote string `json:"currency_quote"` ExchangeTimezone string `json:"exchange_timezone"` Exchange string `json:"exchange"` MicCode string `json:"mic_code"` Type string `json:"type"` }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.