cdcexchange

package module
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 12 Imported by: 0

README

Crypto.com Exchange

Go client for the Crypto.com Spot Exchange REST API.

Installation

To import the package, run:

go get github.com/cshep4/go-cryptocom

Setup

An instance of the client can be created like this:

import (
    cdcexchange "github.com/sngyai/go-cryptocom"
)

client, err := cdcexchange.New("<api_key>", "<secret_key>")
if err != nil {
    return err
}

// optional, configuration can be updated with UpdateConfig
err = client.UpdateConfig("<api_key>", "<secret_key>")
if err != nil {
    return err
}

Optional Configurations

UAT Sandbox Environment

The client can be configured to make requests against the UAT Sandbox environment using the WithUATEnvironment functional option like so:

import (
    cdcexchange "github.com/sngyai/go-cryptocom"
)

client, err := cdcexchange.New("<api_key>", "<secret_key>", 
    cdcexchange.WithUATEnvironment(),
)
if err != nil {
    return err
}
Production Environment

The client can be configured to make requests against the Production environment using the WithProductionEnvironment functional option. Clients will make requests against this environment by default even if this is not specified.

import (
    cdcexchange "github.com/sngyai/go-cryptocom"
)

client, err := cdcexchange.New("<api_key>", "<secret_key>", 
    cdcexchange.WithProductionEnvironment(),
)
if err != nil {
    return err
}
Custom HTTP Client

The client can be configured to use a custom HTTP client using the WithHTTPClient functional option. This can be used to create custom timeouts, enable tracing, etc. This is initialised like so:

import (
    "net/http"

    cdcexchange "github.com/sngyai/go-cryptocom"
)

client, err := cdcexchange.New("<api_key>", "<secret_key>",
    cdcexchange.WithHTTPClient(&http.Client{
        Timeout: 15 * time.Second,
    }),
)
if err != nil {
    return err
}

Supported API (Official Docs):

The supported APIs for each module are listed below.

✅ - API is supported

⚠️ - API is not yet supported (hopefully should be available soon!)

Each API module is separated into separate interfaces, however the CryptoDotComExchange interface can be used to access all methods:

// CryptoDotComExchange is a Crypto.com Exchange client for all available APIs.
type CryptoDotComExchange interface {
    // UpdateConfig can be used to update the configuration of the client object.
    // (e.g. change api key, secret key, environment, etc).
    UpdateConfig(apiKey string, secretKey string, opts ...ClientOption) error
    CommonAPI
    SpotTradingAPI
    MarginTradingAPI
    DerivativesTransferAPI
    SubAccountAPI
    Websocket
}

Client interfaces can be found in client.go.

Common API
// CommonAPI is a Crypto.com Exchange client for Common API.
type CommonAPI interface {
    // GetInstruments provides information on all supported instruments (e.g. BTC_USDT).
    //
    // Method: public/get-instruments
    GetInstruments(ctx context.Context) ([]Instrument, error)
    // GetBook fetches the public order book for a particular instrument and depth.
    //
    // Method: public/get-book
    GetBook(ctx context.Context, instrument string, depth int) (*BookResult, error)
    // GetTickers fetches the public tickers for an instrument (e.g. BTC_USDT).
    //
    // instrument can be left blank to retrieve tickers for ALL instruments.
    //
    // Method: public/get-ticker
    GetTickers(ctx context.Context, instrument string) ([]Ticker, error)
}
Method Support
public/auth ⚠️
public/get-instruments
public/get-book
public/get-candlestick ⚠️
public/get-ticker
public/get-trades ⚠️
private/set-cancel-on-disconnect ⚠️
private/get-cancel-on-disconnect ⚠️
private/create-withdrawal
private/get-withdrawal-history
private/get-deposit-history
private/get-deposit-address
Spot Trading API
// SpotTradingAPI is a Crypto.com Exchange client for Spot Trading API.
type SpotTradingAPI interface {
    // GetAccountSummary returns the account balance of a user for a particular token.
    //
    // currency can be left blank to retrieve balances for ALL tokens.
    //
    // Method: private/get-account-summary
    GetAccountSummary(ctx context.Context, currency string) ([]Account, error)
    // CreateOrder creates a new BUY or SELL order on the Exchange.
    //
    // This call is asynchronous, so the response is simply a confirmation of the request.
    //
    // The user.order subscription can be used to check when the order is successfully created.
    //
    // Method: private/create-order
    CreateOrder(ctx context.Context, req CreateOrderRequest) (*CreateOrderResult, error)
    // CancelOrder cancels an existing order on the Exchange.
    //
    // This call is asynchronous, so the response is simply a confirmation of the request.
    //
    // The user.order subscription can be used to check when the order is successfully cancelled.
    //
    // Method: private/cancel-order
    CancelOrder(ctx context.Context, instrumentName string, orderID string) error
    // CancelAllOrders cancels  all orders for a particular instrument/pair.
    //
    // This call is asynchronous, so the response is simply a confirmation of the request.
    //
    // The user.order subscription can be used to check when the order is successfully cancelled.
    //
    // Method: private/cancel-all-orders
    CancelAllOrders(ctx context.Context, instrumentName string) error
    // GetOrderHistory gets the order history for a particular instrument.
    //
    // Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).
    // If paging is used, enumerate each page (starting with 0) until an empty order_list array appears in the response.
    //
    // req.InstrumentName can be left blank to get open orders for all instruments.
    //
    // Method: private/get-order-history
    GetOrderHistory(ctx context.Context, req GetOrderHistoryRequest) ([]Order, error)
    // GetOpenOrders gets all open orders for a particular instrument.
    //
    // Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).
    //
    // req.InstrumentName can be left blank to get open orders for all instruments.
    //
    // Method: private/get-open-orders
    GetOpenOrders(ctx context.Context, req GetOpenOrdersRequest) (*GetOpenOrdersResult, error)
    // GetOrderDetail gets details of an order for a particular order ID.
    //
    // Method: private/get-order-detail
    GetOrderDetail(ctx context.Context, orderID string) (*GetOrderDetailResult, error)
    // GetTrades gets all executed trades for a particular instrument.
    //
    // Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).
    // If paging is used, enumerate each page (starting with 0) until an empty trade_list array appears in the response.
    //
    // req.InstrumentName can be left blank to get executed trades for all instruments.
    //
    // Method: private/get-trades
    GetTrades(ctx context.Context, req GetTradesRequest) ([]Trade, error)
}
Method Support
private/get-account-summary
private/create-order
private/cancel-order
private/cancel-all-orders
private/get-order-history
private/get-open-orders
private/get-order-detail
private/get-trades
Margin Trading API
// MarginTradingAPI is a Crypto.com Exchange client for Margin Trading API.
type MarginTradingAPI interface {
}
Method Support
public/margin/get-transfer-currencies ⚠️
public/margin/get-loan-currencies ⚠️
private/margin/get-user-config ⚠️
private/margin/get-account-summary ⚠️
private/margin/transfer ⚠️
private/margin/borrow ⚠️
private/margin/repay ⚠️
private/margin/get-transfer-history ⚠️
private/margin/get-borrow-history ⚠️
private/margin/get-interest-history ⚠️
private/margin/get-repay-history ⚠️
private/margin/get-liquidation-history ⚠️
private/margin/get-liquidation-orders ⚠️
private/margin/create-order ⚠️
private/margin/cancel-order ⚠️
private/margin/cancel-all-orders ⚠️
private/margin/get-order-history ⚠️
private/margin/get-open-orders ⚠️
private/margin/get-order-detail ⚠️
private/margin/get-trades ⚠️
Derivatives Transfer API
// DerivativesTransferAPI is a Crypto.com Exchange client for Derivatives Transfer API.
type DerivativesTransferAPI interface {
}
Method Support
private/deriv/transfer ⚠️
private/deriv/get-transfer-history ⚠️
Sub-account API
// SubAccountAPI is a Crypto.com Exchange client for Sub-account API.
type SubAccountAPI interface {
}
Method Support
private/subaccount/get-sub-accounts ⚠️
private/subaccount/get-transfer-history ⚠️
private/subaccount/transfer ⚠️
Websocket
// Websocket is a Crypto.com Exchange client websocket methods & channels.
type Websocket interface {
}
Websocket Heartbeats
Method Support
public/respond-heartbeat ⚠️
Websocket Subscriptions
Channel Support
user.order.{instrument_name} ⚠️
user.trade.{instrument_name} ⚠️
user.balance ⚠️
user.margin.order.{instrument_name} ⚠️
user.margin.trade.{instrument_name} ⚠️
user.margin.balance ⚠️
book.{instrument_name}.{depth} ⚠️
ticker.{instrument_name} ⚠️
trade.{instrument_name} ⚠️
candlestick.{interval}.{instrument_name} ⚠️

