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

1631 lines
60 KiB
Go

package ccxt
type Coincatch struct {
*coincatch
Core *coincatch
}
func NewCoincatch(userConfig map[string]interface{}) Coincatch {
p := &coincatch{}
p.Init(userConfig)
return Coincatch{
coincatch: 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 coincatch#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://coincatch.github.io/github.io/en/spot/#get-server-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 *Coincatch) FetchTime(params ...interface{}) ( int64, error) {
res := <- this.Core.FetchTime(params...)
if IsError(res) {
return -1, CreateReturnError(res)
}
return (res).(int64), nil
}
/**
* @method
* @name coincatch#fetchMarkets
* @description retrieves data on all markets for the exchange
* @see https://coincatch.github.io/github.io/en/spot/#get-all-tickers
* @see https://coincatch.github.io/github.io/en/mix/#get-all-symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
func (this *Coincatch) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
res := <- this.Core.FetchMarkets(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewMarketInterfaceArray(res), nil
}
/**
* @method
* @name coincatch#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://coincatch.github.io/github.io/en/spot/#get-single-ticker
* @see https://coincatch.github.io/github.io/en/mix/#get-single-symbol-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 *Coincatch) 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 coincatch#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://coincatch.github.io/github.io/en/spot/#get-all-tickers
* @see https://coincatch.github.io/github.io/en/mix/#get-all-symbol-ticker
* @param {string[]} [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
* @param {string} [params.type] 'spot' or 'swap' (default 'spot')
* @param {string} [params.productType] 'umcbl' or 'dmcbl' (default 'umcbl') - USDT perpetual contract or Universal margin perpetual contract
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
*/
func (this *Coincatch) 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 coincatch#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://coincatch.github.io/github.io/en/spot/#get-merged-depth-data
* @see https://coincatch.github.io/github.io/en/mix/#get-merged-depth-data
* @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 (maximum and default value is 100)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.precision] 'scale0' (default), 'scale1', 'scale2' or 'scale3' - price accuracy, according to the selected accuracy as the step size to return the cumulative depth
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
*/
func (this *Coincatch) 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 coincatch#fetchOHLCV
* @see https://coincatch.github.io/github.io/en/spot/#get-candle-data
* @see https://coincatch.github.io/github.io/en/mix/#get-candle-data
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @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 (default 100)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
* @param {string} [params.price] "mark" for mark price candles
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
func (this *Coincatch) 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
}
/**
* @method
* @name coincatch#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://coincatch.github.io/github.io/en/spot/#get-recent-trades
* @see https://coincatch.github.io/github.io/en/mix/#get-fills
* @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
* @param {int} [params.until] timestamp in ms of the latest entry to fetch
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
*/
func (this *Coincatch) 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 coincatch#fetchFundingRate
* @description fetch the current funding rate
* @see https://coincatch.github.io/github.io/en/mix/#get-current-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 *Coincatch) 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 coincatch#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://coincatch.github.io/github.io/en/mix/#get-history-funding-rate
* @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 entries to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.pageNo] the page number to fetch
* @param {bool} [params.nextPage] whether to query the next page (default false)
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
*/
func (this *Coincatch) 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 coincatch#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://coincatch.github.io/github.io/en/spot/#get-account-assets
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch balance for (default 'spot')
* @param {string} [params.productType] *swap only* 'umcbl' or 'dmcbl' (default 'umcbl')
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
*/
func (this *Coincatch) FetchBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
/**
* @method
* @name coincatch#transfer
* @description transfer currency internally between wallets on the same account
* @see https://coincatch.github.io/github.io/en/spot/#transfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount 'spot' or 'swap' or 'mix_usdt' or 'mix_usd' - account to transfer from
* @param {string} toAccount 'spot' or 'swap' or 'mix_usdt' or 'mix_usd' - account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] a unique id for the transfer
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Coincatch) 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 coincatch#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://coincatch.github.io/github.io/en/spot/#get-coin-address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] network for fetch deposit address
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
*/
func (this *Coincatch) 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 coincatch#fetchDeposits
* @description fetch all deposits made to an account
* @see https://coincatch.github.io/github.io/en/spot/#get-deposit-list
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
* @param {int} [limit] the maximum number of transfer structures to retrieve (not used by exchange)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
* @param {int} [params.pageNo] pageNo default 1
* @param {int} [params.pageSize] pageSize (default 20, max 100)
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Coincatch) 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 coincatch#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://coincatch.github.io/github.io/en/spot/#get-withdraw-list-v2
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
* @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
* @param {string} [params.clientOid] clientOid
* @param {string} [params.orderId] The response orderId
* @param {string} [params.idLessThan] Requests the content on the page before this ID (older data), the value input should be the orderId of the corresponding interface.
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Coincatch) 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 coincatch#withdraw
* @description make a withdrawal
* @see https://coincatch.github.io/github.io/en/spot/#withdraw
* @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 network for withdraw (mandatory)
* @param {string} [params.remark] remark
* @param {string} [params.clientOid] custom id
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Coincatch) 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 coincatch#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://coincatch.github.io/github.io/en/spot/#place-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 *Coincatch) 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 coincatch#createOrder
* @description create a trade order
* @see https://coincatch.github.io/github.io/en/spot/#place-order
* @see https://coincatch.github.io/github.io/en/spot/#place-plan-order
* @see https://coincatch.github.io/github.io/en/mix/#place-order
* @see https://coincatch.github.io/github.io/en/mix/#place-plan-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit' or 'LIMIT_MAKER' for spot, 'market' or 'limit' or 'STOP' for swap
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of you want to trade in units of the base currency
* @param {float} [price] the price that 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.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
* @param {float} [params.triggerPrice] the price that the order is to be triggered
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
* @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK' or 'PO'
* @param {string} [params.clientOrderId] a unique id for the order - is mandatory for swap
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) 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 coincatch#createOrderWithTakeProfitAndStopLoss
* @description *swap markets only* create an order with a stop loss or take profit attached (type 3)
* @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 or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} [takeProfit] the take profit price, in units of the quote currency
* @param {float} [stopLoss] the stop loss price, 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 *Coincatch) CreateOrderWithTakeProfitAndStopLoss(symbol string, typeVar string, side string, amount float64, options ...CreateOrderWithTakeProfitAndStopLossOptions) (Order, error) {
opts := CreateOrderWithTakeProfitAndStopLossOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var price interface{} = nil
if opts.Price != nil {
price = *opts.Price
}
var takeProfit interface{} = nil
if opts.TakeProfit != nil {
takeProfit = *opts.TakeProfit
}
var stopLoss interface{} = nil
if opts.StopLoss != nil {
stopLoss = *opts.StopLoss
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateOrderWithTakeProfitAndStopLoss(symbol, typeVar, side, amount, price, takeProfit, stopLoss, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coincatch#createOrders
* @description create a list of trade orders (all orders should be of the same symbol)
* @see https://coincatch.github.io/github.io/en/spot/#batch-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 (max 50 entries)
* @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 *Coincatch) 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 coincatch#editOrder
* @description edit a trade trigger, stop-looss or take-profit order
* @see https://coincatch.github.io/github.io/en/spot/#modify-plan-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 currency you want to trade in units of 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
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) 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 coincatch#editSpotOrder
* @ignore
* @description edit a trade order
* @see https://coincatch.github.io/github.io/en/spot/#modify-plan-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 currency you want to trade in units of 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 {string} [params.clientOrderId] a unique id for the order that can be used as an alternative for the id
* @param {string} params.triggerPrice *mandatory* the price that the order is to be triggered at
* @param {float} [params.cost] *market buy only* the quote quantity that can be used as an alternative for the amount
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) EditSpotOrder(id string, symbol string, typeVar string, side string, amount float64, options ...EditSpotOrderOptions) (Order, error) {
opts := EditSpotOrderOptionsStruct{}
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.EditSpotOrder(id, symbol, typeVar, side, amount, price, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name coincatch#fetchOrder
* @description fetches information on an order made by the user (non-trigger orders only)
* @see https://coincatch.github.io/github.io/en/spot/#get-order-details
* @see https://coincatch.github.io/github.io/en/mix/#get-order-details
* @param {string} id the order id
* @param {string} symbol unified symbol of the market the order was made in (is mandatory for swap)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entry for (default 'spot')
* @param {string} [params.clientOrderId] a unique id for the order that can be used as an alternative for the id
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) 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 coincatch#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://coincatch.github.io/github.io/en/spot/#get-order-list
* @see https://coincatch.github.io/github.io/en/spot/#get-current-plan-orders
* @see https://coincatch.github.io/github.io/en/mix/#get-open-order
* @see https://coincatch.github.io/github.io/en/mix/#get-all-open-order
* @see https://coincatch.github.io/github.io/en/mix/#get-plan-order-tpsl-list
* @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] true if fetching trigger orders (default false)
* @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entries for (default 'spot')
* @param {string} [params.productType] *swap only* 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for (default 'umcbl')
* @param {string} [params.marginCoin] *swap only* the margin coin of the market to fetch entries for
* @param {string} [params.isPlan] *swap trigger only* 'plan' or 'profit_loss' ('plan' (default) for trigger (plan) orders, 'profit_loss' for stop-loss and take-profit orders)
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) 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
* @ignore
* @name coincatch#fetchOpenSpotOrders
* @description fetch all unfilled currently open orders for spot markets
* @see https://coincatch.github.io/github.io/en/spot/#get-order-list
* @see https://coincatch.github.io/github.io/en/spot/#get-current-plan-orders
* @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] true if fetching trigger orders (default false)
* @param {string} [params.lastEndId] *for trigger orders only* the last order id to fetch entries after
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) FetchOpenSpotOrders(options ...FetchOpenSpotOrdersOptions) ([]Order, error) {
opts := FetchOpenSpotOrdersOptionsStruct{}
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.FetchOpenSpotOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @ignore
* @name coincatch#fetchOpenSwapOrders
* @description fetch all unfilled currently open orders for swap markets
* @see https://coincatch.github.io/github.io/en/mix/#get-open-order
* @see https://coincatch.github.io/github.io/en/mix/#get-all-open-order
* @see https://coincatch.github.io/github.io/en/mix/#get-plan-order-tpsl-list
* @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] true if fetching trigger orders (default false)
* @param {string} [params.isPlan] 'plan' or 'profit_loss' ('plan' (default) for trigger (plan) orders, 'profit_loss' for stop-loss and take-profit orders)
* @param {string} [params.productType] 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for (default 'umcbl')
* @param {string} [params.marginCoin] the margin coin of the market to fetch entries for
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) FetchOpenSwapOrders(options ...FetchOpenSwapOrdersOptions) ([]Order, error) {
opts := FetchOpenSwapOrdersOptionsStruct{}
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.FetchOpenSwapOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coincatch#fetchCanceledAndClosedOrders
* @description fetches information on multiple canceled and closed orders made by the user
* @see https://coincatch.github.io/github.io/en/spot/#get-order-list
* @see https://coincatch.github.io/github.io/en/spot/#get-history-plan-orders
* @see https://coincatch.github.io/github.io/en/mix/#get-history-orders
* @see https://coincatch.github.io/github.io/en/mix/#get-producttype-history-orders
* @see https://coincatch.github.io/github.io/en/mix/#get-history-plan-orders-tpsl
* @param {string} symbol *is mandatory* 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 {int} [params.until] the latest time in ms to fetch orders for
* @param {boolean} [params.trigger] true if fetching trigger orders (default false)
* @param {string} [params.isPlan] *swap only* 'plan' or 'profit_loss' ('plan' (default) for trigger (plan) orders, 'profit_loss' for stop-loss and take-profit orders)
* @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entries for (default 'spot')
* @param {string} [params.productType] *swap only* 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for (default 'umcbl')
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) FetchCanceledAndClosedOrders(options ...FetchCanceledAndClosedOrdersOptions) ([]Order, error) {
opts := FetchCanceledAndClosedOrdersOptionsStruct{}
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.FetchCanceledAndClosedOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @ignore
* @name coincatch#fetchCanceledAndClosedSpotOrders
* @description fetches information on multiple canceled and closed orders made by the user on spot markets
* @see https://coincatch.github.io/github.io/en/spot/#get-order-history
* @see https://coincatch.github.io/github.io/en/spot/#get-history-plan-orders
* @param {string} symbol *is mandatory* 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 {int} [params.until] *for trigger orders only* the latest time in ms to fetch orders for
* @param {boolean} [params.trigger] true if fetching trigger orders (default false)
* @param {string} [params.lastEndId] *for trigger orders only* the last order id to fetch entries after
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) FetchCanceledAndClosedSpotOrders(options ...FetchCanceledAndClosedSpotOrdersOptions) ([]Order, error) {
opts := FetchCanceledAndClosedSpotOrdersOptionsStruct{}
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.FetchCanceledAndClosedSpotOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @ignore
* @name coincatch#fetchCanceledAndClosedSwapOrders
* @description fetches information on multiple canceled and closed orders made by the user on swap markets
* @see https://coincatch.github.io/github.io/en/mix/#get-history-orders
* @see https://coincatch.github.io/github.io/en/mix/#get-producttype-history-orders
* @see https://coincatch.github.io/github.io/en/mix/#get-history-plan-orders-tpsl
* @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 {int} [params.until] the latest time in ms to fetch orders for
* @param {boolean} [params.trigger] true if fetching trigger orders (default false)
* @param {string} [params.isPlan] *swap only* 'plan' or 'profit_loss' ('plan' (default) for trigger (plan) orders, 'profit_loss' for stop-loss and take-profit orders)
* @param {string} [params.productType] *swap only* 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for (default 'umcbl')
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) FetchCanceledAndClosedSwapOrders(options ...FetchCanceledAndClosedSwapOrdersOptions) ([]Order, error) {
opts := FetchCanceledAndClosedSwapOrdersOptionsStruct{}
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.FetchCanceledAndClosedSwapOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name coincatch#cancelOrder
* @description cancels an open order
* @see https://coincatch.github.io/github.io/en/spot/#cancel-order-v2
* @see https://coincatch.github.io/github.io/en/spot/#cancel-plan-order
* @see https://coincatch.github.io/github.io/en/mix/#cancel-order
* @see https://coincatch.github.io/github.io/en/mix/#cancel-plan-order-tpsl
* @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] a unique id for the order that can be used as an alternative for the id
* @param {bool} [params.trigger] true for canceling a trigger order (default false)
* @param {bool} [params.stop] *swap only* an alternative for trigger param
* @param {string} [params.planType] *swap trigger only* the type of the plan order to cancel: 'profit_plan' - profit order, 'loss_plan' - loss order, 'normal_plan' - plan order, 'pos_profit' - position profit, 'pos_loss' - position loss, 'moving_plan' - Trailing TP/SL, 'track_plan' - Trailing Stop
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) 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 coincatch#cancelAllOrders
* @description cancels all open orders
* @see https://coincatch.github.io/github.io/en/spot/#cancel-all-orders
* @see https://coincatch.github.io/github.io/en/spot/#batch-cancel-plan-orders
* @see https://coincatch.github.io/github.io/en/mix/#batch-cancel-order
* @see https://coincatch.github.io/github.io/en/mix/#cancel-order-by-symbol
* @see https://coincatch.github.io/github.io/en/mix/#cancel-plan-order-tpsl-by-symbol
* @see https://coincatch.github.io/github.io/en/mix/#cancel-all-trigger-order-tpsl
* @param {string} [symbol] unified symbol of the market the orders were made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'spot' or 'swap' - the type of the market to cancel orders for (default 'spot')
* @param {bool} [params.trigger] true for canceling a trigger orders (default false)
* @param {string} [params.productType] *swap only (if symbol is not provided* 'umcbl' or 'dmcbl' - the product type of the market to cancel orders for (default 'umcbl')
* @param {string} [params.marginCoin] *mandatory for swap non-trigger dmcb (if symbol is not provided)* the margin coin of the market to cancel orders for
* @param {string} [params.planType] *swap trigger only* the type of the plan order to cancel: 'profit_plan' - profit order, 'loss_plan' - loss order, 'normal_plan' - plan order, 'pos_profit' - position profit, 'pos_loss' - position loss, 'moving_plan' - Trailing TP/SL, 'track_plan' - Trailing Stop
* @returns {object} response from the exchange
*/
func (this *Coincatch) 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 coincatch#cancelOrders
* @description cancel multiple non-trigger orders
* @see https://coincatch.github.io/github.io/en/spot/#cancel-order-in-batch-v2-single-instruments
* @param {string[]} ids order ids
* @param {string} symbol *is mandatory* unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string[]} [params.clientOrderIds] client order ids
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Coincatch) CancelOrders(ids []string, options ...CancelOrdersOptions) ([]Order, 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 NewOrderArray(res), nil
}
/**
* @method
* @name coincatch#fetchMyTrades
* @description fetch all trades made by the user
* @see https://coincatch.github.io/github.io/en/spot/#get-transaction-details
* @see https://coincatch.github.io/github.io/en/mix/#get-order-fill-detail
* @see https://coincatch.github.io/github.io/en/mix/#get-producttype-order-fill-detail
* @param {string} symbol *is mandatory* unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] *swap markets only* the latest time in ms to fetch trades for, only supports the last 30 days timeframe
* @param {string} [params.lastEndId] *swap markets only* query the data after this tradeId
* @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
*/
func (this *Coincatch) 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 coincatch#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://coincatch.github.io/github.io/en/spot/#get-transaction-details
* @param {string} id order id
* @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 trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
*/
func (this *Coincatch) FetchOrderTrades(id string, options ...FetchOrderTradesOptions) ([]Trade, error) {
opts := FetchOrderTradesOptionsStruct{}
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.FetchOrderTrades(id, symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewTradeArray(res), nil
}
/**
* @method
* @name coincatch#fetchMarginMode
* @description fetches the margin mode of the trading pair
* @see https://coincatch.github.io/github.io/en/mix/#get-single-account
* @param {string} symbol unified symbol of the market to fetch the margin mode for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
*/
func (this *Coincatch) FetchMarginMode(symbol string, options ...FetchMarginModeOptions) (MarginMode, error) {
opts := FetchMarginModeOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchMarginMode(symbol, params)
if IsError(res) {
return MarginMode{}, CreateReturnError(res)
}
return NewMarginMode(res), nil
}
/**
* @method
* @name coincatch#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://coincatch.github.io/github.io/en/mix/#change-margin-mode
* @param {string} marginMode 'cross' or 'isolated'
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
func (this *Coincatch) 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 coincatch#fetchPositionMode
* @description fetchs the position mode, hedged or one way
* @see https://coincatch.github.io/github.io/en/mix/#get-single-account
* @param {string} symbol unified symbol of the market to fetch entry for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an object detailing whether the market is in hedged or one-way mode
*/
func (this *Coincatch) FetchPositionMode(options ...FetchPositionModeOptions) (map[string]interface{}, error) {
opts := FetchPositionModeOptionsStruct{}
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.FetchPositionMode(symbol, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name coincatch#setPositionMode
* @description set hedged to true or false for a market
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Position%20Mode
* @param {bool} hedged set to true to use dualSidePosition
* @param {string} symbol unified symbol of the market to fetch entry for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.productType] 'umcbl' or 'dmcbl' (default 'umcbl' if symbol is not provided)
* @returns {object} response from the exchange
*/
func (this *Coincatch) SetPositionMode(hedged bool, options ...SetPositionModeOptions) (map[string]interface{}, error) {
opts := SetPositionModeOptionsStruct{}
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.SetPositionMode(hedged, symbol, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name coincatch#fetchLeverage
* @description fetch the set leverage for a market
* @see https://coincatch.github.io/github.io/en/mix/#get-single-account
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
*/
func (this *Coincatch) 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 coincatch#setLeverage
* @description set the level of leverage for a market
* @see https://hashkeyglobal-apidoc.readme.io/reference/change-futures-leverage-trade
* @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.side] *for isolated margin mode with hedged position mode only* 'long' or 'short'
* @returns {object} response from the exchange
*/
func (this *Coincatch) SetLeverage(leverage int64, options ...SetLeverageOptions) (Leverage, 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 Leverage{}, CreateReturnError(res)
}
return NewLeverage(res), nil
}
/**
* @method
* @name coincatch#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://coincatch.github.io/github.io/en/mix/#get-symbol-position
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.side] 'long' or 'short' *for non-hedged position mode only* (default 'long')
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Coincatch) 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
* @description fetch open positions for a single market
* @name coincatch#fetchPositionsForSymbol
* @see https://coincatch.github.io/github.io/en/mix/#get-symbol-position
* @description fetch all open positions for specific symbol
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Coincatch) FetchPositionsForSymbol(symbol string, options ...FetchPositionsForSymbolOptions) ([]Position, error) {
opts := FetchPositionsForSymbolOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchPositionsForSymbol(symbol, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewPositionArray(res), nil
}
/**
* @method
* @name coincatch#fetchPositions
* @description fetch all open positions
* @see https://coincatch.github.io/github.io/en/mix/#get-all-position
* @param {string[]} [symbols] list of unified market symbols (all symbols must belong to the same product type)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.productType] 'umcbl' or 'dmcbl' (default 'umcbl' if symbols are not provided)
* @param {string} [params.marginCoin] the settle currency of the positions, needs to match the productType
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Coincatch) 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 coincatch#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
* @see https://coincatch.github.io/github.io/en/spot/#get-bills
* @see https://coincatch.github.io/github.io/en/mix/#get-business-account-bill
* @param {string} [code] unified currency code
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
* @param {int} [limit] max number of ledger entrys to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] *swap only* the latest time in ms to fetch entries for
* @param {string} [params.type] 'spot' or 'swap' (default 'spot')
* @param {string} [params.after] *spot only* billId, return the data less than this billId
* @param {string} [params.before] *spot only* billId, return the data greater than or equals to this billId
* @param {string} [params.groupType] *spot only*
* @param {string} [params.bizType] *spot only*
* @param {string} [params.productType] *swap only* 'umcbl' or 'dmcbl' (default 'umcbl' or 'dmcbl' if code is provided and code is not equal to 'USDT')
* @param {string} [params.business] *swap only*
* @param {string} [params.lastEndId] *swap only*
* @param {bool} [params.next] *swap only*
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
*/
func (this *Coincatch) FetchLedger(options ...FetchLedgerOptions) ([]LedgerEntry, error) {
opts := FetchLedgerOptionsStruct{}
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.FetchLedger(code, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewLedgerEntryArray(res), nil
}