Real-Time Market Data Ingestion & Insider Trading Dashboard: Open-Source NSE API Wrapper
Engineering PNSEA, an open-source Python library for real-time NSE data extraction and Pandas DataFrame formatting, driving a private FastAPI analytics backend on Railway.
Verified Engineering Benchmarks
Founder’s TL;DR:
- The Problem: Third-party financial data providers charge prohibitive subscription fees (up to ₹20 Lakhs/year) for exchange feeds, while public endpoints break constantly due to anti-scraping headers and session timeouts.
- The Engineering Fix: Built
pnsea—a free, open-source Python library—to automate exchange session warming and format Option Chain, Equity, and Insider Trading disclosures into clean Pandas DataFrames. Layered a private FastAPI microservice on Railway to track promoter insider buying/selling in crores.- The Bottom Line: Replaced costly commercial APIs with a 100% free open-source core running on a $5–$15/month Railway + Vercel micro-budget infrastructure.
Executive Summary
Accessing real-time National Stock Exchange (NSE) market data—such as Option Chains, implied volatility surface matrixes, equity quotes, and corporate insider trading disclosures—typically requires expensive commercial vendor feeds running up to ₹20 Lakhs ($24,000) per year.
Furthermore, existing PyPI packages for NSE data are frequently broken, abandoned, or fail under market opening volatility (9:15 AM IST) due to missing session warming protocols, dynamic cookie expiry, and strict anti-scraping headers.
To solve this, Anil Sardiwal created pnsea—a free, open-source Python library that handles session cookies, bypasses anti-scraping checks, and structures raw exchange JSON into production-ready Pandas DataFrames.
For internal analytics, Unreal Brains deployed a private FastAPI backend instance on Railway ($5–$15/mo) using pnsea as its core engine. The microservice aggregates promoter insider buying and selling volume in crores over custom timeframes (7d, 30d, 90d) and feeds a live Astro dashboard hosted on Vercel ($0).
Technical Architecture & Pipeline
- • Session Warmer Protocol & Ephemeral Cookie Rotator
- • Exchange Raw JSON to Pandas DataFrames Normalization
- • Full Coverage: Option Chains, Equity Quotes, Index Weights, Insider Disclosures
- • Aggregates Promoter Insider Trading Volume (Calculates Net Value in Crores)
- • Historical Snapshots stored in NeonDB (Serverless Postgres)
- • REST API Endpoints with Asynchronous Ingestion Pipelines
Architectural Breakdown
-
pnseaOpen-Source Core Library:- Session Warming Protocol: Automatically fetches root landing endpoints to acquire valid
bm_svand session cookies before querying data routes. - Pandas Native Output: Converts complex nested JSON payloads (Option Chains, SAST disclosures, Form 7 filings) directly into clean Pandas DataFrames (
df = nse.get_option_chain("NIFTY")). - Standalone PyPI Solution: Unlike fragmented or broken scripts,
pnseaprovides an active, maintained open-source API layer for Python developers.
- Session Warming Protocol: Automatically fetches root landing endpoints to acquire valid
-
Private FastAPI Ingestion Instance (Railway):
- Deployed on Railway ($5–$15/mo), the private FastAPI service runs scheduled background tasks using
pnsea. - Ingests corporate insider trading disclosures, converts share quantities and transaction prices into net INR values, and aggregates promoter accumulation trends in Crores (₹10M INR).
- Deployed on Railway ($5–$15/mo), the private FastAPI service runs scheduled background tasks using
-
High-Speed Analytics Dashboard (Vercel):
- Renders quantitative visualizations on Vercel ($0 hosting) for zero monthly frontend overhead.
Technical Outcomes & Business Impact
- Commercial Savings: Replaced third-party data vendor subscriptions, saving thousands of dollars per year in third-party API fees.
- Open-Source Contribution: Released
pnseaas a free and open-source PyPI package, filling a major gap for Python financial data engineering. - Micro-Budget Operations: Deployed the complete private analytics engine and live insider tracking dashboard on a $5–$15/month total infrastructure spend (Railway + Vercel).
- Data Structuring Velocity: Enabled instant quantitative manipulation by outputting structured Pandas DataFrames natively out of the box.
Have a Similar Engineering Challenge?
We build data pipelines, bypass TLS anti-bot blocks, and launch production SaaS MVPs on a 100% async basis.
Start a Project Async →