← All packages

@lacspace/paper-trade

v1.1.4StockKit0 deps

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-trade

Usage

paper-trade.ts
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;                      // 500

Exports 1

PaperAccount

Keywords

paper-tradingtrading-simulatorstock-marketvirtual-tradingbacktestingportfolio

More in StockKit