1847 lines
69 KiB
Go
1847 lines
69 KiB
Go
package ccxt
|
|
|
|
type Bingx struct {
|
|
*bingx
|
|
Core *bingx
|
|
}
|
|
|
|
func NewBingx(userConfig map[string]interface{}) Bingx {
|
|
p := &bingx{}
|
|
p.Init(userConfig)
|
|
return Bingx{
|
|
bingx: 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 bingx#fetchTime
|
|
* @description fetches the current integer timestamp in milliseconds from the bingx server
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/base-info.html#Get%20Server%20Time
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {int} the current integer timestamp in milliseconds from the bingx server
|
|
*/
|
|
func (this *Bingx) FetchTime(params ...interface{}) ( int64, error) {
|
|
res := <- this.Core.FetchTime(params...)
|
|
if IsError(res) {
|
|
return -1, CreateReturnError(res)
|
|
}
|
|
return (res).(int64), nil
|
|
}
|
|
func (this *Bingx) FetchSpotMarkets(params interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchSpotMarkets(params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
func (this *Bingx) FetchSwapMarkets(params interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchSwapMarkets(params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
func (this *Bingx) FetchInverseSwapMarkets(params interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchInverseSwapMarkets(params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchMarkets
|
|
* @description retrieves data on all markets for bingx
|
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20Symbols
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Contract%20Information
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Contract%20Information
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object[]} an array of objects representing market data
|
|
*/
|
|
func (this *Bingx) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchMarkets(params...)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchOHLCV
|
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
|
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20Kline/Candlestick%20Data
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20K-line%20Data
|
|
* @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 [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 *Bingx) 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 bingx#fetchTrades
|
|
* @description get the list of most recent trades for a particular symbol
|
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20transaction%20records
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#The%20latest%20Trade%20of%20a%20Trading%20Pair
|
|
* @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 {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchOrderBook
|
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20depth%20information
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Market%20Depth
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%20Depth%20Data
|
|
* @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 *Bingx) 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 bingx#fetchFundingRate
|
|
* @description fetch the current funding rate
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Price%20&%20Current%20Funding%20Rate
|
|
* @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 *Bingx) 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 bingx#fetchFundingRates
|
|
* @description fetch the current funding rate for multiple symbols
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
|
|
* @param {string[]} [symbols] list of unified market symbols
|
|
* @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-structure}
|
|
*/
|
|
func (this *Bingx) FetchFundingRates(options ...FetchFundingRatesOptions) (FundingRates, error) {
|
|
|
|
opts := FetchFundingRatesOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbols interface{} = nil
|
|
if opts.Symbols != nil {
|
|
symbols = *opts.Symbols
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchFundingRates(symbols, params)
|
|
if IsError(res) {
|
|
return FundingRates{}, CreateReturnError(res)
|
|
}
|
|
return NewFundingRates(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchFundingRateHistory
|
|
* @description fetches historical funding rate prices
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Funding%20Rate%20History
|
|
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] timestamp in ms of the latest funding rate 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 {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchOpenInterest
|
|
* @description retrieves the open interest of a trading pair
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Swap%20Open%20Positions
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20Swap%20Open%20Positions
|
|
* @param {string} symbol unified CCXT market symbol
|
|
* @param {object} [params] exchange specific parameters
|
|
* @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
*/
|
|
func (this *Bingx) FetchOpenInterest(symbol string, options ...FetchOpenInterestOptions) (OpenInterest, error) {
|
|
|
|
opts := FetchOpenInterestOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchOpenInterest(symbol, params)
|
|
if IsError(res) {
|
|
return OpenInterest{}, CreateReturnError(res)
|
|
}
|
|
return NewOpenInterest(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchTicker
|
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
|
|
* @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 *Bingx) 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 bingx#fetchTickers
|
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
|
|
* @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 *Bingx) 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 bingx#fetchMarkPrice
|
|
* @description fetches mark prices for the market
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
|
|
* @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 dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchMarkPrices
|
|
* @description fetches mark prices for multiple markets
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
|
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
*/
|
|
func (this *Bingx) FetchMarkPrices(options ...FetchMarkPricesOptions) (Tickers, error) {
|
|
|
|
opts := FetchMarkPricesOptionsStruct{}
|
|
|
|
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.FetchMarkPrices(symbols, params)
|
|
if IsError(res) {
|
|
return Tickers{}, CreateReturnError(res)
|
|
}
|
|
return NewTickers(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchBalance
|
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
|
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Account%20Assets
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {boolean} [params.standard] whether to fetch standard contract balances
|
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
*/
|
|
func (this *Bingx) FetchBalance(params ...interface{}) (Balances, error) {
|
|
res := <- this.Core.FetchBalance(params...)
|
|
if IsError(res) {
|
|
return Balances{}, CreateReturnError(res)
|
|
}
|
|
return NewBalances(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchPositionHistory
|
|
* @description fetches historical positions
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Position%20History
|
|
* @param {string} symbol unified contract symbol
|
|
* @param {int} [since] the earliest time in ms to fetch positions for
|
|
* @param {int} [limit] the maximum amount of records to fetch
|
|
* @param {object} [params] extra parameters specific to the exchange api endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch positions for
|
|
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
*/
|
|
func (this *Bingx) FetchPositionHistory(symbol string, options ...FetchPositionHistoryOptions) ([]Position, error) {
|
|
|
|
opts := FetchPositionHistoryOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchPositionHistory(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewPositionArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchPositions
|
|
* @description fetch all open positions
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
|
* @see https://bingx-api.github.io/docs/#/en-us/standard/contract-interface.html#position
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {boolean} [params.standard] whether to fetch standard contract positions
|
|
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchPosition
|
|
* @description fetch data on a single open contract trade position
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
|
* @param {string} symbol unified market symbol of the market the position is held in
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#createMarketOrderWithCost
|
|
* @description create a market order by providing the symbol, side and cost
|
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
* @param {string} side 'buy' or 'sell'
|
|
* @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 *Bingx) CreateMarketOrderWithCost(symbol string, side string, cost float64, options ...CreateMarketOrderWithCostOptions) (Order, error) {
|
|
|
|
opts := CreateMarketOrderWithCostOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CreateMarketOrderWithCost(symbol, side, cost, params)
|
|
if IsError(res) {
|
|
return Order{}, CreateReturnError(res)
|
|
}
|
|
return NewOrder(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#createMarketBuyOrderWithCost
|
|
* @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 *Bingx) 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 bingx#createMarketSellOrderWithCost
|
|
* @description create a market sell 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 *Bingx) 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 bingx#createOrder
|
|
* @description create a trade order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade%20order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place%20TWAP%20Order
|
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
* @param {string} type 'market' or 'limit'
|
|
* @param {string} side 'buy' or 'sell'
|
|
* @param {float} amount how much you want to trade in units of the base currency
|
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.clientOrderId] a unique id for the order
|
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
* @param {string} [params.timeInForce] spot supports 'PO', 'GTC' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
|
|
* @param {bool} [params.reduceOnly] *swap only* true or false whether the order is reduce only
|
|
* @param {float} [params.triggerPrice] triggerPrice at which the attached take profit / stop loss order will be triggered
|
|
* @param {float} [params.stopLossPrice] stop loss trigger price
|
|
* @param {float} [params.takeProfitPrice] take profit trigger price
|
|
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
|
|
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
* @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
|
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
* @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
|
|
* @param {string} [params.positionSide] *contracts only* "BOTH" for one way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
|
* @param {boolean} [params.hedged] *swap only* whether the order is in hedged mode or one way mode
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#createOrders
|
|
* @description create a list of trade orders
|
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Batch%20Placing%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Bulk%20order
|
|
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {boolean} [params.sync] *spot only* if true, multiple orders are ordered serially and all orders do not require the same symbol/side/type
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#cancelOrder
|
|
* @description cancels an open order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20Order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20Order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20an%20Order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20TWAP%20Order
|
|
* @param {string} id order id
|
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.clientOrderId] a unique id for the order
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#cancelAllOrders
|
|
* @description cancel all open orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20all%20orders
|
|
* @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 *Bingx) 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 bingx#cancelOrders
|
|
* @description cancel multiple orders
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20a%20Batch%20of%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Cancel%20a%20Batch%20of%20Orders
|
|
* @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
|
|
* @param {string[]} [params.clientOrderIds] client order ids
|
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#cancelAllOrdersAfter
|
|
* @description dead man's switch, cancel all orders after the given timeout
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20all%20orders%20in%20countdown
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20all%20orders%20in%20countdown
|
|
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.type] spot or swap market
|
|
* @returns {object} the api result
|
|
*/
|
|
func (this *Bingx) CancelAllOrdersAfter(timeout int64, options ...CancelAllOrdersAfterOptions) (map[string]interface{}, error) {
|
|
|
|
opts := CancelAllOrdersAfterOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CancelAllOrdersAfter(timeout, params)
|
|
if IsError(res) {
|
|
return map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchOrder
|
|
* @description fetches information on an order made by the user
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20details
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20details
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#TWAP%20Order%20Details
|
|
* @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
|
|
* @param {boolean} [params.twap] if fetching twap order
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchOrders
|
|
* @description fetches information on multiple orders made by the user
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#All%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history (returns less fields than above)
|
|
* @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 entries for
|
|
* @param {int} [params.orderId] Only return subsequent orders, and return the latest order by default
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchOpenOrders
|
|
* @description fetch all unfilled currently open orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Current%20Open%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Current%20All%20Open%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20all%20current%20pending%20orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20TWAP%20Entrusted%20Order
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {boolean} [params.twap] if fetching twap open orders
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchClosedOrders
|
|
* @description fetches information on multiple closed orders made by the user
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
|
* @param {string} symbol unified market symbol of the closed orders
|
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
* @param {int} [limit] the max number of closed orders to return
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @param {boolean} [params.standard] whether to fetch standard contract orders
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchCanceledOrders
|
|
* @description fetches information on multiple canceled orders made by the user
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
|
* @param {string} symbol unified market symbol of the canceled orders
|
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
* @param {int} [limit] the max number of canceled orders to return
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @param {boolean} [params.standard] whether to fetch standard contract orders
|
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchCanceledAndClosedOrders
|
|
* @description fetches information on multiple closed orders made by the user
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20TWAP%20Historical%20Orders
|
|
* @param {string} [symbol] unified market symbol of the market orders were made in
|
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
* @param {boolean} [params.standard] whether to fetch standard contract orders
|
|
* @param {boolean} [params.twap] if fetching twap orders
|
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) FetchCanceledAndClosedOrders(options ...FetchCanceledAndClosedOrdersOptions) ([]Order, error) {
|
|
|
|
opts := FetchCanceledAndClosedOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchCanceledAndClosedOrders(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#transfer
|
|
* @description transfer currency internally between wallets on the same account
|
|
* @see https://bingx-api.github.io/docs/#/spot/account-api.html#User%20Universal%20Transfer
|
|
* @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
|
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchTransfers
|
|
* @description fetch a history of internal transfers made on an account
|
|
* @see https://bingx-api.github.io/docs/#/spot/account-api.html#Query%20User%20Universal%20Transfer%20History%20(USER_DATA)
|
|
* @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 *Bingx) 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 bingx#fetchDepositAddressesByNetwork
|
|
* @description fetch the deposit addresses for a currency associated with this account
|
|
* @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
|
|
* @param {string} code unified currency code
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a dictionary [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}, indexed by the network
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchDepositAddress
|
|
* @description fetch the deposit address for a currency associated with this account
|
|
* @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
|
|
* @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 *Bingx) 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 bingx#fetchDeposits
|
|
* @description fetch all deposits made to an account
|
|
* @see https://bingx-api.github.io/docs/#/spot/account-api.html#Deposit%20History(supporting%20network)
|
|
* @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 *Bingx) 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 bingx#fetchWithdrawals
|
|
* @description fetch all withdrawals made from an account
|
|
* @see https://bingx-api.github.io/docs/#/spot/account-api.html#Withdraw%20History%20(supporting%20network)
|
|
* @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 *Bingx) 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 bingx#setMarginMode
|
|
* @description set margin mode to 'cross' or 'isolated'
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Change%20Margin%20Type
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Set%20Margin%20Type
|
|
* @param {string} marginMode 'cross' or 'isolated'
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} response from the exchange
|
|
*/
|
|
func (this *Bingx) SetMarginMode(marginMode string, options ...SetMarginModeOptions) (map[string]interface{}, error) {
|
|
|
|
opts := SetMarginModeOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.SetMarginMode(marginMode, symbol, params)
|
|
if IsError(res) {
|
|
return map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#setMargin
|
|
* @description Either adds or reduces margin in an isolated position in order to set the margin to a specific value
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Adjust%20isolated%20margin
|
|
* @param {string} symbol unified market symbol of the market to set margin in
|
|
* @param {float} amount the amount to set the margin to
|
|
* @param {object} [params] parameters specific to the bingx api endpoint
|
|
* @returns {object} A [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
*/
|
|
func (this *Bingx) SetMargin(symbol string, amount float64, options ...SetMarginOptions) (MarginModification, error) {
|
|
|
|
opts := SetMarginOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.SetMargin(symbol, amount, params)
|
|
if IsError(res) {
|
|
return MarginModification{}, CreateReturnError(res)
|
|
}
|
|
return NewMarginModification(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchLeverage
|
|
* @description fetch the set leverage for a market
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20Leverage
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Leverage
|
|
* @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 *Bingx) 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 bingx#setLeverage
|
|
* @description set the level of leverage for a market
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Switch%20Leverage
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Modify%20Leverage
|
|
* @param {float} leverage the rate of leverage
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.side] hedged: ['long' or 'short']. one way: ['both']
|
|
* @returns {object} response from the exchange
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchMyTrades
|
|
* @description fetch all trades made by the user
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20transaction%20details
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20details
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order%20Trade%20Detail
|
|
* @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] timestamp in ms for the ending date filter, default is undefined
|
|
* @param {string} params.trandingUnit COIN (directly represent assets such as BTC and ETH) or CONT (represents the number of contract sheets)
|
|
* @param {string} params.orderId the order id required for inverse swap
|
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchDepositWithdrawFees
|
|
* @description fetch deposit and withdraw fees
|
|
* @see https://bingx-api.github.io/docs/#/common/account-api.html#All%20Coins'%20Information
|
|
* @param {string[]|undefined} codes list of unified currency codes
|
|
* @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 *Bingx) 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 bingx#withdraw
|
|
* @description make a withdrawal
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/wallet-api.html#Withdraw
|
|
* @param {string} code unified currency code
|
|
* @param {float} amount the amount to withdraw
|
|
* @param {string} address the address to withdraw to
|
|
* @param {string} [tag]
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.walletType] 1 fund account, 2 standard account, 3 perpetual account
|
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
*/
|
|
func (this *Bingx) 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 bingx#fetchMyLiquidations
|
|
* @description retrieves the users liquidated positions
|
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#User's%20Force%20Orders
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20force%20orders
|
|
* @param {string} [symbol] unified CCXT market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
* @param {object} [params] exchange specific parameters for the bingx api endpoint
|
|
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
|
*/
|
|
func (this *Bingx) FetchMyLiquidations(options ...FetchMyLiquidationsOptions) ([]Liquidation, error) {
|
|
|
|
opts := FetchMyLiquidationsOptionsStruct{}
|
|
|
|
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.FetchMyLiquidations(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewLiquidationArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#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://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Get%20Position%20Mode
|
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
|
*/
|
|
func (this *Bingx) 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 bingx#setPositionMode
|
|
* @description set hedged to true or false for a market
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Position%20Mode
|
|
* @param {bool} hedged set to true to use dualSidePosition
|
|
* @param {string} symbol not used by bingx setPositionMode ()
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} response from the exchange
|
|
*/
|
|
func (this *Bingx) 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 bingx#editOrder
|
|
* @description cancels an order and places a new order
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20order%20and%20place%20a%20new%20order // spot
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20an%20order%20and%20then%20Place%20a%20new%20order // swap
|
|
* @param {string} id order id
|
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
* @param {string} type 'market' or 'limit'
|
|
* @param {string} side 'buy' or 'sell'
|
|
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.triggerPrice] Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
|
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.cancelClientOrderID] the user-defined id of the order to be canceled, 1-40 characters, different orders cannot use the same clientOrderID, only supports a query range of 2 hours
|
|
* @param {string} [params.cancelRestrictions] cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
|
|
* @param {string} [params.cancelReplaceMode] STOP_ON_FAILURE - if the cancel order fails, it will not continue to place a new order, ALLOW_FAILURE - regardless of whether the cancel order succeeds or fails, it will continue to place a new order
|
|
* @param {float} [params.quoteOrderQty] order amount
|
|
* @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
|
|
* @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
|
|
* @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
|
|
* @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
|
|
* @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Bingx) EditOrder(id string, symbol string, typeVar string, side string, options ...EditOrderOptions) (Order, error) {
|
|
|
|
opts := EditOrderOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var amount interface{} = nil
|
|
if opts.Amount != nil {
|
|
amount = *opts.Amount
|
|
}
|
|
|
|
var price interface{} = nil
|
|
if opts.Price != nil {
|
|
price = *opts.Price
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.EditOrder(id, symbol, typeVar, side, amount, price, params)
|
|
if IsError(res) {
|
|
return Order{}, CreateReturnError(res)
|
|
}
|
|
return NewOrder(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchMarginMode
|
|
* @description fetches the margin mode of the trading pair
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Type
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Margin%20Type
|
|
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
*/
|
|
func (this *Bingx) FetchMarginMode(symbol string, options ...FetchMarginModeOptions) (MarginMode, error) {
|
|
|
|
opts := FetchMarginModeOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchMarginMode(symbol, params)
|
|
if IsError(res) {
|
|
return MarginMode{}, CreateReturnError(res)
|
|
}
|
|
return NewMarginMode(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name bingx#fetchTradingFee
|
|
* @description fetch the trading fees for a market
|
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Trading%20Commission%20Rate
|
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20Trading%20Commission%20Rate
|
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Trade%20Commission%20Rate
|
|
* @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 *Bingx) 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
|
|
} |