Errors

Custom errors are returned based on the HTTP status code and reason codes returned in the API response. Official documentation on reason codes can be found here. All errors returned from the client can be found in the errors package.

Custom error handling on client errors can be implemented like so:

import (
    "errors"

    cdcerrors "github.com/sngyai/go-cryptocom/errors"
    cdcexchange "github.com/sngyai/go-cryptocom"
)

...

res, err := client.GetAccountSummary(ctx, "CRO")
if err != nil {
    switch {
    case errors.Is(err, cdcerrors.ErrSystemError):
        // handle system error
    case errors.Is(err, cdcerrors.ErrUnauthorized):
        // handle unauthorized error
    case errors.Is(err, cdcerrors.ErrIllegalIP):
        // handle illegal IP error
    ...

    }

    return err
}

Resoonse errors can also be cast to retrieve the response code and HTTP status code:

import (
    "errors"
    "log"
    
    cdcerrors "github.com/sngyai/go-cryptocom/errors"
    cdcexchange "github.com/sngyai/go-cryptocom"
)

...

res, err := client.GetAccountSummary(ctx, "CRO")
if err != nil {
    var responseError cdcerrors.ResponseError
    if errors.Is(err, &responseError) {
        // response code
        log.Println(responseError.Code)
		
        // HTTP status code
        log.Println(responseError.HTTPStatusCode)

        // underlying error
        log.Println(responseError.Err)
    }
	
    return err
}
Response Codes
Code HTTP Status Client Error Message Code Description
0 200 nil -- Success
10001 500 ErrSystemError SYS_ERROR Malformed request, (E.g. not using application/json for REST)
10002 401 ErrUnauthorized UNAUTHORIZED Not authenticated, or key/signature incorrect
10003 401 ErrIllegalIP IP_ILLEGAL IP address not whitelisted
10004 400 ErrBadRequest BAD_REQUEST Missing required fields
10005 401 ErrUserTierInvalid USER_TIER_INVALID Disallowed based on user tier
10006 429 ErrTooManyRequests TOO_MANY_REQUESTS Requests have exceeded rate limits
10007 400 ErrInvalidNonce INVALID_NONCE Nonce value differs by more than 30 seconds from server
10008 400 ErrMethodNotFound METHOD_NOT_FOUND Invalid method specified
10009 400 ErrInvalidDateRange INVALID_DATE_RANGE Invalid date range
20001 400 ErrDuplicateRecord DUPLICATE_RECORD Duplicated record
20002 400 ErrNegativeBalance NEGATIVE_BALANCE Insufficient balance
30003 400 ErrSymbolNotFound SYMBOL_NOT_FOUND Invalid instrument_name specified
30004 400 ErrSideNotSupported SIDE_NOT_SUPPORTED Invalid side specified
30005 400 ErrOrderTypeNotSupported ORDERTYPE_NOT_SUPPORTED Invalid type specified
30006 400 ErrMinPriceViolated MIN_PRICE_VIOLATED Price is lower than the minimum
30007 400 ErrMaxPriceViolated MAX_PRICE_VIOLATED Price is higher than the maximum
30008 400 ErrMinQuantityViolated MIN_QUANTITY_VIOLATED Quantity is lower than the minimum
30009 400 ErrMaxQuantityViolated MAX_QUANTITY_VIOLATED Quantity is higher than the maximum
30010 400 ErrMissingArgument MISSING_ARGUMENT Required argument is blank or missing
30013 400 ErrInvalidPricePrecision INVALID_PRICE_PRECISION Too many decimal places for Price
30014 400 ErrInvalidQuantityPrecision INVALID_QUANTITY_PRECISION Too many decimal places for Quantity
30016 400 ErrMinNotionalViolated MIN_NOTIONAL_VIOLATED The notional amount is less than the minimum
30017 400 ErrMaxNotionalViolated MAX_NOTIONAL_VIOLATED The notional amount exceeds the maximum
30023 400 ErrMinAmountViolated MIN_AMOUNT_VIOLATED Amount is lower than the minimum
30024 400 ErrMaxAmountViolated MAX_AMOUNT_VIOLATED Amount is higher than the maximum
30025 400 ErrAmountPrecisionOverflow AMOUNT_PRECISION_OVERFLOW Amount precision exceeds the maximum
40001 400 ErrMGInvalidAccountStatus MG_INVALID_ACCOUNT_STATUS Operation has failed due to your account's status. Please try again later.
40002 400 ErrMGTransferActiveLoan MG_TRANSFER_ACTIVE_LOAN Transfer has failed due to holding an active loan. Please repay your loan and try again later.
40003 400 ErrMGInvalidLoanCurrency MG_INVALID_LOAN_CURRENCY Currency is not same as loan currency of active loan
40004 400 ErrMGInvalidRepayAmount MG_INVALID_REPAY_AMOUNT Only supporting full repayment of all margin loans
40005 400 ErrMGNoActiveLoan MG_NO_ACTIVE_LOAN No active loan
40006 400 ErrMGBlockedBorrow MG_BLOCKED_BORROW Borrow has been suspended. Please try again later.
40007 400 ErrMGBlockedNewOrder MG_BLOCKED_NEW_ORDER Placing new order has been suspended. Please try again later.
50001 400 ErrMGCreditLineNotMaintained DW_CREDIT_LINE_NOT_MAINTAINED Please ensure your credit line is maintained and try again later.

