crypto_com

package
v0.3.0-dev2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CryptoComDetails = types.ExchangeQueryDetails{
		Exchange:      exchange_common.EXCHANGE_ID_CRYPTO_COM,
		Url:           "https://api.crypto.com/v2/public/get-ticker",
		PriceFunction: CryptoComPriceFunction,
		IsMultiMarket: true,
	}
)

Functions

func CryptoComPriceFunction

func CryptoComPriceFunction(
	response *http.Response,
	tickerToExponent map[string]int32,
	medianizer lib.Medianizer,
) (tickerToPrice map[string]uint64, unavailableTickers map[string]error, err error)

CryptoComPriceFunction transforms an API response from CryptoCom into a map of tickers to prices that have been shifted by a market specific exponent.

Types

type CryptoComResponseBody

type CryptoComResponseBody struct {
	Code   uint32                  `json:"code" validate:"required"`
	Result CryptoComResponseResult `json:"result" validate:"required"`
}

CryptoComResponseBody defines the overall CryptoCom response.

type CryptoComResponseResult

type CryptoComResponseResult struct {
	Tickers []CryptoComTicker `json:"data" validate:"required"`
}

CryptoComResponseResult defines the `result` field of CryptoCom response.

type CryptoComTicker

type CryptoComTicker struct {
	Pair      string `json:"i" validate:"required"`
	AskPrice  string `json:"k" validate:"required,positive-float-string"`
	BidPrice  string `json:"b" validate:"required,positive-float-string"`
	LastPrice string `json:"a" validate:"required,positive-float-string"`
}

CryptoComTicker is our representation of ticker information returned in CryptoCom response. Need to implement interface `Ticker` in util.go. Note: CryptoCom returns `null` for bids and asks if there are none on the orderbook, in which case we mark the ticker as unavailable.

func (CryptoComTicker) GetAskPrice

func (t CryptoComTicker) GetAskPrice() string

func (CryptoComTicker) GetBidPrice

func (t CryptoComTicker) GetBidPrice() string

func (CryptoComTicker) GetLastPrice

func (t CryptoComTicker) GetLastPrice() string

func (CryptoComTicker) GetPair

func (t CryptoComTicker) GetPair() string

Jump to

Keyboard shortcuts

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