observe

package
v0.0.0-...-070cb90 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BinancePairLTCBTC  = "LTCBTC"
	BinancePairWBTCETH = "WBTCETH"
	BinancePairBTCUSDT = "BTCUSDT"
	BinancePairLTCUSDT = "LTCUSDT"
	BinancePairETHUSDT = "ETHUSDT"
	BinancePairETHUSDC = "ETHUSDC"
	BinancePairBTCUSDC = "BTCUSDC"
	BinancePairETHBTC  = "ETHBTC"
	BinancePairDCRBTC  = "DCRBTC"
	BinancePairXLMBTC  = "XLMBTC"
	BinancePairEOSBTC  = "EOSBTC"
	BinancePairZECBTC  = "ZECBTC"
	BinancePairBNBBTC  = "BNBBTC"
	BinancePairADABTC  = "ADABTC"
	BinancePairXTZBTC  = "XTZBTC"
	BinancePairATOMBTC = "ATOMBTC"
	BinancePairZRXBTC  = "ZRXBTC"
)
View Source
const (
	PairXSNBTC  = "XSN_BTC"
	PairXSNLTC  = "XSN_LTC"
	PairLTCBTC  = "LTC_BTC"
	PairETHBTC  = "ETH_BTC"
	PairDCRBTC  = "DCR_BTC"
	PairXLMBTC  = "XLM_BTC"
	PairEOSBTC  = "EOS_BTC"
	PairZECBTC  = "ZEC_BTC"
	PairBNBBTC  = "BNB_BTC"
	PairADABTC  = "ADA_BTC"
	PairXTZBTC  = "XTZ_BTC"
	PairATOMBTC = "ATOM_BTC"
	PairZRXBTC  = "ZRX_BTC"
	PairETHUSDT = "ETH_USDT"
	PairBTCUSDT = "BTC_USDT"
	PairETHUSDC = "ETH_USDC"
	PairBTCUSDC = "BTC_USDC"
	PairBTCETH  = "BTC_ETH"
	PairWBTCETH = "WBTC_ETH"

	CurrencyXSN  = "XSN"
	CurrencyWBTC = "WBTC"
	CurrencyBTC  = "BTC"
	CurrencyLTC  = "LTC"
	CurrencyETH  = "ETH"
	CurrencyDCR  = "DCR"
	CurrencyXLM  = "XLM"
	CurrencyEOS  = "EOS"
	CurrencyZEC  = "ZEC"
	CurrencyBNB  = "BNB"
	CurrencyADA  = "ADA"
	CurrencyXTZ  = "XTZ"
	CurrencyATOM = "ATOM"
	CurrencyZRX  = "ZRX"
	CurrencyUSDT = "USDT"
	CurrencyUSDC = "USDC"

	SourceBinance  = "Binance"
	SourceWhitebit = "Whitebit"
)
View Source
const (
	WhiteBitHost        = "https://whitebit.com"
	WhiteBiTickerRoute  = "/api/v1/public/tickers"
	WhiteBitPairXSNUSDT = "XSN_USDT"
	WhiteBitPairBTCUSDT = "BTC_USDT"
	WhiteBitPairETHUSDT = "ETH_USDT"
)

Variables

This section is empty.

Functions

func GetPrices

func GetPrices() ([]PricePair, []Currency, error)

func GetWhiteBitPrices

func GetWhiteBitPrices() ([]PricePair, []Currency, error)

func InitClients

func InitClients(withBinance bool, binanceKey string, binanceSecret string) (err error)

Types

type BinanceClient

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

func NewBinanceClient

func NewBinanceClient(apiKey string, secret string) (*BinanceClient, error)

func (*BinanceClient) GetPairs

func (b *BinanceClient) GetPairs(symbols []string) ([]binance.SymbolPrice, error)

type Currency

type Currency struct {
	Symbol   string
	PriceUSD float64
	PriceBTC float64
}

type Observer

type Observer struct {
	*BinanceClient
	*WhitebitClient
	Ticker      time.Duration
	WithBinance bool
}
var O Observer

type PricePair

type PricePair struct {
	Pair    string
	Price   float64
	Bid     float64
	Ask     float64
	Sources []string
}

type TickerResponse

type TickerResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  struct {
		ETHBTC struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"ETH_BTC"`
		BTCUSD struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"BTC_USD"`
		ETHUSD struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"ETH_USD"`
		LTCBTC struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"LTC_BTC"`
		LTCETH struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"LTC_ETH"`
		LTCUSD struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"LTC_USD"`
		BCHRUB struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"BCH_RUB"`
		USDTUAH struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"USDT_UAH"`
		USDTUSD struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"USDT_USD"`
		USDTEUR struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"USDT_EUR"`
		BTCTUSD struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"BTC_TUSD"`
		ETHTUSD struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"ETH_TUSD"`
		BTCUSDC struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"BTC_USDC"`
		ETHUSDC struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"ETH_USDC"`
		DAIUSDT struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"DAI_USDT"`
		BTCUSDT struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"BTC_USDT"`
		XSNUSDT struct {
			At     int `json:"at"`
			Ticker struct {
				Bid    string `json:"bid"`
				Ask    string `json:"ask"`
				Low    string `json:"low"`
				High   string `json:"high"`
				Last   string `json:"last"`
				Vol    string `json:"vol"`
				Deal   string `json:"deal"`
				Change string `json:"change"`
			} `json:"ticker"`
		} `json:"XSN_USDT"`
	} `json:"result"`
}

type WhitebitClient

type WhitebitClient struct {
	ApiHost string
	Client  *http.Client
}

func NewWhitebitClient

func NewWhitebitClient(apiHost string) *WhitebitClient

func (*WhitebitClient) GetTicker

func (w *WhitebitClient) GetTicker() (TickerResponse, error)

Jump to

Keyboard shortcuts

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