Documentation ¶
Index ¶
- Constants
- type Account
- type AccountSummaryResponse
- type AccountSummaryResult
- type BookData
- type BookResponse
- type BookResult
- type CancelAllOrdersResponse
- type CancelOrderResponse
- type Client
- func (c *Client) CancelAllOrders(ctx context.Context, instrumentName string) error
- func (c *Client) CancelOrder(ctx context.Context, instrumentName string, orderID string) error
- func (c *Client) CreateOrder(ctx context.Context, req CreateOrderRequest) (*CreateOrderResult, error)
- func (c *Client) CreateWithdrawal(ctx context.Context, req CreateWithdrawalRequest) (*CreateWithdrawalResult, error)
- func (c *Client) GetAccountSummary(ctx context.Context, currency string) ([]Account, error)
- func (c *Client) GetBook(ctx context.Context, instrument string, depth int) (*BookResult, error)
- func (c *Client) GetDepositAddress(ctx context.Context, req GetDepositAddressRequest) ([]DepositAddress, error)
- func (c *Client) GetDepositHistory(ctx context.Context, req GetDepositHistoryRequest) ([]Deposit, error)
- func (c *Client) GetInstruments(ctx context.Context) ([]Instrument, error)
- func (c *Client) GetOpenOrders(ctx context.Context, req GetOpenOrdersRequest) (*GetOpenOrdersResult, error)
- func (c *Client) GetOrderDetail(ctx context.Context, orderID string) (*GetOrderDetailResult, error)
- func (c *Client) GetOrderHistory(ctx context.Context, req GetOrderHistoryRequest) ([]Order, error)
- func (c *Client) GetTickers(ctx context.Context, instrument string) ([]Ticker, error)
- func (c *Client) GetTrades(ctx context.Context, req GetTradesRequest) ([]Trade, error)
- func (c *Client) GetWithdrawalHistory(ctx context.Context, req GetWithdrawalHistoryRequest) ([]Withdrawal, error)
- func (c *Client) UpdateConfig(apiKey string, secretKey string, opts ...ClientOption) error
- func (c *Client) UserBalanceHistory(ctx context.Context, req UserBalanceHistoryRequest) (*UserBalanceHistoryResult, error)
- type ClientOption
- type CommonAPI
- type CreateOrderRequest
- type CreateOrderResponse
- type CreateOrderResult
- type CreateWithdrawalRequest
- type CreateWithdrawalResponse
- type CreateWithdrawalResult
- type CryptoDotComExchange
- type Deposit
- type DepositAddress
- type DerivativesTransferAPI
- type Environment
- type ExecInst
- type GetDepositAddressRequest
- type GetDepositAddressResponse
- type GetDepositAddressResult
- type GetDepositHistoryRequest
- type GetDepositHistoryResponse
- type GetDepositHistoryResult
- type GetOpenOrdersRequest
- type GetOpenOrdersResponse
- type GetOpenOrdersResult
- type GetOrderDetailResponse
- type GetOrderDetailResult
- type GetOrderHistoryRequest
- type GetOrderHistoryResponse
- type GetOrderHistoryResult
- type GetTradesRequest
- type GetTradesResponse
- type GetTradesResult
- type GetWithdrawalHistoryRequest
- type GetWithdrawalHistoryResponse
- type GetWithdrawalHistoryResult
- type Instrument
- type InstrumentResult
- type InstrumentsResponse
- type LiquidityIndicator
- type MarginTradingAPI
- type Order
- type OrderSide
- type OrderStatus
- type OrderType
- type SpotTradingAPI
- type SubAccountAPI
- type Ticker
- type TickerResponse
- type TickerResult
- type TimeInForce
- type Trade
- type UserBalance
- type UserBalanceHistoryRequest
- type UserBalanceHistoryResponse
- type UserBalanceHistoryResult
- type Websocket
- type Withdrawal
Constants ¶
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 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetOrderDetail gets details of an order for a particular order ID.
Method: private/get-order-detail
func (*Client) GetOrderHistory ¶
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 ¶
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 ¶
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 ¶
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 DepositAddress ¶ added in v0.3.5
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 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 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 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 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"` }