currencystate

package
v0.0.0-...-a0d82f2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrCurrencyStateNotFound is an error when the currency state has not been
	// found
	// TODO: distinguish between unsupported and not found
	ErrCurrencyStateNotFound = errors.New("currency state not found")
)

Functions

This section is empty.

Types

type Currency

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

Currency defines the state of currency operations

func (*Currency) CanDeposit

func (c *Currency) CanDeposit() bool

CanDeposit returns if the currency can be deposited onto an exchange

func (*Currency) CanTrade

func (c *Currency) CanTrade() bool

CanTrade returns if the currency is currently tradeable

func (*Currency) CanWithdraw

func (c *Currency) CanWithdraw() bool

CanWithdraw returns if the currency can be withdrawn from the exchange

func (*Currency) GetState

func (c *Currency) GetState() Options

GetState returns the internal state of the currency

func (*Currency) WaitDeposit

func (c *Currency) WaitDeposit(kick <-chan struct{}) <-chan bool

WaitDeposit allows a routine to wait until a deposit change of state occurs

func (*Currency) WaitTrading

func (c *Currency) WaitTrading(kick <-chan struct{}) <-chan bool

WaitTrading allows a routine to wait until a trading change of state occurs

func (*Currency) WaitWithdraw

func (c *Currency) WaitWithdraw(kick <-chan struct{}) <-chan bool

WaitWithdraw allows a routine to wait until a withdraw change of state occurs

type Options

type Options struct {
	Withdraw *bool
	Deposit  *bool
	Trade    *bool
}

Options defines the current allowable options for a currency, using a bool pointer for optional setting for incomplete data, so we can default to true on nil values.

type Snapshot

type Snapshot struct {
	Code  currency.Code
	Asset asset.Item
	Options
}

Snapshot defines a snapshot of the internal asset for exportation

type States

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

States defines all currency states for an exchange

func NewCurrencyStates

func NewCurrencyStates() *States

NewCurrencyStates gets a new type for tracking exchange currency states

func (*States) CanDeposit

func (s *States) CanDeposit(c currency.Code, a asset.Item) error

CanDeposit returns if the currency can be deposited onto this exchange

func (*States) CanTrade

func (s *States) CanTrade(c currency.Code, a asset.Item) error

CanTrade returns if the currency is currently tradeable for this exchange

func (*States) CanTradePair

func (s *States) CanTradePair(pair currency.Pair, a asset.Item) error

CanTradePair returns if the currency pair is currently tradeable for this exchange. If there are no states loaded for a specific currency, this will assume the currency pair is operational. NOTE: Future exchanges will have functionality specific to a currency.Pair, can upgrade this when needed.

func (*States) CanWithdraw

func (s *States) CanWithdraw(c currency.Code, a asset.Item) error

CanWithdraw returns if the currency can be withdrawn from this exchange

func (*States) Get

func (s *States) Get(c currency.Code, a asset.Item) (*Currency, error)

Get returns the currency state by currency code

func (*States) GetCurrencyStateSnapshot

func (s *States) GetCurrencyStateSnapshot() ([]Snapshot, error)

GetCurrencyStateSnapshot returns the exchange currency state snapshot

func (*States) Update

func (s *States) Update(c currency.Code, a asset.Item, o Options) error

Update updates a singular currency state, primarily used for singular websocket updates or alerts.

func (*States) UpdateAll

func (s *States) UpdateAll(a asset.Item, updates map[currency.Code]Options) error

UpdateAll updates the full currency state, used for REST calls

Jump to

Keyboard shortcuts

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