UNPKG

@thoshpathi/utils-smartapi

Version:

Extended utilities for Angel One's smartapi-javascript SDK, including custom methods and helpers for market data like candles, P&L, and more.

18 lines (16 loc) 494 B
// src/pl_utils.ts function isProfitReached({ entry, points, trend, ltp }) { return trend === "BUY" ? ltp >= entry + points : ltp <= entry - points; } function isStoplossReached({ entry, points, trend, ltp }) { return trend === "BUY" ? ltp <= entry - points : ltp >= entry + points; } function calculatePL({ entry, qty, trend, ltp }) { const points = trend === "BUY" ? ltp - entry : entry - ltp; return points * qty; } export { isProfitReached, isStoplossReached, calculatePL };