eodhd

package module
v0.0.0-...-eb3652a Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 16 Imported by: 0

README

eodhd

API Wrapper for EODHD end of day historical pricing API

Documentation

Index

Constants

View Source
const (
	DefaultRateLimitPercent = 0.75
	DefaultBurstPercent     = 0.25
)
View Source
const (
	RateLimitHeader          = "X-RateLimit-Limit"
	RateLimitRemainingHeader = "X-RateLimit-Remaining"
)

Variables

This section is empty.

Functions

func GetPtrString

func GetPtrString(v string) *string

func GetPtrTime

func GetPtrTime(v time.Time) *time.Time

Types

type BulkEod

type BulkEod struct {
	Code          string  `csv:"Code" json:"code"`
	Exchange      string  `csv:"Ex" json:"exchange_short_name"`
	Date          string  `csv:"Date" json:"date"`
	Open          float64 `csv:"Open" json:"open"`
	High          float64 `csv:"High" json:"high"`
	Low           float64 `csv:"Low" json:"low"`
	Close         float64 `csv:"Close" json:"close"`
	AdjustedClose float64 `csv:"Adjusted_close" json:"adjusted_close"`
	Volume        int     `csv:"Volume" json:"volume"`
}

type BulkEodParams

type BulkEodParams struct {
	ApiToken string        `url:"api_token"`
	Format   RequestFormat `url:"fmt"`
	Exchange string        `url:"-"`
}

func NewBulkEodParams

func NewBulkEodParams(apiToken string, exchange *string, format *RequestFormat) *BulkEodParams

func (*BulkEodParams) BuildPath

func (b *BulkEodParams) BuildPath(baseUrl *url.URL) (string, error)

func (*BulkEodParams) GetEncoded

func (b *BulkEodParams) GetEncoded() (string, error)

type BulkEodService

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

func NewBulkEodService

func NewBulkEodService(c RequestClient) *BulkEodService

func (*BulkEodService) GetBulkEod

func (b *BulkEodService) GetBulkEod(exchange *string, format *RequestFormat) ([]*BulkEod, *Response, error)

type Client

type Client struct {
	UserAgent string

	// services
	OhlcvService     *OhlcvService
	ExchangesService *ExchangesService
	TickerService    *TickerService
	BulkEodService   *BulkEodService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string, options ...ClientOption) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *retryablehttp.Request, data interface{}) (*Response, error)

func (*Client) GetApiToken

func (c *Client) GetApiToken() string

func (*Client) GetBaseUrl

func (c *Client) GetBaseUrl() *url.URL

func (*Client) GetCountryCode

func (c *Client) GetCountryCode() string

func (*Client) GetDefaultFormat

func (c *Client) GetDefaultFormat() RequestFormat

func (*Client) NewGetRequest

func (c *Client) NewGetRequest(requestUrl string, headers *map[string]string) (*retryablehttp.Request, error)

type ClientOption

type ClientOption func(*Client) error

func SetPercentOfRateLimit

func SetPercentOfRateLimit(maxPercent float64) ClientOption

type Exchange

type Exchange struct {
	Name         string `json:"Name"`
	Code         string `json:"Code"`
	OperatingMIC string `json:"OperatingMIC"`
	Country      string `json:"Country"`
	Currency     string `json:"Currency"`
	CountryISO2  string `json:"CountryISO2"`
	CountryISO3  string `json:"CountryISO3"`
}

type ExchangeParams

type ExchangeParams struct {
	ApiToken string        `url:"api_token"`
	Format   RequestFormat `url:"fmt"`
}

func NewExchangeParams

func NewExchangeParams(apiToken string) *ExchangeParams

func (*ExchangeParams) BuildPath

func (e *ExchangeParams) BuildPath(baseUrl *url.URL) (string, error)

func (*ExchangeParams) GetEncoded

func (e *ExchangeParams) GetEncoded() (string, error)

type ExchangesService

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

func NewExchangesService

func NewExchangesService(c RequestClient) *ExchangesService

func (*ExchangesService) GetExchanges

