Variable ReflectConst

Reflect: ReflectUtils

Singleton instance of ReflectUtils for convenient position state queries.

import { Reflect } from "backtest-kit";

// Real-time PNL
const pnl = await Reflect.getPositionPnlPercent(
"BTCUSDT",
45000,
{ strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
);
console.log(`PNL: ${pnl}%`);

// Peak profit
const peakPnl = await Reflect.getPositionHighestPnlPercentage(
"BTCUSDT",
{ strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
);
console.log(`Peak PNL: ${peakPnl}%`);

// Drawdown from peak
const drawdown = await Reflect.getPositionHighestProfitDistancePnlPercentage(
"BTCUSDT",
{ strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
);
console.log(`Dropped ${drawdown}% from peak`);