UNPKG

node-binance-api

Version:

Binance API for node https://github.com/ccxt/node-binance-api

1,291 lines (1,290 loc) 94.3 kB
import WebSocket from 'ws'; import { Interval, PositionRisk, Order, FuturesOrder, OrderType, Callback, IConstructorArgs, OrderSide, FundingRate, CancelOrder, AggregatedTrade, Trade, MyTrade, WithdrawHistoryResponse, DepositHistoryResponse, DepositAddress, WithdrawResponse, Candle, OrderBook, FuturesUserTrade, Account, FuturesAccountInfo, FuturesBalance, QueryOrder, HttpMethod, BookTicker, DailyStats, PremiumIndex, OpenInterest, IWebsocketsMethods } from './types.js'; export interface Dictionary<T> { [key: string]: T; } export type Dict = Dictionary<any>; export default class Binance { domain: string; base: string; baseTest: string; wapi: string; sapi: string; fapi: string; dapi: string; fapiTest: string; dapiTest: string; fstream: string; fstreamSingle: string; fstreamSingleTest: string; fstreamTest: string; dstream: string; dstreamSingle: string; dstreamSingleTest: string; dstreamTest: string; stream: string; streamTest: string; combineStream: string; combineStreamTest: string; verbose: boolean; futuresListenKeyKeepAlive: number; spotListenKeyKeepAlive: number; heartBeatInterval: number; urlProxy: string; httpsProxy: string; socksProxy: string; nodeFetch: any; APIKEY: string; APISECRET: string; PRIVATEKEY: string; PRIVATEKEYPASSWORD: string; test: boolean; timeOffset: number; userAgent: string; contentType: string; SPOT_PREFIX: string; CONTRACT_PREFIX: string; isAlive: boolean; socketHeartbeatInterval: any; reconnect: boolean; headers: Dict; subscriptions: Dict; futuresSubscriptions: Dict; futuresInfo: Dict; futuresMeta: Dict; futuresTicks: Dict; futuresRealtime: Dict; futuresKlineQueue: Dict; deliverySubscriptions: Dict; deliveryInfo: Dict; deliveryMeta: Dict; deliveryTicks: Dict; deliveryRealtime: Dict; deliveryKlineQueue: Dict; depthCache: Dict; depthCacheContext: Dict; ohlcLatest: Dict; klineQueue: Dict; ohlc: Dict; info: Dict; websockets: IWebsocketsMethods; default_options: { recvWindow: number; useServerTime: boolean; reconnect: boolean; keepAlive: boolean; verbose: boolean; test: boolean; hedgeMode: boolean; localAddress: boolean; family: number; log(...args: any[]): void; }; Options: any; constructor(userOptions?: Partial<IConstructorArgs> | string); options(opt?: {}): Binance; assignOptions(opt?: {}): void; setOptions(opt?: {}): Promise<Binance>; extend: (...args: any[]) => any; getSpotUrl(): string; getSapiUrl(): string; getFapiUrl(): string; getDapiUrl(): string; getCombineStreamUrl(): string; getStreamUrl(): string; uuid22(a?: any): any; getUrlProxy(): string; getHttpsProxy(): string; getSocksProxy(): string; /** * Replaces socks connection uri hostname with IP address * @param {string} connString - socks connection string * @return {string} modified string with ip address */ proxyReplacewithIp(connString: string): string; /** * Returns an array in the form of [host, port] * @param {string} connString - connection string * @return {array} array of host and port */ parseProxy(connString: string): string[]; /** * Checks to see of the object is iterable * @param {object} obj - The object check * @return {boolean} true or false is iterable */ isIterable(obj: any): boolean; addProxy(opt: any): any; reqHandler(response: any): Promise<void>; proxyRequest(opt: any): Promise<any>; reqObj(url: string, data?: Dict, method?: HttpMethod, key?: string): { url: string; qs: Dict; method: HttpMethod; family: any; localAddress: any; timeout: any; forever: any; headers: { 'User-Agent': string; 'Content-type': string; 'X-MBX-APIKEY': string; }; }; reqObjPOST(url: string, data: Dict, method: string, key: string): { url: string; form: Dict; method: string; family: any; localAddress: any; timeout: any; forever: any; qsStringifyOptions: { arrayFormat: string; }; headers: { 'User-Agent': string; 'Content-type': string; 'X-MBX-APIKEY': string; }; }; publicRequest(url: string, data?: Dict, method?: HttpMethod): Promise<any>; /** * Used to make public requests to the futures (FAPI) API * @param path * @param data * @param method * @returns */ publicFuturesRequest(path: string, data?: Dict, method?: HttpMethod): Promise<any>; /** * Used to make public requests to the delivery (DAPI) API * @param path * @param data * @param method * @returns */ publicDeliveryRequest(path: string, data?: Dict, method?: HttpMethod): Promise<any>; /** * Used to make private requests to the futures (FAPI) API * @param path * @param data * @param method * @returns */ privateFuturesRequest(path: string, data?: Dict, method?: HttpMethod): Promise<any>; /** * Used to make private requests to the delivery (DAPI) API * @param path * @param data * @param method * @returns */ privateDeliveryRequest(path: string, data?: Dict, method?: HttpMethod): Promise<any>; /** * Used to make a request to the futures API, this is a generic function that can be used to make any request to the futures API * @param url * @param data * @param method * @param isPrivate * @returns */ futuresRequest(url: string, data?: Dict, method?: HttpMethod, isPrivate?: boolean): Promise<any>; makeQueryString(q: any): string; /** * Create a http request to the public API * @param {string} url - The http endpoint * @param {object} data - The data to send * @param {function} callback - The callback method to call * @param {string} method - the http method * @return {undefined} */ apiRequest(url: string, data?: Dict, method?: HttpMethod): Promise<any>; requireApiKey(source?: string, fatalError?: boolean): boolean; requireApiSecret(source?: string, fatalError?: boolean): boolean; /** * Create a public spot/margin request * @param {string} path - url path * @param {object} data - The data to send * @param {string} method - the http method * @param {boolean} noDataInSignature - Prevents data from being added to signature * @return {undefined} */ publicSpotRequest(path: string, data?: Dict, method?: HttpMethod): Promise<any>; /** * Create a signed spot request * @param {string} path - url path * @param {object} data - The data to send * @param {string} method - the http method * @param {boolean} noDataInSignature - Prevents data from being added to signature * @return {undefined} */ privateSpotRequest(path: string, data?: Dict, method?: HttpMethod, noDataInSignature?: boolean): Promise<any>; privateSapiRequest(path: string, data?: Dict, method?: HttpMethod, noDataInSignature?: boolean): Promise<any>; /** * Create a signed http request * @param {string} url - The http endpoint * @param {object} data - The data to send * @param {function} callback - The callback method to call * @param {string} method - the http method * @param {boolean} noDataInSignature - Prevents data from being added to signature * @return {undefined} */ signedRequest(url: string, data?: Dict, method?: HttpMethod, noDataInSignature?: boolean): Promise<any>; generateSignature(query: string, encode?: boolean): string; /** * Create a signed spot order * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade * @param {OrderType} type - LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER * @param {OrderSide} side - BUY or SELL * @param {string} symbol - The symbol to buy or sell * @param {string} quantity - The quantity to buy or sell * @param {string} price - The price per unit to transact each unit at * @param {object} params - additional order settings * @return {undefined} */ order(type: OrderType, side: OrderSide, symbol: string, quantity: number, price?: number, params?: Dict): Promise<Order>; /** * Creates a buy order * @param {string} symbol - the symbol to buy * @param {numeric} quantity - the quantity required * @param {numeric} price - the price to pay for each unit * @param {object} flags - additional buy order flags * @return {promise or undefined} - omitting the callback returns a promise */ buy(symbol: string, quantity: number, price: number, flags?: {}): Promise<Order>; /** * Creates a sell order * @param {string} symbol - the symbol to sell * @param {numeric} quantity - the quantity required * @param {numeric} price - the price to pay for each unit * @param {object} flags - additional buy order flags * @param {function} callback - the callback function * @return {promise or undefined} - omitting the callback returns a promise */ sell(symbol: string, quantity: number, price: number, flags?: {}): Promise<Order>; /** * Creates a market buy order * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade * @param {string} symbol - the symbol to buy * @param {numeric} quantity - the quantity required * @param {object} params - additional buy order flags * @return {promise or undefined} - omitting the callback returns a promise */ marketBuy(symbol: string, quantity: number, params?: Dict): Promise<Order>; /** * Creates a spot limit order * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade * @param {string} side - the side of the order (BUY or SELL) * @param {string} symbol - the symbol to buy * @param {numeric} quantity - the quantity required * @param {numeric} price - the price to pay for each unit * @param {object} params - additional buy order flags * @return {promise or undefined} - omitting the callback returns a promise */ limitOrder(side: OrderSide, symbol: string, quantity: number, price: number, params?: Dict): Promise<Order>; /** * Creates a market buy order using the cost instead of the quantity (eg: 100usd instead of 0.01btc) * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade * @param {string} symbol - the symbol to buy * @param {numeric} quantity - the quantity required * @param {object} params - additional buy order flags * @return {promise or undefined} - omitting the callback returns a promise */ marketBuyWithCost(symbol: string, cost: number, params?: Dict): Promise<Order>; /** * Creates a market sell order * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade * @param {string} symbol - the symbol to sell * @param {numeric} quantity - the quantity required * @param {object} flags - additional buy order flags * @return {promise or undefined} - omitting the callback returns a promise */ marketSell(symbol: string, quantity: number, params?: Dict): Promise<Order>; /** * Creates a market sell order using the cost instead of the quantity (eg: 100usd instead of 0.01btc) * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade * @param {string} symbol - the symbol to sell * @param {numeric} quantity - the quantity required * @param {object} flags - additional buy order flags * @return {promise or undefined} - omitting the callback returns a promise */ marketSellWithCost(symbol: string, cost: number, params?: Dict): Promise<Order>; /** * Cancels an order * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-order-trade * @param {string} symbol - the symbol to cancel * @param {string} orderid - the orderid to cancel * @return {promise or undefined} - omitting the callback returns a promise */ cancel(symbol: string, orderid: number | string, params?: Dict): Promise<CancelOrder>; /** * Gets the status of an order * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#query-order-user_data * @param {string} symbol - the symbol to check * @param {string} orderid - the orderid to check if !orderid then use flags to search * @param {object} flags - any additional flags * @return {promise or undefined} - omitting the callback returns a promise */ orderStatus(symbol: string, orderid?: number | string, flags?: {}): Promise<any>; /** * Gets open orders * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#current-open-orders-user_data * @param {string} symbol - the symbol to get * @return {promise or undefined} - omitting the callback returns a promise */ openOrders(symbol?: string, params?: Dict): Promise<QueryOrder[]>; /** * Cancels all orders of a given symbol * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-all-open-orders-on-a-symbol-trade * @param {string} symbol - the symbol to cancel all orders for * @return {promise or undefined} - omitting the callback returns a promise */ cancelAllOrders(symbol: string, params?: Dict): Promise<any>; /** * Gets all order of a given symbol * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data * @param {string} symbol - the symbol * @param {object} options - additional options * @return {promise or undefined} - omitting the callback returns a promise */ allOrders(symbol: string, params?: Dict): Promise<QueryOrder[]>; /** * Create a signed margin order * @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order * @param {string} side - BUY or SELL * @param {string} symbol - The symbol to buy or sell * @param {string} quantity - The quantity to buy or sell * @param {string} price - The price per unit to transact each unit at * @param {object} params - additional order settings * @return {undefined} */ marginOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params?: Dict): Promise<any>; /** * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order * @param type * @param side * @param symbol symbol if the market * @param quantity * @param price * @param params extra parameters to be sent in the request * @returns */ futuresOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params?: Dict): Promise<FuturesOrder>; deliveryOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params?: Dict): Promise<FuturesOrder>; noop(): void; /** * Reworked Tuitio's heartbeat code into a shared single interval tick * @return {undefined} */ socketHeartbeat(): void; /** * Called when socket is opened, subscriptions are registered for later reference * @param {function} opened_callback - a callback function * @return {undefined} */ handleSocketOpen(wsBind: any, opened_callback: Callback): void; /** * Called when socket is closed, subscriptions are de-registered for later reference * @param {Function} reconnect - reconnect callback * @param {string} code - code associated with the socket * @param {string} reason - string with the response * @return {undefined} */ handleSocketClose(wsBind: any, reconnect: Function, code: any, reason: string): void; /** * Called when socket errors * @param {object} error - error object message * @return {undefined} */ handleSocketError(wsBind: any, error: any): void; /** * Called on each socket heartbeat * @return {undefined} */ handleSocketHeartbeat(wsBind: any): void; /** * Get Binance server time * @return {promise or undefined} - omitting the callback returns a promise */ time(): Promise<any>; /** * Used to subscribe to a single websocket endpoint * @param {string} endpoint - endpoint to connect to * @param {function} callback - the function to call when information is received * @param {boolean} reconnect - whether to reconnect on disconnect * @param {object} opened_callback - the function to call when opened * @return {WebSocket} - websocket reference */ subscribe(endpoint: string, callback: Callback, reconnect?: Callback, opened_callback?: Callback): WebSocket; /** * Used to subscribe to a combined websocket endpoint * @param {string} streams - streams to connect to * @param {function} callback - the function to call when information is received * @param {boolean} reconnect - whether to reconnect on disconnect * @param {object} opened_callback - the function to call when opened * @return {WebSocket} - websocket reference */ subscribeCombined(streams: any, callback: Callback, reconnect?: Callback, opened_callback?: Callback): any; /** * Used to terminate a web socket * @param {string} endpoint - endpoint identifier associated with the web socket * @param {boolean} reconnect - auto reconnect after termination * @return {undefined} */ terminate(endpoint: string, reconnect?: boolean): void; /** * Futures heartbeat code with a shared single interval tick * @return {undefined} */ futuresSocketHeartbeat(): void; /** * Called when a futures socket is opened, subscriptions are registered for later reference * @param {function} openCallback - a callback function * @return {undefined} */ handleFuturesSocketOpen(wsBind: any, openCallback: Callback): void; /** * Called when futures websocket is closed, subscriptions are de-registered for later reference * @param {boolean} reconnect - true or false to reconnect the socket * @param {string} code - code associated with the socket * @param {string} reason - string with the response * @return {undefined} */ handleFuturesSocketClose(wsBind: any, reconnect: any, code: any, reason: any): void; /** * Called when a futures websocket errors * @param {object} error - error object message * @return {undefined} */ handleFuturesSocketError(wsBind: any, error: any): void; /** * Called on each futures socket heartbeat * @return {undefined} */ handleFuturesSocketHeartbeat(wsBind: any): void; /** * Used to subscribe to a single futures websocket endpoint * @param {string} endpoint - endpoint to connect to * @param {function} callback - the function to call when information is received * @param {object} params - Optional reconnect {boolean} (whether to reconnect on disconnect), openCallback {function}, id {string} * @return {WebSocket} - websocket reference */ futuresSubscribeSingle(endpoint: string, callback: Callback, params?: Dict): any; /** * Used to subscribe to a combined futures websocket endpoint * @param {string} streams - streams to connect to * @param {function} callback - the function to call when information is received * @param {object} params - Optional reconnect {boolean} (whether to reconnect on disconnect), openCallback {function}, id {string} * @return {WebSocket} - websocket reference */ futuresSubscribe(streams: any, callback: Callback, params?: Dict): any; /** * Used to terminate a futures websocket * @param {string} endpoint - endpoint identifier associated with the web socket * @param {boolean} reconnect - auto reconnect after termination * @return {undefined} */ futuresTerminate(endpoint: string, reconnect?: boolean): void; /** * Combines all futures OHLC data with the latest update * @param {string} symbol - the symbol * @param {string} interval - time interval * @return {array} - interval data for given symbol */ futuresKlineConcat(symbol: string, interval: Interval): any; /** * Used for websocket futures @kline * @param {string} symbol - the symbol * @param {object} kline - object with kline info * @param {string} firstTime - time filter * @return {undefined} */ futuresKlineHandler(symbol: string, kline: any, firstTime?: number): void; /** * Converts the futures liquidation stream data into a friendly object * @param {object} data - liquidation data callback data type * @return {object} - user friendly data type */ fLiquidationConvertData(data: any): { symbol: any; side: any; orderType: any; timeInForce: any; origAmount: any; price: any; avgPrice: any; orderStatus: any; lastFilledQty: any; totalFilledQty: any; eventType: any; tradeTime: any; eventTime: any; }; /** * Converts the futures ticker stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fTickerConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; priceChange: any; percentChange: any; averagePrice: any; close: any; closeQty: any; open: any; high: any; low: any; volume: any; quoteVolume: any; openTime: any; closeTime: any; firstTradeId: any; lastTradeId: any; numTrades: any; }; /** * Converts the futures miniTicker stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fMiniTickerConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; close: any; open: any; high: any; low: any; volume: any; quoteVolume: any; }; /** * Converts the futures bookTicker stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fBookTickerConvertData(data: any): { updateId: any; symbol: any; bestBid: any; bestBidQty: any; bestAsk: any; bestAskQty: any; }; /** * Converts the futures UserData stream MARGIN_CALL data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fUserDataMarginConvertData(data: any): { eventType: any; eventTime: any; crossWalletBalance: any; positions: any; }; /** * Converts the futures UserData stream ACCOUNT_CONFIG_UPDATE into a friendly object * @param {object} data - user config callback data type * @return {object} - user friendly data type */ fUserConfigDataAccountUpdateConvertData(data: any): { eventType: any; eventTime: any; transactionTime: any; ac: { symbol: any; leverage: any; }; }; /** * Converts the futures UserData stream ACCOUNT_UPDATE data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fUserDataAccountUpdateConvertData(data: any): { eventType: any; eventTime: any; transaction: any; updateData: any; }; /** * Converts the futures UserData stream ORDER_TRADE_UPDATE data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fUserDataOrderUpdateConvertData(data: any): { eventType: any; eventTime: any; transaction: any; order: any; }; /** * Converts the futures markPrice stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fMarkPriceConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; markPrice: any; indexPrice: any; fundingRate: any; fundingTime: any; }; /** * Converts the futures aggTrade stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ fAggTradeConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; aggTradeId: any; price: any; amount: any; total: number; firstTradeId: any; lastTradeId: any; timestamp: any; maker: any; }; /** * Delivery heartbeat code with a shared single interval tick * @return {undefined} */ deliverySocketHeartbeat(): void; /** * Called when a delivery socket is opened, subscriptions are registered for later reference * @param {function} openCallback - a callback function * @return {undefined} */ handleDeliverySocketOpen(wsBind: any, openCallback: Callback): void; /** * Called when delivery websocket is closed, subscriptions are de-registered for later reference * @param {boolean} reconnect - true or false to reconnect the socket * @param {string} code - code associated with the socket * @param {string} reason - string with the response * @return {undefined} */ handleDeliverySocketClose(wsBind: any, reconnect: any, code: any, reason: any): void; /** * Called when a delivery websocket errors * @param {object} error - error object message * @return {undefined} */ handleDeliverySocketError(wsBind: any, error: any): void; /** * Called on each delivery socket heartbeat * @return {undefined} */ handleDeliverySocketHeartbeat(): void; /** * Used to subscribe to a single delivery websocket endpoint * @param {string} endpoint - endpoint to connect to * @param {function} callback - the function to call when information is received * @param {object} params - Optional reconnect {boolean} (whether to reconnect on disconnect), openCallback {function}, id {string} * @return {WebSocket} - websocket reference */ deliverySubscribeSingle(endpoint: string, callback: Callback, params?: Dict): any; /** * Used to subscribe to a combined delivery websocket endpoint * @param {string} streams - streams to connect to * @param {function} callback - the function to call when information is received * @param {object} params - Optional reconnect {boolean} (whether to reconnect on disconnect), openCallback {function}, id {string} * @return {WebSocket} - websocket reference */ deliverySubscribe(streams: any, callback: Callback, params?: Dict): any; /** * Used to terminate a delivery websocket * @param {string} endpoint - endpoint identifier associated with the web socket * @param {boolean} reconnect - auto reconnect after termination * @return {undefined} */ deliveryTerminate(endpoint: string, reconnect?: boolean): void; /** * Combines all delivery OHLC data with the latest update * @param {string} symbol - the symbol * @param {string} interval - time interval * @return {array} - interval data for given symbol */ deliveryKlineConcat(symbol: string, interval: Interval): any; /** * Used for websocket delivery @kline * @param {string} symbol - the symbol * @param {object} kline - object with kline info * @param {string} firstTime - time filter * @return {undefined} */ deliveryKlineHandler(symbol: string, kline: any, firstTime?: number): void; /** * Converts the delivery liquidation stream data into a friendly object * @param {object} data - liquidation data callback data type * @return {object} - user friendly data type */ dLiquidationConvertData(data: any): { symbol: any; side: any; orderType: any; timeInForce: any; origAmount: any; price: any; avgPrice: any; orderStatus: any; lastFilledQty: any; totalFilledQty: any; eventType: any; tradeTime: any; eventTime: any; }; /** * Converts the delivery ticker stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ dTickerConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; priceChange: any; percentChange: any; averagePrice: any; close: any; closeQty: any; open: any; high: any; low: any; volume: any; quoteVolume: any; openTime: any; closeTime: any; firstTradeId: any; lastTradeId: any; numTrades: any; }; /** * Converts the delivery miniTicker stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ dMiniTickerConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; close: any; open: any; high: any; low: any; volume: any; quoteVolume: any; }; /** * Converts the delivery bookTicker stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ dBookTickerConvertData(data: any): { updateId: any; symbol: any; bestBid: any; bestBidQty: any; bestAsk: any; bestAskQty: any; }; /** * Converts the delivery markPrice stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ dMarkPriceConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; markPrice: any; fundingRate: any; fundingTime: any; }; /** * Converts the delivery aggTrade stream data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ dAggTradeConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; aggTradeId: any; price: any; amount: any; total: number; firstTradeId: any; lastTradeId: any; timestamp: any; maker: any; }; /** * Converts the delivery UserData stream ORDER_TRADE_UPDATE data into a friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ dUserDataOrderUpdateConvertData(data: any): { eventType: any; eventTime: any; transaction: any; order: any; }; /** * Used as part of the user data websockets callback * @param {object} data - user data callback data type * @return {undefined} */ userDataHandler(data: any): void; /** * Used as part of the user data websockets callback * @param {object} data - user data callback data type * @return {undefined} */ userMarginDataHandler(data: any): void; /** * Used as part of the user data websockets callback * @param {object} data - user data callback data type * @return {undefined} */ userFutureDataHandler(data: any): void; /** * Used as part of the user data websockets callback * @param {object} data - user data callback data type * @return {undefined} */ userDeliveryDataHandler(data: any): void; /** * Universal Transfer requires API permissions enabled * @param {string} type - ENUM , example MAIN_UMFUTURE for SPOT to USDT futures, see https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer * @param {string} asset - the asset - example :USDT * * @param {number} amount - the callback function * @return {promise} */ universalTransfer(type: string, asset: string, amount: number): Promise<any>; /** * Transfer between main account and futures/delivery accounts * @param {string} asset - the asset * @param {number} amount - the asset * @param {object} options - additional options * @return {undefined} */ transferBetweenMainAndFutures(asset: string, amount: number, type: any): Promise<any>; /** * Converts the previous day stream into friendly object * @param {object} data - user data callback data type * @return {object} - user friendly data type */ prevDayConvertData(data: any): any[] | { eventType: any; eventTime: any; symbol: any; priceChange: any; percentChange: any; averagePrice: any; prevClose: any; close: any; closeQty: any; bestBid: any; bestBidQty: any; bestAsk: any; bestAskQty: any; open: any; high: any; low: any; volume: any; quoteVolume: any; openTime: any; closeTime: any; firstTradeId: any; lastTradeId: any; numTrades: any; }; /** * Parses the previous day stream and calls the user callback with friendly object * @param {object} data - user data callback data type * @param {function} callback - user data callback data type * @return {undefined} */ prevDayStreamHandler(data: any, callback: Callback): void; /** * Gets the price of a given symbol or symbols * @param {array} data - array of symbols * @return {array} - symbols with their current prices */ priceData(data: any): { [key: string]: number; }; /** * Used by bookTickers to format the bids and asks given given symbols * @param {array} data - array of symbols * @return {object} - symbols with their bids and asks data */ bookPriceData(data: any): { [key: string]: BookTicker; }; /** * Used by balance to get the balance data * @param {array} data - account info object * @return {object} - balances hel with available, onorder amounts */ balanceData(data: any): {}; /** * Used by web sockets depth and populates OHLC and info * @param {string} symbol - symbol to get candlestick info * @param {string} interval - time interval, 1m, 3m, 5m .... * @param {array} ticks - tick array * @return {undefined} */ klineData(symbol: any, interval: any, ticks: any): void; /** * Combines all OHLC data with latest update * @param {string} symbol - the symbol * @param {string} interval - time interval, 1m, 3m, 5m .... * @return {array} - interval data for given symbol */ klineConcat(symbol: string, interval: Interval): any; /** * Used for websocket @kline * @param {string} symbol - the symbol * @param {object} kline - object with kline info * @param {string} firstTime - time filter * @return {undefined} */ klineHandler(symbol: any, kline: any, firstTime?: number): void; /** * Used by futures websockets chart cache * @param {string} symbol - symbol to get candlestick info * @param {string} interval - time interval, 1m, 3m, 5m .... * @param {array} ticks - tick array * @return {undefined} */ futuresKlineData(symbol: string, interval: Interval, ticks: any[]): void; /** * Used by delivery websockets chart cache * @param {string} symbol - symbol to get candlestick info * @param {string} interval - time interval, 1m, 3m, 5m .... * @param {array} ticks - tick array * @return {undefined} */ deliveryKlineData(symbol: any, interval: any, ticks: any): void; /** * Used for /depth endpoint * @param {object} data - containing the bids and asks * @return {undefined} */ depthData(data: any): { bids: any[]; asks: any[]; lastUpdateId?: undefined; } | { lastUpdateId: any; bids: {}; asks: {}; }; parseOrderBook(data: any, symbol: string): OrderBook; /** * Used for /depth endpoint * @param {object} depth - information * @return {undefined} */ depthHandler(depth: any): void; /** * Gets depth cache for given symbol * @param {string} symbol - the symbol to fetch * @return {object} - the depth cache object */ getDepthCache(symbol: string): any; /** * Calculate Buy/Sell volume from DepthCache * @param {string} symbol - the symbol to fetch * @return {object} - the depth volume cache object */ depthVolume(symbol: string): { bids: number; asks: number; bidQty: number; askQty: number; }; /** * Checks whether or not an array contains any duplicate elements * @param {array} array - the array to check * @return {boolean} - true or false */ isArrayUnique(array: any[]): boolean; /** * Count decimal places * @param {float} float - get the price precision point * @return {int} - number of place */ getPrecision(float: number): number; /** * rounds number with given step * @param {float} qty - quantity to round * @param {float} stepSize - stepSize as specified by exchangeInfo * @return {float} - number */ roundStep(qty: any, stepSize: any): any; /** * rounds price to required precision * @param {float} price - price to round * @param {float} tickSize - tickSize as specified by exchangeInfo * @return {float} - number */ roundTicks(price: any, tickSize: any): any; /** * Gets percentage of given numbers * @param {float} min - the smaller number * @param {float} max - the bigger number * @param {int} width - percentage width * @return {float} - percentage */ percent(min: any, max: any, width?: number): number; /** * Gets the sum of an array of numbers * @param {array} array - the number to add * @return {float} - sum */ sum(array: any): any; /** * Reverses the keys of an object * @param {object} object - the object * @return {object} - the object */ reverse(object: any): {}; /** * Converts an object to an array * @param {object} obj - the object * @return {array} - the array */ array(obj: any): any[][]; /** * Sorts bids * @param {string} symbol - the object * @param {int} max - the max number of bids * @param {string} baseValue - the object * @return {object} - the object */ sortBids(symbol: string, max?: number, baseValue?: string): {}; /** * Sorts asks * @param {string} symbol - the object * @param {int} max - the max number of bids * @param {string} baseValue - the object * @return {object} - the object */ sortAsks(symbol: string, max?: number, baseValue?: string): {}; /** * Returns the first property of an object * @param {object} object - the object to get the first member * @return {string} - the object key */ first(object: any): string; /** * Returns the last property of an object * @param {object} object - the object to get the first member * @return {string} - the object key */ last(object: any): string; /** * Returns an array of properties starting at start * @param {object} object - the object to get the properties form * @param {int} start - the starting index * @return {array} - the array of entires */ slice(object: any, start?: number): string[]; /** * Gets the minimum key form object * @param {object} object - the object to get the properties form * @return {string} - the minimum key */ min(object: any): any; /** * Gets the maximum key form object * @param {object} object - the object to get the properties form * @return {string} - the minimum key */ max(object: any): any; /** * Sets an option given a key and value * @param {string} key - the key to set * @param {object} value - the value of the key * @return {undefined} */ setOption(key: any, value: any): void; /** * Gets an option given a key * @param {string} key - the key to set * @return {undefined} */ getOption(key: string): any; /** * Returns the entire info object * @return {object} - the info object */ getInfo(): Dict; /** * Returns the used weight from the last request * @return {object} - 1m weight used */ usedWeight(): any; /** * Returns the status code from the last http response * @return {object} - status code */ statusCode(): any; /** * Returns the ping time from the last futures request * @return {object} - latency/ping (2ms) */ futuresLatency(): any; /** * Returns the complete URL from the last request * @return {object} - http address including query string */ lastURL(): any; /** * Returns the order count from the last request * @return {object} - orders allowed per 1m */ orderCount(): any; /** * Returns the entire options object * @return {object} - the options object */ getOptions(): any; /** * Gets the depth information for a given symbol * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book * @param {string} symbol - the symbol * @param {int} limit - limit the number of returned orders * @return {promise or undefined} - omitting the callback returns a promise */ depth(symbol: string, limit?: number): Promise<OrderBook>; /** * Gets the average prices of a given symbol * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#current-average-price * @param {string} symbol - the symbol * @return {promise or undefined} - omitting the callback returns a promise */ avgPrice(symbol: string, params?: Dict): Promise<any>; /** * Gets the prices of a given symbol(s) * @param {string} symbol - the symbol * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-price-ticker * @return {promise or undefined} - omitting the callback returns a promise */ prices(symbol?: string, params?: Dict): Promise<{ [key: string]: number; }>; /** * Gets the book tickers of given symbol(s) * @see https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/market-data-endpoints#symbol-order-book-ticker * @param {string} symbol - the symbol * @return {promise or undefined} - omitting the callback returns a promise */ bookTickers(symbol?: string, params?: Dict): Promise<{ [key: string]: BookTicker; }>; /** * Gets the prevday percentage change * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics * @param {string} symbol - the symbol or symbols * @return {promise or undefined} - omitting the callback returns a promise */ prevDay(symbol?: string, params?: Dict): Promise<DailyStats[] | DailyStats>; /** * Gets the prevday percentage change * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics * @param {string} symbol - the symbol or symbols * @return {promise or undefined} - omitting the callback returns a promise */ ticker24h(symbol?: string, params?: Dict): Promise<DailyStats[] | DailyStats>; /** * Gets the prevday percentage change * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics * @param {string} symbol - the symbol or symbols * @return {promise or undefined} - omitting the callback returns a promise */ dailyStats(symbol?: string, params?: Dict): Promise<DailyStats[] | DailyStats>; /** * Gets the the exchange info * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information * @return {promise or undefined} - omitting the callback returns a promise */ exchangeInfo(): Promise<any>; /** * Gets the dust log for user * @return {promise or undefined} - omitting the callback returns a promise */ dustLog(): Promise<any>; dustTransfer(assets: any): Promise<any>; assetDividendRecord(params?: Dict): Promise<any>; /** * Gets the the system status * @see https://developers.binance.com/docs/wallet/others/system-status * @return {promise or undefined} - omitting the callback returns a promise */ systemStatus(params?: Dict): Promise<any>; /** * Withdraws asset to given wallet id * @see https://developers.binance.com/docs/wallet/capital/withdraw * @param {string} asset - the asset symbol * @param {string} address - the wallet to transfer it to * @param {number} amount - the amount to transfer * @param {string} addressTag - and addtional address tag * @param {string} name - the name to save the address as. Set falsy to prevent Binance saving to address book * @return {promise or undefined} - omitting the callback returns a promise */ withdraw(asset: string, address: string, amount: number, addressTag?: string, name?: string, params?: Dict): Promise<WithdrawResponse>; /** * Get the Withdraws history for a given asset * @see https://developers.binance.com/docs/wallet/capital/withdraw-history * @param {object} params - supports limit and fromId parameters * @return {promise or undefined} - omitting the callback returns a promise */ withdrawHistory(params?: Dict): Promise<WithdrawHistoryResponse>; /** * Get the deposit history * @see https://developers.binance.com/docs/wallet/capital/deposite-history#http-request * @param {object} params - additional params * @return {promise or undefined} - omitting the callback returns a promise */ depositHistory(asset?: string, params?: Dict): Promise<DepositHistoryResponse>; /** * Get the deposit address for given asset * @see https://developers.binance.com/docs/wallet/capital/deposite-address * @param {string} coin - the asset * @return {promise or undefined} - omitting the callback returns a promise */ depositAddress(asset: string, params?: Dict): Promise<DepositAddress>; /** * Get the deposit address list for given asset * @see https://developers.binance.com/docs/wallet/capital/fetch-deposit-address-list-with-network * @param {string} coin - the asset * @return {promise or undefined} - omitting the callback returns a promise */ depositAddressList(asset: string, params?: Dict): Promise<any>; /** * Get the account status * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data