3261 lines
135 KiB
Go
3261 lines
135 KiB
Go
![]() |
package ccxt
|
||
|
|
||
|
type Binance struct {
|
||
|
*binance
|
||
|
Core *binance
|
||
|
}
|
||
|
|
||
|
func NewBinance(userConfig map[string]interface{}) Binance {
|
||
|
p := &binance{}
|
||
|
p.Init(userConfig)
|
||
|
return Binance{
|
||
|
binance: 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 binance#fetchTime
|
||
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#check-server-time // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Check-Server-Time // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Check-Server-time // future
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
||
|
*/
|
||
|
func (this *Binance) FetchTime(params ...interface{}) ( int64, error) {
|
||
|
res := <- this.Core.FetchTime(params...)
|
||
|
if IsError(res) {
|
||
|
return -1, CreateReturnError(res)
|
||
|
}
|
||
|
return (res).(int64), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchMarkets
|
||
|
* @description retrieves data on all markets for binance
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#exchange-information // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Exchange-Information // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Exchange-Information // future
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Exchange-Information // option
|
||
|
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs // cross margin
|
||
|
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol // isolated margin
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object[]} an array of objects representing market data
|
||
|
*/
|
||
|
func (this *Binance) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
|
||
|
res := <- this.Core.FetchMarkets(params...)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewMarketInterfaceArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchBalance
|
||
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#account-information-user_data // spot
|
||
|
* @see https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details // cross margin
|
||
|
* @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info // isolated margin
|
||
|
* @see https://developers.binance.com/docs/wallet/asset/funding-wallet // funding
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Futures-Account-Balance-V2 // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Futures-Account-Balance // future
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/account/Option-Account-Information // option
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Account-Balance // portfolio margin
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi'
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
|
||
|
* @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
|
||
|
* @param {string} [params.subType] 'linear' or 'inverse'
|
||
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchBalance(params ...interface{}) (Balances, error) {
|
||
|
res := <- this.Core.FetchBalance(params...)
|
||
|
if IsError(res) {
|
||
|
return Balances{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewBalances(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchOrderBook
|
||
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#order-book // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Order-Book // future
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Order-Book // option
|
||
|
* @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 *Binance) 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 binance#fetchStatus
|
||
|
* @description the latest known information on the availability of the exchange API
|
||
|
* @see https://developers.binance.com/docs/wallet/others/system-status
|
||
|
* @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 *Binance) 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 binance#fetchTicker
|
||
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#24hr-ticker-price-change-statistics // spot
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#rolling-window-price-change-statistics // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/24hr-Ticker-Price-Change-Statistics // future
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics // option
|
||
|
* @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 {boolean} [params.rolling] (spot only) default false, if true, uses the rolling 24 hour ticker endpoint /api/v3/ticker
|
||
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchBidsAsks
|
||
|
* @description fetches the bid and ask price and volume for multiple markets
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#symbol-order-book-ticker // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Symbol-Order-Book-Ticker // future
|
||
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchBidsAsks(options ...FetchBidsAsksOptions) (Tickers, error) {
|
||
|
|
||
|
opts := FetchBidsAsksOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbols interface{} = nil
|
||
|
if opts.Symbols != nil {
|
||
|
symbols = *opts.Symbols
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchBidsAsks(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return Tickers{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewTickers(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchLastPrices
|
||
|
* @description fetches the last price for multiple markets
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#symbol-price-ticker // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Price-Ticker // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Symbol-Price-Ticker // future
|
||
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a dictionary of lastprices structures
|
||
|
*/
|
||
|
func (this *Binance) FetchLastPrices(options ...FetchLastPricesOptions) (LastPrices, error) {
|
||
|
|
||
|
opts := FetchLastPricesOptionsStruct{}
|
||
|
|
||
|
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.FetchLastPrices(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return LastPrices{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLastPrices(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchTickers
|
||
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#24hr-ticker-price-change-statistics // spot
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics // swap
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/24hr-Ticker-Price-Change-Statistics // future
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics // option
|
||
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @param {string} [params.type] 'spot', 'option', use params["subType"] for swap and future markets
|
||
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchMarkPrice
|
||
|
* @description fetches mark price for the market
|
||
|
* @see https://binance-docs.github.io/apidocs/futures/en/#mark-price
|
||
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
|
||
|
* @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 *Binance) 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 binance#fetchMarkPrices
|
||
|
* @description fetches mark prices for multiple markets
|
||
|
* @see https://binance-docs.github.io/apidocs/futures/en/#mark-price
|
||
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
|
||
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchOHLCV
|
||
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#klinecandlestick-data
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Premium-Index-Kline-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Index-Price-Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Mark-Price-Kline-Candlestick-Data
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Premium-Index-Kline-Data
|
||
|
* @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 {string} [params.price] "mark" or "index" for mark price and index price candles
|
||
|
* @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 *Binance) 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 binance#fetchTrades
|
||
|
* @description get the list of most recent trades for a particular symbol
|
||
|
* Default fetchTradesMethod
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#compressedaggregate-trades-list // publicGetAggTrades (spot)
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List // fapiPublicGetAggTrades (swap)
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Compressed-Aggregate-Trades-List // dapiPublicGetAggTrades (future)
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Recent-Trades-List // eapiPublicGetTrades (option)
|
||
|
* Other fetchTradesMethod
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#recent-trades-list // publicGetTrades (spot)
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Recent-Trades-List // fapiPublicGetTrades (swap)
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Recent-Trades-List // dapiPublicGetTrades (future)
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#old-trade-lookup // publicGetHistoricalTrades (spot)
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Old-Trades-Lookup // fapiPublicGetHistoricalTrades (swap)
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Old-Trades-Lookup // dapiPublicGetHistoricalTrades (future)
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Old-Trades-Lookup // eapiPublicGetHistoricalTrades (option)
|
||
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
||
|
* @param {int} [since] only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
|
||
|
* @param {int} [limit] default 500, max 1000
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
|
||
|
* @param {int} [params.fetchTradesMethod] 'publicGetAggTrades' (spot default), 'fapiPublicGetAggTrades' (swap default), 'dapiPublicGetAggTrades' (future default), 'eapiPublicGetTrades' (option default), 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', 'publicGetHistoricalTrades', 'fapiPublicGetHistoricalTrades', 'dapiPublicGetHistoricalTrades', 'eapiPublicGetHistoricalTrades'
|
||
|
* @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)
|
||
|
*
|
||
|
* EXCHANGE SPECIFIC PARAMETERS
|
||
|
* @param {int} [params.fromId] trade id to fetch from, default gets most recent trades, not used when fetchTradesMethod is 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', or 'eapiPublicGetTrades'
|
||
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#editSpotOrder
|
||
|
* @ignore
|
||
|
* @description edit a trade order
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#cancel-an-existing-order-and-send-a-new-order-trade
|
||
|
* @param {string} id cancel order id
|
||
|
* @param {string} symbol unified symbol of the market to create an order in
|
||
|
* @param {string} type 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
|
||
|
* @param {string} side 'buy' or 'sell'
|
||
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
||
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) EditSpotOrder(id string, symbol string, typeVar string, side string, amount float64, options ...EditSpotOrderOptions) (Order, error) {
|
||
|
|
||
|
opts := EditSpotOrderOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var price interface{} = nil
|
||
|
if opts.Price != nil {
|
||
|
price = *opts.Price
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.EditSpotOrder(id, symbol, typeVar, side, amount, price, params)
|
||
|
if IsError(res) {
|
||
|
return Order{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOrder(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#editContractOrder
|
||
|
* @description edit a trade order
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Modify-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-UM-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-CM-Order
|
||
|
* @param {string} id cancel order id
|
||
|
* @param {string} symbol unified symbol of the market to create an order in
|
||
|
* @param {string} type 'market' or 'limit'
|
||
|
* @param {string} side 'buy' or 'sell'
|
||
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
||
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to edit an order in a portfolio margin account
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) EditContractOrder(id string, symbol string, typeVar string, side string, amount float64, options ...EditContractOrderOptions) (Order, error) {
|
||
|
|
||
|
opts := EditContractOrderOptionsStruct{}
|
||
|
|
||
|
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.EditContractOrder(id, symbol, typeVar, side, amount, price, params)
|
||
|
if IsError(res) {
|
||
|
return Order{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOrder(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#editOrder
|
||
|
* @description edit a trade order
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#cancel-an-existing-order-and-send-a-new-order-trade
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Modify-Order
|
||
|
* @param {string} id cancel order id
|
||
|
* @param {string} symbol unified symbol of the market to create an order in
|
||
|
* @param {string} type 'market' or 'limit'
|
||
|
* @param {string} side 'buy' or 'sell'
|
||
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
||
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#editOrders
|
||
|
* @description edit a list of trade orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Multiple-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Modify-Multiple-Orders
|
||
|
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) EditOrders(orders []OrderRequest, options ...EditOrdersOptions) ([]Order, error) {
|
||
|
|
||
|
opts := EditOrdersOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.EditOrders(orders, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOrderArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#createOrders
|
||
|
* @description *contract only* create a list of trade orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Place-Multiple-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Place-Multiple-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Place-Multiple-Orders
|
||
|
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#createOrder
|
||
|
* @description create a trade order
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/New-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/New-Order
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#sor
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#test-new-order-using-sor-trade
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-Margin-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Conditional-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Conditional-Order
|
||
|
* @param {string} symbol unified symbol of the market to create an order in
|
||
|
* @param {string} type 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
|
||
|
* @param {string} side 'buy' or 'sell'
|
||
|
* @param {float} amount how much of you want to trade in units of the base currency
|
||
|
* @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {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.
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
||
|
* @param {boolean} [params.sor] *spot only* whether to use SOR (Smart Order Routing) or not, default is false
|
||
|
* @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
|
||
|
* @param {float} [params.trailingPercent] the percent to trail away from the current market price
|
||
|
* @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
||
|
* @param {float} [params.triggerPrice] the price that a trigger order is triggered at
|
||
|
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
|
||
|
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
|
||
|
* @param {string} [params.selfTradePrevention] set unified value for stp (see .features for available values)
|
||
|
* @param {float} [params.icebergAmount] set iceberg amount for limit orders
|
||
|
* @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
|
||
|
* @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
||
|
* @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#createMarketOrderWithCost
|
||
|
* @description create a market order by providing the symbol, side and cost
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#new-order-trade
|
||
|
* @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 *Binance) 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 binance#createMarketBuyOrderWithCost
|
||
|
* @description create a market buy order by providing the symbol and cost
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#new-order-trade
|
||
|
* @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 *Binance) 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 binance#createMarketSellOrderWithCost
|
||
|
* @description create a market sell order by providing the symbol and cost
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#new-order-trade
|
||
|
* @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 *Binance) 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 binance#fetchOrder
|
||
|
* @description fetches information on an order made by the user
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#query-order-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Query-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Single-Order
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Order
|
||
|
* @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 {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch an order in a portfolio margin account
|
||
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchOrders
|
||
|
* @description fetches information on multiple orders made by the user
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#all-orders-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
|
||
|
* @param {string} symbol unified market symbol of the market orders were made in
|
||
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
||
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
||
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
||
|
* @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)
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
|
||
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchOpenOrders
|
||
|
* @description fetch all unfilled currently open orders
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#current-open-orders-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Current-All-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Current-All-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Current-Open-Option-Orders
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Conditional-Orders
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
||
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch open orders in the portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account conditional orders
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchOpenOrder
|
||
|
* @description fetch an open order by the id
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Current-Open-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Query-Current-Open-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Conditional-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Conditional-Order
|
||
|
* @param {string} id order id
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch for a portfolio margin account
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchOpenOrder(id string, options ...FetchOpenOrderOptions) (Order, error) {
|
||
|
|
||
|
opts := FetchOpenOrderOptionsStruct{}
|
||
|
|
||
|
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.FetchOpenOrder(id, symbol, params)
|
||
|
if IsError(res) {
|
||
|
return Order{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOrder(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchClosedOrders
|
||
|
* @description fetches information on multiple closed orders made by the user
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#all-orders-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
|
||
|
* @param {string} symbol unified market symbol of the market orders were made in
|
||
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
||
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.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)
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
|
||
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchCanceledOrders
|
||
|
* @description fetches information on multiple canceled orders made by the user
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#all-orders-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
|
||
|
* @param {string} symbol unified market symbol of the market the orders were made in
|
||
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
||
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.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)
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
|
||
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchCanceledOrders(options ...FetchCanceledOrdersOptions) (map[string]interface{}, 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 map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchCanceledAndClosedOrders
|
||
|
* @description fetches information on multiple canceled orders made by the user
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#all-orders-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
|
||
|
* @param {string} symbol unified market symbol of the market the orders were made in
|
||
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
||
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.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)
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
|
||
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#cancelOrder
|
||
|
* @description cancels an open order
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#cancel-order-trade
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Cancel-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Cancel-Option-Order
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Conditional-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Conditional-Order
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-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
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to cancel an order in a portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to cancel a portfolio margin account conditional order
|
||
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#cancelAllOrders
|
||
|
* @description cancel all open orders in a market
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#cancel-all-open-orders-on-a-symbol-trade
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-All-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Cancel-all-Option-orders-on-specific-symbol
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-All-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Conditional-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-All-Open-Orders-on-a-Symbol
|
||
|
* @param {string} symbol unified market symbol of the market to cancel orders in
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to cancel orders in a portfolio margin account
|
||
|
* @param {boolean} [params.trigger] set to true if you would like to cancel portfolio margin account conditional orders
|
||
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#cancelOrders
|
||
|
* @description cancel multiple orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Multiple-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Cancel-Multiple-Orders
|
||
|
* @param {string[]} ids order ids
|
||
|
* @param {string} [symbol] unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
*
|
||
|
* EXCHANGE SPECIFIC PARAMETERS
|
||
|
* @param {string[]} [params.origClientOrderIdList] max length 10 e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma
|
||
|
* @param {int[]} [params.recvWindow]
|
||
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchOrderTrades
|
||
|
* @description fetch all the trades made from a single order
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#account-trade-list-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
|
||
|
* @param {string} id order id
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
||
|
* @param {int} [limit] the maximum number of trades to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchOrderTrades(id string, options ...FetchOrderTradesOptions) ([]Trade, error) {
|
||
|
|
||
|
opts := FetchOrderTradesOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbol interface{} = nil
|
||
|
if opts.Symbol != nil {
|
||
|
symbol = *opts.Symbol
|
||
|
}
|
||
|
|
||
|
var since interface{} = nil
|
||
|
if opts.Since != nil {
|
||
|
since = *opts.Since
|
||
|
}
|
||
|
|
||
|
var limit interface{} = nil
|
||
|
if opts.Limit != nil {
|
||
|
limit = *opts.Limit
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchOrderTrades(id, symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewTradeArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchMyTrades
|
||
|
* @description fetch all trades made by the user
|
||
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#account-trade-list-user_data
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Account-Trade-List
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Account-Trade-List
|
||
|
* @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 {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)
|
||
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trades for a portfolio margin account
|
||
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchMyDustTrades
|
||
|
* @description fetch all dust trades made by the user
|
||
|
* @see https://developers.binance.com/docs/wallet/asset/dust-log
|
||
|
* @param {string} symbol not used by binance fetchMyDustTrades ()
|
||
|
* @param {int} [since] the earliest time in ms to fetch my dust trades for
|
||
|
* @param {int} [limit] the maximum number of dust trades to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.type] 'spot' or 'margin', default spot
|
||
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchMyDustTrades(options ...FetchMyDustTradesOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := FetchMyDustTradesOptionsStruct{}
|
||
|
|
||
|
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.FetchMyDustTrades(symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchDeposits
|
||
|
* @description fetch all deposits made to an account
|
||
|
* @see https://developers.binance.com/docs/wallet/capital/deposite-history
|
||
|
* @see https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History
|
||
|
* @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
|
||
|
* @param {bool} [params.fiat] if true, only fiat deposits will be returned
|
||
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
||
|
* @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 list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchWithdrawals
|
||
|
* @description fetch all withdrawals made from an account
|
||
|
* @see https://developers.binance.com/docs/wallet/capital/withdraw-history
|
||
|
* @see https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History
|
||
|
* @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
|
||
|
* @param {bool} [params.fiat] if true, only fiat withdrawals will be returned
|
||
|
* @param {int} [params.until] the latest time in ms to fetch withdrawals for
|
||
|
* @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 list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#transfer
|
||
|
* @description transfer currency internally between wallets on the same account
|
||
|
* @see https://developers.binance.com/docs/wallet/asset/user-universal-transfer
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {float} amount amount to transfer
|
||
|
* @param {string} fromAccount account to transfer from
|
||
|
* @param {string} toAccount account to transfer to
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.type] exchange specific transfer type
|
||
|
* @param {string} [params.symbol] the unified symbol, required for isolated margin transfers
|
||
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchTransfers
|
||
|
* @description fetch a history of internal transfers made on an account
|
||
|
* @see https://developers.binance.com/docs/wallet/asset/query-user-universal-transfer
|
||
|
* @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
|
||
|
* @param {int} [params.until] the latest time in ms to fetch transfers for
|
||
|
* @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)
|
||
|
* @param {boolean} [params.internal] default false, when true will fetch pay trade history
|
||
|
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchDepositAddress
|
||
|
* @description fetch the deposit address for a currency associated with this account
|
||
|
* @see https://developers.binance.com/docs/wallet/capital/deposite-address
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.network] network for fetch deposit address
|
||
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchTransactionFees
|
||
|
* @deprecated
|
||
|
* @description please use fetchDepositWithdrawFees instead
|
||
|
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
|
||
|
* @param {string[]|undefined} codes not used by binance fetchTransactionFees ()
|
||
|
* @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 *Binance) FetchTransactionFees(options ...FetchTransactionFeesOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := FetchTransactionFeesOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var codes interface{} = nil
|
||
|
if opts.Codes != nil {
|
||
|
codes = *opts.Codes
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchTransactionFees(codes, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchDepositWithdrawFees
|
||
|
* @description fetch deposit and withdraw fees
|
||
|
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
|
||
|
* @param {string[]|undefined} codes not used by binance fetchDepositWithdrawFees ()
|
||
|
* @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 *Binance) 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 binance#withdraw
|
||
|
* @description make a withdrawal
|
||
|
* @see https://developers.binance.com/docs/wallet/capital/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
|
||
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchTradingFee
|
||
|
* @description fetch the trading fees for a market
|
||
|
* @see https://developers.binance.com/docs/wallet/asset/trade-fee
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/User-Commission-Rate
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/User-Commission-Rate
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-User-Commission-Rate-for-UM
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-User-Commission-Rate-for-CM
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchTradingFee(symbol string, options ...FetchTradingFeeOptions) (TradingFeeInterface, error) {
|
||
|
|
||
|
opts := FetchTradingFeeOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchTradingFee(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return TradingFeeInterface{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewTradingFeeInterface(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchTradingFees
|
||
|
* @description fetch the trading fees for multiple markets
|
||
|
* @see https://developers.binance.com/docs/wallet/asset/trade-fee
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Config
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
||
|
*/
|
||
|
func (this *Binance) FetchTradingFees(params ...interface{}) (TradingFees, error) {
|
||
|
res := <- this.Core.FetchTradingFees(params...)
|
||
|
if IsError(res) {
|
||
|
return TradingFees{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewTradingFees(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchFundingRate
|
||
|
* @description fetch the current funding rate
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Index-Price-and-Mark-Price
|
||
|
* @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 *Binance) 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 binance#fetchFundingRateHistory
|
||
|
* @description fetches historical funding rate prices
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Get-Funding-Rate-History-of-Perpetual-Futures
|
||
|
* @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
|
||
|
* @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)
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchFundingRates
|
||
|
* @description fetch the funding rate for multiple markets
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Index-Price-and-Mark-Price
|
||
|
* @param {string[]|undefined} symbols list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchLeverageTiers
|
||
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Notional-and-Leverage-Brackets
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Notional-Bracket-for-Symbol
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/UM-Notional-and-Leverage-Brackets
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/CM-Notional-and-Leverage-Brackets
|
||
|
* @param {string[]|undefined} symbols list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
||
|
*/
|
||
|
func (this *Binance) FetchLeverageTiers(options ...FetchLeverageTiersOptions) (LeverageTiers, error) {
|
||
|
|
||
|
opts := FetchLeverageTiersOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbols interface{} = nil
|
||
|
if opts.Symbols != nil {
|
||
|
symbols = *opts.Symbols
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchLeverageTiers(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return LeverageTiers{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLeverageTiers(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchPosition
|
||
|
* @description fetch data on an open position
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
|
||
|
* @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 *Binance) 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 binance#fetchOptionPositions
|
||
|
* @description fetch data on open options positions
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
|
||
|
* @param {string[]|undefined} symbols list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchOptionPositions(options ...FetchOptionPositionsOptions) ([]Position, error) {
|
||
|
|
||
|
opts := FetchOptionPositionsOptionsStruct{}
|
||
|
|
||
|
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.FetchOptionPositions(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewPositionArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchPositions
|
||
|
* @description fetch all open positions
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
|
||
|
* @param {string[]} [symbols] list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {object} [params.params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
||
|
* @param {bool} [params.useV2] set to true if you want to use the obsolete endpoint, where some more additional fields were provided
|
||
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchAccountPositions
|
||
|
* @ignore
|
||
|
* @description fetch account positions
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3
|
||
|
* @param {string[]} [symbols] list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
|
||
|
* @param {boolean} [params.useV2] set to true if you want to use obsolete endpoint, where some more additional fields were provided
|
||
|
* @returns {object} data on account positions
|
||
|
*/
|
||
|
func (this *Binance) FetchAccountPositions(options ...FetchAccountPositionsOptions) ([]Position, error) {
|
||
|
|
||
|
opts := FetchAccountPositionsOptionsStruct{}
|
||
|
|
||
|
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.FetchAccountPositions(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewPositionArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchPositionsRisk
|
||
|
* @ignore
|
||
|
* @description fetch positions risk
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-UM-Position-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-CM-Position-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V3
|
||
|
* @param {string[]|undefined} symbols list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @param {bool} [params.useV2] set to true if you want to use the obsolete endpoint, where some more additional fields were provided
|
||
|
* @returns {object} data on the positions risk
|
||
|
*/
|
||
|
func (this *Binance) FetchPositionsRisk(options ...FetchPositionsRiskOptions) ([]Position, error) {
|
||
|
|
||
|
opts := FetchPositionsRiskOptionsStruct{}
|
||
|
|
||
|
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.FetchPositionsRisk(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewPositionArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchFundingHistory
|
||
|
* @description fetch the history of funding payments paid and received on this account
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
||
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest funding history entry
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchFundingHistory(options ...FetchFundingHistoryOptions) ([]FundingHistory, error) {
|
||
|
|
||
|
opts := FetchFundingHistoryOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbol interface{} = nil
|
||
|
if opts.Symbol != nil {
|
||
|
symbol = *opts.Symbol
|
||
|
}
|
||
|
|
||
|
var since interface{} = nil
|
||
|
if opts.Since != nil {
|
||
|
since = *opts.Since
|
||
|
}
|
||
|
|
||
|
var limit interface{} = nil
|
||
|
if opts.Limit != nil {
|
||
|
limit = *opts.Limit
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchFundingHistory(symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewFundingHistoryArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#setLeverage
|
||
|
* @description set the level of leverage for a market
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Initial-Leverage
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Change-Initial-Leverage
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Change-UM-Initial-Leverage
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Change-CM-Initial-Leverage
|
||
|
* @param {float} leverage the rate of leverage
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to set the leverage for a trading pair in a portfolio margin account
|
||
|
* @returns {object} response from the exchange
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#setMarginMode
|
||
|
* @description set margin mode to 'cross' or 'isolated'
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Margin-Type
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Change-Margin-Type
|
||
|
* @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 *Binance) 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 binance#setPositionMode
|
||
|
* @description set hedged to true or false for a market
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Position-Mode
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Change-Position-Mode
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Current-Position-Mode
|
||
|
* @param {bool} hedged set to true to use dualSidePosition
|
||
|
* @param {string} symbol not used by binance setPositionMode ()
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} response from the exchange
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchLeverages
|
||
|
* @description fetch the set leverage for all markets
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
|
||
|
* @param {string[]} [symbols] a list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchLeverages(options ...FetchLeveragesOptions) (Leverages, error) {
|
||
|
|
||
|
opts := FetchLeveragesOptionsStruct{}
|
||
|
|
||
|
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.FetchLeverages(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return Leverages{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLeverages(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchSettlementHistory
|
||
|
* @description fetches historical settlement records
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Historical-Exercise-Records
|
||
|
* @param {string} symbol unified market symbol of the settlement history
|
||
|
* @param {int} [since] timestamp in ms
|
||
|
* @param {int} [limit] number of records, default 100, max 100
|
||
|
* @param {object} [params] exchange specific params
|
||
|
* @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/#/?id=settlement-history-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchSettlementHistory(options ...FetchSettlementHistoryOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := FetchSettlementHistoryOptionsStruct{}
|
||
|
|
||
|
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.FetchSettlementHistory(symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchMySettlementHistory
|
||
|
* @description fetches historical settlement records of the user
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/trade/User-Exercise-Record
|
||
|
* @param {string} symbol unified market symbol of the settlement history
|
||
|
* @param {int} [since] timestamp in ms
|
||
|
* @param {int} [limit] number of records
|
||
|
* @param {object} [params] exchange specific params
|
||
|
* @returns {object[]} a list of [settlement history objects]
|
||
|
*/
|
||
|
func (this *Binance) FetchMySettlementHistory(options ...FetchMySettlementHistoryOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := FetchMySettlementHistoryOptionsStruct{}
|
||
|
|
||
|
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.FetchMySettlementHistory(symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchLedgerEntry
|
||
|
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
|
||
|
* @param {string} id the identification number of the ledger entry
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
||
|
*/
|
||
|
func (this *Binance) FetchLedgerEntry(id string, options ...FetchLedgerEntryOptions) (LedgerEntry, error) {
|
||
|
|
||
|
opts := FetchLedgerEntryOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var code interface{} = nil
|
||
|
if opts.Code != nil {
|
||
|
code = *opts.Code
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchLedgerEntry(id, code, params)
|
||
|
if IsError(res) {
|
||
|
return LedgerEntry{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLedgerEntry(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchLedger
|
||
|
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
|
||
|
* @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)
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchCrossBorrowRate
|
||
|
* @description fetch the rate of interest to borrow a currency for margin trading
|
||
|
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchCrossBorrowRate(code string, options ...FetchCrossBorrowRateOptions) (CrossBorrowRate, error) {
|
||
|
|
||
|
opts := FetchCrossBorrowRateOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchCrossBorrowRate(code, params)
|
||
|
if IsError(res) {
|
||
|
return CrossBorrowRate{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewCrossBorrowRate(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchIsolatedBorrowRate
|
||
|
* @description fetch the rate of interest to borrow a currency for margin trading
|
||
|
* @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
*
|
||
|
* EXCHANGE SPECIFIC PARAMETERS
|
||
|
* @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
|
||
|
* @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchIsolatedBorrowRate(symbol string, options ...FetchIsolatedBorrowRateOptions) (IsolatedBorrowRate, error) {
|
||
|
|
||
|
opts := FetchIsolatedBorrowRateOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchIsolatedBorrowRate(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return IsolatedBorrowRate{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewIsolatedBorrowRate(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchIsolatedBorrowRates
|
||
|
* @description fetch the borrow interest rates of all currencies
|
||
|
* @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {object} [params.symbol] unified market symbol
|
||
|
*
|
||
|
* EXCHANGE SPECIFIC PARAMETERS
|
||
|
* @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
|
||
|
* @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchIsolatedBorrowRates(params ...interface{}) (IsolatedBorrowRates, error) {
|
||
|
res := <- this.Core.FetchIsolatedBorrowRates(params...)
|
||
|
if IsError(res) {
|
||
|
return IsolatedBorrowRates{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewIsolatedBorrowRates(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchBorrowRateHistory
|
||
|
* @description retrieves a history of a currencies borrow interest rate at specific time slots
|
||
|
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {int} [since] timestamp for the earliest borrow rate
|
||
|
* @param {int} [limit] the maximum number of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure} to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object[]} an array of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchBorrowRateHistory(code string, options ...FetchBorrowRateHistoryOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := FetchBorrowRateHistoryOptionsStruct{}
|
||
|
|
||
|
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.FetchBorrowRateHistory(code, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#createGiftCode
|
||
|
* @description create gift code
|
||
|
* @see https://developers.binance.com/docs/gift_card/market-data/Create-a-single-token-gift-card
|
||
|
* @param {string} code gift code
|
||
|
* @param {float} amount amount of currency for the gift
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} The gift code id, code, currency and amount
|
||
|
*/
|
||
|
func (this *Binance) CreateGiftCode(code string, amount interface{}, options ...CreateGiftCodeOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := CreateGiftCodeOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.CreateGiftCode(code, amount, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchBorrowInterest
|
||
|
* @description fetch the interest owed by the user for borrowing currency for margin trading
|
||
|
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-Margin-BorrowLoan-Interest-History
|
||
|
* @param {string} [code] unified currency code
|
||
|
* @param {string} [symbol] unified market symbol when fetch interest in isolated markets
|
||
|
* @param {int} [since] the earliest time in ms to fetch borrrow interest for
|
||
|
* @param {int} [limit] the maximum number of structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the borrow interest in a portfolio margin account
|
||
|
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchBorrowInterest(options ...FetchBorrowInterestOptions) ([]BorrowInterest, error) {
|
||
|
|
||
|
opts := FetchBorrowInterestOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var code interface{} = nil
|
||
|
if opts.Code != nil {
|
||
|
code = *opts.Code
|
||
|
}
|
||
|
|
||
|
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.FetchBorrowInterest(code, symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewBorrowInterestArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchOpenInterestHistory
|
||
|
* @description Retrieves the open interest history of a currency
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest-Statistics
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Open-Interest-Statistics
|
||
|
* @param {string} symbol Unified CCXT market symbol
|
||
|
* @param {string} timeframe "5m","15m","30m","1h","2h","4h","6h","12h", or "1d"
|
||
|
* @param {int} [since] the time(ms) of the earliest record to retrieve as a unix timestamp
|
||
|
* @param {int} [limit] default 30, max 500
|
||
|
* @param {object} [params] exchange specific parameters
|
||
|
* @param {int} [params.until] the time(ms) of the latest record to retrieve as a unix timestamp
|
||
|
* @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} an array of [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchOpenInterestHistory(symbol string, options ...FetchOpenInterestHistoryOptions) ([]OpenInterest, error) {
|
||
|
|
||
|
opts := FetchOpenInterestHistoryOptionsStruct{}
|
||
|
|
||
|
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.FetchOpenInterestHistory(symbol, timeframe, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOpenInterestArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchOpenInterest
|
||
|
* @description retrieves the open interest of a contract trading pair
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Open-Interest
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Open-Interest
|
||
|
* @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 *Binance) 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 binance#fetchMyLiquidations
|
||
|
* @description retrieves the users liquidated positions
|
||
|
* @see https://developers.binance.com/docs/margin_trading/trade/Get-Force-Liquidation-Record
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Users-Force-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Users-Force-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-UM-Force-Orders
|
||
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-CM-Force-Orders
|
||
|
* @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 binance api endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
||
|
* @param {boolean} [params.paginate] *spot only* 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)
|
||
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
|
||
|
* @param {string} [params.type] "spot"
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchGreeks
|
||
|
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price
|
||
|
* @param {string} symbol unified symbol of the market to fetch greeks for
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchGreeks(symbol string, options ...FetchGreeksOptions) (Greeks, error) {
|
||
|
|
||
|
opts := FetchGreeksOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchGreeks(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return Greeks{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewGreeks(res), nil
|
||
|
}
|
||
|
func (this *Binance) FetchTradingLimits(options ...FetchTradingLimitsOptions) (map[string]interface{}, error) {
|
||
|
|
||
|
opts := FetchTradingLimitsOptionsStruct{}
|
||
|
|
||
|
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.FetchTradingLimits(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return map[string]interface{}{}, CreateReturnError(res)
|
||
|
}
|
||
|
return res.(map[string]interface{}), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#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://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Current-Position-Mode
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Current-Position-Mode
|
||
|
* @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
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchMarginModes
|
||
|
* @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
|
||
|
* @param {string[]} symbols unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchMarginModes(options ...FetchMarginModesOptions) (MarginModes, error) {
|
||
|
|
||
|
opts := FetchMarginModesOptionsStruct{}
|
||
|
|
||
|
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.FetchMarginModes(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return MarginModes{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewMarginModes(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchMarginMode
|
||
|
* @description fetches the margin mode of a specific symbol
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
|
||
|
* @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.subType] "linear" or "inverse"
|
||
|
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
||
|
*/
|
||
|
func (this *Binance) 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 binance#fetchOption
|
||
|
* @description fetches option data that is commonly found in an option chain
|
||
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchOption(symbol string, options ...FetchOptionOptions) (Option, error) {
|
||
|
|
||
|
opts := FetchOptionOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchOption(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return Option{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOption(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchMarginAdjustmentHistory
|
||
|
* @description fetches the history of margin added or reduced from contract isolated positions
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Get-Position-Margin-Change-History
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Get-Position-Margin-Change-History
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {string} [type] "add" or "reduce"
|
||
|
* @param {int} [since] timestamp in ms of the earliest change to fetch
|
||
|
* @param {int} [limit] the maximum amount of changes to fetch
|
||
|
* @param {object} params extra parameters specific to the exchange api endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest change to fetch
|
||
|
* @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchMarginAdjustmentHistory(options ...FetchMarginAdjustmentHistoryOptions) ([]MarginModification, error) {
|
||
|
|
||
|
opts := FetchMarginAdjustmentHistoryOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbol interface{} = nil
|
||
|
if opts.Symbol != nil {
|
||
|
symbol = *opts.Symbol
|
||
|
}
|
||
|
|
||
|
var typeVar interface{} = nil
|
||
|
if opts.Type != nil {
|
||
|
typeVar = *opts.Type
|
||
|
}
|
||
|
|
||
|
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.FetchMarginAdjustmentHistory(symbol, typeVar, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewMarginModificationArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchConvertCurrencies
|
||
|
* @description fetches all available currencies that can be converted
|
||
|
* @see https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an associative dictionary of currencies
|
||
|
*/
|
||
|
func (this *Binance) FetchConvertCurrencies(params ...interface{}) (Currencies, error) {
|
||
|
res := <- this.Core.FetchConvertCurrencies(params...)
|
||
|
if IsError(res) {
|
||
|
return Currencies{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewCurrencies(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchConvertQuote
|
||
|
* @description fetch a quote for converting from one currency to another
|
||
|
* @see https://developers.binance.com/docs/convert/trade/Send-quote-request
|
||
|
* @param {string} fromCode the currency that you want to sell and convert from
|
||
|
* @param {string} toCode the currency that you want to buy and convert into
|
||
|
* @param {float} amount how much you want to trade in units of the from currency
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.walletType] either 'SPOT' or 'FUNDING', the default is 'SPOT'
|
||
|
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchConvertQuote(fromCode string, toCode string, options ...FetchConvertQuoteOptions) (Conversion, error) {
|
||
|
|
||
|
opts := FetchConvertQuoteOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var amount interface{} = nil
|
||
|
if opts.Amount != nil {
|
||
|
amount = *opts.Amount
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchConvertQuote(fromCode, toCode, amount, params)
|
||
|
if IsError(res) {
|
||
|
return Conversion{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewConversion(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#createConvertTrade
|
||
|
* @description convert from one currency to another
|
||
|
* @see https://developers.binance.com/docs/convert/trade/Accept-Quote
|
||
|
* @param {string} id the id of the trade that you want to make
|
||
|
* @param {string} fromCode the currency that you want to sell and convert from
|
||
|
* @param {string} toCode the currency that you want to buy and convert into
|
||
|
* @param {float} [amount] how much you want to trade in units of the from currency
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
||
|
*/
|
||
|
func (this *Binance) CreateConvertTrade(id string, fromCode string, toCode string, options ...CreateConvertTradeOptions) (Conversion, error) {
|
||
|
|
||
|
opts := CreateConvertTradeOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var amount interface{} = nil
|
||
|
if opts.Amount != nil {
|
||
|
amount = *opts.Amount
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.CreateConvertTrade(id, fromCode, toCode, amount, params)
|
||
|
if IsError(res) {
|
||
|
return Conversion{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewConversion(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchConvertTrade
|
||
|
* @description fetch the data for a conversion trade
|
||
|
* @see https://developers.binance.com/docs/convert/trade/Order-Status
|
||
|
* @param {string} id the id of the trade that you want to fetch
|
||
|
* @param {string} [code] the unified currency code of the conversion trade
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchConvertTrade(id string, options ...FetchConvertTradeOptions) (Conversion, error) {
|
||
|
|
||
|
opts := FetchConvertTradeOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var code interface{} = nil
|
||
|
if opts.Code != nil {
|
||
|
code = *opts.Code
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchConvertTrade(id, code, params)
|
||
|
if IsError(res) {
|
||
|
return Conversion{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewConversion(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchConvertTradeHistory
|
||
|
* @description fetch the users history of conversion trades
|
||
|
* @see https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History
|
||
|
* @param {string} [code] the unified currency code
|
||
|
* @param {int} [since] the earliest time in ms to fetch conversions for
|
||
|
* @param {int} [limit] the maximum number of conversion structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest conversion to fetch
|
||
|
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchConvertTradeHistory(options ...FetchConvertTradeHistoryOptions) ([]Conversion, error) {
|
||
|
|
||
|
opts := FetchConvertTradeHistoryOptionsStruct{}
|
||
|
|
||
|
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.FetchConvertTradeHistory(code, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewConversionArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchFundingIntervals
|
||
|
* @description fetch the funding rate interval for multiple markets
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Info
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Get-Funding-Info
|
||
|
* @param {string[]} [symbols] list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] "linear" or "inverse"
|
||
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchFundingIntervals(options ...FetchFundingIntervalsOptions) (FundingRates, error) {
|
||
|
|
||
|
opts := FetchFundingIntervalsOptionsStruct{}
|
||
|
|
||
|
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.FetchFundingIntervals(symbols, params)
|
||
|
if IsError(res) {
|
||
|
return FundingRates{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewFundingRates(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name binance#fetchLongShortRatioHistory
|
||
|
* @description fetches the long short ratio history for a unified market symbol
|
||
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
|
||
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Long-Short-Ratio
|
||
|
* @param {string} symbol unified symbol of the market to fetch the long short ratio for
|
||
|
* @param {string} [timeframe] the period for the ratio, default is 24 hours
|
||
|
* @param {int} [since] the earliest time in ms to fetch ratios for
|
||
|
* @param {int} [limit] the maximum number of long short ratio structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest ratio to fetch
|
||
|
* @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
|
||
|
*/
|
||
|
func (this *Binance) FetchLongShortRatioHistory(options ...FetchLongShortRatioHistoryOptions) ([]LongShortRatio, error) {
|
||
|
|
||
|
opts := FetchLongShortRatioHistoryOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbol interface{} = nil
|
||
|
if opts.Symbol != nil {
|
||
|
symbol = *opts.Symbol
|
||
|
}
|
||
|
|
||
|
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.FetchLongShortRatioHistory(symbol, timeframe, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLongShortRatioArray(res), nil
|
||
|
}
|