gofer

package
v0.5.3-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gofer

type Gofer interface {
	// Models describes price models which are used to calculate prices.
	// If no pairs are specified, models for all pairs are returned.
	Models(pairs ...Pair) (map[Pair]*Model, error)
	// Price returns a Price for the given pair.
	Price(pair Pair) (*Price, error)
	// Prices returns prices for the given pairs. If no pairs are specified,
	// prices for all pairs are returned.
	Prices(pairs ...Pair) (map[Pair]*Price, error)
	// Pairs returns all pairs.
	Pairs() ([]Pair, error)
}

Gofer provides prices for asset pairs.

type Model

type Model struct {
	// Type is used to differentiate between model types.
	Type string
	// Parameters is a optional list of model's parameters.
	Parameters map[string]string
	// Pair is a asset pair for which this model returns a price.
	Pair Pair
	// Models is a list of sub models used to calculate price.
	Models []*Model
}

Model is a simplified representation of a model which is used to calculate asset pair prices. The main purpose of this structure is to help the end user to understand how prices are derived and calculated.

This structure is purely informational. The way it is used depends on a specific implementation.

type Pair

type Pair struct {
	Base  string
	Quote string
}

Pair represents an asset pair.

func NewPair

func NewPair(s string) (Pair, error)

NewPair returns a new Pair for given string. The string must be formatted as "BASE/QUOTE".

func NewPairs

func NewPairs(s ...string) ([]Pair, error)

NewPairs returns a Pair slice for given strings. Given strings must be formatted as "BASE/QUOTE".

func (Pair) Empty

func (p Pair) Empty() bool

func (Pair) Equal

func (p Pair) Equal(c Pair) bool

func (Pair) String

func (p Pair) String() string

type Price

type Price struct {
	Type       string
	Parameters map[string]string
	Pair       Pair
	Price      float64
	Bid        float64
	Ask        float64
	Volume24h  float64
	Time       time.Time
	Prices     []*Price
	Error      string
}

Price represents price for a single pair. If the Price price was calculated indirectly it will also contain all prices used to calculate the price.

type StartableGofer

type StartableGofer interface {
	Gofer
	Start(ctx context.Context) error
	Wait() chan error
}

StartableGofer interface represents a Gofer instances that have to be started first to work properly.

Directories

Path Synopsis
TODO: check if it's possible to merge coinbase and coinbasepro
TODO: check if it's possible to merge coinbase and coinbasepro

Jump to

Keyboard shortcuts

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