Documentation

Index

Constants

View Source
const (
	OrderSideBuy  OrderSide = "BUY"
	OrderSideSell OrderSide = "SELL"

	OrderTypeLimit           OrderType = "LIMIT"
	OrderTypeMarket          OrderType = "MARKET"
	OrderTypeStopLoss        OrderType = "STOP_LOSS"
	OrderTypeStopLimit       OrderType = "STOP_LIMIT"
	OrderTypeTakeProfit      OrderType = "TAKE_PROFIT"
	OrderTypeTakeProfitLimit OrderType = "TAKE_PROFIT_LIMIT"

	TimeInForceGoodTilCancelled  TimeInForce = "GOOD_TILL_CANCEL"
	TimeInForceFillOrKill        TimeInForce = "FILL_OR_KILL"
	TimeInForceImmediateOrCancel TimeInForce = "IMMEDIATE_OR_CANCEL"

	ExecInstPostOnly ExecInst = "POST_ONLY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// Balance is the total balance (Available + Order + Stake).
	Balance float64 `json:"balance"`
	// Available is the available balance (e.g. not in orders, or locked, etc.).
	Available float64 `json:"available"`
	// Order is the balance locked in orders.
	Order float64 `json:"order"`
	// Stake is the balance locked for staking (typically only used for CRO).
	Stake float64 `json:"stake"`
	// Currency is the symbol for the currency (e.g. CRO).
	Currency string `json:"currency"`
}

Account represents balance details of a specific token.

type AccountSummaryResponse

type AccountSummaryResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result AccountSummaryResult `json:"result"`
}

AccountSummaryResponse is the base response returned from the private/get-account-summary API.

type AccountSummaryResult

type AccountSummaryResult struct {
	// Accounts is the returned account data.
	Accounts []Account `json:"accounts"`
}

AccountSummaryResult is the result returned from the private/get-account-summary API.

type BookData

type BookData struct {
	// Bids is an array of bids.
	// [0] = Price, [1] = Quantity, [2] = Number of Orders.
	Bids [][]string `json:"bids"`
	// Asks is an array of asks.
	// [0] = Price, [1] = Quantity, [2] = Number of Orders.
	Asks [][]string `json:"asks"`
	// Timestamp is the timestamp of the data.
	Timestamp time.Time `json:"t"`
}

BookData is the result returned from the public/get-book API.

type BookResponse

type BookResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result BookResult `json:"result"`
}

BookResponse is the base response returned from the public/get-book API when no instrument is specified.

type BookResult

type BookResult struct {
	Depth          int        `json:"depth"`
	Data           []BookData `json:"data"`
	InstrumentName string     `json:"instrument_name"`
}

type CancelAllOrdersResponse

type CancelAllOrdersResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
}

CancelAllOrdersResponse is the base response returned from the private/cancel-all-orders API.

type CancelOrderResponse

type CancelOrderResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
}

CancelOrderResponse is the base response returned from the private/cancel-order API.

type Client

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

Client is a concrete implementation of CryptoDotComExchange.

func New

func New(apiKey string, secretKey string, opts ...ClientOption) (*Client, error)

New will construct a new instance of Client.

func (*Client) CancelAllOrders

func (c *Client) CancelAllOrders(ctx context.Context, instrumentName string) error

CancelAllOrders cancels all orders for a particular instrument/pair.

This call is asynchronous, so the response is simply a confirmation of the request.

The user.order subscription can be used to check when the order is successfully cancelled.

Method: private/cancel-all-orders

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context, instrumentName string, orderID string) error

CancelOrder cancels an existing order on the Exchange.

This call is asynchronous, so the response is simply a confirmation of the request.

The user.order subscription can be used to check when the order is successfully cancelled.

Method: private/cancel-order

func (*Client) CreateOrder

func (c *Client) CreateOrder(ctx context.Context, req CreateOrderRequest) (*CreateOrderResult, error)

CreateOrder creates a new BUY or SELL order on the Exchange.

This call is asynchronous, so the response is simply a confirmation of the request.

The user.order subscription can be used to check when the order is successfully created.

Method: private/create-order

func (*Client) CreateWithdrawal added in v0.3.5

func (c *Client) CreateWithdrawal(ctx context.Context, req CreateWithdrawalRequest) (*CreateWithdrawalResult, error)

CreateWithdrawal gets the withdrawal history for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based). If paging is used, enumerate each page (starting with 0) until an empty withdrawal_list array appears in the response.

req.Timeframe can be left blank to get withdrawals for all instruments.

Method: private/create-withdrawal

func (*Client) GetAccountSummary

func (c *Client) GetAccountSummary(ctx context.Context, currency string) ([]Account, error)

GetAccountSummary returns the account balance of a user for a particular token.

currency can be left blank to retrieve balances for ALL tokens.

Method: private/get-account-summary

func (*Client) GetBook

func (c *Client) GetBook(ctx context.Context, instrument string, depth int) (*BookResult, error)

GetBook fetches the public order book for a particular instrument and depth.

Method: public/get-book

func (*Client) GetDepositAddress added in v0.3.5

func (c *Client) GetDepositAddress(ctx context.Context, req GetDepositAddressRequest) ([]DepositAddress, error)

GetDepositAddress gets the deposit address for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based). If paging is used, enumerate each page (starting with 0) until an empty deposit_list array appears in the response.

req.Timeframe can be left blank to get deposits for all instruments.

