tardis-dev
Version:
Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js
101 lines • 4.74 kB
TypeScript
import type { Agent } from 'https';
import { Mapper } from './mappers/index.ts';
import { Exchange, Filter, FilterForExchange } from './types.ts';
export declare function parseAsUTCDate(val: string): Date;
export declare function wait(delayMS: number): Promise<unknown>;
export declare function getRandomString(): string;
export declare function formatDateToPath(date: Date): string;
export declare function doubleDigit(input: number): string;
export declare function sha256(obj: object): string;
export declare function addMinutes(date: Date, minutes: number): Date;
export declare function addDays(date: Date, days: number): Date;
export declare function sequence(end: number, seed?: number): Generator<number, void, unknown>;
export declare const ONE_SEC_IN_MS = 1000;
export declare class HttpError extends Error {
readonly status: number;
readonly responseText: string;
readonly url: string;
constructor(status: number, responseText: string, url: string);
}
export declare function take(iterable: Iterable<any>, length: number): Generator<any, void, unknown>;
export declare function normalizeMessages(exchange: Exchange, symbols: string[] | undefined, messages: AsyncIterableIterator<{
localTimestamp: Date;
message: any;
} | undefined>, mappers: Mapper<any, any>[], createMappers: (localTimestamp: Date) => Mapper<any, any>[], withDisconnectMessages: boolean | undefined, filter?: (symbol: string) => boolean, currentTimestamp?: Date | undefined): AsyncGenerator<any, void, unknown>;
export declare function getFilters<T extends Exchange>(mappers: Mapper<T, any>[], symbols?: string[]): FilterForExchange[T][];
export declare function batch(symbols: string[], batchSize: number): Generator<string[], void, unknown>;
export declare function batchObjects<T>(payload: T[], batchSize: number): Generator<T[], void, unknown>;
export declare function parseμs(dateString: string): number;
export declare function optimizeFilters(filters: Filter<any>[]): Filter<any>[];
export declare const httpsProxyAgent: Agent | undefined;
type HttpRetryOptions = number | {
limit?: number;
statusCodes?: number[];
maxRetryAfter?: number;
};
type HttpRequestOptions = {
headers?: Record<string, string>;
body?: string | object;
timeout?: number;
retry?: HttpRetryOptions;
};
type JSONResponse<T> = {
data: T;
headers: Record<string, string>;
statusCode: number;
};
export declare function getJSON<T>(url: string, options?: HttpRequestOptions): Promise<JSONResponse<T>>;
export declare function postJSON<T>(url: string, options?: HttpRequestOptions): Promise<JSONResponse<T>>;
export declare function download({ apiKey, downloadPath, url, userAgent, appendContentEncodingExtension, acceptEncoding }: {
url: string;
downloadPath: string;
userAgent: string;
apiKey: string;
appendContentEncodingExtension?: boolean;
acceptEncoding?: string;
}): Promise<{
downloadPath: string;
headers: Record<string, string>;
}>;
export declare function cleanTempFiles(): void;
export declare class CircularBuffer<T> {
private readonly _bufferSize;
private _buffer;
private _index;
constructor(_bufferSize: number);
append(value: T): T | undefined;
items(): Generator<T, void, unknown>;
get count(): number;
clear(): void;
}
export declare class CappedSet<T> {
private readonly _maxSize;
private _set;
constructor(_maxSize: number);
has(value: T): boolean;
add(value: T): void;
remove(value: T): void;
size(): number;
}
export declare function decimalPlaces(n: number): number;
/**
* Parses optional numeric fields where:
* * `0` **is valid and preserved**
* * `undefined`, `null`, `NaN`, `Infinity`, and `-Infinity` are treated as not valid and mapped to `undefined`
*
* Use for nullable/optional numeric fields such as open interest, funding rates, and greeks.
*/
export declare function asNumberOrUndefined(val: string | number | undefined | null): number | undefined;
/**
* Parses optional numeric fields where:
* * `0`, `undefined`, `null`, `NaN`, `Infinity`, and `-Infinity` are treated as not valid and mapped to `undefined`.
*
* Use for empty quote/top-of-book values that exchanges encode as zero.
*/
export declare function asNonZeroNumberOrUndefined(val: string | number | undefined | null): number | undefined;
export declare function upperCaseSymbols(symbols?: string[]): string[] | undefined;
export declare function lowerCaseSymbols(symbols?: string[]): string[] | undefined;
export declare const fromMicroSecondsToDate: (micros: number) => Date;
export declare function onlyUnique(value: string, index: number, array: string[]): boolean;
export {};
//# sourceMappingURL=handy.d.ts.map