@stoqey/ibkr
Version:
NodeJS Interactive Brokers wrapper & utilities using @stoqey/ib
47 lines (46 loc) • 2 kB
TypeScript
import { Instrument, MarketData } from "../interfaces";
import { Contract } from "@stoqey/ib";
export declare class MkdManager {
logsNames: string;
marketData: Record<string, MarketData[]>;
_cleanUp: Record<string, Date>;
getSymbolKey(instrument: Instrument | Contract): string;
cacheBar(data: MarketData): void;
findIndex(symbol: string, targetTimestamp: number, last?: boolean): number;
/**
* Get historical data for a given time range using binary search
*
* @param contract - The instrument to query
* @param startDate - Start of the range
* @param endDate - End of the range
* @param interval - Optional interval for aggregation (not yet implemented)
* @returns Array of market data within the range
*
* @example
* const data = await manager.historicalData(
* instrument,
* new Date('2024-01-15T10:30:00Z'),
* new Date('2024-01-15T10:35:00Z')
* );
*/
historicalData(contract: Instrument | Contract, startDate: Date, endDate: Date, interval?: string): Promise<MarketData[]>;
/**
* Get quote at or before specified timestamp (point-in-time lookup)
* Returns the most recent data point at or before the requested time.
* If no data exists before the requested time, returns the first available data point.
*
* @param contract - The instrument to query
* @param date - The timestamp to query (defaults to current time)
* @returns The market data at or before the specified time, or null if no data exists
*
* @example
* // Get current quote
* const quote = await manager.getQuote(instrument);
*
* @example
* // Get historical quote at specific time
* const quote = await manager.getQuote(instrument, new Date('2024-01-15T10:32:00Z'));
*/
getQuote(contract: Instrument | Contract, date?: Date): Promise<MarketData>;
doCleanUp: (symbol: any, data: MarketData, buffer: MarketData[]) => void;
}