Method: private/get-deposit-address

func (*Client) GetDepositHistory added in v0.3.2

func (c *Client) GetDepositHistory(ctx context.Context, req GetDepositHistoryRequest) ([]Deposit, error)

GetDepositHistory gets the deposit history for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based). If paging is used, enumerate each page (starting with 0) until an empty deposit_list array appears in the response.

req.Timeframe can be left blank to get deposits for all instruments.

Method: private/get-deposit-history

func (*Client) GetInstruments

func (c *Client) GetInstruments(ctx context.Context) ([]Instrument, error)

GetInstruments provides information on all supported instruments (e.g. BTC_USDT).

Method: public/get-instruments

func (*Client) GetOpenOrders

func (c *Client) GetOpenOrders(ctx context.Context, req GetOpenOrdersRequest) (*GetOpenOrdersResult, error)

GetOpenOrders gets all open orders for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).

req.Timeframe can be left blank to get open orders for all instruments.

Method: private/get-open-orders

func (*Client) GetOrderDetail

func (c *Client) GetOrderDetail(ctx context.Context, orderID string) (*GetOrderDetailResult, error)

GetOrderDetail gets details of an order for a particular order ID.

Method: private/get-order-detail

func (*Client) GetOrderHistory

func (c *Client) GetOrderHistory(ctx context.Context, req GetOrderHistoryRequest) ([]Order, error)

GetOrderHistory gets the order history for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based). If paging is used, enumerate each page (starting with 0) until an empty order_list array appears in the response.

req.Timeframe can be left blank to get orders for all instruments.

Method: private/get-order-history

func (*Client) GetTickers

func (c *Client) GetTickers(ctx context.Context, instrument string) ([]Ticker, error)

GetTickers fetches the public tickers for an instrument (e.g. BTC_USDT).

instrument can be left blank to retrieve tickers for ALL instruments.

Method: public/get-ticker

func (*Client) GetTrades

func (c *Client) GetTrades(ctx context.Context, req GetTradesRequest) ([]Trade, error)

GetTrades gets all executed trades for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based). If paging is used, enumerate each page (starting with 0) until an empty trade_list array appears in the response.

req.Timeframe can be left blank to get executed trades for all instruments.

Method: private/get-trades

func (*Client) GetWithdrawalHistory added in v0.3.2

func (c *Client) GetWithdrawalHistory(ctx context.Context, req GetWithdrawalHistoryRequest) ([]Withdrawal, error)

GetWithdrawalHistory gets the withdrawal history for a particular instrument.

Pagination is handled using page size (Default: 20, Max: 200) & number (0-based). If paging is used, enumerate each page (starting with 0) until an empty withdrawal_list array appears in the response.

req.Timeframe can be left blank to get withdrawals for all instruments.

Method: private/get-withdrawal-history

func (*Client) UpdateConfig

func (c *Client) UpdateConfig(apiKey string, secretKey string, opts ...ClientOption) error

UpdateConfig can be used to update the configuration of the Client object. (e.g. change api key, secret key, environment, etc).

func (*Client) UserBalanceHistory added in v0.3.7

func (c *Client) UserBalanceHistory(ctx context.Context, req UserBalanceHistoryRequest) (*UserBalanceHistoryResult, error)

UserBalanceHistory gets all executed trades for a particular instrument. Method: private/user-balance-history

type ClientOption

type ClientOption func(*Client) error

ClientOption represents optional configurations for the Client.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient will allow the Client to be initialised with a custom http Client. Can be used to create custom timeouts, enable tracing, etc.

func WithProductionEnvironment

func WithProductionEnvironment() ClientOption

WithProductionEnvironment will initialise the Client to make requests against the production environment. This is the default setting.

func WithUATEnvironment

func WithUATEnvironment() ClientOption

WithUATEnvironment will initialise the Client to make requests against the UAT sandbox environment.

type CommonAPI

type CommonAPI interface {
	// GetInstruments provides information on all supported instruments (e.g. BTC_USDT).
	//
	// Method: public/get-instruments
	GetInstruments(ctx context.Context) ([]Instrument, error)
	// GetBook fetches the public order book for a particular instrument and depth.
	//
	// Method: public/get-book
	GetBook(ctx context.Context, instrument string, depth int) (*BookResult, error)
	// GetTickers fetches the public tickers for an instrument (e.g. BTC_USDT).
	//
	// instrument can be left blank to retrieve tickers for ALL instruments.
	//
	// Method: public/get-ticker
	GetTickers(ctx context.Context, instrument string) ([]Ticker, error)
}

CommonAPI is a Crypto.com Exchange Client for Common API.

type CreateOrderRequest

type CreateOrderRequest struct {
	// InstrumentName represents the currency pair to trade (e.g. ETH_CRO or BTC_USDT).
	InstrumentName string `json:"instrument_name"`
	// Side represents whether the order is buy or sell.
	Side OrderSide `json:"side"`
	// Type represents the type of order.
	Type OrderType `json:"type"`
	// Price determines the price of which the trade should be executed.
	// For LIMIT and STOP_LIMIT orders only.
	Price float64 `json:"price"`
	// Quantity is the quantity to be sold
	// For LIMIT, MARKET, STOP_LOSS, TAKE_PROFIT orders only.
	Quantity float64 `json:"quantity"`
	// Notional is the amount to spend.
	// For MARKET (BUY), STOP_LOSS (BUY), TAKE_PROFIT (BUY) orders only.
	Notional float64 `json:"notional"`
	// ClientOID is the optional Client order ID.
	ClientOID string `json:"client_oid"`
	// TimeInForce represents how long the order should be active before being cancelled.
	// (Limit Orders Only) Options are:
	//  - GOOD_TILL_CANCEL (Default if unspecified)
	//  - FILL_OR_KILL
	//  - IMMEDIATE_OR_CANCEL
	TimeInForce TimeInForce `json:"time_in_force"`
	// (Limit Orders Only) Options are:
	// - POST_ONLY
	// - Or leave empty
	ExecInst ExecInst `json:"exec_inst"`
	// TriggerPrice is the price at which the order is triggered.
	// Used with STOP_LOSS, STOP_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
	TriggerPrice float64 `json:"trigger_price"`
}

