How deshwalmahesh/nse-stock-scanner works
1. Overall shape
- This is a local, notebook-driven stock analysis toolkit, not a deployed service.
- The primary user entry point is Tutorial.ipynb, which orchestrates code in helpers/.
- Execution is done in a Python/Jupyter kernel with file-based inputs and outputs.
2. Main orchestration boundary
- The notebook layer is the “UI” of the project: users run cells to fetch data, scan stocks, plot charts, backtest, and inspect results.
- The reusable business logic lives in the helpers/ package, so the notebook stays relatively thin and interactive.
3. Data acquisition subsystem
- helpers/nse_data.py is the main boundary for NSE market data access.
- The repo supports both historical data and live data, with README emphasis on multiple intraday intervals.
- helpers/online_brokers.py suggests a separate adapter layer for broker/platform connectivity rather than mixing it into strategy code.
4. Local market data store
- The data/ directory contains a large set of per-stock CSV files, one file per NSE symbol with date-stamped historical records.
- data.json appears to act as a metadata/config index for the dataset.
- This means the system can run largely offline against cached market history, while live feeds are an add-on path.
5. Strategy and signal engine
- helpers/investing.py, helpers/intraday.py, and helpers/FnO.py partition the logic by trading style:
- Swing / investing-style screening
- Intraday scanning
- Futures & options support
- The README’s supported indicators and setups indicate the engine computes signals from price series, indicator values, and pattern checks.
6. Technical analysis layer
- helpers/candlestick.py handles candlestick pattern recognition.
- helpers/stock_analyser.py likely ties together indicators, filters, and ranking logic for the stock scanner.
- The project’s outputs are not just raw indicators; they are actionable candidate lists based on combined technical conditions.
7. Risk and trade planning
- helpers/risk_management.py is a distinct subsystem for entry, stop-loss, target, and position sizing logic.
- This is important architecturally because the scanner does not only “find stocks”; it also emits a trade plan and risk-aware recommendation.
- The README also references expected change, risk appetite, and budget-based filtering, which are part of this boundary.
8. Backtesting subsystem
- helpers/backtest.py provides the simulation layer for validating strategies on historical data.
- README mentions built-in backtests for CCI, MACD, RSI, Stochastic, and Moving Average strategies.
- Architecturally, this is a separate consumer of the same historical data and indicator pipeline used by the live scanner.
9. Visualization and reporting
- helpers/plotting.py is the chart/report boundary for turning time series into visual analysis.
- helpers/journal_handler.py supports trade journaling and post-trade analysis, likely reading/writing spreadsheet-like records.
- These modules sit at the output end of the pipeline: they don’t decide signals, they present and record them.
10. Market structure / intraday context
- helpers/experimental/trading_alerts.py and related experimental modules suggest support for market mood, alerts, and sentiment-like context.
- The README’s “market mood” features imply this project can combine stock-level scans with broader sector/index context for intraday decisions.
- This is a higher-level aggregation layer above single-symbol analysis.
11. Experimental boundary
- helpers/experimental/psychology.py, risk_management.py, strategies_signals.py, and trading_alerts.py are clearly separated from the main stable helpers.
- They represent R&D / extension code, not the core runtime path.
- For a diagram, treat them as optional satellite modules feeding ideas or alerts into the core scanner, not as mandatory dependencies.
12. Repository content that is not runtime
- ebooks/ is reference material, not part of the execution flow.
- .ipynb_checkpoints/ and __pycache__ are development artifacts.
- requirements.txt defines the Python dependency boundary for local setup.
13. End-to-end data flow
- The typical flow is: market data source or CSV cache → helper modules compute indicators/patterns → scanner ranks candidates → plotting/reporting shows results → journal/backtest validates or records outcomes.
- Broker integration, if used, is an optional branch off the analysis path rather than the center of the system.
14. What to diagram as the core architecture
- Draw the project as a local analytical engine with these main boxes:
- Notebook orchestrator
- NSE/live data ingestion
- Local CSV/historical store
- Indicator/strategy engine
- Risk management
- Backtesting
- Visualization/journaling
- Optional broker/alert integrations
- The key architectural idea is that the same historical/live price data feeds multiple consumers: screening, charting, backtesting, and journaling.
Main entry points: stock_analyser.py Stock analyser · Tutorial.ipynb Tutorial · risk_management.py Risk rules · data Local cache
Components 18
Notebook layer
Interactive Jupyter entry point and local execution context.
- Tutorial · Primary interactive entry point for running scans, charts, backtests, and analysis cells.
Tutorial.ipynb
Market data
Historical cache plus live NSE and broker adapters.
- NSE data · Main market data boundary for historical and live NSE price retrieval.
helpers/nse_data.py - Broker adapters · Optional connectivity layer for online broker or platform access.
helpers/online_brokers.py - Local cache · Per-symbol historical CSV archive used for offline and cached analysis.
data - Data index · Repository index or dataset catalog for local market files.
data.json - Data handler · Shared file and dataset handling utilities that bridge notebook and stored market data.
helpers/datahandler.py
Analysis engine
Core screening, indicators, strategy, and risk logic.
- Investing · Swing and investing-style screening logic over price series and indicators.
helpers/investing.py - Intraday · Intraday analysis path for shorter interval market scanning.
helpers/intraday.py - FnO · Futures and options analysis support.
helpers/FnO.py - Stock analyser · Combines indicator checks, filters, and candidate ranking into actionable stock picks.
helpers/stock_analyser.py - Candlestick · Candlestick pattern recognition used by the signal engine.
helpers/candlestick.py - Risk rules · Entry, stop-loss, target, sizing, and budget-aware trade planning logic.
helpers/risk_management.py - Alerts · Market mood and trading alert support for broader intraday context.
helpers/experimental/trading_alerts.py - Signals R&D · Experimental strategy and signal ideas outside the core runtime path.
helpers/experimental/strategies_signals.py - Psychology · R&D module for trader psychology and behavioral ideas.
helpers/experimental/psychology.py
Outputs and validation
Charts, journals, and simulation results.
Connections 26
- Tutorial → Data handler: uses · Notebook cells call shared loaders and helpers.
- Tutorial → NSE data: fetches · Interactive analysis pulls market data from NSE access layer.
- Tutorial → Local cache: reads · Notebook works against local CSV history when available.
- Tutorial → Plotting: plots · Notebook renders charts and analysis views.
- Tutorial → Backtest: backtests · Notebook runs strategy validation workflows.
- NSE data → Local cache: caches · Live or historical data can be persisted into local CSV files.
- NSE data → Broker adapters: optional route · Broker connectivity extends the data acquisition path.
- Data index → Local cache: indexes · Metadata catalog describes the local dataset.
- Data handler → Local cache: loads · File handling utilities read symbol CSVs.
- Data handler → Data index: resolves · Loader can use the dataset index to locate assets.
- Data handler → NSE data: adapts · Shared handler sits between notebook code and market data access.
- Investing → Stock analyser: feeds · Investing scans feed the ranking/analyser boundary.
- Intraday → Stock analyser: feeds · Intraday scans feed candidate selection.
- FnO → Stock analyser: feeds · F&O logic contributes to stock analysis and screening.
- Stock analyser → Candlestick: checks · Stock analysis incorporates candlestick pattern recognition.
- Stock analyser → Risk rules: plans · Selected candidates are translated into trade plans and risk levels.
- Candlestick → Risk rules: informs · Pattern context can influence trade planning and stops.
- Investing → Risk rules: applies · Swing workflows use risk management before recommendations.
- Intraday → Risk rules: applies · Intraday workflows use risk management before recommendations.
- Backtest → Local cache: replays · Backtests consume historical CSV data.
- Backtest → Stock analyser: validates · Simulation validates the same signal pipeline used for screening.
- Plotting → Stock analyser: renders · Visualization presents scanner outputs and series analysis.
- Journal → Risk rules: records · Journals capture executed or recommended trade plans.
- Alerts → Intraday: augments · Alerts add market context to intraday analysis.
- Signals R&D → Stock analyser: proposes · Experimental signals can feed ideas into the core analyser.
- Psychology → Risk rules: influences · Psychology experiments relate to decision and risk framing.