types

package
v0.0.0-...-b2dae14 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "price-feeder"

Variables

View Source
var (
	ErrProviderConnection  = sdkerrors.Register(ModuleName, 1, "provider connection")
	ErrMissingExchangeRate = sdkerrors.Register(ModuleName, 2, "missing exchange rate for %s")
	ErrTickerNotFound      = sdkerrors.Register(ModuleName, 3, "%s failed to get ticker price for %s")
	ErrCandleNotFound      = sdkerrors.Register(ModuleName, 4, "%s failed to get candle price for %s")

	ErrWebsocketDial  = sdkerrors.Register(ModuleName, 5, "error connecting to %s websocket: %w")
	ErrWebsocketClose = sdkerrors.Register(ModuleName, 6, "error closing %s websocket: %w")
	ErrWebsocketSend  = sdkerrors.Register(ModuleName, 7, "error sending to %s websocket: %w")
	ErrWebsocketRead  = sdkerrors.Register(ModuleName, 8, "error reading from %s websocket: %w")
)

Price feeder errors

Functions

This section is empty.

Types

type CandlePrice

type CandlePrice struct {
	Price     sdk.Dec // last trade price
	Volume    sdk.Dec // volume
	TimeStamp int64   // timestamp
}

CandlePrice defines price, volume, and time information for an exchange rate.

func NewCandlePrice

func NewCandlePrice(provider, symbol, lastPrice, volume string, timeStamp int64) (CandlePrice, error)

NewCandlePrice parses the lastPrice and volume to a decimal and returns a CandlePrice

type CurrencyPair

type CurrencyPair struct {
	Base  string
	Quote string
}

CurrencyPair defines a currency exchange pair consisting of a base and a quote. We primarily utilize the base for broadcasting exchange rates and use the pair for querying for the ticker prices.

func MapPairsToSlice

func MapPairsToSlice(mapPairs map[string]CurrencyPair) []CurrencyPair

MapPairsToSlice returns the map of currency pairs as slice.

func (CurrencyPair) String

func (cp CurrencyPair) String() string

String implements the Stringer interface and defines a ticker symbol for querying the exchange rate.

type TickerPrice

type TickerPrice struct {
	Price  sdk.Dec // last trade price
	Volume sdk.Dec // 24h volume
}

TickerPrice defines price and volume information for a symbol or ticker exchange rate.

func NewTickerPrice

func NewTickerPrice(provider, symbol, lastPrice, volume string) (TickerPrice, error)

NewTickerPrice parses the lastPrice and volume to a decimal and returns a TickerPrice

Jump to

Keyboard shortcuts

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