CreateOrderRequest is the request params sent for the private/create-order API. Mandatory parameters based on order type: ------------------+------+----------------------------------------- Type | Side | Additional Mandatory Parameters ------------------+------+----------------------------------------- LIMIT | Both | quantity, price MARKET | BUY | notional or quantity, mutually exclusive MARKET | SELL | quantity STOP_LIMIT | Both | price, quantity, trigger_price TAKE_PROFIT_LIMIT | Both | price, quantity, trigger_price STOP_LOSS | BUY | notional, trigger_price STOP_LOSS | SELL | quantity, trigger_price TAKE_PROFIT | BUY | notional, trigger_price TAKE_PROFIT | SELL | quantity, trigger_price ------------------+------+-----------------------------------------

type CreateOrderResponse

type CreateOrderResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result CreateOrderResult `json:"result"`
}

CreateOrderResponse is the base response returned from the private/create-order API.

type CreateOrderResult

type CreateOrderResult struct {
	// OrderID is the newly created order ID.
	OrderID string `json:"order_id"`
	// ClientOID is the optional Client order ID (if provided in request).
	ClientOID string `json:"client_oid"`
}

CreateOrderResult is the result returned from the private/create-order API.

type CreateWithdrawalRequest added in v0.3.5

type CreateWithdrawalRequest struct {
	// Currency represents the currency symbol for the withdrawals (e.g. BTC or ETH).
	// if Currency is omitted, all currencies will be returned.
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
	Address  string  `json:"address"`

	ClientWid  string `json:"client_wid"`
	AddressTag string `json:"address_tag"`
	NetworkId  string `json:"network_id"`
}

CreateWithdrawalRequest is the request params sent for the private/create-withdrawal API.

The maximum duration between Start and EndTime is 24 hours.

You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.

For users looking to pull longer historical withdrawal data, users can create a loop to make a request for each 24-period from the desired start to end time.

type CreateWithdrawalResponse added in v0.3.5

type CreateWithdrawalResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result CreateWithdrawalResult `json:"result"`
}

CreateWithdrawalResponse is the base response returned from the private/create-withdrawal API.

type CreateWithdrawalResult added in v0.3.5

type CreateWithdrawalResult struct {
	Id         int64   `json:"id"`
	Amount     float64 `json:"amount"`
	Fee        float64 `json:"fee"`
	Symbol     string  `json:"symbol"`
	Address    string  `json:"address"`
	ClientWid  string  `json:"client_wid"`
	CreateTime int64   `json:"create_time"`
	NetworkId  string  `json:"network_id"`
}

CreateWithdrawalResult is the result returned from the private/create-withdrawal API.

type CryptoDotComExchange

type CryptoDotComExchange interface {
	// UpdateConfig can be used to update the configuration of the Client object.
	// (e.g. change api key, secret key, environment, etc).
	UpdateConfig(apiKey string, secretKey string, opts ...ClientOption) error
	CommonAPI
	SpotTradingAPI
	MarginTradingAPI
	DerivativesTransferAPI
	SubAccountAPI
	Websocket
}

CryptoDotComExchange is a Crypto.com Exchange Client for all available APIs.

type Deposit added in v0.3.2

type Deposit struct {
	Currency   string  `json:"currency"`
	Fee        float64 `json:"fee"`
	CreateTime int64   `json:"create_time"`
	Id         string  `json:"id"`
	UpdateTime int64   `json:"update_time"`
	Amount     float64 `json:"amount"`
	Address    string  `json:"address"`
	Status     string  `json:"status"`
}

type DepositAddress added in v0.3.5

type DepositAddress struct {
	Currency   string `json:"currency"`
	CreateTime int64  `json:"create_time"`
	Id         string `json:"id"`
	Address    string `json:"address"`
	Status     string `json:"status"`
	Network    string `json:"network"`
}

type DerivativesTransferAPI

type DerivativesTransferAPI interface {
}

DerivativesTransferAPI is a Crypto.com Exchange Client for Derivatives Transfer API.

type Environment

type Environment string

Environment represents the environment against which calls are made.

const (
	EnvironmentUATSandbox Environment = "uat_sandbox"
	EnvironmentProduction Environment = "production"
)

type ExecInst

type ExecInst string

ExecInst for Limit Orders Only (POST_ONLY or left blank).

type GetDepositAddressRequest added in v0.3.5

type GetDepositAddressRequest struct {
	// Currency represents the currency symbol for the deposits (e.g. BTC or ETH).
	// if Currency is omitted, all currencies will be returned.
	Currency string `json:"currency"`
}

GetDepositAddressRequest is the request params sent for the private/get-deposit-address API.

The maximum duration between Start and EndTime is 24 hours.

You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.

For users looking to pull longer historical deposit data, users can create a loop to make a request for each 24-period from the desired start to end time.

type GetDepositAddressResponse added in v0.3.5

type GetDepositAddressResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetDepositAddressResult `json:"result"`
}

GetDepositAddressResponse is the base response returned from the private/get-deposit-address API.

type GetDepositAddressResult added in v0.3.5

type GetDepositAddressResult struct {
	// DepositList is the array of deposits.
	DepositAddressList []DepositAddress `json:"deposit_address_list"`
}

GetDepositAddressResult is the result returned from the private/get-deposit-address API.

type GetDepositHistoryRequest added in v0.3.2

type GetDepositHistoryRequest struct {
	// Currency represents the currency symbol for the deposits (e.g. BTC or ETH).
	// if Currency is omitted, all currencies will be returned.
	Currency string `json:"currency"`
	// Start is the start timestamp (milliseconds since the Unix epoch)
	// (Default: 24 hours ago)
	Start time.Time `json:"start_ts"`
	// End is the end timestamp (milliseconds since the Unix epoch)
	// (Default: now)
	End time.Time `json:"end_ts"`
	// PageSize represents maximum number of deposits returned (for pagination)
	// (Default: 20, Max: 200)
	// if PageSize is 0, it will be set as 20 by default.
	PageSize int `json:"page_size"`
	// Page represents the page number (for pagination)
	// (0-based)
	Page int `json:"page"`

	Status string `json:"status"`
}

GetDepositHistoryRequest is the request params sent for the private/get-deposit-history API.

The maximum duration between Start and End is 24 hours.

You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.

For users looking to pull longer historical deposit data, users can create a loop to make a request for each 24-period from the desired start to end time.

type GetDepositHistoryResponse added in v0.3.2

type GetDepositHistoryResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetDepositHistoryResult `json:"result"`
}

GetDepositHistoryResponse is the base response returned from the private/get-deposit-history API.

type GetDepositHistoryResult added in v0.3.2

type GetDepositHistoryResult struct {
	// DepositList is the array of deposits.
	DepositList []Deposit `json:"deposit_list"`
}

