cryptocom

package module
v0.0.0-...-81ab215 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Types
	AuthRequest = iota + 1
	SubscribeRequest
	HeartBeat
	OrderRequest
	RestOrderRequest
	RestBalanceRequest
	RestTradesRequest
	RestOpenOrdersRequest
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	LogFunc LogFunc
	// contains filtered or unexported fields
}

func New

func New(wsRootURL, restRootURL, key, secret string) *Client

New returns a pointer of Client struct

func (*Client) AuthRequest

func (c *Client) AuthRequest() *Request

func (*Client) CancelAllOrders

func (c *Client) CancelAllOrders(reqID int, market string) error

func (*Client) CancelOrder

func (c *Client) CancelOrder(reqID int, remoteID, market string) error

func (*Client) Connect

func (c *Client) Connect() error

Connect instansiate WS Connections

func (*Client) CreateLimitOrder

func (c *Client) CreateLimitOrder(
	reqID int,
	ask string,
	bid string,
	orderSide string,
	price decimal.Decimal,
	amount decimal.Decimal,
	uuid uuid.UUID,
) error

For MARKET BUY orders, amount is notional (https://exchange-docs.crypto.com/#private-create-order).

func (*Client) CreateMarketOrder

func (c *Client) CreateMarketOrder(
	reqID int,
	ask string,
	bid string,
	orderSide string,
	amount decimal.Decimal,
	uuid uuid.UUID,
) error

func (*Client) GetOrderDetails

func (c *Client) GetOrderDetails(reqID int, remoteID string) error

func (*Client) Listen

func (c *Client) Listen() <-chan Response

func (*Client) RestGetBalance

func (c *Client) RestGetBalance(reqID int) (Response, error)

func (*Client) RestGetOrderDetails

func (c *Client) RestGetOrderDetails(reqID int, remoteID string) (Response, error)

func (*Client) RestGetTrades

func (c *Client) RestGetTrades(reqID int, market string) (Response, error)

func (*Client) RestOpenOrders

func (c *Client) RestOpenOrders(reqID int, market string, pageNumber int, pageSize int) (Response, error)

func (*Client) Shutdown

func (c *Client) Shutdown()

func (*Client) SubscribePrivateBalanceUpdates

func (c *Client) SubscribePrivateBalanceUpdates() error

func (*Client) SubscribePrivateOrders

func (c *Client) SubscribePrivateOrders(markets ...string) error

SubscribePrivateOrders is subscription private order user.order.markets channel

func (*Client) SubscribePrivateTrades

func (c *Client) SubscribePrivateTrades(markets ...string) error

SubscribePrivateTrades is subscription private user.trade channel

func (*Client) SubscribePublicOrderBook

func (c *Client) SubscribePublicOrderBook(depth int, markets ...string) error

SubscribePublicOrderBook is subscription orderbook channel Example: SubscribeOrderBook(depth, "ETH_BTC", "ETH_CRO") depth: Number of bids and asks to return. Allowed values: 10 or 150

func (*Client) SubscribePublicTickers

func (c *Client) SubscribePublicTickers(markets ...string) error

SubscribePublicTickers is subscription ticker channel

func (*Client) SubscribePublicTrades

func (c *Client) SubscribePublicTrades(markets ...string) error

SubscribePublicTrades is subscription trade channel Example: SubscribeTrades("ETH_BTC", "ETH_CRO")

type Connection

type Connection struct {
	Endpoint  string
	IsPrivate bool
	Transport
	*sync.Mutex
}

func (*Connection) Type

func (c *Connection) Type() string

type HTTPClient

type HTTPClient interface {
	Post(url, contentType string, body io.Reader) (resp *http.Response, err error)
	Get(url string) (resp *http.Response, err error)
}

type LogFunc

type LogFunc func(format string, args ...interface{})

type Request

type Request struct {
	Id        int
	Type      uint8
	Method    string
	ApiKey    string
	Signature string
	Nonce     string
	Params    map[string]interface{}
}

func (*Request) Encode

func (r *Request) Encode() ([]byte, error)

type Response

type Response struct {
	Id      int
	Method  string
	Code    int
	Message string
	Result  map[string]interface{}
}

type Transport

type Transport interface {
	ReadMessage() (int, []byte, error)
	WriteMessage(int, []byte) error
	Close() error
}

Jump to

Keyboard shortcuts

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