@lacspace/paper-trade
Headless paper-trading engine — virtual wallet, market/limit/stop orders that fill against live prices, positions, holdings and live P&L. The simulator core behind StockYatra. Zero-dependency.
npm i @lacspace/paper-tradeUsage
import { PaperAccount } from "@lacspace/paper-trade";
const acct = new PaperAccount({ cash: 100_000 });
// feed prices (from your ticker / websocket), then trade
acct.mark({ RELIANCE: 2900 });
acct.buy("RELIANCE", { qty: 10 }); // market buy — fills at 2900
acct.mark({ RELIANCE: 2950 }); // price moves up
acct.unrealizedPnl; // 500
acct.summary().equity; // 100500 (cash + market value)
acct.sell("RELIANCE", { qty: 10 }); // book the profit
acct.realizedPnl; // 500Exports 1
PaperAccountKeywords
paper-tradingtrading-simulatorstock-marketvirtual-tradingbacktestingportfolio
More in StockKit
@lacspace/indicators
Streaming technical indicators (RSI, MACD, EMA, Bollinger, ATR, Supertrend, ADX, VWAP) with O(1) incremental updates for live price feeds. Zero-dependency.
@lacspace/marketStock-market money math — P&L, returns, CAGR, XIRR, tick-size rounding, circuit limits, position sizing and an Indian brokerage & charges calculator (STT, GST, SEBI, stamp). Zero-dependency.
@lacspace/market-clockHoliday-aware, timezone-correct trading clock — is NSE/BSE open now, next open/close, pre-open, holidays. Bring your own exchange spec. Zero-dependency.