func (e *ExchangesService) GetExchanges() ([]*Exchange, *Response, error)

type Ohlcv

type Ohlcv struct {
	Date     string  `csv:"Date" json:"date"`
	Open     float64 `csv:"Open" json:"open"`
	High     float64 `csv:"High" json:"high"`
	Low      float64 `csv:"Low" json:"low"`
	Close    float64 `csv:"Close" json:"close"`
	AdjClose float64 `csv:"Adjusted_close" json:"adjusted_close"`
	Volume   float64 `csv:"Volume" json:"volume"`

	// Set via ParseDate from standard urlDateFormat
	DateParsed *time.Time `csv:"-" json:"-"`
}

Ohlcv represents the OHLCV response for both JSON and CSV formats for historical EOD data.

func (*Ohlcv) ParseDate

func (o *Ohlcv) ParseDate() error

type OhlcvParams

type OhlcvParams struct {
	Symbol      string         `url:"-"`
	CountryCode string         `url:"-"`
	Format      *RequestFormat `url:"fmt"`
	FromTime    *time.Time     `url:"-"`
	ToTime      *time.Time     `url:"-"`
	From        *string        `url:"from,omitempty"`
	To          *string        `url:"from,omitempty"`
	ApiToken    string         `url:"api_token"`
}

func (*OhlcvParams) BuildPath

func (o *OhlcvParams) BuildPath(baseUrl *url.URL) (string, error)

func (*OhlcvParams) GetEncoded

func (o *OhlcvParams) GetEncoded() (string, error)

type OhlcvService

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

func NewOhlcvService

func NewOhlcvService(c RequestClient) *OhlcvService

func (*OhlcvService) GetOhlcv

func (o *OhlcvService) GetOhlcv(symbol string, countryCode *string, format *RequestFormat, from, to *time.Time) ([]*Ohlcv, *Response, error)

type Params

type Params interface {
	GetEncoded() (string, error)
	BuildPath(baseUrl *url.URL) (string, error)
}

type RequestClient

type RequestClient interface {
	NewGetRequest(requestUrl string, headers *map[string]string) (*retryablehttp.Request, error)
	Do(req *retryablehttp.Request, data interface{}) (*Response, error)
	GetApiToken() string
	GetBaseUrl() *url.URL
}

type RequestFormat

type RequestFormat string

func GetFormatCsv

func GetFormatCsv() *RequestFormat

func GetFormatJson

func GetFormatJson() *RequestFormat

type Response

type Response struct {
	*http.Response

	RateLimit          int
	RateLimitRemaining int
}

func (*Response) SetHeaderValues

func (r *Response) SetHeaderValues()

type Ticker

type Ticker struct {
	Code     string  `json:"Code" csv:"Code"`
	Name     string  `json:"Name" csv:"Name"`
	Country  string  `json:"Country" csv:"Country"`
	Exchange string  `json:"Exchange" csv:"Exchange"`
	Currency string  `json:"Currency" csv:"Currency"`
	Type     string  `json:"Type" csv:"Type"`
	Isin     *string `json:"Isin,omitempty" csv:"Isin,omitempty"`
}

type TickerParams

type TickerParams struct {
	ApiToken     string         `url:"api_token"`
	Format       *RequestFormat `url:"fmt"`
	ExchangeCode *string        `url:"-"`
}

func NewTickerParams

func NewTickerParams(apiToken, exchangeCode string, format RequestFormat) *TickerParams

func NewTickerParamsDefault

func NewTickerParamsDefault(apiToken string) *TickerParams

func (*TickerParams) BuildPath

func (t *TickerParams) BuildPath(baseUrl *url.URL) (string, error)

func (*TickerParams) GetEncoded

func (t *TickerParams) GetEncoded() (string, error)

type TickerService

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

func NewTickerService

func NewTickerService(c RequestClient) *TickerService

func (*TickerService) GetTickers

func (t *TickerService) GetTickers(exchangeCode string, format *RequestFormat) ([]*Ticker, *Response, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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