2096 lines
82 KiB
Go
2096 lines
82 KiB
Go
![]() |
package ccxt
|
||
|
|
||
|
type Bitget struct {
|
||
|
*bitget
|
||
|
Core *bitget
|
||
|
}
|
||
|
|
||
|
func NewBitget(userConfig map[string]interface{}) Bitget {
|
||
|
p := &bitget{}
|
||
|
p.Init(userConfig)
|
||
|
return Bitget{
|
||
|
bitget: 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 bitget#fetchTime
|
||
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
||
|
* @see https://www.bitget.com/api-doc/common/public/Get-Server-Time
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
||
|
*/
|
||
|
func (this *Bitget) FetchTime(params ...interface{}) ( int64, error) {
|
||
|
res := <- this.Core.FetchTime(params...)
|
||
|
if IsError(res) {
|
||
|
return -1, CreateReturnError(res)
|
||
|
}
|
||
|
return (res).(int64), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchMarkets
|
||
|
* @description retrieves data on all markets for bitget
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
||
|
* @see https://www.bitget.com/api-doc/margin/common/support-currencies
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object[]} an array of objects representing market data
|
||
|
*/
|
||
|
func (this *Bitget) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
|
||
|
res := <- this.Core.FetchMarkets(params...)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewMarketInterfaceArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchMarketLeverageTiers
|
||
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
|
||
|
* @see https://www.bitget.com/api-doc/contract/position/Get-Query-Position-Lever
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/account/Cross-Tier-Data
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Tier-Data
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] for spot margin 'cross' or 'isolated', default is 'isolated'
|
||
|
* @param {string} [params.code] required for cross spot margin
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
|
||
|
*/
|
||
|
func (this *Bitget) FetchMarketLeverageTiers(symbol string, options ...FetchMarketLeverageTiersOptions) ([]LeverageTier, error) {
|
||
|
|
||
|
opts := FetchMarketLeverageTiersOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchMarketLeverageTiers(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLeverageTierArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchDeposits
|
||
|
* @description fetch all deposits made to an account
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Get-Deposit-Record
|
||
|
* @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 {int} [params.until] end time in milliseconds
|
||
|
* @param {string} [params.idLessThan] return records with id less than the provided value
|
||
|
* @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 *Bitget) 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 bitget#withdraw
|
||
|
* @description make a withdrawal
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Wallet-Withdrawal
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {float} amount the amount to withdraw
|
||
|
* @param {string} address the address to withdraw to
|
||
|
* @param {string} tag
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.chain] the blockchain network the withdrawal is taking place on
|
||
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchWithdrawals
|
||
|
* @description fetch all withdrawals made from an account
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Get-Withdraw-Record
|
||
|
* @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 {int} [params.until] end time in milliseconds
|
||
|
* @param {string} [params.idLessThan] return records with id less than the provided value
|
||
|
* @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 *Bitget) 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 bitget#fetchDepositAddress
|
||
|
* @description fetch the deposit address for a currency associated with this account
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Get-Deposit-Address
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchOrderBook
|
||
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Orderbook
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Merge-Depth
|
||
|
* @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 *Bitget) 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 bitget#fetchTicker
|
||
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Ticker
|
||
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchMarkPrice
|
||
|
* @description fetches the mark price for a specific market
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-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
|
||
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchTickers
|
||
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
|
||
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] *contract only* 'linear', 'inverse'
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchTrades
|
||
|
* @description get the list of most recent trades for a particular symbol
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Recent-Trades
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Market-Trades
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Recent-Fills
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Fills-History
|
||
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
||
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
||
|
* @param {int} [limit] the maximum amount of trades to fetch
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* the latest time in ms to fetch trades for
|
||
|
* @param {boolean} [params.paginate] *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* default false, when true will automatically paginate by calling this endpoint multiple times
|
||
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchTradingFee
|
||
|
* @description fetch the trading fees for a market
|
||
|
* @see https://www.bitget.com/api-doc/common/public/Get-Trade-Rate
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'isolated' or 'cross', for finding the fee rate of spot margin trading pairs
|
||
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchTradingFees
|
||
|
* @description fetch the trading fees for multiple markets
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
||
|
* @see https://www.bitget.com/api-doc/margin/common/support-currencies
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @param {boolean} [params.margin] set to true for spot margin
|
||
|
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
||
|
*/
|
||
|
func (this *Bitget) FetchTradingFees(params ...interface{}) (TradingFees, error) {
|
||
|
res := <- this.Core.FetchTradingFees(params...)
|
||
|
if IsError(res) {
|
||
|
return TradingFees{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewTradingFees(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchOHLCV
|
||
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Candle-Data
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-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 {int} [params.until] timestamp in ms of the latest candle to fetch
|
||
|
* @param {boolean} [params.useHistoryEndpoint] whether to force to use historical endpoint (it has max limit of 200)
|
||
|
* @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.price] *swap only* "mark" (to fetch mark price candles) or "index" (to fetch index price candles)
|
||
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchBalance
|
||
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Get-Account-Assets
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Get-Account-List
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Assets
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/account/Get-Isolated-Assets
|
||
|
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-assets
|
||
|
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-assets
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
||
|
*/
|
||
|
func (this *Bitget) FetchBalance(params ...interface{}) (Balances, error) {
|
||
|
res := <- this.Core.FetchBalance(params...)
|
||
|
if IsError(res) {
|
||
|
return Balances{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewBalances(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#createMarketBuyOrderWithCost
|
||
|
* @description create a market buy order by providing the symbol and cost
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Place-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
|
||
|
* @param {string} symbol unified symbol of the market to create an order in
|
||
|
* @param {float} cost how much you want to trade in units of the quote currency
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#createOrder
|
||
|
* @description create a trade order
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Place-Order
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Place-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
|
||
|
* @param {string} symbol unified symbol of the market to create an order in
|
||
|
* @param {string} type 'market' or 'limit'
|
||
|
* @param {string} side 'buy' or 'sell'
|
||
|
* @param {float} amount how much you want to trade in units of the base currency
|
||
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {float} [params.cost] *spot only* how much you want to trade in units of the quote currency, for market buy orders only
|
||
|
* @param {float} [params.triggerPrice] *swap only* The price at which a trigger order is triggered at
|
||
|
* @param {float} [params.stopLossPrice] *swap only* The price at which a stop loss order is triggered at
|
||
|
* @param {float} [params.takeProfitPrice] *swap only* The price at which a take profit order is triggered at
|
||
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
|
||
|
* @param {float} [params.takeProfit.triggerPrice] *swap only* take profit trigger price
|
||
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
||
|
* @param {float} [params.stopLoss.triggerPrice] *swap only* stop loss trigger price
|
||
|
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
||
|
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
|
||
|
* @param {string} [params.loanType] *spot margin only* 'normal', 'autoLoan', 'autoRepay', or 'autoLoanAndRepay' default is 'normal'
|
||
|
* @param {string} [params.holdSide] *contract stopLossPrice, takeProfitPrice only* Two-way position: ('long' or 'short'), one-way position: ('buy' or 'sell')
|
||
|
* @param {float} [params.stopLoss.price] *swap only* the execution price for a stop loss attached to a trigger order
|
||
|
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
|
||
|
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
||
|
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
||
|
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
|
||
|
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
||
|
* @param {string} [params.triggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
||
|
* @param {boolean} [params.oneWayMode] *swap and future only* required to set this to true in one_way_mode and you can leave this as undefined in hedge_mode, can adjust the mode using the setPositionMode() method
|
||
|
* @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode, default is false
|
||
|
* @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#createOrders
|
||
|
* @description create a list of trade orders (all orders should be of the same symbol)
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Batch-Place-Orders
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Batch-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Order
|
||
|
* @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 api endpoint
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#editOrder
|
||
|
* @description edit a trade order
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Modify-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/Modify-Plan-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 you want to trade in units of the base currency
|
||
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {float} [params.triggerPrice] the price that a trigger order is triggered at
|
||
|
* @param {float} [params.stopLossPrice] *swap only* The price at which a stop loss order is triggered at
|
||
|
* @param {float} [params.takeProfitPrice] *swap only* The price at which a take profit order is triggered at
|
||
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
|
||
|
* @param {float} [params.takeProfit.triggerPrice] *swap only* take profit trigger price
|
||
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
||
|
* @param {float} [params.stopLoss.triggerPrice] *swap only* stop loss trigger price
|
||
|
* @param {float} [params.stopLoss.price] *swap only* the execution price for a stop loss attached to a trigger order
|
||
|
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
|
||
|
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
||
|
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
||
|
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
|
||
|
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
||
|
* @param {string} [params.newTriggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
||
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#cancelOrder
|
||
|
* @description cancels an open order
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Cancel-Order
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Cancel-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Cancel-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Cancel-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 {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
|
||
|
* @param {boolean} [params.trigger] set to true for canceling trigger orders
|
||
|
* @param {string} [params.planType] *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
|
||
|
* @param {boolean} [params.trailing] set to true if you want to cancel a trailing order
|
||
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#cancelOrders
|
||
|
* @description cancel multiple orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Orders
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
|
||
|
* @param {string[]} ids order ids
|
||
|
* @param {string} symbol unified market symbol, default is undefined
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
|
||
|
* @param {boolean} [params.trigger] *contract only* set to true for canceling trigger orders
|
||
|
* @returns {object} an array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) CancelOrders(ids interface{}, options ...CancelOrdersOptions) ([]Order, error) {
|
||
|
|
||
|
opts := CancelOrdersOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbol interface{} = nil
|
||
|
if opts.Symbol != nil {
|
||
|
symbol = *opts.Symbol
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.CancelOrders(ids, symbol, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOrderArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#cancelAllOrders
|
||
|
* @description cancel all open orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
|
||
|
* @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
|
||
|
* @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
|
||
|
* @param {boolean} [params.trigger] *contract only* set to true for canceling trigger orders
|
||
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchOrder
|
||
|
* @description fetches information on an order made by the user
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Get-Order-Info
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
|
||
|
* @param {string} id the order id
|
||
|
* @param {string} symbol unified symbol of the market the order was made in
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchOpenOrders
|
||
|
* @description fetch all unfilled currently open orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Get-Unfilled-Orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Get-Current-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-Pending
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/get-orders-plan-pending
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Open-Orders
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Open-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 order structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
||
|
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
|
||
|
* @param {boolean} [params.trigger] set to true for fetching trigger orders
|
||
|
* @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.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
||
|
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
||
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchClosedOrders
|
||
|
* @description fetches information on multiple closed orders made by the user
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
||
|
* @param {string} symbol unified market symbol of the closed orders
|
||
|
* @param {int} [since] timestamp in ms of the earliest order
|
||
|
* @param {int} [limit] the max number of closed orders to return
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] the latest time in ms to fetch 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)
|
||
|
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
||
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchCanceledOrders
|
||
|
* @description fetches information on multiple canceled orders made by the user
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
||
|
* @param {string} symbol unified market symbol of the canceled orders
|
||
|
* @param {int} [since] timestamp in ms of the earliest order
|
||
|
* @param {int} [limit] the max number of canceled orders to return
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] the latest time in ms to fetch 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)
|
||
|
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
||
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) FetchCanceledOrders(options ...FetchCanceledOrdersOptions) ([]Order, error) {
|
||
|
|
||
|
opts := FetchCanceledOrdersOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbol interface{} = nil
|
||
|
if opts.Symbol != nil {
|
||
|
symbol = *opts.Symbol
|
||
|
}
|
||
|
|
||
|
var since interface{} = nil
|
||
|
if opts.Since != nil {
|
||
|
since = *opts.Since
|
||
|
}
|
||
|
|
||
|
var limit interface{} = nil
|
||
|
if opts.Limit != nil {
|
||
|
limit = *opts.Limit
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchCanceledOrders(symbol, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewOrderArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchCanceledAndClosedOrders
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
||
|
* @see https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
||
|
* @see https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
||
|
* @description fetches information on multiple canceled and closed orders made by the user
|
||
|
* @param {string} symbol unified market symbol of the market orders were made in
|
||
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
||
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchLedger
|
||
|
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
||
|
* @param {string} [code] unified currency code, default is undefined
|
||
|
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
||
|
* @param {int} [limit] max number of ledger entries to return, default is undefined
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] end time in ms
|
||
|
* @param {string} [params.symbol] *contract only* unified market symbol
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
||
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchMyTrades
|
||
|
* @description fetch all trades made by the user
|
||
|
* @see https://www.bitget.com/api-doc/spot/trade/Get-Fills
|
||
|
* @see https://www.bitget.com/api-doc/contract/trade/Get-Order-Fills
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-Fills
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Transaction-Details
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
||
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] the latest time in ms to fetch trades for
|
||
|
* @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 {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchPosition
|
||
|
* @description fetch data on a single open contract trade position
|
||
|
* @see https://www.bitget.com/api-doc/contract/position/get-single-position
|
||
|
* @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 *Bitget) 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 bitget#fetchPositions
|
||
|
* @description fetch all open positions
|
||
|
* @see https://www.bitget.com/api-doc/contract/position/get-all-position
|
||
|
* @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
||
|
* @param {string[]} [symbols] list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.marginCoin] the settle currency of the positions, needs to match the productType
|
||
|
* @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @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.useHistoryEndpoint] default false, when true will use the historic endpoint to fetch positions
|
||
|
* @param {string} [params.method] either (default) 'privateMixGetV2MixPositionAllPosition' or 'privateMixGetV2MixPositionHistoryPosition'
|
||
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchFundingRateHistory
|
||
|
* @description fetches historical funding rate prices
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate
|
||
|
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
||
|
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
||
|
* @param {int} [limit] the maximum amount of funding rate structures to fetch
|
||
|
* @param {object} [params] extra parameters specific to the 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 [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
||
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchFundingRate
|
||
|
* @description fetch the current funding rate
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchFundingRates
|
||
|
* @description fetch the current funding rates for all markets
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
|
||
|
* @param {string[]} [symbols] list of unified market symbols
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.subType] *contract only* 'linear', 'inverse'
|
||
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @returns {object} a dictionary of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchFundingHistory
|
||
|
* @description fetch the funding history
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {int} [since] the starting timestamp in milliseconds
|
||
|
* @param {int} [limit] the number of entries to return
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {int} [params.until] the latest time in ms to fetch funding history 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 [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchLeverage
|
||
|
* @description fetch the set leverage for a market
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Get-Single-Account
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
||
|
*/
|
||
|
func (this *Bitget) FetchLeverage(symbol string, options ...FetchLeverageOptions) (Leverage, error) {
|
||
|
|
||
|
opts := FetchLeverageOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchLeverage(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return Leverage{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewLeverage(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#setLeverage
|
||
|
* @description set the level of leverage for a market
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Change-Leverage
|
||
|
* @param {int} leverage the rate of leverage
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.holdSide] *isolated only* position direction, 'long' or 'short'
|
||
|
* @returns {object} response from the exchange
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#setMarginMode
|
||
|
* @description set margin mode to 'cross' or 'isolated'
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode
|
||
|
* @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 *Bitget) 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 bitget#setPositionMode
|
||
|
* @description set hedged to true or false for a market
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
|
||
|
* @param {bool} hedged set to true to use dualSidePosition
|
||
|
* @param {string} symbol not used by bitget setPositionMode ()
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.productType] required if symbol is undefined: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
||
|
* @returns {object} response from the exchange
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchOpenInterest
|
||
|
* @description retrieves the open interest of a contract trading pair
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-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 *Bitget) 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 bitget#fetchTransfers
|
||
|
* @description fetch a history of internal transfers made on an account
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Get-Account-TransferRecords
|
||
|
* @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 entries for
|
||
|
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#transfer
|
||
|
* @description transfer currency internally between wallets on the same account
|
||
|
* @see https://www.bitget.com/api-doc/spot/account/Wallet-Transfer
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {float} amount amount to transfer
|
||
|
* @param {string} fromAccount account to transfer from
|
||
|
* @param {string} toAccount account to transfer to
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.symbol] unified CCXT market symbol, required when transferring to or from an account type that is a leveraged position-by-position account
|
||
|
* @param {string} [params.clientOid] custom id
|
||
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchDepositWithdrawFees
|
||
|
* @description fetch deposit and withdraw fees
|
||
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Coin-List
|
||
|
* @param {string[]|undefined} codes list of unified currency codes
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchMyLiquidations
|
||
|
* @description retrieves the users liquidated positions
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Liquidation-Records
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Liquidation-Records
|
||
|
* @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 bitget api endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
||
|
* @param {string} [params.marginMode] 'cross' or 'isolated' default value is 'cross'
|
||
|
* @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} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchIsolatedBorrowRate
|
||
|
* @description fetch the rate of interest to borrow a currency for margin trading
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Margin-Interest-Rate-And-Max-Borrowable-Amount
|
||
|
* @param {string} symbol unified market symbol
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchCrossBorrowRate
|
||
|
* @description fetch the rate of interest to borrow a currency for margin trading
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Margin-Interest-Rate-And-Borrowable
|
||
|
* @param {string} code unified currency code
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @param {string} [params.symbol] required for isolated margin
|
||
|
* @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchBorrowInterest
|
||
|
* @description fetch the interest owed by the user for borrowing currency for margin trading
|
||
|
* @see https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
|
||
|
* @see https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Interest-Records
|
||
|
* @param {string} [code] unified currency code
|
||
|
* @param {string} [symbol] unified market symbol when fetching interest in isolated markets
|
||
|
* @param {int} [since] the earliest time in ms to fetch borrow 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.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 [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchMarginMode
|
||
|
* @description fetches the margin mode of a trading pair
|
||
|
* @see https://www.bitget.com/api-doc/contract/account/Get-Single-Account
|
||
|
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchPositionsHistory
|
||
|
* @description fetches historical positions
|
||
|
* @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
||
|
* @param {string[]} [symbols] unified contract symbols
|
||
|
* @param {int} [since] timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
|
||
|
* @param {int} [limit] the maximum amount of records to fetch, default=20, max=100
|
||
|
* @param {object} params extra parameters specific to the exchange api endpoint
|
||
|
* @param {int} [params.until] timestamp in ms of the latest position to fetch, max range for params["until"] - since is 3 months
|
||
|
*
|
||
|
* EXCHANGE SPECIFIC PARAMETERS
|
||
|
* @param {string} [params.productType] USDT-FUTURES (default), COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, or SUSDC-FUTURES
|
||
|
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
||
|
*/
|
||
|
func (this *Bitget) FetchPositionsHistory(options ...FetchPositionsHistoryOptions) ([]Position, error) {
|
||
|
|
||
|
opts := FetchPositionsHistoryOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var symbols interface{} = nil
|
||
|
if opts.Symbols != nil {
|
||
|
symbols = *opts.Symbols
|
||
|
}
|
||
|
|
||
|
var since interface{} = nil
|
||
|
if opts.Since != nil {
|
||
|
since = *opts.Since
|
||
|
}
|
||
|
|
||
|
var limit interface{} = nil
|
||
|
if opts.Limit != nil {
|
||
|
limit = *opts.Limit
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchPositionsHistory(symbols, since, limit, params)
|
||
|
if IsError(res) {
|
||
|
return nil, CreateReturnError(res)
|
||
|
}
|
||
|
return NewPositionArray(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchConvertQuote
|
||
|
* @description fetch a quote for converting from one currency to another
|
||
|
* @see https://www.bitget.com/api-doc/common/convert/Get-Quoted-Price
|
||
|
* @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 *Bitget) 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 bitget#createConvertTrade
|
||
|
* @description convert from one currency to another
|
||
|
* @see https://www.bitget.com/api-doc/common/convert/Trade
|
||
|
* @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
|
||
|
* @param {string} params.price the price of the conversion, obtained from fetchConvertQuote()
|
||
|
* @param {string} params.toAmount the amount you want to trade in units of the toCurrency, obtained from fetchConvertQuote()
|
||
|
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchConvertTradeHistory
|
||
|
* @description fetch the users history of conversion trades
|
||
|
* @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Record
|
||
|
* @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
|
||
|
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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 bitget#fetchConvertCurrencies
|
||
|
* @description fetches all available currencies that can be converted
|
||
|
* @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Currencies
|
||
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
||
|
* @returns {object} an associative dictionary of currencies
|
||
|
*/
|
||
|
func (this *Bitget) FetchConvertCurrencies(params ...interface{}) (Currencies, error) {
|
||
|
res := <- this.Core.FetchConvertCurrencies(params...)
|
||
|
if IsError(res) {
|
||
|
return Currencies{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewCurrencies(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchFundingInterval
|
||
|
* @description fetch the current funding rate interval
|
||
|
* @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
|
||
|
* @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 *Bitget) FetchFundingInterval(symbol string, options ...FetchFundingIntervalOptions) (FundingRate, error) {
|
||
|
|
||
|
opts := FetchFundingIntervalOptionsStruct{}
|
||
|
|
||
|
for _, opt := range options {
|
||
|
opt(&opts)
|
||
|
}
|
||
|
|
||
|
var params interface{} = nil
|
||
|
if opts.Params != nil {
|
||
|
params = *opts.Params
|
||
|
}
|
||
|
res := <- this.Core.FetchFundingInterval(symbol, params)
|
||
|
if IsError(res) {
|
||
|
return FundingRate{}, CreateReturnError(res)
|
||
|
}
|
||
|
return NewFundingRate(res), nil
|
||
|
}
|
||
|
/**
|
||
|
* @method
|
||
|
* @name bitget#fetchLongShortRatioHistory
|
||
|
* @description fetches the long short ratio history for a unified market symbol
|
||
|
* @see https://www.bitget.com/api-doc/common/apidata/Margin-Ls-Ratio
|
||
|
* @see https://www.bitget.com/api-doc/common/apidata/Account-Long-Short
|
||
|
* @param {string} symbol unified symbol of the market to fetch the long short ratio for
|
||
|
* @param {string} [timeframe] the period for the ratio
|
||
|
* @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
|
||
|
* @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
|
||
|
*/
|
||
|
func (this *Bitget) 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
|
||
|
}
|