UNPKG

binance-futures-wrapper

Version:

A comprehensive TypeScript wrapper for Binance USDT-M Futures API with full REST and WebSocket support

109 lines 3.24 kB
/** * Utility functions for Binance Futures API */ import { BinanceConfig } from '../types'; /** * Create HMAC SHA256 signature for Binance API */ export declare function createSignature(queryString: string, apiSecret: string): string; /** * Get current timestamp in milliseconds */ export declare function getTimestamp(): number; /** * Convert object to query string */ export declare function objectToQueryString(obj: Record<string, any>): string; /** * Add signature to parameters */ export declare function addSignature(params: Record<string, any>, apiSecret: string, timestamp?: number): Record<string, any>; /** * Get base URLs based on testnet configuration */ export declare function getBaseUrls(testnet?: boolean): { rest: string; ws: string; }; /** * Validate Binance configuration */ export declare function validateConfig(config: BinanceConfig): void; /** * Generate random string for client order ID */ export declare function generateClientOrderId(prefix?: string): string; /** * Format number to string with proper precision */ export declare function formatNumber(num: number, precision?: number): string; /** * Sleep function for delays */ export declare function sleep(ms: number): Promise<void>; /** * Retry function with exponential backoff */ export declare function retry<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number): Promise<T>; /** * Logger utility */ export declare class Logger { private enabled; private prefix; constructor(enabled?: boolean, prefix?: string); log(message: string, ...args: unknown[]): void; error(message: string, ...args: unknown[]): void; warn(message: string, ...args: unknown[]): void; debug(message: string, ...args: unknown[]): void; } /** * Rate limiter utility */ export declare class RateLimiter { private requests; private maxRequests; private timeWindow; constructor(maxRequests?: number, timeWindow?: number); checkLimit(): Promise<void>; } /** * WebSocket reconnection utility */ export declare class ReconnectionManager { private attempts; private maxAttempts; private baseDelay; private maxDelay; constructor(maxAttempts?: number, baseDelay?: number, maxDelay?: number); getDelay(): Promise<number>; reset(): void; canReconnect(): boolean; } /** * REST Data Converters */ /** * Convert raw kline array to Kline object * Binance returns klines as arrays in this format: * [ * 1499040000000, // Open time * "0.01634790", // Open * "0.80000000", // High * "0.01575800", // Low * "0.01577100", // Close * "148976.11427815", // Volume * 1499644799999, // Close time * "2434.19055334", // Quote asset volume * 308, // Number of trades * "1756.87402397", // Taker buy base asset volume * "28.46694368", // Taker buy quote asset volume * "17928899.62484339" // Ignore * ] */ export declare function convertKlineData(rawKline: any[]): import('../types').Kline; /** * Convert array of raw klines to array of Kline objects */ export declare function convertKlinesData(rawKlines: any[][]): import('../types').Kline[]; //# sourceMappingURL=index.d.ts.map