ccxt-go/coinex_wrapper.go
zhangkun9038@dingtalk.com 1a2ce7046a first add
2025-02-28 10:33:20 +08:00

1650 lines
58 KiB
Go

package ccxt
type Coinex struct {
*coinex
Core *coinex
}
func NewCoinex(userConfig map[string]interface{}) Coinex {
p := &coinex{}
p.Init(userConfig)
return Coinex{
coinex: p,
Core: p,
}
}
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
/**
* @method
* @name coinex#fetchMarkets
* @description retrieves data on all markets for coinex
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
func (this *Coinex) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
res := <- this.Core.FetchMarkets(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewMarketInterfaceArray(res), nil
}
func (this *Coinex) FetchSpotMarkets(params interface{}) ([]MarketInterface, error) {
res := <- this.Core.FetchSpotMarkets(params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewMarketInterfaceArray(res), nil
}
func (this *Coinex) FetchContractMarkets(params interface{}) ([]map[string]interface{}, error) {
res := <- this.Core.FetchContractMarkets(params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return res.([]map[string]interface{}), nil
}
/**
* @method
* @name coinex#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
*/
func (this *Coinex) FetchTicker(symbol string, options ...FetchTickerOptions) (Ticker, error) {
opts := FetchTickerOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTicker(symbol, params)
if IsError(res) {
return Ticker{}, CreateReturnError(res)
}
return NewTicker(res), nil
}
/**
* @method
* @name coinex#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
*/
func (this *Coinex) FetchTickers(options ...FetchTickersOptions) (Tickers, error) {
opts := FetchTickersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbols interface{} = nil
if opts.Symbols != nil {
symbols = *opts.Symbols
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTickers(symbols, params)
if IsError(res) {
return Tickers{}, CreateReturnError(res)
}
return NewTickers(res), nil
}
/**
* @method
* @name coinex#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://docs.coinex.com/api/v2/common/http/time
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
func (this *Coinex) FetchTime(params ...interface{}) ( int64, error) {
res := <- this.Core.FetchTime(params...)
if IsError(res) {
return -1, CreateReturnError(res)
}
return (res).(int64), nil
}
/**
* @method
* @name coinex#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-depth
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
*/
func (this *Coinex) FetchOrderBook(symbol string, options ...FetchOrderBookOptions) (OrderBook, error) {
opts := FetchOrderBookOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOrderBook(symbol, limit, params)
if IsError(res) {
return OrderBook{}, CreateReturnError(res)
}
return NewOrderBook(res), nil
}
/**
* @method
* @name coinex#fetchTrades
* @description get the list of the most recent trades for a particular symbol
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-deals
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
*/
func (this *Coinex) FetchTrades(symbol string, options ...FetchTradesOptions) ([]Trade, error) {
opts := FetchTradesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTrades(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTradeArray(res), nil
}
/**
* @method
* @name coinex#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
*/
func (this *Coinex) FetchTradingFee(symbol string, options ...FetchTradingFeeOptions) (TradingFeeInterface, error) {
opts := FetchTradingFeeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTradingFee(symbol, params)
if IsError(res) {
return TradingFeeInterface{}, CreateReturnError(res)
}
return NewTradingFeeInterface(res), nil
}
/**
* @method
* @name coinex#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
*/
func (this *Coinex) FetchTradingFees(params ...interface{}) (TradingFees, error) {
res := <- this.Core.FetchTradingFees(params...)
if IsError(res) {
return TradingFees{}, CreateReturnError(res)
}
return NewTradingFees(res), nil
}
/**
* @method
* @name coinex#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
func (this *Coinex) FetchOHLCV(symbol string, options ...FetchOHLCVOptions) ([]OHLCV, error) {
opts := FetchOHLCVOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var timeframe interface{} = nil
if opts.Timeframe != nil {
timeframe = *opts.Timeframe
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOHLCV(symbol, timeframe, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOHLCVArray(res), nil
}
func (this *Coinex) FetchMarginBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchMarginBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
func (this *Coinex) FetchSpotBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchSpotBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
func (this *Coinex) FetchSwapBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchSwapBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
func (this *Coinex) FetchFinancialBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchFinancialBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
/**
* @method
* @name coinex#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance // spot
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance // swap
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance // margin
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance // financial
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'margin', 'swap', 'financial', or 'spot'
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
*/
func (this *Coinex) FetchBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
/**
* @method
* @name coinex#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
* @see https://docs.coinex.com/api/v2/spot/order/http/put-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) CreateMarketBuyOrderWithCost(symbol string, cost float64, options ...CreateMarketBuyOrderWithCostOptions) (Order, error) {
opts := CreateMarketBuyOrderWithCostOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateMarketBuyOrderWithCost(symbol, cost, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coinex#createOrder
* @description create a trade order
* @see https://docs.coinex.com/api/v2/spot/order/http/put-order
* @see https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/put-order
* @see https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
* @see https://docs.coinex.com/api/v2/futures/position/http/close-position
* @see https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
* @see https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.triggerPrice] price to trigger stop orders
* @param {float} [params.stopLossPrice] price to trigger stop loss orders
* @param {float} [params.takeProfitPrice] price to trigger take profit orders
* @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK', 'PO'
* @param {boolean} [params.postOnly] set to true if you wish to make a post only order
* @param {boolean} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) CreateOrder(symbol string, typeVar string, side string, amount float64, options ...CreateOrderOptions) (Order, error) {
opts := CreateOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var price interface{} = nil
if opts.Price != nil {
price = *opts.Price
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateOrder(symbol, typeVar, side, amount, price, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coinex#createOrders
* @description create a list of trade orders (all orders should be of the same symbol)
* @see https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
* @see https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
* @see https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-order
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
* @param {object} [params] extra parameters specific to the api endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) CreateOrders(orders []OrderRequest, options ...CreateOrdersOptions) ([]Order, error) {
opts := CreateOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateOrders(orders, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coinex#cancelOrders
* @description cancel multiple orders
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] set to true for canceling stop orders
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) CancelOrders(ids interface{}, options ...CancelOrdersOptions) ([]map[string]interface{}, error) {
opts := CancelOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CancelOrders(ids, symbol, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return res.([]map[string]interface{}), nil
}
/**
* @method
* @name coinex#editOrder
* @description edit a trade order
* @see https://docs.coinex.com/api/v2/spot/order/http/edit-order
* @see https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/edit-order
* @see https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
* @param {string} id order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of the currency you want to trade in units of the base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.triggerPrice] the price to trigger stop orders
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) EditOrder(id string, symbol string, typeVar string, side string, options ...EditOrderOptions) (Order, error) {
opts := EditOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var amount interface{} = nil
if opts.Amount != nil {
amount = *opts.Amount
}
var price interface{} = nil
if opts.Price != nil {
price = *opts.Price
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.EditOrder(id, symbol, typeVar, side, amount, price, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coinex#cancelOrder
* @description cancels an open order
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-order
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-order
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] client order id, defaults to id if not passed
* @param {boolean} [params.trigger] set to true for canceling a trigger order
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) CancelOrder(id string, options ...CancelOrderOptions) (Order, error) {
opts := CancelOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CancelOrder(id, symbol, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coinex#cancelAllOrders
* @description cancel all open orders in a market
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
* @param {string} symbol unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' for canceling spot margin orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) CancelAllOrders(options ...CancelAllOrdersOptions) ([]Order, error) {
opts := CancelAllOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CancelAllOrders(symbol, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coinex#fetchOrder
* @description fetches information on an order made by the user
* @see https://docs.coinex.com/api/v2/spot/order/http/get-order-status
* @see https://docs.coinex.com/api/v2/futures/order/http/get-order-status
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) FetchOrder(id string, options ...FetchOrderOptions) (Order, error) {
opts := FetchOrderOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOrder(id, symbol, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coinex#fetchOrdersByStatus
* @description fetch a list of orders
* @see https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
* @see https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
* @see https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
* @param {string} status order status to fetch for
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @param {string} [params.marginMode] 'cross' or 'isolated' for fetching spot margin orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) FetchOrdersByStatus(status interface{}, options ...FetchOrdersByStatusOptions) ([]Order, error) {
opts := FetchOrdersByStatusOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOrdersByStatus(status, symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coinex#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
* @see https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
* @see https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @param {string} [params.marginMode] 'cross' or 'isolated' for fetching spot margin orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) FetchOpenOrders(options ...FetchOpenOrdersOptions) ([]Order, error) {
opts := FetchOpenOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchOpenOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coinex#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
* @see https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
* @see https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
* @see https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @param {string} [params.marginMode] 'cross' or 'isolated' for fetching spot margin orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coinex) FetchClosedOrders(options ...FetchClosedOrdersOptions) ([]Order, error) {
opts := FetchClosedOrdersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchClosedOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coinex#createDepositAddress
* @description create a currency deposit address
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] the blockchain network to create a deposit address on
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
*/
func (this *Coinex) CreateDepositAddress(code string, options ...CreateDepositAddressOptions) (DepositAddress, error) {
opts := CreateDepositAddressOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateDepositAddress(code, params)
if IsError(res) {
return DepositAddress{}, CreateReturnError(res)
}
return NewDepositAddress(res), nil
}
/**
* @method
* @name coinex#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] the blockchain network to create a deposit address on
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
*/
func (this *Coinex) FetchDepositAddress(code string, options ...FetchDepositAddressOptions) (DepositAddress, error) {
opts := FetchDepositAddressOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchDepositAddress(code, params)
if IsError(res) {
return DepositAddress{}, CreateReturnError(res)
}
return NewDepositAddress(res), nil
}
/**
* @method
* @name coinex#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.coinex.com/api/v2/spot/deal/http/list-user-deals
* @see https://docs.coinex.com/api/v2/futures/deal/http/list-user-deals
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trade structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest trades
* @param {string} [params.side] the side of the trades, either 'buy' or 'sell', required for swap
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
*/
func (this *Coinex) FetchMyTrades(options ...FetchMyTradesOptions) ([]Trade, error) {
opts := FetchMyTradesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchMyTrades(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTradeArray(res), nil
}
/**
* @method
* @name coinex#fetchPositions
* @description fetch all open positions
* @see https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
* @see https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.method] the method to use 'v2PrivateGetFuturesPendingPosition' or 'v2PrivateGetFuturesFinishedPosition' default is 'v2PrivateGetFuturesPendingPosition'
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Coinex) FetchPositions(options ...FetchPositionsOptions) ([]Position, error) {
opts := FetchPositionsOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbols interface{} = nil
if opts.Symbols != nil {
symbols = *opts.Symbols
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchPositions(symbols, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewPositionArray(res), nil
}
/**
* @method
* @name coinex#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
* @param {string} symbol unified market symbol of the market the position is held in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Coinex) FetchPosition(symbol string, options ...FetchPositionOptions) (Position, error) {
opts := FetchPositionOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchPosition(symbol, params)
if IsError(res) {
return Position{}, CreateReturnError(res)
}
return NewPosition(res), nil
}
/**
* @method
* @name coinex#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
* @param {string} marginMode 'cross' or 'isolated'
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} params.leverage the rate of leverage
* @returns {object} response from the exchange
*/
func (this *Coinex) SetMarginMode(marginMode string, options ...SetMarginModeOptions) (map[string]interface{}, error) {
opts := SetMarginModeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.SetMarginMode(marginMode, symbol, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name coinex#setLeverage
* @see https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
* @description set the level of leverage for a market
* @param {float} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' (default is 'cross')
* @returns {object} response from the exchange
*/
func (this *Coinex) SetLeverage(leverage int64, options ...SetLeverageOptions) (map[string]interface{}, error) {
opts := SetLeverageOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.SetLeverage(leverage, symbol, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name coinex#fetchLeverageTiers
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
*/
func (this *Coinex) FetchLeverageTiers(options ...FetchLeverageTiersOptions) (LeverageTiers, error) {
opts := FetchLeverageTiersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbols interface{} = nil
if opts.Symbols != nil {
symbols = *opts.Symbols
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchLeverageTiers(symbols, params)
if IsError(res) {
return LeverageTiers{}, CreateReturnError(res)
}
return NewLeverageTiers(res), nil
}
/**
* @method
* @name coinex#fetchFundingHistory
* @description fetch the history of funding fee payments paid and received on this account
* @see https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch funding history for
* @param {int} [limit] the maximum number of funding history structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
*/
func (this *Coinex) FetchFundingHistory(options ...FetchFundingHistoryOptions) ([]FundingHistory, error) {
opts := FetchFundingHistoryOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchFundingHistory(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewFundingHistoryArray(res), nil
}
/**
* @method
* @name coinex#fetchFundingRate
* @description fetch the current funding rate
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
*/
func (this *Coinex) FetchFundingRate(symbol string, options ...FetchFundingRateOptions) (FundingRate, error) {
opts := FetchFundingRateOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchFundingRate(symbol, params)
if IsError(res) {
return FundingRate{}, CreateReturnError(res)
}
return NewFundingRate(res), nil
}
/**
* @method
* @name coinex#fetchFundingInterval
* @description fetch the current funding rate interval
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
*/
func (this *Coinex) FetchFundingInterval(symbol string, options ...FetchFundingIntervalOptions) (FundingRate, error) {
opts := FetchFundingIntervalOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchFundingInterval(symbol, params)
if IsError(res) {
return FundingRate{}, CreateReturnError(res)
}
return NewFundingRate(res), nil
}
/**
* @method
* @name coinex#fetchFundingRates
* @description fetch the current funding rates for multiple markets
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
* @param {string[]} symbols unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
*/
func (this *Coinex) FetchFundingRates(options ...FetchFundingRatesOptions) (FundingRates, error) {
opts := FetchFundingRatesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbols interface{} = nil
if opts.Symbols != nil {
symbols = *opts.Symbols
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchFundingRates(symbols, params)
if IsError(res) {
return FundingRates{}, CreateReturnError(res)
}
return NewFundingRates(res), nil
}
/**
* @method
* @name coinex#withdraw
* @description make a withdrawal
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] unified network code
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Coinex) Withdraw(code string, amount float64, address string, options ...WithdrawOptions) (Transaction, error) {
opts := WithdrawOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var tag interface{} = nil
if opts.Tag != nil {
tag = *opts.Tag
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.Withdraw(code, amount, address, tag, params)
if IsError(res) {
return Transaction{}, CreateReturnError(res)
}
return NewTransaction(res), nil
}
/**
* @method
* @name coinex#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {int} [params.until] timestamp in ms of the latest funding rate
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
*/
func (this *Coinex) FetchFundingRateHistory(options ...FetchFundingRateHistoryOptions) ([]FundingRateHistory, error) {
opts := FetchFundingRateHistoryOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchFundingRateHistory(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewFundingRateHistoryArray(res), nil
}
/**
* @method
* @name coinex#transfer
* @description transfer currency internally between wallets on the same account
* @see https://docs.coinex.com/api/v2/assets/transfer/http/transfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.symbol] unified ccxt symbol, required when either the fromAccount or toAccount is margin
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Coinex) Transfer(code string, amount float64, fromAccount string, toAccount string, options ...TransferOptions) (TransferEntry, error) {
opts := TransferOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.Transfer(code, amount, fromAccount, toAccount, params)
if IsError(res) {
return TransferEntry{}, CreateReturnError(res)
}
return NewTransferEntry(res), nil
}
/**
* @method
* @name coinex#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfer structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' for fetching transfers to and from your margin account
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Coinex) FetchTransfers(options ...FetchTransfersOptions) ([]TransferEntry, error) {
opts := FetchTransfersOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTransfers(code, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTransferEntryArray(res), nil
}
/**
* @method
* @name coinex#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
* @param {string} [code] unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawal structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Coinex) FetchWithdrawals(options ...FetchWithdrawalsOptions) ([]Transaction, error) {
opts := FetchWithdrawalsOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchWithdrawals(code, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTransactionArray(res), nil
}
/**
* @method
* @name coinex#fetchDeposits
* @description fetch all deposits made to an account
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
* @param {string} [code] unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposit structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Coinex) FetchDeposits(options ...FetchDepositsOptions) ([]Transaction, error) {
opts := FetchDepositsOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchDeposits(code, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTransactionArray(res), nil
}
/**
* @method
* @name coinex#fetchIsolatedBorrowRate
* @description fetch the rate of interest to borrow a currency for margin trading
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
* @param {string} symbol unified symbol of the market to fetch the borrow rate for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.code unified currency code
* @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
*/
func (this *Coinex) FetchIsolatedBorrowRate(symbol string, options ...FetchIsolatedBorrowRateOptions) (IsolatedBorrowRate, error) {
opts := FetchIsolatedBorrowRateOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchIsolatedBorrowRate(symbol, params)
if IsError(res) {
return IsolatedBorrowRate{}, CreateReturnError(res)
}
return NewIsolatedBorrowRate(res), nil
}
/**
* @method
* @name coinex#fetchBorrowInterest
* @description fetch the interest owed by the user for borrowing currency for margin trading
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
* @param {string} [code] unified currency code
* @param {string} [symbol] unified market symbol when fetch interest in isolated markets
* @param {int} [since] the earliest time in ms to fetch borrrow interest for
* @param {int} [limit] the maximum number of structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
*/
func (this *Coinex) FetchBorrowInterest(options ...FetchBorrowInterestOptions) ([]BorrowInterest, error) {
opts := FetchBorrowInterestOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchBorrowInterest(code, symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewBorrowInterestArray(res), nil
}
/**
* @method
* @name coinex#fetchDepositWithdrawFee
* @description fetch the fee for deposits and withdrawals
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
*/
func (this *Coinex) FetchDepositWithdrawFee(code string, options ...FetchDepositWithdrawFeeOptions) (map[string]interface{}, error) {
opts := FetchDepositWithdrawFeeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchDepositWithdrawFee(code, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name coinex#fetchLeverage
* @description fetch the set leverage for a market
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.code unified currency code
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
*/
func (this *Coinex) FetchLeverage(symbol string, options ...FetchLeverageOptions) (Leverage, error) {
opts := FetchLeverageOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchLeverage(symbol, params)
if IsError(res) {
return Leverage{}, CreateReturnError(res)
}
return NewLeverage(res), nil
}
/**
* @method
* @name coinex#fetchPositionHistory
* @description fetches historical positions
* @see https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
* @param {string} symbol unified contract symbol
* @param {int} [since] the earliest time in ms to fetch positions for
* @param {int} [limit] the maximum amount of records to fetch, default is 10
* @param {object} [params] extra parameters specific to the exchange api endpoint
* @param {int} [params.until] the latest time in ms to fetch positions for
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Coinex) FetchPositionHistory(symbol string, options ...FetchPositionHistoryOptions) ([]Position, error) {
opts := FetchPositionHistoryOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchPositionHistory(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewPositionArray(res), nil
}
/**
* @method
* @name coinex#fetchMarginAdjustmentHistory
* @description fetches the history of margin added or reduced from contract isolated positions
* @see https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
* @param {string} symbol unified market symbol
* @param {string} [type] not used by coinex fetchMarginAdjustmentHistory
* @param {int} [since] timestamp in ms of the earliest change to fetch
* @param {int} [limit] the maximum amount of changes to fetch, default is 10
* @param {object} params extra parameters specific to the exchange api endpoint
* @param {int} [params.until] timestamp in ms of the latest change to fetch
* @param {int} [params.positionId] the id of the position that you want to retrieve margin adjustment history for
* @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
*/
func (this *Coinex) FetchMarginAdjustmentHistory(options ...FetchMarginAdjustmentHistoryOptions) ([]MarginModification, error) {
opts := FetchMarginAdjustmentHistoryOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbol interface{} = nil
if opts.Symbol != nil {
symbol = *opts.Symbol
}
var typeVar interface{} = nil
if opts.Type != nil {
typeVar = *opts.Type
}
var since interface{} = nil
if opts.Since != nil {
since = *opts.Since
}
var limit interface{} = nil
if opts.Limit != nil {
limit = *opts.Limit
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchMarginAdjustmentHistory(symbol, typeVar, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewMarginModificationArray(res), nil
}