okex

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OkexWSAddr     = "wss://real.okex.com:8443/ws/v3"
	OkexTESTWSAddr = "wss://real.okex.com:8443/ws/v3?brokerId=9999"
	OKEX           = "okex"
)

Variables

This section is empty.

Functions

func FillsParam added in v0.3.0

func FillsParam(instrumentID string, orderID string, before string, after string, limit string) url.Values

func NewSpotSymbol

func NewSpotSymbol(base, quote string) exchange.SpotSymbol

func ParseTime

func ParseTime(timestamp string) (time.Time, error)

func SubscribeCB

func SubscribeCB(channel string, cb ResponseParseCB)

Types

type Client added in v0.3.0

type Client interface {
	Request(ctx context.Context, method string, endPoint string, param url.Values,
		body io.Reader, sign bool, dst interface{}) error
}

type CodeC

type CodeC struct {
	LastSUBID string //okex op fail do not return operate type. we have to record
}

func NewCodeC

func NewCodeC() *CodeC

func (*CodeC) Decode

func (cc *CodeC) Decode(raw []byte) (rpc.Response, error)

func (*CodeC) Encode

func (cc *CodeC) Encode(req rpc.Request) ([]byte, error)

type Ledger added in v0.3.0

type Ledger struct {
	LedgerID     string          `json:"ledger_id"`
	Amount       decimal.Decimal `json:"amount"`
	Type         LedgerType      `json:"type"`
	Fee          decimal.Decimal `json:"fee"`
	Timestamp    string          `json:"timestamp"`
	InstrumentID string          `json:"instrument_id"`
	Currency     string          `json:"currency"`
	Details      interface{}     `json:"details"`
	OrderID      string          `json:"order_id"`
	From         string          `json:"from"`
	To           string          `json:"to"`
	Balance      decimal.Decimal `json:"balance"`
}

Leder response for margin, swap

func FetchLedgers added in v0.3.0

func FetchLedgers(ctx context.Context, cl Client, path string, before, after, limit, typ string) ([]Ledger, error)

func (*Ledger) Parse added in v0.3.0

func (l *Ledger) Parse(pcb Pcb) (*exchange.Finance, error)

type LedgerType added in v0.3.0

type LedgerType string

func (LedgerType) Parse added in v0.3.0

func (typ LedgerType) Parse() exchange.FinanceType

type Pcb added in v0.3.0

type Pcb func(string) (exchange.Symbol, error)

type ResponseParseCB

type ResponseParseCB func(string, string, json.RawMessage) (*rpc.Notify, error)

type RestClient

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

func NewRestClient

func NewRestClient(key, secret, passPhrase string) *RestClient

func NewTESTRestClient

func NewTESTRestClient(key, secret, passPhrase string) *RestClient

func (*RestClient) Property added in v0.3.0

func (rc *RestClient) Property() exchange.Property

func (*RestClient) Request

func (rc *RestClient) Request(ctx context.Context, method, endPoint string, params url.Values, body io.Reader, sign bool, dst interface{}) error

type SpotSymbol

type SpotSymbol struct {
	*exchange.BaseSpotSymbol
}

func (*SpotSymbol) String

func (ss *SpotSymbol) String() string

type WSClient

type WSClient struct {
	*exchange.WSClient

	Key        string
	Secret     string
	PassPhrase string
	// contains filtered or unexported fields
}

func NewTESTWSClient

func NewTESTWSClient(key, secret, passPhrase string, data chan interface{}) *WSClient

NewTESTWSClient return a wsclient for okex testnet

func NewWSClient

func NewWSClient(key, secret, passPhrase string, data chan interface{}) *WSClient

func (*WSClient) Auth

func (ws *WSClient) Auth(ctx context.Context) error

func (*WSClient) Handle

func (ws *WSClient) Handle(ctx context.Context, notify *rpc.Notify)

func (*WSClient) Run

func (ws *WSClient) Run(ctx context.Context) error

Run start the websocket loop and create a goroutine which will send ping message to okex server periodically

func (*WSClient) Subscribe

func (ws *WSClient) Subscribe(ctx context.Context, channels ...exchange.Channel) error

Subscribe due to okex api limit subscribe result can not ensure

func (*WSClient) UnSubscribe added in v0.3.0

func (ws *WSClient) UnSubscribe(ctx context.Context, channels ...exchange.Channel) error

UnSubscribe due to okex api limit subscribe result can not ensure

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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