UNPKG

betfair-node

Version:

A comprehensive Node.js TypeScript library for the Betfair Exchange API, providing both JSON-RPC API integration and real-time Exchange Stream API support for automated betting and trading applications.

75 lines 2.88 kB
/** * Generates a random packet ID for API requests * @returns A random number between 100000000 and 999999999 */ export declare const generatePacketId: () => number; /** * Validates if a string is a valid market ID format * @param marketId - The market ID to validate * @returns True if valid, false otherwise */ export declare const isValidMarketId: (marketId: string) => boolean; /** * Converts a price to the Betfair price format * @param price - The price to convert * @returns The formatted price */ export declare const formatBetfairPrice: (price: number) => number; /** * Converts currency amount using the provided rate * @param amount - The amount to convert * @param rate - The currency conversion rate * @returns The converted amount */ export declare const convertCurrency: (amount: number, rate: number) => number; /** * Validates if a selection ID is valid * @param selectionId - The selection ID to validate * @returns True if valid, false otherwise */ export declare const isValidSelectionId: (selectionId: number) => boolean; /** * Creates a delay promise * @param ms - Milliseconds to delay * @returns Promise that resolves after the delay */ export declare const delay: (ms: number) => Promise<void>; /** * Safely parses JSON with error handling * @param json - JSON string to parse * @returns Parsed object or null if invalid */ export declare const safeJsonParse: <T>(json: string) => T | null; /** * Finds the appropriate tick size for a given price * @param price - The price to find the tick size for * @returns The tick increment for the price range */ export declare const getTickSize: (price: number) => number; /** * Generates a complete price ladder for a given range with memoization * @param minPrice - Minimum price (default: 1.01) * @param maxPrice - Maximum price (default: 1000) * @returns Array of valid prices in the ladder */ export declare const generatePriceLadder: (minPrice?: number, maxPrice?: number) => number[]; /** * Gets the next valid tick price from a given price * @param price - The current price * @returns The next valid price in the ladder, or null if at maximum */ export declare const getNextTick: (price: number) => number | null; /** * Gets the previous valid tick price from a given price * @param price - The current price * @returns The previous valid price in the ladder, or null if at minimum */ export declare const getPreviousTick: (price: number) => number | null; /** * Finds the nearest valid price in the ladder * @param price - The price to find the nearest valid price for * @param direction - 'up' to round up, 'down' to round down, 'nearest' for closest * @returns The nearest valid price in the ladder */ export declare const getNearestValidPrice: (price: number, direction?: "up" | "down" | "nearest") => number; //# sourceMappingURL=utils.d.ts.map