847 lines
28 KiB
Go
847 lines
28 KiB
Go
package ccxt
|
|
|
|
type Defx struct {
|
|
*defx
|
|
Core *defx
|
|
}
|
|
|
|
func NewDefx(userConfig map[string]interface{}) Defx {
|
|
p := &defx{}
|
|
p.Init(userConfig)
|
|
return Defx{
|
|
defx: 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 defx#fetchStatus
|
|
* @description the latest known information on the availability of the exchange API
|
|
* @see https://api-docs.defx.com/#4b03bb3b-a0fa-4dfb-b96c-237bde0ce9e6
|
|
* @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 *Defx) 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 defx#fetchTime
|
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
* @see https://api-docs.defx.com/#4b03bb3b-a0fa-4dfb-b96c-237bde0ce9e6
|
|
* @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 *Defx) FetchTime(params ...interface{}) ( int64, error) {
|
|
res := <- this.Core.FetchTime(params...)
|
|
if IsError(res) {
|
|
return -1, CreateReturnError(res)
|
|
}
|
|
return (res).(int64), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#fetchMarkets
|
|
* @description retrieves data on all markets for defx
|
|
* @see https://api-docs.defx.com/#73cce0c8-f842-4891-9145-01bb6d61324d
|
|
* @see https://api-docs.defx.com/#24fd4e5b-840e-451e-99e0-7fea47c7f371
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object[]} an array of objects representing market data
|
|
*/
|
|
func (this *Defx) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchMarkets(params...)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#fetchTicker
|
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
* @see https://api-docs.defx.com/#fe6f81d0-2f3a-4eee-976f-c8fc8f4c5d56
|
|
* @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 *Defx) 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 defx#fetchTickers
|
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
* @see https://api-docs.defx.com/#8c61cfbd-40d9-410e-b014-f5b36eba51d1
|
|
* @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 *Defx) 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 defx#fetchOHLCV
|
|
* @see https://api-docs.defx.com/#54b71951-1472-4670-b5af-4c2dc41e73d0
|
|
* @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] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms)))
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
*/
|
|
func (this *Defx) 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 defx#fetchTrades
|
|
* @description get the list of most recent trades for a particular symbol
|
|
* @see https://api-docs.defx.com/#5865452f-ea32-4f13-bfbc-03af5f5574fd
|
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
*/
|
|
func (this *Defx) 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 defx#fetchMyTrades
|
|
* @description fetch all trades made by the user
|
|
* @see https://api-docs.defx.com/#06b5b33c-2fc6-48de-896c-fc316f5871a7
|
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
*/
|
|
func (this *Defx) 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 defx#fetchOrderBook
|
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
* @see https://api-docs.defx.com/#6c1a2971-8325-4e7d-9962-e0bfcaacf9c4
|
|
* @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
|
|
* @param {string} [params.slab] slab from market.info.depthSlabs
|
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
*/
|
|
func (this *Defx) 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 defx#fetchMarkPrice
|
|
* @description fetches mark price for the market
|
|
* @see https://api-docs.defx.com/#12168192-4e7b-4458-a001-e8b80961f0b7
|
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.subType] "linear" or "inverse"
|
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
*/
|
|
func (this *Defx) FetchMarkPrice(symbol string, options ...FetchMarkPriceOptions) (Ticker, error) {
|
|
|
|
opts := FetchMarkPriceOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchMarkPrice(symbol, params)
|
|
if IsError(res) {
|
|
return Ticker{}, CreateReturnError(res)
|
|
}
|
|
return NewTicker(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#fetchFundingRate
|
|
* @description fetch the current funding rate
|
|
* @see https://api-docs.defx.com/#12168192-4e7b-4458-a001-e8b80961f0b7
|
|
* @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 *Defx) 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 defx#fetchBalance
|
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
* @see https://api-docs.defx.com/#26414338-14f7-40a1-b246-f8ea8571493f
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
*/
|
|
func (this *Defx) FetchBalance(params ...interface{}) (Balances, error) {
|
|
res := <- this.Core.FetchBalance(params...)
|
|
if IsError(res) {
|
|
return Balances{}, CreateReturnError(res)
|
|
}
|
|
return NewBalances(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#createOrder
|
|
* @description create a trade order
|
|
* @see https://api-docs.defx.com/#ba222d88-8856-4d3c-87a9-7cec07bb2622
|
|
* @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 {float} [params.triggerPrice] The price a trigger order is triggered at
|
|
* @param {string} [params.reduceOnly] for swap and future reduceOnly is a string 'true' or 'false' that cant be sent with close position set to true or in hedge mode. For spot margin and option reduceOnly is a boolean.
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) 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 defx#cancelOrder
|
|
* @see https://api-docs.defx.com/#09186f23-f8d1-4993-acf4-9974d8a6ddb0
|
|
* @description cancels an open order
|
|
* @param {string} id order id
|
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) CancelOrder(id string, options ...CancelOrderOptions) (map[string]interface{}, 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 map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#cancelAllOrders
|
|
* @description cancel all open orders
|
|
* @see https://api-docs.defx.com/#db5531da-3692-4a53-841f-6ad6495f823a
|
|
* @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
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) CancelAllOrders(options ...CancelAllOrdersOptions) (map[string]interface{}, 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 map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#fetchPosition
|
|
* @description fetch data on a single open contract trade position
|
|
* @see https://api-docs.defx.com/#d89dbb86-9aba-4f59-ac5d-a97ff25ea80e
|
|
* @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 *Defx) 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 defx#fetchPositions
|
|
* @description fetch all open positions
|
|
* @see https://api-docs.defx.com/#d89dbb86-9aba-4f59-ac5d-a97ff25ea80e
|
|
* @param {string[]} [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 *Defx) 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 defx#fetchOrder
|
|
* @description fetches information on an order made by the user
|
|
* @see https://api-docs.defx.com/#44f82dd5-26b3-4e1f-b4aa-88ceddd65237
|
|
* @param {string} id the order id
|
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) 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 defx#fetchOrders
|
|
* @description fetches information on multiple orders made by the user
|
|
* @see https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) 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
|
|
}
|
|
/**
|
|
* @method
|
|
* @name defx#fetchOpenOrders
|
|
* @description fetch all unfilled currently open orders
|
|
* @see https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) 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 defx#fetchClosedOrders
|
|
* @description fetches information on multiple closed orders made by the user
|
|
* @see https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) 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 defx#fetchCanceledOrders
|
|
* @description fetches information on multiple canceled orders made by the user
|
|
* @see https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Defx) 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 defx#fetchLedger
|
|
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
|
* @see https://api-docs.defx.com/#38cc8974-794f-48c0-b959-db045a0ee565
|
|
* @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 exchange API endpoint
|
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
* @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 {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
|
*/
|
|
func (this *Defx) 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 defx#withdraw
|
|
* @description make a withdrawal
|
|
* @see https://api-docs.defx.com/#2600f503-63ed-4672-b8f6-69ea5f03203b
|
|
* @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 *Defx) 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 defx#setLeverage
|
|
* @description set the level of leverage for a market
|
|
* @see https://api-docs.defx.com/#4cb4ecc4-6c61-4194-8353-be67faaf7ca7
|
|
* @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 *Defx) SetLeverage(leverage int64, options ...SetLeverageOptions) (Leverage, error) {
|
|
|
|
opts := SetLeverageOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.SetLeverage(leverage, symbol, params)
|
|
if IsError(res) {
|
|
return Leverage{}, CreateReturnError(res)
|
|
}
|
|
return NewLeverage(res), nil
|
|
} |