Documentation ¶
Index ¶
- Constants
- Variables
- func ConfirmPairAvailability(p Provider, providerName types.ProviderName, logger zerolog.Logger, ...) ([]types.CurrencyPair, error)
- func PastUnixTime(t time.Duration) int64
- func SecondsToMilli(t int64) int64
- func TelemetryFailure(n types.ProviderName, mt MessageType)
- type AstroportAssetResponse
- type AstroportProvider
- func (p *AstroportProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *AstroportProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *AstroportProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *AstroportProvider) StartConnections()
- func (p *AstroportProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type AstroportTickerPairs
- type AstroportTickersResponse
- type BinanceCandle
- type BinanceCandleMetadata
- type BinancePairSummary
- type BinanceProvider
- func (p *BinanceProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *BinanceProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *BinanceProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *BinanceProvider) StartConnections()
- func (p *BinanceProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type BinanceSubscriptionMsg
- type BinanceSubscriptionResp
- type BinanceTicker
- type BitgetCandle
- type BitgetCandleResponse
- type BitgetErrResponse
- type BitgetPairData
- type BitgetPairsSummary
- type BitgetProvider
- func (p *BitgetProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *BitgetProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *BitgetProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *BitgetProvider) StartConnections()
- func (p *BitgetProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- 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 (ps *CoinbaseProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *CoinbaseProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *CoinbaseProvider) StartConnections()
- func (p *CoinbaseProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type CoinbaseSubscriptionMsg
- type CoinbaseTicker
- type CoinbaseTrade
- type CoinbaseTradeResponse
- type CrescentCandle
- type CrescentPairData
- type CrescentPairsSummary
- type CrescentProvider
- func (p *CrescentProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *CrescentProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *CrescentProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *CrescentProvider) StartConnections()
- func (p *CrescentProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type CrescentTicker
- type CryptoCandle
- type CryptoCandleResponse
- type CryptoCandleResult
- type CryptoHeartbeatRequest
- type CryptoHeartbeatResponse
- type CryptoInstruments
- type CryptoPairsSummary
- type CryptoProvider
- func (p *CryptoProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *CryptoProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *CryptoProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *CryptoProvider) StartConnections()
- func (p *CryptoProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type CryptoSubscriptionMsg
- type CryptoSubscriptionParams
- type CryptoTicker
- type CryptoTickerResponse
- type CryptoTickerResult
- type Endpoint
- type GateCandle
- type GateCandleResponse
- type GateCandleSubscriptionMsg
- type GateEvent
- type GateEventResult
- type GatePairSummary
- type GateProvider
- func (p *GateProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *GateProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *GateProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *GateProvider) StartConnections()
- func (p *GateProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- 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 (ps *HuobiProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *HuobiProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *HuobiProvider) StartConnections()
- func (p *HuobiProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type HuobiSubscriptionMsg
- type HuobiSubscriptionResp
- type HuobiTick
- type HuobiTicker
- type KrakenCandle
- type KrakenEvent
- type KrakenEventSubscriptionStatus
- type KrakenPairData
- type KrakenPairsSummary
- type KrakenProvider
- func (p *KrakenProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *KrakenProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *KrakenProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *KrakenProvider) StartConnections()
- func (p *KrakenProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type KrakenSubscriptionChannel
- type KrakenSubscriptionMsg
- type KrakenTicker
- type KujiraCandle
- type KujiraPairData
- type KujiraPairsSummary
- type KujiraProvider
- func (p *KujiraProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *KujiraProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *KujiraProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *KujiraProvider) StartConnections()
- func (p *KujiraProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type KujiraTicker
- type MessageHandler
- type MessageType
- type MexcCandle
- type MexcCandleData
- type MexcCandleResponse
- type MexcCandleSubscription
- type MexcPairData
- type MexcPairSummary
- type MexcProvider
- func (p *MexcProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *MexcProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *MexcProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *MexcProvider) StartConnections()
- func (p *MexcProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type MexcTicker
- type MexcTickerResponse
- type MexcTickerSubscription
- type MockProvider
- func (p MockProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (p MockProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (p MockProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *MockProvider) StartConnections()
- func (p MockProvider) SubscribeCurrencyPairs(...types.CurrencyPair)
- type OkxCandlePair
- type OkxCandleResponse
- type OkxID
- type OkxInstID
- type OkxPairsSummary
- type OkxProvider
- func (p *OkxProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *OkxProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *OkxProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *OkxProvider) StartConnections()
- func (p *OkxProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type OkxSubscriptionMsg
- type OkxSubscriptionTopic
- type OkxTickerPair
- type OkxTickerResponse
- type OsmosisCandle
- type OsmosisPairData
- type OsmosisPairsSummary
- type OsmosisProvider
- func (p *OsmosisProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *OsmosisProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *OsmosisProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *OsmosisProvider) StartConnections()
- func (p *OsmosisProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type OsmosisTicker
- type PolygonAggregatesResponse
- type PolygonProvider
- func (p *PolygonProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *PolygonProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *PolygonProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *PolygonProvider) StartConnections()
- func (p *PolygonProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type PolygonStatusResponse
- type PolygonSubscriptionMsg
- type PolygonTicker
- type PolygonTickersResponse
- type Provider
- type UniswapCandle
- type UniswapPairData
- type UniswapPairsSummary
- type UniswapProvider
- func (p *UniswapProvider) GetAvailablePairs() (map[string]struct{}, error)
- func (ps *UniswapProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
- func (ps *UniswapProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
- func (p *UniswapProvider) StartConnections()
- func (p *UniswapProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
- type UniswapTicker
- type WebsocketConnection
- type WebsocketController
Constants ¶
const ( KrakenRestHost = "https://api.kraken.com" KrakenRestPath = "/0/public/AssetPairs" )
const ( ProviderKraken types.ProviderName = "kraken" ProviderBinance types.ProviderName = "binance" ProviderBinanceUS types.ProviderName = "binanceus" ProviderOsmosis types.ProviderName = "osmosis" ProviderHuobi types.ProviderName = "huobi" ProviderOkx types.ProviderName = "okx" ProviderGate types.ProviderName = "gate" ProviderCoinbase types.ProviderName = "coinbase" ProviderBitget types.ProviderName = "bitget" ProviderMexc types.ProviderName = "mexc" ProviderCrypto types.ProviderName = "crypto" ProviderPolygon types.ProviderName = "polygon" ProviderCrescent types.ProviderName = "crescent" ProviderEthUniswap types.ProviderName = "eth-uniswap" ProviderKujira types.ProviderName = "kujira" ProviderMock types.ProviderName = "mock" )
const ( MessageTypeCandle = MessageType("candle") MessageTypeTicker = MessageType("ticker") MessageTypeTrade = MessageType("trade") )
const (
ProviderAstroport = "astroport"
)
Variables ¶
var ( OJOUSDT = types.CurrencyPair{Base: "OJO", Quote: "USDT"} BTCUSDT = types.CurrencyPair{Base: "BTC", Quote: "USDT"} ATOMUSDT = types.CurrencyPair{Base: "ATOM", Quote: "USDT"} LUNAUSDT = types.CurrencyPair{Base: "LUNA", Quote: "USDT"} ATOMUSDC = types.CurrencyPair{Base: "ATOM", Quote: "USDC"} OSMOATOM = types.CurrencyPair{Base: "OSMO", Quote: "ATOM"} BCREATOM = types.CurrencyPair{Base: "BCRE", Quote: "ATOM"} KUJIATOM = types.CurrencyPair{Base: "KUJI", Quote: "ATOM"} EURUSD = types.CurrencyPair{Base: "EUR", Quote: "USD"} JPYUSD = types.CurrencyPair{Base: "JPY", Quote: "USD"} )
Functions ¶
func ConfirmPairAvailability ¶ added in v0.1.1
func ConfirmPairAvailability( p Provider, providerName types.ProviderName, logger zerolog.Logger, cps ...types.CurrencyPair, ) ([]types.CurrencyPair, error)
ConfirmPairAvailability takes a list of pairs that are meant to be subscribed to, and uses the given provider's GetAvailablePairs method to check that the given pairs can be subscribed to. It will return an updated list of pairs that can be subsribed to, and send a warning log about any pairs passed in that cannot be subsribed to.
func PastUnixTime ¶
PastUnixTime returns a millisecond timestamp that represents the unix time minus t.
func SecondsToMilli ¶
SecondsToMilli converts seconds to milliseconds for our unix timestamps.
func TelemetryFailure ¶
func TelemetryFailure(n types.ProviderName, mt MessageType)
TelemetryFailure gives an standard way to add `price_feeder_failure_provider{type="x", provider="x"}` metric.
Types ¶
type AstroportAssetResponse ¶ added in v0.1.9
type AstroportAssetResponse struct { BaseID string `json:"base_id"` BaseName string `json:"base_name"` BaseSymbol string `json:"base_symbol"` QuoteID string `json:"quote_id"` QuoteName string `json:"quote_name"` QuoteSymbol interface{} `json:"quote_symbol"` LastPrice float64 `json:"last_price"` BaseVolume float64 `json:"base_volume"` QuoteVolume float64 `json:"quote_volume"` USDVolume float64 `json:"USD_volume"` }
AstroportAssetResponse is the response from the Astroport assets endpoint.
type AstroportProvider ¶ added in v0.1.9
type AstroportProvider struct {
// contains filtered or unexported fields
}
func NewAstroportProvider ¶ added in v0.1.9
func NewAstroportProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*AstroportProvider, error)
NewAstroportProvider returns a new AstroportProvider. It also starts a go routine to poll for new data.
func (*AstroportProvider) GetAvailablePairs ¶ added in v0.1.9
func (p *AstroportProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pair symbols.
func (*AstroportProvider) GetCandlePrices ¶ added in v0.1.9
func (ps *AstroportProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*AstroportProvider) GetTickerPrices ¶ added in v0.1.9
func (ps *AstroportProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*AstroportProvider) StartConnections ¶ added in v0.1.9
func (p *AstroportProvider) StartConnections()
StartConnections begins the polling process for the astroport provider.
func (*AstroportProvider) SubscribeCurrencyPairs ¶ added in v0.1.9
func (p *AstroportProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array.
type AstroportTickerPairs ¶ added in v0.1.9
type AstroportTickerPairs struct {
// contains filtered or unexported fields
}
AstroportTickerPairs is a struct to hold the AstroportTickersResponse and the corresponding pair. It satisfies the TickerPrice interface.
type AstroportTickersResponse ¶ added in v0.1.9
type AstroportTickersResponse struct { TickerID string `json:"ticker_id"` BaseCurrency string `json:"base_currency"` TargetCurrency string `json:"target_currency"` LastPrice float64 `json:"last_price"` LiquidityInUSD float64 `json:"liquidity_in_usd"` BaseVolume float64 `json:"base_volume"` TargetVolume float64 `json:"target_volume"` PoolID string `json:"pool_id"` }
AstroportTickersResponse is the response from the Astroport tickers endpoint.
type BinanceCandle ¶
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 ¶
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 ¶
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, binanceUS bool, pairs ...types.CurrencyPair, ) (*BinanceProvider, error)
func (*BinanceProvider) GetAvailablePairs ¶
func (p *BinanceProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*BinanceProvider) GetCandlePrices ¶
func (ps *BinanceProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*BinanceProvider) GetTickerPrices ¶
func (ps *BinanceProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*BinanceProvider) StartConnections ¶ added in v0.1.2
func (p *BinanceProvider) StartConnections()
func (*BinanceProvider) SubscribeCurrencyPairs ¶
func (p *BinanceProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type BinanceSubscriptionMsg ¶
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 BinanceSubscriptionResp ¶
BinanceSubscriptionResp the response structure for a binance subscription response
type BinanceTicker ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
type BitgetPairsSummary ¶
type BitgetPairsSummary struct { RespCode string `json:"code"` Data []BitgetPairData `json:"data"` }
BitgetPairsSummary defines the response structure for a Bitget pairs summary.
type BitgetProvider ¶
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 ¶
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 ¶
func (p *BitgetProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*BitgetProvider) GetCandlePrices ¶
func (ps *BitgetProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*BitgetProvider) GetTickerPrices ¶
func (ps *BitgetProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*BitgetProvider) StartConnections ¶ added in v0.1.2
func (p *BitgetProvider) StartConnections()
func (*BitgetProvider) SubscribeCurrencyPairs ¶
func (p *BitgetProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type BitgetSubscriptionArg ¶
type BitgetSubscriptionMsg ¶
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 ¶
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 ¶
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 ¶
type CoinbaseErrResponse ¶
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 ¶
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 ¶
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 ¶
func NewCoinbaseProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*CoinbaseProvider, error)
NewCoinbaseProvider creates a new CoinbaseProvider.
func (*CoinbaseProvider) GetAvailablePairs ¶
func (p *CoinbaseProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*CoinbaseProvider) GetCandlePrices ¶
func (ps *CoinbaseProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*CoinbaseProvider) GetTickerPrices ¶
func (ps *CoinbaseProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*CoinbaseProvider) StartConnections ¶ added in v0.1.2
func (p *CoinbaseProvider) StartConnections()
func (*CoinbaseProvider) SubscribeCurrencyPairs ¶
func (p *CoinbaseProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type CoinbaseSubscriptionMsg ¶
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 ¶
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 ¶
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 ¶
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 CrescentCandle ¶ added in v0.1.2
type CrescentPairData ¶ added in v0.1.2
CrescentPairData defines the data response structure for an Crescent pair.
type CrescentPairsSummary ¶ added in v0.1.2
type CrescentPairsSummary struct {
Data []CrescentPairData `json:"data"`
}
CrescentPairsSummary defines the response structure for an Crescent pairs summary.
type CrescentProvider ¶ added in v0.1.2
type CrescentProvider struct {
// contains filtered or unexported fields
}
CrescentProvider defines an Oracle provider implemented by OJO's Crescent API.
func NewCrescentProvider ¶ added in v0.1.2
func NewCrescentProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*CrescentProvider, error)
func (*CrescentProvider) GetAvailablePairs ¶ added in v0.1.2
func (p *CrescentProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*CrescentProvider) GetCandlePrices ¶ added in v0.1.2
func (ps *CrescentProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*CrescentProvider) GetTickerPrices ¶ added in v0.1.2
func (ps *CrescentProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*CrescentProvider) StartConnections ¶ added in v0.1.2
func (p *CrescentProvider) StartConnections()
func (*CrescentProvider) SubscribeCurrencyPairs ¶ added in v0.1.2
func (p *CrescentProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type CrescentTicker ¶ added in v0.1.2
type CryptoCandle ¶
type CryptoCandleResponse ¶
type CryptoCandleResponse struct {
Result CryptoCandleResult `json:"result"`
}
type CryptoCandleResult ¶
type CryptoCandleResult struct { InstrumentName string `json:"instrument_name"` // ex.: ATOM_USDT Channel string `json:"channel"` // ex.: candlestick Data []CryptoCandle `json:"data"` // candlestick data }
type CryptoHeartbeatRequest ¶
type CryptoHeartbeatResponse ¶
type CryptoInstruments ¶
type CryptoInstruments struct {
Data []CryptoTicker `json:"data"`
}
type CryptoPairsSummary ¶
type CryptoPairsSummary struct {
Result CryptoInstruments `json:"result"`
}
type CryptoProvider ¶
type CryptoProvider struct {
// contains filtered or unexported fields
}
CryptoProvider defines an Oracle provider implemented by the Crypto.com public API.
REF: https://exchange-docs.crypto.com/spot/index.html#introduction
func NewCryptoProvider ¶
func NewCryptoProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*CryptoProvider, error)
func (*CryptoProvider) GetAvailablePairs ¶
func (p *CryptoProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*CryptoProvider) GetCandlePrices ¶
func (ps *CryptoProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*CryptoProvider) GetTickerPrices ¶
func (ps *CryptoProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*CryptoProvider) StartConnections ¶ added in v0.1.2
func (p *CryptoProvider) StartConnections()
func (*CryptoProvider) SubscribeCurrencyPairs ¶
func (p *CryptoProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type CryptoSubscriptionMsg ¶
type CryptoSubscriptionMsg struct { ID int64 `json:"id"` Method string `json:"method"` // subscribe, unsubscribe Params CryptoSubscriptionParams `json:"params"` Nonce int64 `json:"nonce"` // Current timestamp (milliseconds since the Unix epoch) }
type CryptoSubscriptionParams ¶
type CryptoSubscriptionParams struct {
Channels []string `json:"channels"` // Channels to be subscribed ex. ticker.ATOM_USDT
}
type CryptoTicker ¶
type CryptoTickerResponse ¶
type CryptoTickerResponse struct {
Result CryptoTickerResult `json:"result"`
}
type CryptoTickerResult ¶
type CryptoTickerResult struct { InstrumentName string `json:"instrument_name"` // ex.: ATOM_USDT Channel string `json:"channel"` // ex.: ticker Data []CryptoTicker `json:"data"` // ticker data }
type Endpoint ¶
type Endpoint struct { // Name of the provider, ex. "binance" Name types.ProviderName `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"` // APIKey for API Key protected endpoints APIKey string `toml:"apikey"` }
Endpoint defines an override setting in our config for the hardcoded rest and websocket api endpoints.
type GateCandle ¶
type GateCandle struct { Close string // Closing price TimeStamp int64 // Unix timestamp Volume string // Total candle volume Symbol string // Total symbol }
func (*GateCandle) UnmarshalParams ¶
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 ¶
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 ¶
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 ¶
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 ¶
type GateEventResult struct {
Status string `json:"status"` // ex. "successful"
}
GateEventResult defines the Result body for the GateEvent response.
type GatePairSummary ¶
GatePairSummary defines the response structure for a Gate pair summary.
type GateProvider ¶
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 ¶
func NewGateProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*GateProvider, error)
NewGateProvider creates a new GateProvider.
func (*GateProvider) GetAvailablePairs ¶
func (p *GateProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*GateProvider) GetCandlePrices ¶
func (ps *GateProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*GateProvider) GetTickerPrices ¶
func (ps *GateProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*GateProvider) StartConnections ¶ added in v0.1.2
func (p *GateProvider) StartConnections()
func (*GateProvider) SubscribeCurrencyPairs ¶
func (p *GateProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type GateTicker ¶
type GateTickerResponse ¶
type GateTickerResponse struct { Method string `json:"method"` Params []interface{} `json:"params"` }
GateTickerResponse defines the response body for gate tickers.
type GateTickerSubscriptionMsg ¶
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 ¶
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 ¶
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 ¶
type HuobiPairData struct {
Symbol string `json:"symbol"`
}
HuobiPairData defines the data response structure for an Huobi pair.
type HuobiPairsSummary ¶
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 ¶
func (p *HuobiProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*HuobiProvider) GetCandlePrices ¶
func (ps *HuobiProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*HuobiProvider) GetTickerPrices ¶
func (ps *HuobiProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*HuobiProvider) StartConnections ¶ added in v0.1.2
func (p *HuobiProvider) StartConnections()
func (*HuobiProvider) SubscribeCurrencyPairs ¶
func (p *HuobiProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type HuobiSubscriptionMsg ¶
type HuobiSubscriptionMsg struct {
Sub string `json:"sub"` // channel to subscribe market.$symbol.ticker
}
HuobiSubscriptionMsg Msg to subscribe to one ticker channel at time.
type HuobiSubscriptionResp ¶
type HuobiSubscriptionResp struct {
Status string `json:"status"`
}
HuobiSubscriptionResp the response structure for a Huobi subscription response
type HuobiTick ¶
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 ¶
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 ¶
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 ¶
func (candle *KrakenCandle) UnmarshalJSON(buf []byte) error
type KrakenEvent ¶
type KrakenEvent struct {
Event string `json:"event"` // events from kraken ex.: systemStatus | subscriptionStatus
}
KrakenEvent wraps the possible events from the provider.
type KrakenEventSubscriptionStatus ¶
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 KrakenPairData ¶
type KrakenPairData struct {
WsName string `json:"wsname"`
}
KrakenPairData defines the data response structure for an Kraken pair.
type KrakenPairsSummary ¶
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 ¶
func (p *KrakenProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe.
func (*KrakenProvider) GetCandlePrices ¶
func (ps *KrakenProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*KrakenProvider) GetTickerPrices ¶
func (ps *KrakenProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*KrakenProvider) StartConnections ¶ added in v0.1.2
func (p *KrakenProvider) StartConnections()
func (*KrakenProvider) SubscribeCurrencyPairs ¶
func (p *KrakenProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type KrakenSubscriptionChannel ¶
type KrakenSubscriptionChannel struct {
Name string `json:"name"` // channel to be subscribed ex.: ticker
}
KrakenSubscriptionChannel Msg with the channel name to be subscribed.
type KrakenSubscriptionMsg ¶
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 ¶
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 KujiraCandle ¶ added in v0.1.5
type KujiraPairData ¶ added in v0.1.5
KujiraPairData defines the data response structure for an Kujira pair.
type KujiraPairsSummary ¶ added in v0.1.5
type KujiraPairsSummary struct {
Data []KujiraPairData `json:"data"`
}
KujiraPairsSummary defines the response structure for an Kujira pairs summary.
type KujiraProvider ¶ added in v0.1.5
type KujiraProvider struct {
// contains filtered or unexported fields
}
KujiraProvider defines an Oracle provider implemented by OJO's Kujira API.
REF: https://github.com/ojo-network/kujira-api
func NewKujiraProvider ¶ added in v0.1.5
func NewKujiraProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*KujiraProvider, error)
func (*KujiraProvider) GetAvailablePairs ¶ added in v0.1.5
func (p *KujiraProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*KujiraProvider) GetCandlePrices ¶ added in v0.1.5
func (ps *KujiraProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*KujiraProvider) GetTickerPrices ¶ added in v0.1.5
func (ps *KujiraProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*KujiraProvider) StartConnections ¶ added in v0.1.5
func (p *KujiraProvider) StartConnections()
func (*KujiraProvider) SubscribeCurrencyPairs ¶ added in v0.1.5
func (p *KujiraProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type KujiraTicker ¶ added in v0.1.5
type MessageHandler ¶
type MessageHandler func(int, *WebsocketConnection, []byte)
type MessageType ¶
type MessageType string
func (MessageType) String ¶
func (mt MessageType) String() string
String cast provider MessageType to string.
type MexcCandle ¶
type MexcCandle struct {
Data MexcCandleData `json:"k"`
}
type MexcCandleData ¶ added in v0.1.10
type MexcCandleResponse ¶
type MexcCandleResponse struct { Symbol string `json:"s"` // Symbol ex.: ATOMUSDT Metadata MexcCandle `json:"d"` // Metadata for candle }
MexcCandle is the candle websocket response object.
type MexcCandleSubscription ¶
type MexcCandleSubscription struct { Method string `json:"method"` // ex.: SUBSCRIPTION Params []string `json:"params"` // ex.: [spot@public.kline.v3.api@<symbol>@<interval>] }
MexcCandleSubscription Msg to subscribe all the candle channels.
type MexcPairData ¶ added in v0.1.1
type MexcPairData struct {
Symbol string `json:"symbol"`
}
MexcPairData defines the data response structure for an Mexc pair.
type MexcPairSummary ¶
type MexcPairSummary []MexcPairData
MexcPairSummary defines the response structure for a Mexc pair summary.
type MexcProvider ¶
type MexcProvider struct {
// contains filtered or unexported fields
}
MexcProvider defines an Oracle provider implemented by the Mexc public API.
REF: https://mexcdevelop.github.io/apidocs/spot_v3_en/
func NewMexcProvider ¶
func NewMexcProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*MexcProvider, error)
func (*MexcProvider) GetAvailablePairs ¶
func (p *MexcProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*MexcProvider) GetCandlePrices ¶
func (ps *MexcProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*MexcProvider) GetTickerPrices ¶
func (ps *MexcProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*MexcProvider) StartConnections ¶ added in v0.1.2
func (p *MexcProvider) StartConnections()
func (*MexcProvider) SubscribeCurrencyPairs ¶
func (p *MexcProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type MexcTicker ¶
type MexcTickerResponse ¶
type MexcTickerResponse struct { Symbol string `json:"s"` // e.x. ATOMUSDT Metadata MexcTicker `json:"d"` // Metadata for ticker }
MexcTickerResponse is the ticker price response object.
type MexcTickerSubscription ¶
type MexcTickerSubscription struct { Method string `json:"method"` // ex.: SUBSCRIPTION Params []string `json:"params"` // ex.: [spot@public.bookTicker.v3.api@<symbol>] }
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 ¶
func (p MockProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to susbscribe.
func (MockProvider) GetCandlePrices ¶
func (p MockProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
func (MockProvider) GetTickerPrices ¶
func (p MockProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
func (*MockProvider) StartConnections ¶ added in v0.1.2
func (p *MockProvider) StartConnections()
func (MockProvider) SubscribeCurrencyPairs ¶
func (p MockProvider) SubscribeCurrencyPairs(...types.CurrencyPair)
SubscribeCurrencyPairs performs a no-op since mock does not use websockets
type OkxCandlePair ¶
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 ¶
OkxCandleResponse defines the response structure of a Okx candle request.
type OkxInstID ¶
type OkxInstID struct {
InstID string `json:"instId"` // Instrument ID ex.: BTC-USDT
}
OkxInstId defines the id Symbol of an pair.
type OkxPairsSummary ¶
type OkxPairsSummary struct {
Data []OkxInstID `json:"data"`
}
OkxPairsSummary defines the response structure for an Okx pairs summary.
type OkxProvider ¶
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 ¶
func NewOkxProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*OkxProvider, error)
NewOkxProvider creates a new OkxProvider.
func (*OkxProvider) GetAvailablePairs ¶
func (p *OkxProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to subscribe.
func (*OkxProvider) GetCandlePrices ¶
func (ps *OkxProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*OkxProvider) GetTickerPrices ¶
func (ps *OkxProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*OkxProvider) StartConnections ¶ added in v0.1.2
func (p *OkxProvider) StartConnections()
func (*OkxProvider) SubscribeCurrencyPairs ¶
func (p *OkxProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type OkxSubscriptionMsg ¶
type OkxSubscriptionMsg struct { Op string `json:"op"` // Operation ex.: subscribe Args []OkxSubscriptionTopic `json:"args"` }
OkxSubscriptionMsg Message to subscribe/unsubscribe with N Topics.
type OkxSubscriptionTopic ¶
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 ¶
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 ¶
type OkxTickerResponse struct { Data []OkxTickerPair `json:"data"` ID OkxID `json:"arg"` }
OkxTickerResponse defines the response structure of a Okx ticker request.
type OsmosisCandle ¶ added in v0.1.6
type OsmosisPairData ¶
OsmosisPairData defines the data response structure for an Osmosis pair.
type OsmosisPairsSummary ¶
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 OJO's Osmosis API.
REF: https://github.com/ojo-network/osmosis-api
func NewOsmosisProvider ¶
func NewOsmosisProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*OsmosisProvider, error)
func (*OsmosisProvider) GetAvailablePairs ¶
func (p *OsmosisProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*OsmosisProvider) GetCandlePrices ¶
func (ps *OsmosisProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*OsmosisProvider) GetTickerPrices ¶
func (ps *OsmosisProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*OsmosisProvider) StartConnections ¶ added in v0.1.2
func (p *OsmosisProvider) StartConnections()
func (*OsmosisProvider) SubscribeCurrencyPairs ¶
func (p *OsmosisProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type OsmosisTicker ¶ added in v0.1.6
type PolygonAggregatesResponse ¶ added in v0.1.1
type PolygonAggregatesResponse struct { EV string `json:"ev"` // Event type Pair string `json:"pair"` // ex.: USD/EUR Close float64 `json:"c"` // Rate at close Volume float64 `json:"v"` // Volume during 1 minute interval Timestamp int64 `json:"e"` // Endtime of candle (Unix milliseconds) }
Real-time per-minute forex aggregates for a given forex pair.
type PolygonProvider ¶ added in v0.1.1
type PolygonProvider struct {
// contains filtered or unexported fields
}
PolygonProvider defines an Oracle provider implemented by the polygon.io API.
REF: https://polygon.io/docs/forex/getting-started
func NewPolygonProvider ¶ added in v0.1.1
func NewPolygonProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*PolygonProvider, error)
func (*PolygonProvider) GetAvailablePairs ¶ added in v0.1.1
func (p *PolygonProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs return all available pairs symbol to susbscribe.
func (*PolygonProvider) GetCandlePrices ¶ added in v0.1.1
func (ps *PolygonProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*PolygonProvider) GetTickerPrices ¶ added in v0.1.1
func (ps *PolygonProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*PolygonProvider) StartConnections ¶ added in v0.1.2
func (p *PolygonProvider) StartConnections()
func (*PolygonProvider) SubscribeCurrencyPairs ¶ added in v0.1.1
func (p *PolygonProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type PolygonStatusResponse ¶ added in v0.1.1
type PolygonStatusResponse struct { EV string `json:"ev"` // Event type Message string `json:"message"` // ex.: "Connected Successfully" }
Status response send back when connecting and authenticating with polygon's websocket API.
type PolygonSubscriptionMsg ¶ added in v0.1.1
type PolygonTicker ¶ added in v0.1.1
type PolygonTicker struct {
Ticker string `json:"ticker"` // ex: C.EURUSD
}
type PolygonTickersResponse ¶ added in v0.1.1
type PolygonTickersResponse struct {
Result []PolygonTicker `json:"results"`
}
Response returns all tickers available to be subsribed to.
type Provider ¶
type Provider interface { // GetTickerPrices returns the tickerPrices based on the provided pairs. GetTickerPrices(...types.CurrencyPair) (types.CurrencyPairTickers, error) // GetCandlePrices returns the candlePrices based on the provided pairs. GetCandlePrices(...types.CurrencyPair) (types.CurrencyPairCandles, error) // GetAvailablePairs return all available pairs symbol to subscribe. GetAvailablePairs() (map[string]struct{}, error) // SubscribeCurrencyPairs sends subscription messages for the new currency // pairs and adds them to the providers subscribed pairs SubscribeCurrencyPairs(...types.CurrencyPair) // StartConnections starts the websocket connections. StartConnections() }
Provider defines an interface an exchange price provider must implement.
type UniswapCandle ¶ added in v0.1.8
type UniswapPairData ¶ added in v0.1.8
UniswapPairData defines the data response structure for an Uniswap pair.
type UniswapPairsSummary ¶ added in v0.1.8
type UniswapPairsSummary struct {
Data []UniswapPairData `json:"data"`
}
UniswapPairsSummary defines the response structure for an Uniswap pairs summary.
type UniswapProvider ¶ added in v0.1.5
type UniswapProvider struct {
// contains filtered or unexported fields
}
UniswapProvider defines an Oracle provider implemented by OJO's Uniswap API.
REF: https://github.com/ojo-network/ehereum-api
func NewUniswapProvider ¶ added in v0.1.5
func NewUniswapProvider( ctx context.Context, logger zerolog.Logger, endpoints Endpoint, pairs ...types.CurrencyPair, ) (*UniswapProvider, error)
func (*UniswapProvider) GetAvailablePairs ¶ added in v0.1.5
func (p *UniswapProvider) GetAvailablePairs() (map[string]struct{}, error)
GetAvailablePairs returns all pairs to which the provider can subscribe. ex.: map["ATOMUSDT" => {}, "OJOUSDC" => {}].
func (*UniswapProvider) GetCandlePrices ¶ added in v0.1.5
func (ps *UniswapProvider) GetCandlePrices(pairs ...types.CurrencyPair) (types.CurrencyPairCandles, error)
GetCandlePrices returns a copy of the the candlePrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*UniswapProvider) GetTickerPrices ¶ added in v0.1.5
func (ps *UniswapProvider) GetTickerPrices(pairs ...types.CurrencyPair) (types.CurrencyPairTickers, error)
GetTickerPrices returns the tickerPrices based on the provided pairs. Logs a warning for each currency pair that is not available.
func (*UniswapProvider) StartConnections ¶ added in v0.1.5
func (p *UniswapProvider) StartConnections()
func (*UniswapProvider) SubscribeCurrencyPairs ¶ added in v0.1.5
func (p *UniswapProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair)
SubscribeCurrencyPairs sends the new subscription messages to the websocket and adds them to the providers subscribedPairs array
type UniswapTicker ¶ added in v0.1.8
type WebsocketConnection ¶ added in v0.1.1
type WebsocketConnection struct {
// contains filtered or unexported fields
}
func (*WebsocketConnection) SendJSON ¶ added in v0.1.1
func (conn *WebsocketConnection) SendJSON(msg interface{}) error
SendJSON sends a json message to the websocket connection using the connections mutex to ensure multiple writes do not happen at once.
type WebsocketController ¶
type WebsocketController struct {
// contains filtered or unexported fields
}
WebsocketController defines a provider agnostic websocket handler that manages reconnecting, subscribing, and receiving messages.
func NewWebsocketController ¶
func NewWebsocketController( ctx context.Context, providerName types.ProviderName, websocketURL url.URL, subscriptionMsgs []interface{}, messageHandler MessageHandler, pingDuration time.Duration, pingMessageType uint, logger zerolog.Logger, ) *WebsocketController
func (*WebsocketController) AddWebsocketConnection ¶ added in v0.1.1
func (wsc *WebsocketController) AddWebsocketConnection( msgs []interface{}, messageHandler MessageHandler, pingDuration time.Duration, pingMessageType uint, )
AddWebsocketConnection adds a new websocket connection to subribe to a new pair.
func (*WebsocketController) StartConnections ¶ added in v0.1.1
func (wsc *WebsocketController) StartConnections()