GetDepositHistoryResult is the result returned from the private/get-deposit-history API.

type GetOpenOrdersRequest

type GetOpenOrdersRequest struct {
	// InstrumentName represents the currency pair for the orders (e.g. ETH_CRO or BTC_USDT).
	// if InstrumentName is omitted, all instruments will be returned.
	InstrumentName string `json:"instrument_name"`
	// PageSize represents maximum number of orders returned (for pagination)
	// (Default: 20, Max: 200)
	// if PageSize is 0, it will be set as 20 by default.
	PageSize int `json:"page_size"`
	// Page represents the page number (for pagination)
	// (0-based)
	Page int `json:"page"`
}

GetOpenOrdersRequest is the request params sent for the private/get-open-orders API.

type GetOpenOrdersResponse

type GetOpenOrdersResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetOpenOrdersResult `json:"result"`
}

GetOpenOrdersResponse is the base response returned from the private/get-open-orders API.

type GetOpenOrdersResult

type GetOpenOrdersResult struct {
	// Count is the total count of orders.
	Count int `json:"count"`
	// OrderList is the array of open orders.
	OrderList []Order `json:"order_list"`
}

GetOpenOrdersResult is the result returned from the private/get-open-orders API.

type GetOrderDetailResponse

type GetOrderDetailResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetOrderDetailResult `json:"result"`
}

GetOrderDetailResponse is the base response returned from the private/get-order-detail API.

type GetOrderDetailResult

type GetOrderDetailResult struct {
	// TradeList is a list of trades for the order (if any).
	TradeList []Trade `json:"trade_list"`
	// OrderInfo is the detailed information about the order.
	OrderInfo Order `json:"order_info"`
}

GetOrderDetailResult is the result returned from the private/get-order-detail API.

type GetOrderHistoryRequest

type GetOrderHistoryRequest struct {
	// InstrumentName represents the currency pair for the orders (e.g. ETH_CRO or BTC_USDT).
	// if InstrumentName is omitted, all instruments will be returned.
	InstrumentName string `json:"instrument_name"`
	// Start is the start timestamp (milliseconds since the Unix epoch)
	// (Default: 24 hours ago)
	Start time.Time `json:"start_ts"`
	// End is the end timestamp (milliseconds since the Unix epoch)
	// (Default: now)
	End time.Time `json:"end_ts"`
	// PageSize represents maximum number of orders returned (for pagination)
	// (Default: 20, Max: 200)
	// if PageSize is 0, it will be set as 20 by default.
	PageSize int `json:"page_size"`
	// Page represents the page number (for pagination)
	// (0-based)
	Page int `json:"page"`
}

GetOrderHistoryRequest is the request params sent for the private/get-order-history API.

The maximum duration between Start and End is 24 hours.

You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.

For users looking to pull longer historical order data, users can create a loop to make a request for each 24-period from the desired start to end time.

type GetOrderHistoryResponse

type GetOrderHistoryResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetOrderHistoryResult `json:"result"`
}

GetOrderHistoryResponse is the base response returned from the private/get-order-history API.

type GetOrderHistoryResult

type GetOrderHistoryResult struct {
	// OrderList is the array of orders.
	OrderList []Order `json:"order_list"`
}

GetOrderHistoryResult is the result returned from the private/get-order-history API.

type GetTradesRequest

type GetTradesRequest struct {
	// InstrumentName represents the currency pair for the trades (e.g. ETH_CRO or BTC_USDT).
	// if InstrumentName is omitted, all instruments will be returned.
	InstrumentName string `json:"instrument_name"`
	// Start is the start timestamp (milliseconds since the Unix epoch)
	// (Default: 24 hours ago)
	Start time.Time `json:"start_ts"`
	// End is the end timestamp (milliseconds since the Unix epoch)
	// (Default: now)
	End time.Time `json:"end_ts"`
	// PageSize represents maximum number of trades returned (for pagination)
	// (Default: 20, Max: 200)
	// if PageSize is 0, it will be set as 20 by default.
	PageSize int `json:"page_size"`
	// Page represents the page number (for pagination)
	// (0-based)
	Page int `json:"page"`
}

GetTradesRequest is the request params sent for the private/get-trades API.

The maximum duration between Start and End is 24 hours.

You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.

For users looking to pull longer historical trade data, users can create a loop to make a request for each 24-period from the desired start to end time.

type GetTradesResponse

type GetTradesResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetTradesResult `json:"result"`
}

GetTradesResponse is the base response returned from the private/get-trades API.

type GetTradesResult

type GetTradesResult struct {
	// TradeList is the array of trades.
	TradeList []Trade `json:"trade_list"`
}

GetTradesResult is the result returned from the private/get-trades API.

type GetWithdrawalHistoryRequest added in v0.3.2

type GetWithdrawalHistoryRequest struct {
	// Currency represents the currency symbol for the withdrawals (e.g. BTC or ETH).
	// if Currency is omitted, all currencies will be returned.
	Currency string `json:"currency"`
	// Start is the start timestamp (milliseconds since the Unix epoch)
	// (Default: 24 hours ago)
	Start time.Time `json:"start_ts"`
	// End is the end timestamp (milliseconds since the Unix epoch)
	// (Default: now)
	End time.Time `json:"end_ts"`
	// PageSize represents maximum number of withdrawals returned (for pagination)
	// (Default: 20, Max: 200)
	// if PageSize is 0, it will be set as 20 by default.
	PageSize int `json:"page_size"`
	// Page represents the page number (for pagination)
	// (0-based)
	Page int `json:"page"`

	Status string `json:"status"`
}

GetWithdrawalHistoryRequest is the request params sent for the private/get-withdrawal-history API.

The maximum duration between Start and End is 24 hours.

You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.

For users looking to pull longer historical withdrawal data, users can create a loop to make a request for each 24-period from the desired start to end time.

type GetWithdrawalHistoryResponse added in v0.3.2

type GetWithdrawalHistoryResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result GetWithdrawalHistoryResult `json:"result"`
}

GetWithdrawalHistoryResponse is the base response returned from the private/get-withdrawal-history API.

type GetWithdrawalHistoryResult added in v0.3.2

type GetWithdrawalHistoryResult struct {
	// WithdrawalList is the array of withdrawals.
	WithdrawalList []Withdrawal `json:"withdrawal_list"`
}

GetWithdrawalHistoryResult is the result returned from the private/get-withdrawal-history API.

type Instrument

