How naushikmaurya/fros-project works
Purpose and Entry Points
FROS is an internal financial-research pipeline: financial and market data ingestion → PostgreSQL warehouse → analytics, comparison, validation, forecasting, reports, and Streamlit exploration. Main operational entry points are run_pipeline.sh, ETL scripts under python/etl/, the dashboard at dashboard/app.py, and forecast commands in python/forecasting/backtest.py and python/forecasting/forecast_future.py.
Warehouse-Centered Data Model
PostgreSQL is the system-of-record boundary for all downstream features. Schema evolution defines core financial, source-tracking, and forecast tables in sql/01_schema.sql, sql/02_add_data_source_tracking.sql, and sql/03_forecast_schema.sql. Python data access/loading is concentrated in python/etl/load_to_postgres.py and python/data_sources/db_writer.py.
Synthetic ETL and Canonical Dataset
In restricted-network environments, the platform generates realistic synthetic financial statements, stock prices, and macro series, then loads them into PostgreSQL. The stages are python/etl/generate_financials.py, python/etl/generate_prices.py, python/etl/generate_macro.py, and python/etl/load_to_postgres.py. Company/sector scope originates in python/etl/company_master.py; generated/intermediate files are persisted under data/processed/, data/yahoo/, and data/fred/.
Live Financial-Source Ingestion
Source-specific ingestion is separated from the warehouse through a dispatcher/client/load pattern. SEC EDGAR extraction is implemented in python/data_sources/sec/sec_edgar_client.py, transformed by python/data_sources/sec/build_real_dataset.py, and upserted by python/data_sources/sec/load_real_financials.py. Parallel NSE integration exists under python/data_sources/nse/, while python/data_sources/dispatcher.py is the cross-source routing boundary. Loaded records retain provenance through the data-source tracking schema.
Analytics and Research Outputs
Financial statements in the warehouse feed ratio calculation, health scoring, peer comparison, red-flag analysis, and research-note generation. The core engines are python/analytics/ratio_engine.py, python/analytics/comparison_engine.py, and python/reports/report_generator.py. Generated analyst-facing artifacts are materialized as Markdown under reports/, including per-ticker research notes.
Validation and Forecasting
Post-load validation checks warehouse integrity and accounting/plausibility assumptions in python/validation/data_validator.py; independent SEC-versus-platform accuracy assessment is in python/validation/ground_truth_validator.py. Forecasting reads historical warehouse metrics, evaluates multiple methods by walk-forward error, persists backtest summaries/results, then produces future values. This sequence is owned by python/forecasting/backtest.py, python/forecasting/forecast_methods.py, and python/forecasting/forecast_future.py; backtesting must precede future forecasting because it resets forecast result tables.
User and Runtime Surface
dashboard/app.py is the Streamlit interactive surface for company research, comparisons, and sector benchmarking, backed by PostgreSQL-derived outputs. The deployable runtime is Python with pandas, SQLAlchemy, psycopg2, and Streamlit, plus PostgreSQL 16. Containerized local/deployment infrastructure is defined by Dockerfile and docker-compose.yml; environment configuration is represented by .env.example.
Main entry points: backtest.py Forecast backtesting · generate_financials.py Financial generator · forecast_future.py Future forecasting · load_to_postgres.py Warehouse loader
Components 23
Synthetic ETL
- Company master
python/etl/company_master.py - Financial generator
python/etl/generate_financials.py - Price generator
python/etl/generate_prices.py - Macro generator
python/etl/generate_macro.py - Staged datasets · Generated and downloaded intermediate data.
Live Source Ingestion
- Source dispatcher
python/data_sources/dispatcher.py - SEC EDGAR client
python/data_sources/sec/sec_edgar_client.py - SEC dataset builder
python/data_sources/sec/build_real_dataset.py - SEC financial loader
python/data_sources/sec/load_real_financials.py - NSE integration
Analytics & Forecasting
- Research analytics · Ratios, health scoring, peer comparison, and red flags.
python/analytics/ratio_engine.py - Research reports · Produces per-ticker Markdown research notes.
python/reports/report_generator.py - Analyst reports
- Data validation · Checks integrity, plausibility, and SEC accuracy.
python/validation/data_validator.py - Forecast backtesting · Walk-forward method evaluation; resets forecast result tables.
python/forecasting/backtest.py - Forecast methods
python/forecasting/forecast_methods.py - Future forecasting
python/forecasting/forecast_future.py
User & Runtime
- Pipeline runner · Operational entry point for pipeline stages.
run_pipeline.sh - Streamlit dashboard · Company research, comparisons, and sector benchmarking.
dashboard/app.py - Container runtime · Python and PostgreSQL local/deployment environment.
docker-compose.yml
Other components
- Warehouse schema · Defines financial, provenance, and forecast tables.
sql/01_schema.sql - PostgreSQL warehouse · Central boundary for downstream data and results.
- Warehouse loader
python/etl/load_to_postgres.py
Connections 29
- Pipeline runner → Financial generator: runs
- Pipeline runner → Warehouse loader: runs
- Company master → Financial generator: defines scope
- Company master → Price generator: defines scope
- Financial generator → Staged datasets: writes
- Price generator → Staged datasets: writes
- Macro generator → Staged datasets: writes
- Staged datasets → Warehouse loader: loads
- Warehouse schema → PostgreSQL warehouse: defines
- Warehouse loader → PostgreSQL warehouse: loads
- Source dispatcher → SEC EDGAR client: routes SEC
- Source dispatcher → NSE integration: routes NSE
- SEC EDGAR client → SEC dataset builder: extracts
- SEC dataset builder → SEC financial loader: transforms
- SEC financial loader → PostgreSQL warehouse: upserts with provenance
- NSE integration → PostgreSQL warehouse: loads
- PostgreSQL warehouse → Research analytics: financial data
- Research analytics → Research reports: research findings
- Research reports → Analyst reports: writes
- PostgreSQL warehouse → Data validation: validates
- PostgreSQL warehouse → Forecast backtesting: historical metrics
- Forecast methods → Forecast backtesting: evaluates
- Forecast backtesting → PostgreSQL warehouse: persists results
- Forecast backtesting → Future forecasting: must precede
- Forecast methods → Future forecasting: generates values
- Future forecasting → PostgreSQL warehouse: persists forecasts
- PostgreSQL warehouse → Streamlit dashboard: serves derived outputs
- Container runtime → PostgreSQL warehouse: runs
- Container runtime → Streamlit dashboard: runs