Interface PerformanceContract

Contract for performance tracking events.

Emitted during execution to track performance metrics for various operations. Useful for profiling and identifying bottlenecks.

import { listenPerformance } from "backtest-kit";

listenPerformance((event) => {
console.log(`${event.metricType}: ${event.duration.toFixed(2)}ms`);
console.log(`${event.strategyName} @ ${event.exchangeName}`);
});
interface PerformanceContract {
    backtest: boolean;
    duration: number;
    exchangeName: string;
    metricType: PerformanceMetricType;
    previousTimestamp: number;
    strategyName: string;
    symbol: string;
    timestamp: number;
}

Properties

backtest: boolean

Whether this metric is from backtest mode (true) or live mode (false)

duration: number

Duration of the operation in milliseconds

exchangeName: string

Exchange name associated with this metric

Type of operation being measured

previousTimestamp: number

Timestamp of the previous event (milliseconds since epoch, null for first event)

strategyName: string

Strategy name associated with this metric

symbol: string

Trading symbol associated with this metric

timestamp: number

Timestamp when the metric was recorded (milliseconds since epoch)