How basavaraj1985/screeni-py works
Project Type and Purpose
• Screeni-py is a Docker-packaged, Python-based stock-screening application for the NSE (India) that can be run via a Streamlit GUI or a legacy CLI. It fetches market data, applies technical-analysis and ML models, then renders results in a web UI (Streamlit) or exports to Excel/console.
High-Level File Structure Analysis
• Top-Level:
• Dockerfile, .dockerignore, Makefile – container build & run scripts
• requirements.txt, run_screenipy.sh – dependency and entrypoint scripts
• .github/workflows – CI for build, test, data-download
• actions-data-download – pre-downloaded data cache
• patterns – candle pattern definitions
• src/: core Python code
• src/screenipy.py – main orchestration CLI entrypoint
• src/streamlit_app.py + src/.streamlit – Streamlit GUI entrypoint & config
• src/classes/ – modular components (Fetcher, Screener, ConfigManager, OtaUpdater, ParallelProcessing, CandlePatterns, ScreenipyTA, Utility, SuppressOutput, Changelog, ColorText)
• src/ml/ – pretrained ML models (.h5, .pkl) and eval notebooks/scripts
• src/static/tablefilter/ – JavaScript/CSS assets for interactive tables
• src/screenipy.ini – user-editable config template
• test/: automated tests for core functionality
Key Components
A. User Interfaces (UI)
1. CLI Interface
• Entry: screenipy.py
• Interactive console or Excel export
2. Streamlit Web UI
• Entry: streamlit_app.py
• Static assets: tablefilter JS/CSS
B. Application Core (Business Logic)
• ConfigManager: loads/parses screenipy.ini
• OtaUpdater: checks/releases new versions
• Fetcher: retrieves or loads cached stock_data_*.pkl
• ParallelProcessing: orchestrates multi-threaded data downloads & computation
• Screener: applies CandlePatterns, TA-lib signals via ScreenipyTA
• Utility & ColorText / SuppressOutput / Changelog: support functions/logging
(Group under “Backend” – e.g., green)
C. Machine Learning Subsystem
• Stored models (nifty_model_v2/v3.h5/.pkl, best_model_0.7438acc.h5)
• Eval script (eval.py) for on-the-fly predictions
D. Data Layer
• External Data Source: NSE API or CSV downloads (GitHub action for data)
• Local Cache: actions-data-download/stock_data_*.pkl
• Configuration File: src/screenipy.ini
(“Data & Config” – orange)
E. Deployment & CI/CD
• Docker Container: encapsulates Python runtime, Streamlit server, scripts
• GitHub Actions: workflow-build-matrix.yml, workflow-test.yml, workflow-download-data.yml
(“Infrastructure” – gray)
Interactions and Data Flows
1. User → [CLI or Browser] → Entrypoint
2. Entrypoint → ConfigManager → loads parameters
3. Entrypoint → OtaUpdater (optional) → version check
4. Entrypoint → Fetcher → loads or refreshes market data
5. Fetcher ↔ External Data Source / Local Cache
6. Entrypoint → ParallelProcessing → dispatches Screener jobs
7. Screener → CandlePatterns + ScreenipyTA (TA-lib)
8. Screener → ML Engine (eval.py + model files)
9. Results → UI layer (Streamlit table via tablefilter.js/CSS or CLI console/Excel)
10. UI → renders to user
11. Docker Container wraps all, exposing ports 8501/8000
Architectural Patterns & Design Principles
• Modular, class-based separation of concerns (Fetcher vs. Screener vs. UI)
• Parallel processing to speed up I/O-bound & CPU-bound tasks
• Plugin-style integration of technical-analysis (TA-lib), pattern definitions, ML models
• Containerization for environment consistency and cross-platform support
• CI/CD pipelines automate testing, packaging, and data provisioning