Documentation ¶
Index ¶
- Constants
- func PastUnixTime(t time.Duration) int64
- func SecondsToMilli(t int64) int64
- func TelemetryFailure(n Name, mt MessageType)
- type AggregatedProviderCandles
- type AggregatedProviderPrices
- type BinanceCandle
- type BinanceCandleMetadata
- type BinancePairSummary
- type BinanceProvider
- func (p *BinanceProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *BinanceProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *BinanceProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *BinanceProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type BinanceSubscriptionMsg
- type BinanceTicker
- type BitgetCandle
- type BitgetCandleResponse
- type BitgetErrResponse
- type BitgetPairData
- type BitgetPairsSummary
- type BitgetProvider
- func (p *BitgetProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *BitgetProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *BitgetProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *BitgetProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type BitgetSubscriptionArg
- type BitgetSubscriptionMsg
- type BitgetSubscriptionResponse
- type BitgetTicker
- type BitgetTickerData
- type CoinbaseErrResponse
- type CoinbasePairSummary
- type CoinbaseProvider
- func (p *CoinbaseProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *CoinbaseProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *CoinbaseProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *CoinbaseProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type CoinbaseSubscriptionMsg
- type CoinbaseTicker
- type CoinbaseTrade
- type CoinbaseTradeResponse
- type Endpoint
- type FTXCandle
- type FTXCandleResponse
- type FTXMarkets
- type FTXMarketsResponse
- type FTXProvider
- func (p *FTXProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *FTXProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *FTXProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *FTXProvider) SubscribeCurrencyPairs(pairs ...types.CurrencyPair) error
- type GateCandle
- type GateCandleResponse
- type GateCandleSubscriptionMsg
- type GateEvent
- type GateEventResult
- type GatePairSummary
- type GateProvider
- func (p *GateProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *GateProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *GateProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *GateProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type GateTicker
- type GateTickerResponse
- type GateTickerSubscriptionMsg
- type HuobiCandle
- type HuobiCandleTick
- type HuobiPairData
- type HuobiPairsSummary
- type HuobiProvider
- func (p *HuobiProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *HuobiProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *HuobiProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *HuobiProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type HuobiSubscriptionMsg
- type HuobiTick
- type HuobiTicker
- type KrakenCandle
- type KrakenEvent
- type KrakenEventSubscriptionStatus
- type KrakenEventSystemStatus
- type KrakenPairData
- type KrakenPairsSummary
- type KrakenProvider
- func (p *KrakenProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *KrakenProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *KrakenProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *KrakenProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type KrakenSubscriptionChannel
- type KrakenSubscriptionMsg
- type KrakenTicker
- type MessageType
- type MexcCandle
- type MexcCandleResponse
- type MexcCandleSubscription
- type MexcPairSummary
- type MexcProvider
- func (p *MexcProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *MexcProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *MexcProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *MexcProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type MexcTicker
- type MexcTickerResponse
- type MexcTickerSubscription
- type MockProvider
- func (p MockProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p MockProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p MockProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p MockProvider) SubscribeCurrencyPairs(pairs ...types.CurrencyPair) error
- type Name
- type OkxCandlePair
- type OkxCandleResponse
- type OkxID
- type OkxInstID
- type OkxPairsSummary
- type OkxProvider
- func (p *OkxProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p *OkxProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p *OkxProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p *OkxProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
- type OkxSubscriptionMsg
- type OkxSubscriptionTopic
- type OkxTickerPair
- type OkxTickerResponse
- type OsmosisCandleResponse
- type OsmosisPairData
- type OsmosisPairsSummary
- type OsmosisProvider
- func (p OsmosisProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p OsmosisProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
- func (p OsmosisProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
- func (p OsmosisProvider) SubscribeCurrencyPairs(pairs ...types.CurrencyPair) error
- type OsmosisTokenResponse
- type Provider
Constants ¶
const ( KrakenRestHost = "https://api.kraken.com" KrakenRestPath = "/0/public/AssetPairs" )
const ( MessageTypeCandle = MessageType("candle") MessageTypeTicker = MessageType("ticker") MessageTypeTrade = MessageType("trade") )
Variables ¶
This section is empty.
Functions ¶
func PastUnixTime ¶ added in v0.1.2
PastUnixTime returns a millisecond timestamp that represents the unix time minus t.
func SecondsToMilli ¶ added in v0.3.0
SecondsToMilli converts seconds to milliseconds for our unix timestamps.
func TelemetryFailure ¶ added in v1.0.0
func TelemetryFailure(n Name, mt MessageType)
TelemetryFailure gives an standard way to add `price_feeder_failure_provider{type="x", provider="x"}` metric.
Types ¶
type AggregatedProviderCandles ¶ added in v0.1.2
type AggregatedProviderCandles map[Name]map[string][]types.CandlePrice
AggregatedProviderCandles defines a type alias for a map of provider -> asset -> []types.CandlePrice
type AggregatedProviderPrices ¶ added in v0.1.2
type AggregatedProviderPrices map[Name]map[string]types.TickerPrice
AggregatedProviderPrices defines a type alias for a map of provider -> asset -> TickerPrice
type BinanceCandle ¶ added in v0.1.2
type BinanceCandle struct { Symbol string `json:"s"` // Symbol ex.: BTCUSDT Metadata BinanceCandleMetadata `json:"k"` // Metadata for candle }
BinanceCandle candle binance websocket channel "kline_1m" response.
type BinanceCandleMetadata ¶ added in v0.1.2
type BinanceCandleMetadata struct { Close string `json:"c"` // Price at close TimeStamp int64 `json:"T"` // Close time in unix epoch ex.: 1645756200000 Volume string `json:"v"` // Volume during period }
BinanceCandleMetadata candle metadata used to compute tvwap price.
type BinancePairSummary ¶ added in v0.1.3
type BinancePairSummary struct {
Symbol string `json:"symbol"`
}
BinancePairSummary defines the response structure for a Binance pair summary.
type BinanceProvider ¶
type BinanceProvider struct {
// contains filtered or unexported fields
}
BinanceProvider defines an Oracle provider implemented by the Binance public API.
REF: https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream REF: https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-streams
func NewBinanceProvider ¶
func NewBinanceProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*BinanceProvider, error)
func (*BinanceProvider) GetAvailablePairs ¶ added in v0.1.3
func (p *BinanceProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "UMEEUSDC" => {}].
func (*BinanceProvider) GetCandlePrices ¶ added in v0.1.2
func (p *BinanceProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns the candlePrices based on the provided pairs.
func (*BinanceProvider) GetTickerPrices ¶
func (p *BinanceProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the provided pairs.
func (*BinanceProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p *BinanceProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe all currency pairs into ticker and candle channels.
type BinanceSubscriptionMsg ¶ added in v0.1.1
type BinanceSubscriptionMsg struct { Method string `json:"method"` // SUBSCRIBE/UNSUBSCRIBE Params []string `json:"params"` // streams to subscribe ex.: usdtatom@ticker ID uint16 `json:"id"` // identify messages going back and forth }
BinanceSubscribeMsg Msg to subscribe all the tickers channels.
type BinanceTicker ¶ added in v0.1.1
type BinanceTicker struct { Symbol string `json:"s"` // Symbol ex.: BTCUSDT LastPrice string `json:"c"` // Last price ex.: 0.0025 Volume string `json:"v"` // Total traded base asset volume ex.: 1000 C uint64 `json:"C"` // Statistics close time }
BinanceTicker ticker price response. https://pkg.go.dev/encoding/json#Unmarshal Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match. C field which is Statistics close time is not used, but it avoids to implement specific UnmarshalJSON.
type BitgetCandle ¶ added in v1.0.0
type BitgetCandle struct { Arg BitgetSubscriptionArg // subscription event argument TimeStamp int64 // unix timestamp in milliseconds e.x. 1597026383085 Close string // Most recent price e.x. "8533.02" Volume string // volume e.x. "45247" }
type BitgetCandleResponse ¶ added in v1.0.0
type BitgetCandleResponse struct { Action string `json:"action"` // e.x. "snapshot" Arg BitgetSubscriptionArg `json:"arg"` // subscription event argument Data [][]string `json:"data"` // candle data in an array at data[0]. }
BitgetCandleResponse is the response structure for the bitget ticker message.
func (BitgetCandleResponse) ToBitgetCandle ¶ added in v1.0.0
func (bcr BitgetCandleResponse) ToBitgetCandle() (BitgetCandle, error)
ToBitgetCandle turns a BitgetCandleResponse into a more-readable BitgetCandle. The Close and Volume responses are at the [0][4] and [0][5] indexes respectively. Ref: https://bitgetlimited.github.io/apidoc/en/spot/#candlesticks-channel
type BitgetErrResponse ¶ added in v1.0.0
type BitgetErrResponse struct { Event string `json:"event"` // e.x. "error" Code uint64 `json:"code"` // e.x. 30003 for invalid op Msg string `json:"msg"` // e.x. "INVALID op" }
BitgetErrResponse is the structure for bitget subscription errors.
type BitgetPairData ¶ added in v1.0.0
type BitgetPairsSummary ¶ added in v1.0.0
type BitgetPairsSummary struct { RespCode string `json:"code"` Data []BitgetPairData `json:"data"` }
BitgetPairsSummary defines the response structure for a Bitget pairs summary.
type BitgetProvider ¶ added in v1.0.0
type BitgetProvider struct {
// contains filtered or unexported fields
}
BitgetProvider defines an Oracle provider implemented by the Bitget public API.
REF: https://bitgetlimited.github.io/apidoc/en/spot/#tickers-channel REF: https://bitgetlimited.github.io/apidoc/en/spot/#candlesticks-channel
func NewBitgetProvider ¶ added in v1.0.0
func NewBitgetProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*BitgetProvider, error)
NewBitgetProvider returns a new Bitget provider with the WS connection and msg handler.
func (*BitgetProvider) GetAvailablePairs ¶ added in v1.0.0
func (p *BitgetProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*BitgetProvider) GetCandlePrices ¶ added in v1.0.0
func (p *BitgetProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*BitgetProvider) GetTickerPrices ¶ added in v1.0.0
func (p *BitgetProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*BitgetProvider) SubscribeCurrencyPairs ¶ added in v1.0.0
func (p *BitgetProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe all currency pairs into ticker and candle channels.
type BitgetSubscriptionArg ¶ added in v1.0.0
type BitgetSubscriptionMsg ¶ added in v1.0.0
type BitgetSubscriptionMsg struct { Operation string `json:"op"` // Operation (e.x. "subscribe") Args []BitgetSubscriptionArg `json:"args"` // Arguments to subscribe to }
BitgetSubscriptionMsg Msg to subscribe all at once.
type BitgetSubscriptionResponse ¶ added in v1.0.0
type BitgetSubscriptionResponse struct { Event string `json:"event"` // e.x. "subscribe" Arg BitgetSubscriptionArg `json:"arg"` // subscription event argument }
BitgetSubscriptionResponse is the structure for bitget subscription confirmations.
type BitgetTicker ¶ added in v1.0.0
type BitgetTicker struct { Action string `json:"action"` // e.x. "snapshot" Arg BitgetSubscriptionArg `json:"arg"` // subscription event argument Data []BitgetTickerData `json:"data"` // ticker data }
BitgetTickerResponse is the structure for bitget ticker messages.
type BitgetTickerData ¶ added in v1.0.0
type CoinbaseErrResponse ¶ added in v0.1.4
type CoinbaseErrResponse struct { Type string `json:"type"` // should be "error" Reason string `json:"reason"` // ex.: "tickers" is not a valid channel }
CoinbaseErrResponse defines the response body for errors.
type CoinbasePairSummary ¶ added in v0.1.4
type CoinbasePairSummary struct { Base string `json:"base_currency"` Quote string `json:"quote_currency"` }
CoinbasePairSummary defines the response structure for a Coinbase pair summary.
type CoinbaseProvider ¶ added in v0.1.4
type CoinbaseProvider struct {
// contains filtered or unexported fields
}
CoinbaseProvider defines an Oracle provider implemented by the Coinbase public API.
REF: https://www.coinbase.io/docs/websocket/index.html
func NewCoinbaseProvider ¶ added in v0.1.4
func NewCoinbaseProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*CoinbaseProvider, error)
NewCoinbaseProvider creates a new CoinbaseProvider.
func (*CoinbaseProvider) GetAvailablePairs ¶ added in v0.1.4
func (p *CoinbaseProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*CoinbaseProvider) GetCandlePrices ¶ added in v0.1.4
func (p *CoinbaseProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns candles based off of the saved trades map. Candles need to be cut up into one-minute intervals.
func (*CoinbaseProvider) GetTickerPrices ¶ added in v0.1.4
func (p *CoinbaseProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*CoinbaseProvider) SubscribeCurrencyPairs ¶ added in v0.1.4
func (p *CoinbaseProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribes to websockets for all currency pairs.
type CoinbaseSubscriptionMsg ¶ added in v0.1.4
type CoinbaseSubscriptionMsg struct { Type string `json:"type"` // ex. "subscribe" ProductIDs []string `json:"product_ids"` // streams to subscribe ex.: ["BOT-USDT", ...] Channels []string `json:"channels"` // channels to subscribe to ex.: "ticker" }
CoinbaseSubscriptionMsg Msg to subscribe to all channels.
type CoinbaseTicker ¶ added in v0.1.4
type CoinbaseTicker struct { ProductID string `json:"product_id"` // ex.: ATOM-USDT Price string `json:"price"` // ex.: 523.0 Volume string `json:"volume_24h"` // 24-hour volume }
CoinbaseTicker defines the ticker info we'd like to save.
type CoinbaseTrade ¶ added in v0.1.4
type CoinbaseTrade struct { ProductID string // ex.: ATOM-USDT Time int64 // Time in unix epoch ex.: 164732388700 Size string // Size of the trade ex.: 10.41 Price string // ex.: 14.02 }
CoinbaseTrade defines the trade info we'd like to save.
type CoinbaseTradeResponse ¶ added in v0.1.4
type CoinbaseTradeResponse struct { Type string `json:"type"` // "last_match" or "match" ProductID string `json:"product_id"` // ex.: ATOM-USDT Time string `json:"time"` // Time in format 2006-01-02T15:04:05.000000Z Size string `json:"size"` // Size of the trade ex.: 10.41 Price string `json:"price"` // ex.: 14.02 }
CoinbaseMatchResponse defines the response body for coinbase trades.
type Endpoint ¶ added in v0.3.0
type Endpoint struct { // Name of the provider, ex. "binance" Name Name `toml:"name"` // Rest endpoint for the provider, ex. "https://api1.binance.com" Rest string `toml:"rest"` // Websocket endpoint for the provider, ex. "stream.binance.com:9443" Websocket string `toml:"websocket"` }
Endpoint defines an override setting in our config for the hardcoded rest and websocket api endpoints.
type FTXCandleResponse ¶ added in v0.3.0
FTXCandleResponse is the response object used for candle information.
type FTXMarkets ¶ added in v0.3.0
type FTXMarketsResponse ¶ added in v0.3.0
type FTXMarketsResponse struct { Success bool `json:"success"` Markets []FTXMarkets `json:"result"` }
FTXMarketsResponse is the response object used for available exchange rates and tickers.
type FTXProvider ¶ added in v0.3.0
type FTXProvider struct {
// contains filtered or unexported fields
}
FTXProvider defines an Oracle provider implemented by the FTX public API.
func NewFTXProvider ¶ added in v0.3.0
func NewFTXProvider( ctx context.Context, logger zerolog.Logger, endpoint Endpoint, pairs ...types.CurrencyPair, ) *FTXProvider
func (*FTXProvider) GetAvailablePairs ¶ added in v0.3.0
func (p *FTXProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to susbscribe.
func (*FTXProvider) GetCandlePrices ¶ added in v0.3.0
func (p *FTXProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns the cached candlePrices based on provided pairs.
func (*FTXProvider) GetTickerPrices ¶ added in v0.3.0
func (p *FTXProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the provided pairs.
func (*FTXProvider) SubscribeCurrencyPairs ¶ added in v0.3.0
func (p *FTXProvider) SubscribeCurrencyPairs(pairs ...types.CurrencyPair) error
SubscribeCurrencyPairs performs a no-op since ftx does not use websockets
type GateCandle ¶ added in v0.1.2
type GateCandle struct { Close string // Closing price TimeStamp int64 // Unix timestamp Volume string // Total candle volume Symbol string // Total symbol }
func (*GateCandle) UnmarshalParams ¶ added in v0.1.2
func (candle *GateCandle) UnmarshalParams(params [][]interface{}) error
UnmarshalParams is a helper function which unmarshals the 2d slice of interfaces from a GateCandleResponse into the GateCandle.
type GateCandleResponse ¶ added in v0.1.2
type GateCandleResponse struct { Method string `json:"method"` Params [][]interface{} `json:"params"` }
GateTickerResponse defines the response body for gate tickers. The Params response is a 2D slice of multiple candles and their data.
type GateCandleSubscriptionMsg ¶ added in v0.1.2
type GateCandleSubscriptionMsg struct { Method string `json:"method"` // ticker.subscribe Params []interface{} `json:"params"` // streams to subscribe ex.: ["BOT_USDT": 1800] ID uint16 `json:"id"` // identify messages going back and forth }
GateCandleSubscriptionMsg Msg to subscribe to a candle channel.
type GateEvent ¶ added in v0.1.2
type GateEvent struct { ID int `json:"id"` // subscription id, ex.: 123 Result GateEventResult `json:"result"` // event result body }
GateEvent defines the response body for gate subscription statuses.
type GateEventResult ¶ added in v0.1.2
type GateEventResult struct {
Status string `json:"status"` // ex. "successful"
}
GateEventResult defines the Result body for the GateEvent response.
type GatePairSummary ¶ added in v0.1.3
GatePairSummary defines the response structure for a Gate pair summary.
type GateProvider ¶ added in v0.1.2
type GateProvider struct {
// contains filtered or unexported fields
}
GateProvider defines an Oracle provider implemented by the Gate public API.
REF: https://www.gate.io/docs/websocket/index.html
func NewGateProvider ¶ added in v0.1.2
func NewGateProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*GateProvider, error)
NewGateProvider creates a new GateProvider.
func (*GateProvider) GetAvailablePairs ¶ added in v0.1.3
func (p *GateProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*GateProvider) GetCandlePrices ¶ added in v0.1.2
func (p *GateProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns the candlePrices based on the saved map
func (*GateProvider) GetTickerPrices ¶ added in v0.1.2
func (p *GateProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*GateProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p *GateProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe to ticker and candle channels for all pairs.
type GateTicker ¶ added in v0.1.2
type GateTickerResponse ¶ added in v0.1.2
type GateTickerResponse struct { Method string `json:"method"` Params []interface{} `json:"params"` }
GateTickerResponse defines the response body for gate tickers.
type GateTickerSubscriptionMsg ¶ added in v0.1.2
type GateTickerSubscriptionMsg struct { Method string `json:"method"` // ticker.subscribe Params []string `json:"params"` // streams to subscribe ex.: BOT_USDT ID uint16 `json:"id"` // identify messages going back and forth }
GateTickerSubscriptionMsg Msg to subscribe all the tickers channels.
type HuobiCandle ¶ added in v0.1.2
type HuobiCandle struct { CH string `json:"ch"` // Channel name. Format:market.$symbol.kline.$period Tick HuobiCandleTick `json:"tick"` }
HuobiCandle defines the response type for the channel and the tick object for a given ticker/symbol.
type HuobiCandleTick ¶ added in v0.1.2
type HuobiCandleTick struct { Close float64 `json:"close"` // Closing price during this period TimeStamp int64 `json:"id"` // TimeStamp for this as an ID Volume float64 `json:"vol"` // Volume during this period }
HuobiCandleTick defines the response type for the candle.
type HuobiPairData ¶ added in v0.1.3
type HuobiPairData struct {
Symbol string `json:"symbol"`
}
HuobiPairData defines the data response structure for an Huobi pair.
type HuobiPairsSummary ¶ added in v0.1.3
type HuobiPairsSummary struct {
Data []HuobiPairData `json:"data"`
}
HuobiPairsSummary defines the response structure for an Huobi pairs summary.
type HuobiProvider ¶
type HuobiProvider struct {
// contains filtered or unexported fields
}
HuobiProvider defines an Oracle provider implemented by the Huobi public API.
REF: https://huobiapi.github.io/docs/spot/v1/en/#market-ticker REF: https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles
func NewHuobiProvider ¶
func NewHuobiProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*HuobiProvider, error)
NewHuobiProvider returns a new Huobi provider with the WS connection and msg handler.
func (*HuobiProvider) GetAvailablePairs ¶ added in v0.1.3
func (p *HuobiProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*HuobiProvider) GetCandlePrices ¶ added in v0.1.2
func (p *HuobiProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*HuobiProvider) GetTickerPrices ¶
func (p *HuobiProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*HuobiProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p *HuobiProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe all currency pairs into ticker and candle channels.
type HuobiSubscriptionMsg ¶ added in v0.1.1
type HuobiSubscriptionMsg struct {
Sub string `json:"sub"` // channel to subscribe market.$symbol.ticker
}
HuobiSubscriptionMsg Msg to subscribe to one ticker channel at time.
type HuobiTick ¶ added in v0.1.1
type HuobiTick struct { Vol float64 `json:"vol"` // Accumulated trading value of last 24 hours LastPrice float64 `json:"lastPrice"` // Last traded price }
HuobiTick defines the response type for the last 24h market summary and the last traded price for a given ticker/symbol.
type HuobiTicker ¶ added in v0.1.1
type HuobiTicker struct { CH string `json:"ch"` // Channel name. Format:market.$symbol.ticker Tick HuobiTick `json:"tick"` }
HuobiTicker defines the response type for the channel and the tick object for a given ticker/symbol.
type KrakenCandle ¶ added in v0.1.2
type KrakenCandle struct { Close string // Close price during this period TimeStamp int64 // Linux epoch timestamp Volume string // Volume during this period Symbol string // Symbol for this candle }
KrakenCandle candle response from Kraken candle channel. REF: https://docs.kraken.com/websockets/#message-ohlc
func (*KrakenCandle) UnmarshalJSON ¶ added in v0.1.2
func (candle *KrakenCandle) UnmarshalJSON(buf []byte) error
type KrakenEvent ¶ added in v0.1.1
type KrakenEvent struct {
Event string `json:"event"` // events from kraken ex.: systemStatus | subscriptionStatus
}
KrakenEvent wraps the possible events from the provider.
type KrakenEventSubscriptionStatus ¶ added in v0.1.1
type KrakenEventSubscriptionStatus struct { Status string `json:"status"` // subscribed|unsubscribed|error Pair string `json:"pair"` // Pair symbol base/quote ex.: "XBT/USD" ErrorMessage string `json:"errorMessage"` // error description }
KrakenEventSubscriptionStatus parse the subscriptionStatus event message.
type KrakenEventSystemStatus ¶ added in v0.1.1
type KrakenEventSystemStatus struct {
Status string `json:"status"` // online|maintenance|cancel_only|limit_only|post_only
}
KrakenEventSystemStatus parse the systemStatus event message.
type KrakenPairData ¶ added in v0.1.3
type KrakenPairData struct {
WsName string `json:"wsname"`
}
KrakenPairData defines the data response structure for an Kraken pair.
type KrakenPairsSummary ¶ added in v0.1.3
type KrakenPairsSummary struct {
Result map[string]KrakenPairData `json:"result"`
}
KrakenPairsSummary defines the response structure for an Kraken pairs summary.
type KrakenProvider ¶
type KrakenProvider struct {
// contains filtered or unexported fields
}
KrakenProvider defines an Oracle provider implemented by the Kraken public API.
REF: https://docs.kraken.com/websockets/#overview
func NewKrakenProvider ¶
func NewKrakenProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*KrakenProvider, error)
NewKrakenProvider returns a new Kraken provider with the WS connection and msg handler.
func (*KrakenProvider) GetAvailablePairs ¶ added in v0.1.3
func (p *KrakenProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*KrakenProvider) GetCandlePrices ¶ added in v0.1.2
func (p *KrakenProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns the candlePrices based on the saved map.
func (*KrakenProvider) GetTickerPrices ¶
func (p *KrakenProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*KrakenProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p *KrakenProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe all currency pairs into ticker and candle channels.
type KrakenSubscriptionChannel ¶ added in v0.1.1
type KrakenSubscriptionChannel struct {
Name string `json:"name"` // channel to be subscribed ex.: ticker
}
KrakenSubscriptionChannel Msg with the channel name to be subscribed.
type KrakenSubscriptionMsg ¶ added in v0.1.1
type KrakenSubscriptionMsg struct { Event string `json:"event"` // subscribe/unsubscribe Pair []string `json:"pair"` // Array of currency pairs ex.: "BTC/USDT", Subscription KrakenSubscriptionChannel `json:"subscription"` // subscription object }
KrakenSubscriptionMsg Msg to subscribe to all the pairs at once.
type KrakenTicker ¶ added in v0.1.1
type KrakenTicker struct { C []string `json:"c"` // Close with Price in the first position V []string `json:"v"` // Volume with the value over last 24 hours in the second position }
KrakenTicker ticker price response from Kraken ticker channel. REF: https://docs.kraken.com/websockets/#message-ticker
type MessageType ¶ added in v1.0.0
type MessageType string
func (MessageType) String ¶ added in v1.0.0
func (mt MessageType) String() string
String cast provider MessageType to string.
type MexcCandle ¶ added in v1.0.0
type MexcCandleResponse ¶ added in v1.0.0
type MexcCandleResponse struct { Symbol string `json:"symbol"` // Symbol ex.: ATOM_USDT Metadata MexcCandle `json:"data"` // Metadata for candle }
MexcCandle is the candle websocket response object.
type MexcCandleSubscription ¶ added in v1.0.0
type MexcCandleSubscription struct { OP string `json:"op"` // kline Symbol string `json:"symbol"` // streams to subscribe ex.: atom_usdt Interval string `json:"interval"` // Min1、Min5、Min15、Min30 }
MexcCandleSubscription Msg to subscribe all the candle channels.
type MexcPairSummary ¶ added in v1.0.0
type MexcPairSummary struct {
Symbol string `json:"symbol"`
}
MexcPairSummary defines the response structure for a Mexc pair summary.
type MexcProvider ¶ added in v1.0.0
type MexcProvider struct {
// contains filtered or unexported fields
}
MexcProvider defines an Oracle provider implemented by the Mexc public API.
REF: https://mxcdevelop.github.io/apidocs/spot_v2_en/#ticker-information REF: https://mxcdevelop.github.io/apidocs/spot_v2_en/#k-line REF: https://mxcdevelop.github.io/apidocs/spot_v2_en/#overview
func NewMexcProvider ¶ added in v1.0.0
func NewMexcProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*MexcProvider, error)
func (*MexcProvider) GetAvailablePairs ¶ added in v1.0.0
func (p *MexcProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "UMEEUSDC" => {}].
func (*MexcProvider) GetCandlePrices ¶ added in v1.0.0
func (p *MexcProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns the candlePrices based on the provided pairs.
func (*MexcProvider) GetTickerPrices ¶ added in v1.0.0
func (p *MexcProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the provided pairs.
func (*MexcProvider) SubscribeCurrencyPairs ¶ added in v1.0.0
func (p *MexcProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe all currency pairs into ticker and candle channels.
type MexcTicker ¶ added in v1.0.0
type MexcTickerResponse ¶ added in v1.0.0
type MexcTickerResponse struct {
Symbol map[string]MexcTicker `json:"data"` // e.x. ATOM_USDT
}
MexcTickerResponse is the ticker price response object.
type MexcTickerSubscription ¶ added in v1.0.0
type MexcTickerSubscription struct {
OP string `json:"op"` // kline
}
MexcTickerSubscription Msg to subscribe all the ticker channels.
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider defines a mocked exchange rate provider using a published Google sheets document to fetch mocked/fake exchange rates.
func NewMockProvider ¶
func NewMockProvider() *MockProvider
func (MockProvider) GetAvailablePairs ¶ added in v0.1.3
func (p MockProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to susbscribe.
func (MockProvider) GetCandlePrices ¶ added in v0.1.2
func (p MockProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
func (MockProvider) GetTickerPrices ¶
func (p MockProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
func (MockProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p MockProvider) SubscribeCurrencyPairs(pairs ...types.CurrencyPair) error
SubscribeCurrencyPairs performs a no-op since mock does not use websockets
type Name ¶ added in v0.3.0
type Name string
Name name of an oracle provider. Usually it is an exchange but this can be any provider name that can give token prices examples.: "binance", "osmosis", "kraken".
const ( ProviderKraken Name = "kraken" ProviderBinance Name = "binance" ProviderOsmosis Name = "osmosis" ProviderHuobi Name = "huobi" ProviderOkx Name = "okx" ProviderGate Name = "gate" ProviderCoinbase Name = "coinbase" ProviderFTX Name = "ftx" ProviderBitget Name = "bitget" ProviderMexc Name = "mexc" ProviderMock Name = "mock" )
type OkxCandlePair ¶ added in v0.1.2
type OkxCandlePair struct { Close string `json:"c"` // Close price for this time period TimeStamp int64 `json:"ts"` // Linux epoch timestamp Volume string `json:"vol"` // Volume for this time period InstID string `json:"instId"` // Instrument ID ex.: BTC-USDT }
OkxCandlePair defines a candle for Okx.
type OkxCandleResponse ¶ added in v0.1.2
OkxCandleResponse defines the response structure of a Okx candle request.
type OkxID ¶ added in v0.1.2
OkxInst defines the structure containing ID information for the OkxResponses.
type OkxInstID ¶ added in v0.3.0
type OkxInstID struct {
InstID string `json:"instId"` // Instrument ID ex.: BTC-USDT
}
OkxInstId defines the id Symbol of an pair.
type OkxPairsSummary ¶ added in v0.1.3
type OkxPairsSummary struct {
Data []OkxInstID `json:"data"`
}
OkxPairsSummary defines the response structure for an Okx pairs summary.
type OkxProvider ¶ added in v0.1.1
type OkxProvider struct {
// contains filtered or unexported fields
}
OkxProvider defines an Oracle provider implemented by the Okx public API.
REF: https://www.okx.com/docs-v5/en/#websocket-api-public-channel-tickers-channel
func NewOkxProvider ¶ added in v0.1.1
func NewOkxProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*OkxProvider, error)
NewOkxProvider creates a new OkxProvider.
func (*OkxProvider) GetAvailablePairs ¶ added in v0.1.3
func (p *OkxProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to susbscribe.
func (*OkxProvider) GetCandlePrices ¶ added in v0.1.2
func (p *OkxProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
GetCandlePrices returns the candlePrices based on the saved map
func (*OkxProvider) GetTickerPrices ¶ added in v0.1.1
func (p *OkxProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
GetTickerPrices returns the tickerPrices based on the saved map.
func (*OkxProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p *OkxProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
SubscribeCurrencyPairs subscribe all currency pairs into ticker and candle channels.
type OkxSubscriptionMsg ¶ added in v0.1.1
type OkxSubscriptionMsg struct { Op string `json:"op"` // Operation ex.: subscribe Args []OkxSubscriptionTopic `json:"args"` }
OkxSubscriptionMsg Message to subscribe/unsubscribe with N Topics.
type OkxSubscriptionTopic ¶ added in v0.1.1
type OkxSubscriptionTopic struct { Channel string `json:"channel"` // Channel name ex.: tickers InstID string `json:"instId"` // Instrument ID ex.: BTC-USDT }
OkxSubscriptionTopic Topic with the ticker to be subscribed/unsubscribed.
type OkxTickerPair ¶ added in v0.1.1
type OkxTickerPair struct { OkxInstID Last string `json:"last"` // Last traded price ex.: 43508.9 Vol24h string `json:"vol24h"` // 24h trading volume ex.: 11159.87127845 }
OkxTickerPair defines a ticker pair of Okx.
type OkxTickerResponse ¶ added in v0.1.1
type OkxTickerResponse struct { Data []OkxTickerPair `json:"data"` ID OkxID `json:"arg"` }
OkxTickerResponse defines the response structure of a Okx ticker request.
type OsmosisCandleResponse ¶ added in v0.1.2
type OsmosisCandleResponse struct { Time int64 `json:"time"` Close float64 `json:"close"` Volume float64 `json:"volume"` }
OsmosisCandleResponse defines the response structure for an Osmosis candle request.
type OsmosisPairData ¶ added in v0.1.3
OsmosisPairData defines the data response structure for an Osmosis pair.
type OsmosisPairsSummary ¶ added in v0.1.3
type OsmosisPairsSummary struct {
Data []OsmosisPairData `json:"data"`
}
OsmosisPairsSummary defines the response structure for an Osmosis pairs summary.
type OsmosisProvider ¶
type OsmosisProvider struct {
// contains filtered or unexported fields
}
OsmosisProvider defines an Oracle provider implemented by the Osmosis public API.
REF: https://api-osmosis.imperator.co/swagger/
func NewOsmosisProvider ¶
func NewOsmosisProvider(endpoint Endpoint) *OsmosisProvider
func (OsmosisProvider) GetAvailablePairs ¶ added in v0.1.3
func (p OsmosisProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to susbscribe.
func (OsmosisProvider) GetCandlePrices ¶ added in v0.1.2
func (p OsmosisProvider) GetCandlePrices(pairs ...types.CurrencyPair) (map[string][]types.CandlePrice, error)
func (OsmosisProvider) GetTickerPrices ¶
func (p OsmosisProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[string]types.TickerPrice, error)
func (OsmosisProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p OsmosisProvider) SubscribeCurrencyPairs(pairs ...types.CurrencyPair) error
SubscribeCurrencyPairs performs a no-op since osmosis does not use websockets
type OsmosisTokenResponse ¶
type OsmosisTokenResponse struct { Price float64 `json:"price"` Symbol string `json:"symbol"` Volume float64 `json:"volume_24h"` }
OsmosisTokenResponse defines the response structure for an Osmosis token request.
type Provider ¶
type Provider interface { // GetTickerPrices returns the tickerPrices based on the provided pairs. GetTickerPrices(...types.CurrencyPair) (map[string]types.TickerPrice, error) // GetCandlePrices returns the candlePrices based on the provided pairs. GetCandlePrices(...types.CurrencyPair) (map[string][]types.CandlePrice, error) // GetAvailablePairs return all available pairs symbol to susbscribe. GetAvailablePairs() (map[string]struct{}, error) // SubscribeCurrencyPairs subscribe to ticker and candle channels for all pairs. SubscribeCurrencyPairs(...types.CurrencyPair) error }
Provider defines an interface an exchange price provider must implement.