JSPM

@nepse-toolkit/analysis

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q57007F
  • License MIT

Technical indicators, screening strategies, and backtesting for NEPSE

Package Exports

  • @nepse-toolkit/analysis

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/analysis

Quick 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 test

License

MIT