Hi, yes getProfit is not working in runtime.
in runtime you need to store position history then calculate profit by new reduce order is coming.
profit calculated as diff between entryPrice and closePrice
take a look Exchange/heplers.ts
export function longProfit(entryPrice: number, closePrice: number, size: number, contractSize: number = 1): number {
return (closePrice - entryPrice) * size * contractSize;
}
export function shortProfit(entryPrice: number, closePrice: number, size: number, contractSize: number = 1): number {
return (entryPrice - closePrice) * size * contractSize;
}