npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nse-holiday-calendar

v1.0.1

Published

A lightweight JavaScript library to check NSE trading holidays and calculate next/previous trading days for Indian stock market

Readme

nse-holiday-calendar

🇮🇳 NSE Trading Holiday Calendar for JavaScript

A lightweight, zero-dependency library to check NSE (National Stock Exchange) trading holidays and calculate next/previous trading days for the Indian stock market.

✨ Features

  • Zero dependencies - Lightweight and fast
  • 📅 Complete holiday data (2022-2026)
  • 🚀 Framework agnostic - Works with React, Node.js, Vue, etc.
  • 📈 Perfect for trading bots and backtesting
  • 🌐 ES6 modules with TypeScript support
  • Weekend detection included

📦 Installation

npm install nse-holiday-calendar

🚀 Quick Start

import { isTradingDay, nextTradingDay, previousTradingDay } from "nse-holiday-calendar";

// Check if today is a trading day
console.log(isTradingDay(new Date())); // true/false

// Get next trading day after Republic Day
console.log(nextTradingDay("2024-01-26")); // 2024-01-29

// Get previous trading day
console.log(previousTradingDay("2024-01-29")); // 2024-01-25

📋 Usage Examples

React Trading Dashboard

import { isTradingDay, nextTradingDay } from "nse-holiday-calendar";

function TradingStatus() {
  const today = new Date();
  const isOpen = isTradingDay(today);
  
  return (
    <div>
      <h2>Market Status: {isOpen ? "🟢 Open" : "🔴 Closed"}</h2>
      {!isOpen && (
        <p>Next trading day: {nextTradingDay(today).toDateString()}</p>
      )}
    </div>
  );
}

Node.js Trading Bot

import { isTradingDay, nextTradingDay } from "nse-holiday-calendar";

// Only execute trades on trading days
function executeTrade(orderData) {
  if (!isTradingDay(new Date())) {
    console.log(`Market closed. Next trading day: ${nextTradingDay(new Date())}`);
    return;
  }
  
  // Execute your trading logic
  processOrder(orderData);
}

Backtesting & Data Analysis

import { isTradingDay } from "nse-holiday-calendar";

// Filter only trading day data
const tradingDayData = historicalData.filter(candle => 
  isTradingDay(new Date(candle.timestamp))
);

// Skip processing on holidays/weekends
function processCandle(candle) {
  if (!isTradingDay(candle.time)) return; // Skip holidays
  
  // Your backtesting logic here
  calculateIndicators(candle);
}

Scheduling & Automation

import { isTradingDay, nextTradingDay } from "nse-holiday-calendar";

// Schedule reports only on trading days
function scheduleReport() {
  const today = new Date();
  
  if (isTradingDay(today)) {
    generateDailyReport();
  } else {
    console.log(`Skipping report. Next trading day: ${nextTradingDay(today)}`);
  }
}

📚 API Reference

isTradingDay(date)

Checks if a given date is a trading day (excludes weekends and NSE holidays).

Parameters:

  • date (Date | string): Date to check

Returns: boolean

isTradingDay(new Date());           // true/false
isTradingDay("2024-01-26");         // false (Republic Day)
isTradingDay("2024-01-27");         // false (Saturday)
isTradingDay("2024-01-29");         // true (Monday)

nextTradingDay(date)

Returns the next available trading day after the given date.

Parameters:

  • date (Date | string): Starting date

Returns: Date

nextTradingDay("2024-01-26");       // Mon Jan 29 2024 (skips weekend)
nextTradingDay("2024-12-25");       // Thu Dec 26 2024

previousTradingDay(date)

Returns the previous trading day before the given date.

Parameters:

  • date (Date | string): Starting date

Returns: Date

previousTradingDay("2024-01-29");   // Thu Jan 25 2024
previousTradingDay("2024-01-26");   // Wed Jan 24 2024

📅 Supported Years

Currently includes NSE holiday data for:

  • 2022 - 13 holidays
  • 2023 - 15 holidays
  • 2024 - 16 holidays
  • 2025 - 14 holidays
  • 2026 - 15 holidays

🏦 Included Holidays

Major NSE holidays covered:

  • Republic Day, Independence Day
  • Diwali, Holi, Dussehra
  • Good Friday, Christmas
  • Gandhi Jayanti, Ambedkar Jayanti
  • Eid festivals, Guru Nanak Jayanti
  • And more regional holidays

🤝 Contributing

Contributions welcome! Please feel free to submit issues and pull requests.

📄 License

MIT © Sonu Kumar

🔗 Links