Documentation ¶
Index ¶
- Constants
- Variables
- type BitfinexClient
- func (b *BitfinexClient) AddCacheConnection(conn *redis.Client)
- func (b *BitfinexClient) Do(req *http.Request) (*http.Response, error)
- func (b *BitfinexClient) FetchCached() (*TickerData, error)
- func (b *BitfinexClient) ParseResponseBody(resp *http.Response) ([]byte, error)
- func (b *BitfinexClient) Request(method string, url string, data io.Reader) (*http.Request, error)
- func (b *BitfinexClient) Ticker(t Ticker) (*TickerData, error)
- func (b *BitfinexClient) WriteCached(t *TickerData) error
- type Error
- type Ticker
- type TickerData
Constants ¶
View Source
const ( APIHost = "https://api.bitfinex.com" Version = "v1" // DefaultRateLimitEnabled = true DefaultCacheEnabled = false // RateLimit interval AllowedInterval = time.Second * 10 )
View Source
const ( KeyStringBase = "prices/bitfinex/btcusd" DefaultCacheTimeout = time.Second * 3 )
Variables ¶
View Source
var ( // ErrRequestFailed is returned in the instance a // http request does not return a 200 ErrRequestFailed = errors.New("failed request not successful") // ErrNotFound is returned in the instance a // http request returns a 404 ErrNotFound = errors.New("resource not found") // ErrCacheEntryExpired is returned if // the cached entry that is returned has expired. // This SHOULD be taken care of by key expiry, but there is a chance // a stale result is returned and by the time of presentation // has exceeded the expiry timeline, therefore should be discarded ErrCacheEntryExpired = errors.New("cache entry expired, please refresh") )
Functions ¶
This section is empty.
Types ¶
type BitfinexClient ¶
type BitfinexClient struct { Host string Version string CacheEnabled bool RateLimit bool // contains filtered or unexported fields }
func NewV1Client ¶
func NewV1Client() *BitfinexClient
func (*BitfinexClient) AddCacheConnection ¶
func (b *BitfinexClient) AddCacheConnection(conn *redis.Client)
func (*BitfinexClient) FetchCached ¶
func (b *BitfinexClient) FetchCached() (*TickerData, error)
func (*BitfinexClient) ParseResponseBody ¶
func (b *BitfinexClient) ParseResponseBody(resp *http.Response) ([]byte, error)
ParseResponseBody takes an http response and turns the body to a []byte
func (*BitfinexClient) Ticker ¶
func (b *BitfinexClient) Ticker(t Ticker) (*TickerData, error)
func (*BitfinexClient) WriteCached ¶
func (b *BitfinexClient) WriteCached(t *TickerData) error
type TickerData ¶
type TickerData struct { Mid string `json:"mid"` Bid string `json:"bid"` Ask string `json:"ask"` LastPrice string `json:"last_price"` Low string `json:"low"` High string `json:"high"` Volume string `json:"volume"` Timestamp string `json:"timestamp"` }
func (*TickerData) FormatPrice ¶
func (t *TickerData) FormatPrice(price int) string
func (TickerData) GetHigh ¶
func (t TickerData) GetHigh() (float64, error)
func (*TickerData) GetLastPrice ¶
func (t *TickerData) GetLastPrice() (float64, error)
func (TickerData) GetLow ¶
func (t TickerData) GetLow() (float64, error)
func (TickerData) GetTimestamp ¶
func (t TickerData) GetTimestamp() (*time.Time, error)
func (*TickerData) SatsPerDollar ¶
func (t *TickerData) SatsPerDollar() int64
Click to show internal directories.
Click to hide internal directories.