type Instrument struct {
	// InstrumentName represents the name of the instrument (e.g. BTC_USDT).
	InstrumentName string `json:"instrument_name"`
	// QuoteCurrency represents the quote currency (e.g. USDT).
	QuoteCurrency string `json:"quote_currency"`
	// BaseCurrency represents the base currency (e.g. BTC).
	BaseCurrency string `json:"base_currency"`
	// PriceDecimals is the maximum decimal places for specifying price.
	PriceDecimals int `json:"price_decimals"`
	// QuantityDecimals is the maximum decimal places for specifying quantity.
	QuantityDecimals int `json:"quantity_decimals"`
	// MarginTradingEnabled represents whether margin trading is enabled for the instrument.
	MarginTradingEnabled bool `json:"margin_trading_enabled"`
	// MinimumOrderSize represents the minimum order size for the instrument.
	MarginTradingEnabled5X  bool   `json:"margin_trading_enabled_5x"`
	MarginTradingEnabled10X bool   `json:"margin_trading_enabled_10x"`
	MaxQuantity             string `json:"max_quantity"`
	MinQuantity             string `json:"min_quantity"`
	MaxPrice                string `json:"max_price"`
	MinPrice                string `json:"min_price"`
	LastUpdateDate          int64  `json:"last_update_date"`
	QuantityTickSize        string `json:"quantity_tick_size"`
	PriceTickSize           string `json:"price_tick_size"`
}

Instrument represents details of a specific currency pair

type InstrumentResult

type InstrumentResult struct {
	// Instruments is a list of the returned instruments.
	Instruments []Instrument `json:"instruments"`
}

InstrumentResult is the result returned from the public/get-instruments API.

type InstrumentsResponse

type InstrumentsResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result InstrumentResult `json:"result"`
}

InstrumentsResponse is the base response returned from the public/get-instruments API.

type LiquidityIndicator

type LiquidityIndicator string

LiquidityIndicator represents liquidity indicator (MAKER or TAKER).

const (
	LiquidityIndicatorMaker LiquidityIndicator = "MAKER"
	LiquidityIndicatorTaker LiquidityIndicator = "TAKER"
)

type MarginTradingAPI

type MarginTradingAPI interface {
}

MarginTradingAPI is a Crypto.com Exchange Client for Margin Trading API.

type Order

type Order struct {
	// Status is the status of the order, can be ACTIVE, CANCELED, FILLED, REJECTED or EXPIRED.
	Status OrderStatus `json:"status"`
	// Reason is the reason code for rejected orders (see "Response and Reason Codes").
	Reason int64 `json:"reason"`
	// Side represents whether the order is buy or sell.
	Side OrderSide `json:"side"`
	// Price is the price specified in the order.
	Price float64 `json:"price"`
	// Quantity	is the quantity specified in the order.
	Quantity float64 `json:"quantity"`
	// OrderID is the unique identifier for the order.
	OrderID string `json:"order_id"`
	// ClientOID is the optional Client order ID (if provided in request when creating the order).
	ClientOID string `json:"client_oid"`
	// CreateTime is the order creation time.
	CreateTime time.Time `json:"create_time"`
	// UpdateTime is the order update time.
	UpdateTime time.Time `json:"update_time"`
	// Type represents the type of order.
	OrderType OrderType `json:"type"`
	// InstrumentName represents the currency pair to trade (e.g. ETH_CRO or BTC_USDT).
	InstrumentName string `json:"instrument_name"`
	// CumulativeQuantity is the cumulative-executed quantity (for partially filled orders).
	CumulativeQuantity float64 `json:"cumulative_quantity"`
	// CumulativeValue is the cumulative-executed value (for partially filled orders).
	CumulativeValue float64 `json:"cumulative_value"`
	// AvgPrice is the average filled price. If none is filled, 0 is returned.
	AvgPrice float64 `json:"avg_price"`
	// FeeCurrency is the currency used for the fees (e.g. CRO).
	FeeCurrency string `json:"fee_currency"`
	// TimeInForce represents how long the order should be active before being cancelled.
	// (Limit Orders Only) Options are:
	//  - GOOD_TILL_CANCEL (Default if unspecified)
	//  - FILL_OR_KILL
	//  - IMMEDIATE_OR_CANCEL
	TimeInForce TimeInForce `json:"time_in_force"`
	// (Limit Orders Only) Options are:
	// - POST_ONLY
	// - Or leave empty
	ExecInst ExecInst `json:"exec_inst"`
	// TriggerPrice is the price at which the order is triggered.
	// Used with STOP_LOSS, STOP_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
	TriggerPrice float64 `json:"trigger_price"`
}

Order represents the details of a specific order. Note: To detect a 'partial filled' status, look for status as ACTIVE and cumulative_quantity > 0.

type OrderSide

type OrderSide string

OrderSide is the side of the order (BUY/SELL).

type OrderStatus

type OrderStatus string

OrderStatus is the current status of the order.

const (
	OrderStatusActive    OrderStatus = "ACTIVE"
	OrderStatusCancelled OrderStatus = "CANCELED"
	OrderStatusFilled    OrderStatus = "FILLED"
	OrderStatusRejected  OrderStatus = "REJECTED"
	OrderStatusExpired   OrderStatus = "EXPIRED"
)

type OrderType

type OrderType string

OrderType is the type of order (e.g. LIMIT, MARKET, etc).

type SpotTradingAPI

