opendax_protocol

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Types and helpers for easy formatting and parsing open-finance protocol messages.

Events/metods names for open-finance.org protocol implementation client and server.

Index

Constants

View Source
const (
	// Request type code
	Request = 1

	// Response type code
	Response = 2

	// EventPublic is public event type code
	EventPublic = 3

	// EventPrivate is private event type code
	EventPrivate = 4

	// EventAdmin is admin event type code
	EventAdmin = 5
)
View Source
const (
	EventBalanceUpdate      = "bu"
	EventWithdrawalUpdate   = "wu"
	EventDepositUpdate      = "du"
	EventOrderCreate        = "on"
	EventOrderCancel        = "oc"
	EventOrderUpdate        = "ou"
	EventOrderReject        = "or"
	EventPrivateTrade       = "tr"
	EventTrade              = "trade"
	EventTickers            = "tickers"
	EventMarkets            = "markets"
	EventKLine              = "kline-"
	EventOrderBookIncrement = "obi"
	EventOrderBookSnapshot  = "obs"
	EventRawBookIncrement   = "rbi"
	EventRawBookSnapshot    = "rbs"
	EventSystem             = "sys"
	EventConfig             = "config"

	MethodAuth               = "authenticate"
	MethodSubscribe          = "subscribe"
	MethodUnsubscribe        = "unsubscribe"
	MethodListOrders         = "list_orders"
	MethodListOrdersByUUIDS  = "list_orders_by_uuids"
	MethodListOrderTrades    = "list_order_trades"
	MethodListChannelTrades  = "list_channel_trades"
	MethodCreateOrder        = "create_order"
	MethodCreateOrderBulk    = "create_bulk"
	MethodCancelOrder        = "cancel_order"
	MethodCancelOrdersAll    = "cancel_all"
	MethodGetKlines          = "klines"
	MethodGetMarkets         = "get_markets"
	MethodGetSymbols         = "get_symbols"
	MethodGetTokens          = "get_tokens"
	MethodGetTokenBySymbol   = "get_token_by_symbol_id"
	MethodGetTokenById       = "get_token_by_id"
	MethodGetNetworks        = "get_networks"
	MethodGetDeposits        = "get_deposits"
	MethodGetWithdrawals     = "get_withdrawals"
	MethodCheckSMTPConfig    = "check_smtp_config"
	MethodSendMetrics        = "send_metrics"
	MethodCreateDeposit      = "create_deposit"
	MethodCreateWithdrawal   = "create_withdrawal"
	MethodCancelDeposit      = "cancel_deposit"
	MethodCancelWithdrawal   = "cancel_withdrawal"
	MethodGetPublicConfig    = "get_public_config"
	MethodSetConfig          = "set_config"
	MethodGetConfig          = "get_config"
	MethodGetParticipantData = "get_participation_data"
	MethodAddAddress         = "add_address"
	MethodVerifyAddress      = "verify_address"
	MethodGetAddresses       = "get_addresses"

	MethodAdminCreateOrder = "admin_create_order"
	MethodAdminCancelOrder = "admin_cancel_order"
	MethodAdminDeposit     = "admin_deposit"
	MethodAdminWithdraw    = "admin_withdraw"

	OrderSideSell = "sell"
	OrderSideBuy  = "buy"

	OrderStatePending       = "p"
	OrderStateWait          = "w"
	OrderStateDone          = "d"
	OrderStateReject        = "r"
	OrderStateCancel        = "c"
	OrderStateTriggerWait   = "tw"
	OrderStateTriggerCancel = "tc"
	OrderStateTriggerReject = "tr"

	OrderTypeLimit      = "l"
	OrderTypeMarket     = "m"
	OrderTypePostOnly   = "p"
	OrderTypeFillOrKill = "f"
	OrderTypeStopLoss   = "sl"
	OrderTypeStopLimit  = "slm"
	OrderTypeTakeProfit = "tp"
	OrderTypeTakeLimit  = "tlm"

	TopicBalances      = "balances"
	TopicOrders        = "order"
	TopicTickers       = "tickers"
	TopicWithdrawals   = "withdrawals"
	TopicDeposits      = "deposits"
	TopicTrades        = "trades"
	TopicOrderbooksInc = "ob-inc"
	TopicKLines        = "kline-"

	ScopePrivate = "private"
	ScopePublic  = "public"
)
View Source
const ParseError = "unexpected message"

Variables

View Source
var ErrInvalidType = errors.New("invalid type")

ErrInvalidType is returned when type conversion is not successful

View Source
var ErrIterationDone = errors.New("iteration done")

ErrIterationDone is returned when no more elements in array to iterate

View Source
var ErrValueNil = errors.New("value is nil")

ErrValueNil is returned when next value is nil

Functions

func DescribeEvents

func DescribeEvents() ([]string, [][]string)

func DescribeTopics

func DescribeTopics() ([]string, [][]string)

Types

type ArgIterator

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

ArgIterator is a helper for msg arguments processing.

func NewArgIterator

func NewArgIterator(args []any) *ArgIterator

NewArgIterator creates new ready-to-use iterator

func (*ArgIterator) Err

func (a *ArgIterator) Err() error

Err returns first met iterator error1

func (*ArgIterator) Index

func (a *ArgIterator) Index() int

Index returns current iterator position

func (*ArgIterator) More

func (a *ArgIterator) More() bool

More returns true if there are values not scanned, intended to be used for iterating

func (*ArgIterator) Next

func (a *ArgIterator) Next() any

Next returns next value or nil, sets ErrIterationDone

func (*ArgIterator) NextBool

func (a *ArgIterator) NextBool() bool

NextBool returns next value converted to bool

func (*ArgIterator) NextDecimal

func (a *ArgIterator) NextDecimal() decimal.Decimal

NextDecimal returns next value converted to decimal

func (*ArgIterator) NextFloat64

func (a *ArgIterator) NextFloat64() float64

NextFloat64 returns next value converted to float64

func (*ArgIterator) NextInt

func (a *ArgIterator) NextInt() int

NextInt returns next value converted to int

func (*ArgIterator) NextInt64

func (a *ArgIterator) NextInt64() int64

NextInt64 returns next value converted to int64

func (*ArgIterator) NextInterface

func (a *ArgIterator) NextInterface() any

NextInterface returns next value converted to any

func (*ArgIterator) NextSlice

func (a *ArgIterator) NextSlice() []any

NextSlice returns next value converted to []any

func (*ArgIterator) NextString

func (a *ArgIterator) NextString() string

NextString returns next value converted to string

func (*ArgIterator) NextTimestamp

func (a *ArgIterator) NextTimestamp() int64

NextTimestamp returns next value converted to Unix()

func (*ArgIterator) NextUUID

func (a *ArgIterator) NextUUID() uuid.UUID

NextUUID returns next value parsed as UUID

func (*ArgIterator) NextUint64

func (a *ArgIterator) NextUint64() uint64

NextUint64 returns next value converted to uint64

type Msg

type Msg struct {
	Type   uint8
	ReqID  uint64
	Method string
	Args   []any
}

Msg represent websocket messages, it could be either a request, a response or an event

func NewSubscribeMessage

func NewSubscribeMessage(reqID uint64, topics ...any) *Msg

func NewUnsubscribeMessage added in v0.0.13

func NewUnsubscribeMessage(reqID uint64, topics ...any) *Msg

func ParseRaw

func ParseRaw(msg []byte) (*Msg, error)

func (*Msg) Encode

func (m *Msg) Encode() ([]byte, error)

Encode msg into json

Jump to

Keyboard shortcuts

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