ccxt-go/mexc_wrapper.go

1794 lines
62 KiB
Go
Raw Normal View History

2025-02-28 10:33:20 +08:00
package ccxt
type Mexc struct {
*mexc
Core *mexc
}
func NewMexc(userConfig map[string]interface{}) Mexc {
p := &mexc{}
p.Init(userConfig)
return Mexc{
mexc: 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 mexc#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#test-connectivity
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-server-time
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
*/
func (this *Mexc) FetchStatus(params ...interface{}) (map[string]interface{}, error) {
res := <- this.Core.FetchStatus(params...)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name mexc#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#check-server-time
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-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 *Mexc) FetchTime(params ...interface{}) ( int64, error) {
res := <- this.Core.FetchTime(params...)
if IsError(res) {
return -1, CreateReturnError(res)
}
return (res).(int64), nil
}
/**
* @ignore
* @method
* @name mexc#fetchMarkets
* @description retrieves data on all swap markets for mexc
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
func (this *Mexc) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
res := <- this.Core.FetchMarkets(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewMarketInterfaceArray(res), nil
}
func (this *Mexc) FetchSpotMarkets(params ...interface{}) ([]map[string]interface{}, error) {
res := <- this.Core.FetchSpotMarkets(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return res.([]map[string]interface{}), nil
}
func (this *Mexc) FetchSwapMarkets(params ...interface{}) ([]map[string]interface{}, error) {
res := <- this.Core.FetchSwapMarkets(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return res.([]map[string]interface{}), nil
}
/**
* @method
* @name mexc#fetchOrderBook
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other 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
* @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 *Mexc) 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 mexc#fetchTrades
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
* @description get the list of most recent trades for a particular symbol
* @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] *spot only* *since must be defined* the latest time in ms to fetch entries for
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
*/
func (this *Mexc) 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 mexc#fetchOHLCV
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-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
* @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 {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
func (this *Mexc) 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 mexc#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
* @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 *Mexc) 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 mexc#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
* @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 *Mexc) 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 mexc#fetchBidsAsks
* @description fetches the bid and ask price and volume for multiple markets
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets 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 *Mexc) FetchBidsAsks(options ...FetchBidsAsksOptions) (Tickers, error) {
opts := FetchBidsAsksOptionsStruct{}
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.FetchBidsAsks(symbols, params)
if IsError(res) {
return Tickers{}, CreateReturnError(res)
}
return NewTickers(res), nil
}
/**
* @method
* @name mexc#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-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 *Mexc) 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 mexc#createMarketSellOrderWithCost
* @description create a market sell order by providing the symbol and cost
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-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 *Mexc) CreateMarketSellOrderWithCost(symbol string, cost float64, options ...CreateMarketSellOrderWithCostOptions) (Order, error) {
opts := CreateMarketSellOrderWithCostOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.CreateMarketSellOrderWithCost(symbol, cost, params)
if IsError(res) {
return Order{}, CreateReturnError(res)
}
return NewOrder(res), nil
}
/**
* @method
* @name mexc#createOrder
* @description create a trade order
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
* @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.marginMode] only 'isolated' is supported for spot-margin trading
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
* @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
* @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
* @param {string} [params.timeInForce] 'IOC' or 'FOK', default is 'GTC'
* EXCHANGE SPECIFIC PARAMETERS
* @param {int} [params.leverage] *contract only* leverage is necessary on isolated margin
* @param {long} [params.positionId] *contract only* it is recommended to fill in this parameter when closing a position
* @param {string} [params.externalOid] *contract only* external order ID
* @param {int} [params.positionMode] *contract only* 1:hedge, 2:one-way, default: the user's current config
* @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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 mexc#createOrders
* @description *spot only* *all orders must have the same symbol* create a list of trade orders
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#batch-orders
* @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 api endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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 mexc#fetchOrder
* @description fetches information on an order made by the user
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
* @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.marginMode] only 'isolated' is supported, for spot-margin trading
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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 mexc#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-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 {int} [params.until] the latest time in ms to fetch orders for
* @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) FetchOrders(options ...FetchOrdersOptions) ([]Order, error) {
opts := FetchOrdersOptionsStruct{}
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.FetchOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
func (this *Mexc) FetchOrdersByIds(ids interface{}, options ...FetchOrdersByIdsOptions) ([]Order, error) {
opts := FetchOrdersByIdsOptionsStruct{}
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.FetchOrdersByIds(ids, symbol, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name mexc#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#current-open-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
* @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 orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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 mexc#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-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
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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 mexc#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
* @param {int} [limit] max number of orders to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) FetchCanceledOrders(options ...FetchCanceledOrdersOptions) ([]Order, error) {
opts := FetchCanceledOrdersOptionsStruct{}
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.FetchCanceledOrders(symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
func (this *Mexc) FetchOrdersByState(state interface{}, options ...FetchOrdersByStateOptions) ([]Order, error) {
opts := FetchOrdersByStateOptionsStruct{}
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.FetchOrdersByState(state, symbol, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewOrderArray(res), nil
}
/**
* @method
* @name mexc#cancelOrder
* @description cancels an open order
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-order
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-stop-limit-trigger-order-under-maintenance
* @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.marginMode] only 'isolated' is supported for spot-margin trading
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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 mexc#cancelOrders
* @description cancel multiple orders
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) CancelOrders(ids interface{}, 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 mexc#cancelAllOrders
* @description cancel all open orders
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
func (this *Mexc) 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
}
func (this *Mexc) FetchAccountHelper(typeVar interface{}, params interface{}) (map[string]interface{}, error) {
res := <- this.Core.FetchAccountHelper(typeVar, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name mexc#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
*/
func (this *Mexc) FetchAccounts(params ...interface{}) ([]Account, error) {
res := <- this.Core.FetchAccounts(params...)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewAccountArray(res), nil
}
/**
* @method
* @name mexc#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-mx-deduct-status
* @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 *Mexc) 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 mexc#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.symbols] // required for margin, market id's separated by commas
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
*/
func (this *Mexc) FetchBalance(params ...interface{}) (Balances, error) {
res := <- this.Core.FetchBalance(params...)
if IsError(res) {
return Balances{}, CreateReturnError(res)
}
return NewBalances(res), nil
}
/**
* @method
* @name mexc#fetchMyTrades
* @description fetch all trades made by the user
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
* @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 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 trades for
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
*/
func (this *Mexc) 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 mexc#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
* @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 *Mexc) 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 mexc#setLeverage
* @description set the level of leverage for a market
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
* @param {float} leverage the rate of leverage
* @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 *Mexc) 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 mexc#fetchFundingHistory
* @description fetch the history of funding payments paid and received on this account
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
* @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 *Mexc) 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 mexc#fetchFundingInterval
* @description fetch the current funding rate interval
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-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 *Mexc) 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 mexc#fetchFundingRate
* @description fetch the current funding rate
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-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 *Mexc) 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 mexc#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] not used by mexc, but filtered internally by ccxt
* @param {int} [limit] mexc limit is page_size default 20, maximum is 100
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
*/
func (this *Mexc) 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 mexc#fetchLeverageTiers
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for this market
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
* @param {string[]} [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 *Mexc) 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 mexc#fetchDepositAddressesByNetwork
* @description fetch a dictionary of addresses for a currency, indexed by network
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure} indexed by the network
*/
func (this *Mexc) FetchDepositAddressesByNetwork(code string, options ...FetchDepositAddressesByNetworkOptions) ([]DepositAddress, error) {
opts := FetchDepositAddressesByNetworkOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchDepositAddressesByNetwork(code, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewDepositAddressArray(res), nil
}
/**
* @method
* @name mexc#createDepositAddress
* @description create a currency deposit address
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
* @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 name
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
*/
func (this *Mexc) 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 mexc#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] the chain of currency, this only apply for multi-chain currency, and there is no need for single chain currency
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
*/
func (this *Mexc) 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 mexc#fetchDeposits
* @description fetch all deposits made to an account
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
* @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 deposits 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 *Mexc) 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 mexc#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
* @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 withdrawals 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 *Mexc) 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 mexc#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
* @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
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Mexc) 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 mexc#fetchPositions
* @description fetch all open positions
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
* @param {string[]|undefined} symbols list of unified market symbols
* @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 *Mexc) 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 mexc#fetchTransfer
* @description fetches a transfer
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
* @param {string} id transfer id
* @param {string} [code] not used by mexc fetchTransfer
* @param {object} params extra parameters specific to the exchange api endpoint
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Mexc) FetchTransfer(id string, options ...FetchTransferOptions) (TransferEntry, error) {
opts := FetchTransferOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var code interface{} = nil
if opts.Code != nil {
code = *opts.Code
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTransfer(id, code, params)
if IsError(res) {
return TransferEntry{}, CreateReturnError(res)
}
return NewTransferEntry(res), nil
}
/**
* @method
* @name mexc#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
* @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 transfers structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Mexc) 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 mexc#transfer
* @description transfer currency internally between wallets on the same account
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-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] market symbol required for margin account transfers eg:BTCUSDT
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
func (this *Mexc) 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 mexc#withdraw
* @description make a withdrawal
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-new
* @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
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
func (this *Mexc) 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 mexc#setPositionMode
* @description set hedged to true or false for a market
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#change-position-mode
* @param {bool} hedged set to true to use dualSidePosition
* @param {string} symbol not used by mexc setPositionMode ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
func (this *Mexc) 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 mexc#fetchPositionMode
* @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode
* @param {string} symbol not used by mexc fetchPositionMode
* @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 *Mexc) 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 mexc#fetchTransactionFees
* @description fetch deposit and withdrawal fees
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
* @param {string[]|undefined} codes returns fees for all currencies if undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
*/
func (this *Mexc) FetchTransactionFees(options ...FetchTransactionFeesOptions) (map[string]interface{}, error) {
opts := FetchTransactionFeesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var codes interface{} = nil
if opts.Codes != nil {
codes = *opts.Codes
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchTransactionFees(codes, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name mexc#fetchDepositWithdrawFees
* @description fetch deposit and withdrawal fees
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
* @param {string[]|undefined} codes returns fees for all currencies if undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
*/
func (this *Mexc) FetchDepositWithdrawFees(options ...FetchDepositWithdrawFeesOptions) (map[string]interface{}, error) {
opts := FetchDepositWithdrawFeesOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var codes interface{} = nil
if opts.Codes != nil {
codes = *opts.Codes
}
var params interface{} = nil
if opts.Params != nil {
params = *opts.Params
}
res := <- this.Core.FetchDepositWithdrawFees(codes, params)
if IsError(res) {
return map[string]interface{}{}, CreateReturnError(res)
}
return res.(map[string]interface{}), nil
}
/**
* @method
* @name mexc#fetchLeverage
* @description fetch the set leverage for a market
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
* @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 *Mexc) 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 mexc#fetchPositionsHistory
* @description fetches historical positions
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
* @param {string[]} [symbols] unified contract symbols
* @param {int} [since] not used by mexc fetchPositionsHistory
* @param {int} [limit] the maximum amount of candles to fetch, default=1000
* @param {object} [params] extra parameters specific to the exchange api endpoint
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {int} [params.type] position type1: long, 2: short
* @param {int} [params.page_num] current page number, default is 1
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
func (this *Mexc) FetchPositionsHistory(options ...FetchPositionsHistoryOptions) ([]Position, error) {
opts := FetchPositionsHistoryOptionsStruct{}
for _, opt := range options {
opt(&opts)
}
var symbols interface{} = nil
if opts.Symbols != nil {
symbols = *opts.Symbols
}
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.FetchPositionsHistory(symbols, since, limit, params)
if IsError(res) {
return nil, CreateReturnError(res)
}
return NewPositionArray(res), nil
}
/**
* @method
* @name mexc#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
* @param {string} marginMode 'cross' or 'isolated'
* @param {string} [symbol] required when there is no position, else provide params["positionId"]
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.positionId] required when a position is set
* @param {string} [params.direction] "long" or "short" required when there is no position
* @returns {object} response from the exchange
*/
func (this *Mexc) SetMarginMode(marginMode string, options ...SetMarginModeOptions) (Leverage, 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 Leverage{}, CreateReturnError(res)
}
return NewLeverage(res), nil
}