type SpotTradingAPI interface {
	// GetAccountSummary returns the account balance of a user for a particular token.
	//
	// currency can be left blank to retrieve balances for ALL tokens.
	//
	// Method: private/get-account-summary
	GetAccountSummary(ctx context.Context, currency string) ([]Account, error)
	// CreateOrder creates a new BUY or SELL order on the Exchange.
	//
	// This call is asynchronous, so the response is simply a confirmation of the request.
	//
	// The user.order subscription can be used to check when the order is successfully created.
	//
	// Method: private/create-order
	CreateOrder(ctx context.Context, req CreateOrderRequest) (*CreateOrderResult, error)
	// CancelOrder cancels an existing order on the Exchange.
	//
	// This call is asynchronous, so the response is simply a confirmation of the request.
	//
	// The user.order subscription can be used to check when the order is successfully cancelled.
	//
	// Method: private/cancel-order
	CancelOrder(ctx context.Context, instrumentName string, orderID string) error
	// CancelAllOrders cancels  all orders for a particular instrument/pair.
	//
	// This call is asynchronous, so the response is simply a confirmation of the request.
	//
	// The user.order subscription can be used to check when the order is successfully cancelled.
	//
	// Method: private/cancel-all-orders
	CancelAllOrders(ctx context.Context, instrumentName string) error
	// GetOrderHistory gets the order history for a particular instrument.
	//
	// Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).
	// If paging is used, enumerate each page (starting with 0) until an empty order_list array appears in the response.
	//
	// req.Timeframe can be left blank to get open orders for all instruments.
	//
	// Method: private/get-order-history
	GetOrderHistory(ctx context.Context, req GetOrderHistoryRequest) ([]Order, error)
	// GetOpenOrders gets all open orders for a particular instrument.
	//
	// Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).
	//
	// req.Timeframe can be left blank to get open orders for all instruments.
	//
	// Method: private/get-open-orders
	GetOpenOrders(ctx context.Context, req GetOpenOrdersRequest) (*GetOpenOrdersResult, error)
	// GetOrderDetail gets details of an order for a particular order ID.
	//
	// Method: private/get-order-detail
	GetOrderDetail(ctx context.Context, orderID string) (*GetOrderDetailResult, error)
	// GetTrades gets all executed trades for a particular instrument.
	//
	// Pagination is handled using page size (Default: 20, Max: 200) & number (0-based).
	// If paging is used, enumerate each page (starting with 0) until an empty trade_list array appears in the response.
	//
	// req.Timeframe can be left blank to get executed trades for all instruments.
	//
	// Method: private/get-trades
	GetTrades(ctx context.Context, req GetTradesRequest) ([]Trade, error)
}

SpotTradingAPI is a Crypto.com Exchange Client for Spot Trading API.

type SubAccountAPI

type SubAccountAPI interface {
}

SubAccountAPI is a Crypto.com Exchange Client for Sub-account API.

type Ticker

type Ticker struct {
	// Instrument is the instrument name (e.g. BTC_USDT, ETH_CRO, etc).
	Instrument string `json:"i"`
	// BidPrice is the current best bid price, 0 if there aren't any bids.
	BidPrice float64 `json:"b,string"`
	// AskPrice is the current best ask price, 0 if there aren't any asks.
	AskPrice float64 `json:"k,string"`
	// LatestTradePrice is the price of the latest trade, 0 if there weren't any trades.
	LatestTradePrice float64 `json:"a,string"`
	// Timestamp is the timestamp of the data.
	Timestamp time.Time `json:"t"`
	// Volume24H is the total 24h traded volume.
	Volume24H float64 `json:"v,string"`
	// PriceHigh24h is the price of the 24h highest trade, 0 if there weren't any trades.
	PriceHigh24h float64 `json:"h,string"`
	// PriceLow24h is the price of the 24h lowest trade, 0 if there weren't any trades.
	PriceLow24h float64 `json:"l,string"`
	// PriceChange24h is the 24-hour price change, 0 if there weren't any trades.
	PriceChange24h float64 `json:"c,string"`
}

Ticker represents ticker details of a specific currency pair.

type TickerResponse

type TickerResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result TickerResult `json:"result"`
}

TickerResponse is the base response returned from the public/get-ticker API. when no instrument is specified.

type TickerResult

type TickerResult struct {
	// Data is the returned ticker data for all instruments.
	Data []Ticker `json:"data"`
}

TickerResult is the result returned from the public/get-ticker API.

type TimeInForce

type TimeInForce string

TimeInForce represents how long the order should be active before being cancelled.

type Trade

type Trade struct {
	// Side represents whether the trade is buy or sell.
	Side OrderSide `json:"side"`
	// InstrumentName represents the currency pair to trade (e.g. ETH_CRO or BTC_USDT).
	InstrumentName string `json:"instrument_name"`
	// Fee is the trade fee.
	Fee float64 `json:"fee"`
	// TradeID is the unique identifier for the trade.
	TradeID string `json:"trade_id"`
	// CreateTime is the trade creation time.
	CreateTime time.Time `json:"create_time"`
	// TradedPrice is the executed trade price
	TradedPrice float64 `json:"traded_price"`
	// TradedQuantity is the executed trade quantity
	TradedQuantity float64 `json:"traded_quantity"`
	// FeeCurrency is the currency used for the fees (e.g. CRO).
	FeeCurrency string `json:"fee_currency"`
	// OrderID is the unique identifier for the order.
	OrderID string `json:"order_id"`
	// ClientOrderID is the Client order id (if provided in request when creating the order).
	ClientOrderID string `json:"client_order_id"`
	// LiquidityIndicator is the liquidity indicator for the trade (MAKER/TAKER).
	LiquidityIndicator LiquidityIndicator `json:"liquidity_indicator"`
}

Trade represents the details of a specific trade.

type UserBalance added in v0.3.7

type UserBalance struct {
	T int64  `json:"t"`
	C string `json:"c"`
}

type UserBalanceHistoryRequest added in v0.3.7

type UserBalanceHistoryRequest struct {
	Timeframe string    `json:"timeframe"`
	EndTime   time.Time `json:"end_time"`
	Limit     int       `json:"limit"`
}

UserBalanceHistoryRequest is the request params sent for the private/user-balance-history API.

type UserBalanceHistoryResponse added in v0.3.7

type UserBalanceHistoryResponse struct {
	// api.BaseResponse is the common response fields.
	api.BaseResponse
	// Result is the response attributes of the endpoint.
	Result UserBalanceHistoryResult `json:"result"`
}

UserBalanceHistoryResponse is the base response returned from the private/user-balance-history API.

type UserBalanceHistoryResult added in v0.3.7

type UserBalanceHistoryResult struct {
	InstrumentName string        `json:"instrument_name"`
	Data           []UserBalance `json:"data"`
}

UserBalanceHistoryResult is the result returned from the private/user-balance-history API.

type Websocket

type Websocket interface {
}

Websocket is a Crypto.com Exchange Client websocket methods & channels.

type Withdrawal added in v0.3.2

type Withdrawal struct {
	Currency   string      `json:"currency"`
	ClientWid  string      `json:"client_wid"`
	Fee        float64     `json:"fee"`
	CreateTime int64       `json:"create_time"`
	Id         string      `json:"id"`
	UpdateTime int64       `json:"update_time"`
	Amount     float64     `json:"amount"`
	Address    string      `json:"address"`
	Status     string      `json:"status"`
	Txid       string      `json:"txid"`
	NetworkId  interface{} `json:"network_id"`
}

Directories

Path Synopsis
api
id
mocks/id
Package id_mocks is a generated GoMock package.
Package id_mocks is a generated GoMock package.
mocks/signature
Package signature_mocks is a generated GoMock package.
Package signature_mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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