@nepse-toolkit/analysis
v0.2.5
Published
Technical indicators, screening strategies, and backtesting for NEPSE
Downloads
445
Maintainers
Readme
@nepse-toolkit/analysis
Technical indicators, screening strategies, valuation helpers, and backtesting utilities for NEPSE.
Part of the nepse-toolkit monorepo.
Overview
- 9 technical indicators (SMA, EMA, RSI, MACD, Bollinger, ATR, VWAP, OBV, Stochastic)
- 7 built-in screening strategies
- Backtesting with optimization, walk-forward validation, and Monte Carlo stress testing
- Portfolio/valuation helpers with NEPSE-oriented assumptions
Install
npm install @nepse-toolkit/analysisQuick Start
import {
analyzeTechnicals,
runScreen,
backtest,
optimizeStrategy,
monteCarloStressTest,
walkForwardValidate,
} from "@nepse-toolkit/analysis";
const technicals = analyzeTechnicals(history);
const opportunities = runScreen(
"oversold_bounce",
new Map([["NABIL", { quote, history }]])
);
const result = backtest(new Map([["NABIL", history]]), {
strategy: "momentum_breakout",
holdingPeriod: 10,
startCapital: 1_000_000,
positionSize: 10,
slippageBps: 10,
feePercent: 0.4,
maxConcurrentPositions: 5,
maxPortfolioExposurePercent: 80,
});
const optimization = optimizeStrategy(
new Map([["NABIL", history]]),
{
strategy: "momentum_breakout",
startCapital: 1_000_000,
positionSize: 10,
},
{
holdingPeriods: [8, 10, 12],
stopLossPercents: [5, 8],
takeProfitPercents: [12, 20],
topN: 5,
}
);
const stress = monteCarloStressTest(
new Map([["NABIL", history]]),
{
strategy: "momentum_breakout",
holdingPeriod: 10,
startCapital: 1_000_000,
positionSize: 10,
slippageBps: 10,
feePercent: 0.4,
},
{
simulations: 300,
confidence: 0.95,
slippageJitterBps: 5,
feeJitterPercent: 0.1,
shockPercent: 8,
seed: 42,
}
);
const walkForward = walkForwardValidate(
new Map([["NABIL", history]]),
{
strategy: "momentum_breakout",
baseConfig: {
startCapital: 1_000_000,
positionSize: 10,
},
sweep: {
holdingPeriods: [8, 10, 12],
stopLossPercents: [5, 8],
takeProfitPercents: [12, 20],
topN: 5,
},
trainWindow: 160,
testWindow: 60,
stepWindow: 60,
maxFolds: 4,
}
);Export Groups
- Indicators: moving averages, oscillators, volatility, volume metrics
- Signals and screeners: predefined NEPSE-oriented trade setups
- Backtesting: engine, optimizer, stress and walk-forward modules
- Valuation and portfolio utilities: intrinsic value, tax and sizing helpers
Development
bun --filter @nepse-toolkit/analysis run build
bun --filter @nepse-toolkit/analysis run typecheck
bun --filter @nepse-toolkit/analysis run testLicense
MIT
