1341 lines
44 KiB
Go
1341 lines
44 KiB
Go
package ccxt
|
|
|
|
type Xt struct {
|
|
*xt
|
|
Core *xt
|
|
}
|
|
|
|
func NewXt(userConfig map[string]interface{}) Xt {
|
|
p := &xt{}
|
|
p.Init(userConfig)
|
|
return Xt{
|
|
xt: 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 xt#fetchTime
|
|
* @description fetches the current integer timestamp in milliseconds from the xt server
|
|
* @see https://doc.xt.com/#market1serverInfo
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {int} the current integer timestamp in milliseconds from the xt server
|
|
*/
|
|
func (this *Xt) FetchTime(params ...interface{}) ( int64, error) {
|
|
res := <- this.Core.FetchTime(params...)
|
|
if IsError(res) {
|
|
return -1, CreateReturnError(res)
|
|
}
|
|
return (res).(int64), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#fetchMarkets
|
|
* @description retrieves data on all markets for xt
|
|
* @see https://doc.xt.com/#market2symbol
|
|
* @see https://doc.xt.com/#futures_quotesgetSymbols
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} an array of objects representing market data
|
|
*/
|
|
func (this *Xt) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchMarkets(params...)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
func (this *Xt) 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 *Xt) FetchSwapAndFutureMarkets(params ...interface{}) ([]map[string]interface{}, error) {
|
|
res := <- this.Core.FetchSwapAndFutureMarkets(params...)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return res.([]map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#fetchOHLCV
|
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
* @see https://doc.xt.com/#market4kline
|
|
* @see https://doc.xt.com/#futures_quotesgetKLine
|
|
* @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 xt 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 [available 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 *Xt) 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 xt#fetchOrderBook
|
|
* @see https://doc.xt.com/#market3depth
|
|
* @see https://doc.xt.com/#futures_quotesgetDepth
|
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
* @param {string} symbol unified market symbol 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 xt api endpoint
|
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-book-structure} indexed by market symbols
|
|
*/
|
|
func (this *Xt) 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 xt#fetchTicker
|
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
* @see https://doc.xt.com/#market10ticker24h
|
|
* @see https://doc.xt.com/#futures_quotesgetAggTicker
|
|
* @param {string} symbol unified market symbol to fetch the ticker for
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchTickers
|
|
* @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
|
* @see https://doc.xt.com/#market10ticker24h
|
|
* @see https://doc.xt.com/#futures_quotesgetAggTickers
|
|
* @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 xt api endpoint
|
|
* @returns {object} an array of [ticker structures]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchBidsAsks
|
|
* @description fetches the bid and ask price and volume for multiple markets
|
|
* @see https://doc.xt.com/#market9tickerBook
|
|
* @param {string} [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 xt api endpoint
|
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchTrades
|
|
* @description get the list of most recent trades for a particular symbol
|
|
* @see https://doc.xt.com/#market5tradeRecent
|
|
* @see https://doc.xt.com/#futures_quotesgetDeal
|
|
* @param {string} symbol unified market symbol 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 xt api endpoint
|
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchMyTrades
|
|
* @description fetch all trades made by the user
|
|
* @see https://doc.xt.com/#tradetradeGet
|
|
* @see https://doc.xt.com/#futures_ordergetTrades
|
|
* @param {string} [symbol] unified market symbol 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 xt api endpoint
|
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchBalance
|
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
* @see https://doc.xt.com/#balancebalancesGet
|
|
* @see https://doc.xt.com/#futures_usergetBalances
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/en/latest/manual.html?#balance-structure}
|
|
*/
|
|
func (this *Xt) FetchBalance(params ...interface{}) (Balances, error) {
|
|
res := <- this.Core.FetchBalance(params...)
|
|
if IsError(res) {
|
|
return Balances{}, CreateReturnError(res)
|
|
}
|
|
return NewBalances(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#createMarketBuyOrderWithCost
|
|
* @see https://doc.xt.com/#orderorderPost
|
|
* @description create a market buy order by providing the symbol and cost
|
|
* @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 *Xt) 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 xt#createOrder
|
|
* @description create a trade order
|
|
* @see https://doc.xt.com/#orderorderPost
|
|
* @see https://doc.xt.com/#futures_ordercreate
|
|
* @see https://doc.xt.com/#futures_entrustcreatePlan
|
|
* @see https://doc.xt.com/#futures_entrustcreateProfit
|
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
* @param {string} type 'market' or 'limit'
|
|
* @param {string} side 'buy' or 'sell'
|
|
* @param {float} amount how much you want to trade in units of the base currency
|
|
* @param {float} [price] the price to fulfill the order, in units of the quote currency, can be ignored in market orders
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK' or 'GTX'
|
|
* @param {string} [params.entrustType] 'TAKE_PROFIT', 'STOP', 'TAKE_PROFIT_MARKET', 'STOP_MARKET', 'TRAILING_STOP_MARKET', required if stopPrice is defined, currently isn't functioning on xt's side
|
|
* @param {string} [params.triggerPriceType] 'INDEX_PRICE', 'MARK_PRICE', 'LATEST_PRICE', required if stopPrice is defined
|
|
* @param {float} [params.triggerPrice] price to trigger a stop order
|
|
* @param {float} [params.stopPrice] alias for triggerPrice
|
|
* @param {float} [params.stopLoss] price to set a stop-loss on an open position
|
|
* @param {float} [params.takeProfit] price to set a take-profit on an open position
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchOrder
|
|
* @description fetches information on an order made by the user
|
|
* @see https://doc.xt.com/#orderorderGet
|
|
* @see https://doc.xt.com/#futures_ordergetById
|
|
* @see https://doc.xt.com/#futures_entrustgetPlanById
|
|
* @see https://doc.xt.com/#futures_entrustgetProfitById
|
|
* @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 xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @param {bool} [params.stopLossTakeProfit] if the order is a stop-loss or take-profit order
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchOrders
|
|
* @description fetches information on multiple orders made by the user
|
|
* @see https://doc.xt.com/#orderhistoryOrderGet
|
|
* @see https://doc.xt.com/#futures_ordergetHistory
|
|
* @see https://doc.xt.com/#futures_entrustgetPlanHistory
|
|
* @param {string} [symbol] unified market symbol of the market the orders were made in
|
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 *Xt) FetchOrdersByStatus(status interface{}, options ...FetchOrdersByStatusOptions) ([]Order, error) {
|
|
|
|
opts := FetchOrdersByStatusOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchOrdersByStatus(status, symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#fetchOpenOrders
|
|
* @description fetch all unfilled currently open orders
|
|
* @see https://doc.xt.com/#orderopenOrderGet
|
|
* @see https://doc.xt.com/#futures_ordergetOrders
|
|
* @see https://doc.xt.com/#futures_entrustgetPlan
|
|
* @see https://doc.xt.com/#futures_entrustgetProfit
|
|
* @param {string} [symbol] unified market symbol of the market the orders were made in
|
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @param {bool} [params.stopLossTakeProfit] if the order is a stop-loss or take-profit order
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchClosedOrders
|
|
* @description fetches information on multiple closed orders made by the user
|
|
* @see https://doc.xt.com/#orderhistoryOrderGet
|
|
* @see https://doc.xt.com/#futures_ordergetOrders
|
|
* @see https://doc.xt.com/#futures_entrustgetPlan
|
|
* @see https://doc.xt.com/#futures_entrustgetProfit
|
|
* @param {string} [symbol] unified market symbol of the market the orders were made in
|
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @param {bool} [params.stopLossTakeProfit] if the order is a stop-loss or take-profit order
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchCanceledOrders
|
|
* @description fetches information on multiple canceled orders made by the user
|
|
* @see https://doc.xt.com/#orderhistoryOrderGet
|
|
* @see https://doc.xt.com/#futures_ordergetOrders
|
|
* @see https://doc.xt.com/#futures_entrustgetPlan
|
|
* @see https://doc.xt.com/#futures_entrustgetProfit
|
|
* @param {string} [symbol] unified market symbol of the market the orders were made in
|
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @param {bool} [params.stopLossTakeProfit] if the order is a stop-loss or take-profit order
|
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#cancelOrder
|
|
* @description cancels an open order
|
|
* @see https://doc.xt.com/#orderorderDel
|
|
* @see https://doc.xt.com/#futures_ordercancel
|
|
* @see https://doc.xt.com/#futures_entrustcancelPlan
|
|
* @see https://doc.xt.com/#futures_entrustcancelProfit
|
|
* @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 xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @param {bool} [params.stopLossTakeProfit] if the order is a stop-loss or take-profit order
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#cancelAllOrders
|
|
* @description cancel all open orders in a market
|
|
* @see https://doc.xt.com/#orderopenOrderDel
|
|
* @see https://doc.xt.com/#futures_ordercancelBatch
|
|
* @see https://doc.xt.com/#futures_entrustcancelPlanBatch
|
|
* @see https://doc.xt.com/#futures_entrustcancelProfitBatch
|
|
* @param {string} [symbol] unified market symbol of the market to cancel orders in
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {bool} [params.trigger] if the order is a trigger order or not
|
|
* @param {bool} [params.stopLossTakeProfit] if the order is a stop-loss or take-profit order
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#cancelOrders
|
|
* @description cancel multiple orders
|
|
* @see https://doc.xt.com/#orderbatchOrderDel
|
|
* @param {string[]} ids order ids
|
|
* @param {string} [symbol] unified market symbol of the market to cancel orders in
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchLedger
|
|
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
|
* @see https://doc.xt.com/#futures_usergetBalanceBill
|
|
* @param {string} [code] unified currency code
|
|
* @param {int} [since] timestamp in ms of the earliest ledger entry
|
|
* @param {int} [limit] max number of ledger entries to return
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/en/latest/manual.html#ledger-structure}
|
|
*/
|
|
func (this *Xt) 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
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#fetchDepositAddress
|
|
* @description fetch the deposit address for a currency associated with this account
|
|
* @see https://doc.xt.com/#deposit_withdrawaldepositAddressGet
|
|
* @param {string} code unified currency code
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {string} params.network required network id
|
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/en/latest/manual.html#address-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchDeposits
|
|
* @description fetch all deposits made to an account
|
|
* @see https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
|
|
* @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 transaction structures to retrieve
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/en/latest/manual.html#transaction-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchWithdrawals
|
|
* @description fetch all withdrawals made from an account
|
|
* @see https://doc.xt.com/#deposit_withdrawalwithdrawHistory
|
|
* @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 transaction structures to retrieve
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/en/latest/manual.html#transaction-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#withdraw
|
|
* @description make a withdrawal
|
|
* @see https://doc.xt.com/#deposit_withdrawalwithdraw
|
|
* @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 xt api endpoint
|
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/en/latest/manual.html#transaction-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#setLeverage
|
|
* @description set the level of leverage for a market
|
|
* @see https://doc.xt.com/#futures_useradjustLeverage
|
|
* @param {float} leverage the rate of leverage
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @param {string} params.positionSide 'LONG' or 'SHORT'
|
|
* @returns {object} response from the exchange
|
|
*/
|
|
func (this *Xt) 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 xt#fetchLeverageTiers
|
|
* @description retrieve information on the maximum leverage for different trade sizes
|
|
* @see https://doc.xt.com/#futures_quotesgetLeverageBrackets
|
|
* @param {string} [symbols] a list of unified market symbols
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchMarketLeverageTiers
|
|
* @description retrieve information on the maximum leverage for different trade sizes of a single market
|
|
* @see https://doc.xt.com/#futures_quotesgetLeverageBracket
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
|
|
*/
|
|
func (this *Xt) FetchMarketLeverageTiers(symbol string, options ...FetchMarketLeverageTiersOptions) ([]LeverageTier, error) {
|
|
|
|
opts := FetchMarketLeverageTiersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchMarketLeverageTiers(symbol, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewLeverageTierArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name xt#fetchFundingRateHistory
|
|
* @description fetches historical funding rates
|
|
* @see https://doc.xt.com/#futures_quotesgetFundingRateRecord
|
|
* @param {string} [symbol] unified symbol of the market to fetch the funding rate history for
|
|
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
* @param {int} [limit] the maximum amount of [funding rate structures] to fetch
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/en/latest/manual.html?#funding-rate-history-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchFundingInterval
|
|
* @description fetch the current funding rate interval
|
|
* @see https://doc.xt.com/#futures_quotesgetFundingRate
|
|
* @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 *Xt) 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 xt#fetchFundingRate
|
|
* @description fetch the current funding rate
|
|
* @see https://doc.xt.com/#futures_quotesgetFundingRate
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchFundingHistory
|
|
* @description fetch the funding history
|
|
* @see https://doc.xt.com/#futures_usergetFunding
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the starting timestamp in milliseconds
|
|
* @param {int} [limit] the number of entries to return
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchPosition
|
|
* @description fetch data on a single open contract trade position
|
|
* @see https://doc.xt.com/#futures_usergetPosition
|
|
* @param {string} symbol unified market symbol of the market the position is held in
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#fetchPositions
|
|
* @description fetch all open positions
|
|
* @see https://doc.xt.com/#futures_usergetPosition
|
|
* @param {string} [symbols] list of unified market symbols, not supported with xt
|
|
* @param {object} params extra parameters specific to the xt api endpoint
|
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#transfer
|
|
* @description transfer currency internally between wallets on the same account
|
|
* @see https://doc.xt.com/#transfersubTransferPost
|
|
* @param {string} code unified currency code
|
|
* @param {float} amount amount to transfer
|
|
* @param {string} fromAccount account to transfer from - spot, swap, leverage, finance
|
|
* @param {string} toAccount account to transfer to - spot, swap, leverage, finance
|
|
* @param {object} params extra parameters specific to the whitebit api endpoint
|
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
*/
|
|
func (this *Xt) 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 xt#setMarginMode
|
|
* @description set margin mode to 'cross' or 'isolated'
|
|
* @see https://doc.xt.com/#futures_userchangePositionType
|
|
* @param {string} marginMode 'cross' or 'isolated'
|
|
* @param {string} [symbol] required
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.positionSide] *required* "long" or "short"
|
|
* @returns {object} response from the exchange
|
|
*/
|
|
func (this *Xt) 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
|
|
} |