ccxt
Version:
396 lines (395 loc) • 24.3 kB
TypeScript
import Exchange from './abstract/bitmex.js';
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Dict, Transaction, Ticker, Tickers, Market, Strings, Currency, Leverage, Leverages, Num, Currencies, int, LedgerEntry, FundingRate, FundingRates, DepositAddress, Position } from './base/types.js';
/**
* @class bitmex
* @augments Exchange
*/
export default class bitmex extends Exchange {
describe(): any;
/**
* @method
* @name bitmex#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://www.bitmex.com/api/explorer/#!/Wallet/Wallet_getAssetsConfig
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
fetchCurrencies(params?: {}): Promise<Currencies>;
convertFromRealAmount(code: any, amount: any): number;
convertToRealAmount(code: Str, amount: Str): string;
amountToPrecision(symbol: any, amount: any): string;
convertFromRawQuantity(symbol: any, rawQuantity: any, currencySide?: string): number;
convertFromRawCost(symbol: any, rawQuantity: any): number;
/**
* @method
* @name bitmex#fetchMarkets
* @description retrieves data on all markets for bitmex
* @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActive
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
fetchMarkets(params?: {}): Promise<Market[]>;
parseMarket(market: Dict): Market;
parseBalance(response: any): Balances;
/**
* @method
* @name bitmex#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://www.bitmex.com/api/explorer/#!/User/User_getMargin
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
*/
fetchBalance(params?: {}): Promise<Balances>;
/**
* @method
* @name bitmex#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://www.bitmex.com/api/explorer/#!/OrderBook/OrderBook_getL2
* @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
*/
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
/**
* @method
* @name bitmex#fetchOrder
* @description fetches information on an order made by the user
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
* @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}
*/
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
/**
* @method
* @name bitmex#fetchOrders
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
* @description fetches information on multiple 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
* @param {int} [params.until] the earliest time in ms to fetch orders for
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitmex#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitmex#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
* @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}
*/
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitmex#fetchMyTrades
* @description fetch all trades made by the user
* @see https://www.bitmex.com/api/explorer/#!/Execution/Execution_getTradeHistory
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble 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}
*/
fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
parseLedgerEntryType(type: any): string;
parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
/**
* @method
* @name bitmex#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://www.bitmex.com/api/explorer/#!/User/User_getWalletHistory
* @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
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
*/
fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
/**
* @method
* @name bitmex#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://www.bitmex.com/api/explorer/#!/User/User_getWalletHistory
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
parseTransactionStatus(status: Str): string;
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
/**
* @method
* @name bitmex#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.bitmex.com/api/explorer/#!/Instrument/Instrument_get
* @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}
*/
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
/**
* @method
* @name bitmex#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
*/
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
parseTicker(ticker: Dict, market?: Market): Ticker;
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
/**
* @method
* @name bitmex#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://www.bitmex.com/api/explorer/#!/Trade/Trade_getBucketed
* @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 {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 {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
parseTrade(trade: Dict, market?: Market): Trade;
parseOrderStatus(status: Str): string;
parseTimeInForce(timeInForce: Str): string;
parseOrder(order: Dict, market?: Market): Order;
/**
* @method
* @name bitmex#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://www.bitmex.com/api/explorer/#!/Trade/Trade_get
* @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 {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 {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
*/
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
/**
* @method
* @name bitmex#createOrder
* @description create a trade order
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_new
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {object} [params.triggerPrice] the price at which a trigger order is triggered at
* @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'ascending' or 'descending'
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
/**
* @method
* @name bitmex#cancelOrder
* @description cancels an open order
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancel
* @param {string} id order id
* @param {string} symbol not used by bitmex cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
/**
* @method
* @name bitmex#cancelOrders
* @description cancel multiple orders
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancel
* @param {string[]} ids order ids
* @param {string} symbol not used by bitmex cancelOrders ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitmex#cancelAllOrders
* @description cancel all open orders
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancelAll
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitmex#cancelAllOrdersAfter
* @description dead man's switch, cancel all orders after the given timeout
* @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancelAllAfter
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} the api result
*/
cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<any>;
/**
* @method
* @name bitmex#fetchLeverages
* @description fetch the set leverage for all contract markets
* @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
* @param {string[]} [symbols] a list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
*/
fetchLeverages(symbols?: Strings, params?: {}): Promise<Leverages>;
parseLeverage(leverage: Dict, market?: Market): Leverage;
/**
* @method
* @name bitmex#fetchPositions
* @description fetch all open positions
* @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
*/
fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
parsePosition(position: Dict, market?: Market): Position;
/**
* @method
* @name bitmex#withdraw
* @description make a withdrawal
* @see https://www.bitmex.com/api/explorer/#!/User/User_requestWithdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
/**
* @method
* @name bitmex#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
*/
fetchFundingRates(symbols?: Strings, params?: {}): Promise<FundingRates>;
parseFundingRate(contract: any, market?: Market): FundingRate;
/**
* @method
* @name bitmex#fetchFundingRateHistory
* @description Fetches the history of funding rates
* @see https://www.bitmex.com/api/explorer/#!/Funding/Funding_get
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms for ending date filter
* @param {bool} [params.reverse] if true, will sort results newest first
* @param {int} [params.start] starting point for results
* @param {string} [params.columns] array of column names to fetch in info, if omitted, will return all columns
* @param {string} [params.filter] generic table filter, send json key/value pairs, such as {"key": "value"}, you can key on individual fields, and do more advanced querying on timestamps, see the [timestamp docs]{@link https://www.bitmex.com/app/restAPI#Timestamp-Filters} for more details
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
*/
fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").FundingRateHistory[]>;
parseFundingRateHistory(info: any, market?: Market): {
info: any;
symbol: string;
fundingRate: number;
timestamp: number;
datetime: string;
};
/**
* @method
* @name bitmex#setLeverage
* @description set the level of leverage for a market
* @see https://www.bitmex.com/api/explorer/#!/Position/Position_updateLeverage
* @param {float} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
/**
* @method
* @name bitmex#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://www.bitmex.com/api/explorer/#!/Position/Position_isolateMargin
* @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
*/
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
/**
* @method
* @name bitmex#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://www.bitmex.com/api/explorer/#!/User/User_getDepositAddress
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] deposit chain, can view all chains via this.publicGetWalletAssets, default is eth, unless the currency has a default chain within this.options['networks']
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
*/
fetchDepositAddress(code: string, params?: {}): Promise<DepositAddress>;
parseDepositWithdrawFee(fee: any, currency?: Currency): Dict;
/**
* @method
* @name bitmex#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://www.bitmex.com/api/explorer/#!/Wallet/Wallet_getAssetsConfig
* @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}
*/
fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
/**
* @method
* @name bitmex#fetchLiquidations
* @description retrieves the public liquidations of a trading pair
* @see https://www.bitmex.com/api/explorer/#!/Liquidation/Liquidation_get
* @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 bitmex api endpoint
* @param {int} [params.until] timestamp in ms of the latest liquidation
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
*/
fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
parseLiquidation(liquidation: any, market?: Market): Liquidation;
handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
nonce(): number;
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
url: string;
method: string;
body: any;
headers: any;
};
}