A fully reproducible project that ingests market and macroeconomic data, builds financial features, trains predictive models, backtests a risk aware trading strategy, exposes results through a FastAPI service, and visualizes everything in an interactive Streamlit dashboard.
Stack
- Python (pandas, scikit-learn, xgboost, statsmodels, shap)
- PostgreSQL
- FastAPI
- Streamlit + Plotly
- Docker Compose
- Next-day return
- Next-day volatility
These predictions feed a risk aware trading signal:
- Go long when:
- Predicted return is sufficiently positive and predicted volatility is below a certain threshold
- Otherwise, stay CASH
- Includes:
- Transaction costs
- Volatility targeted position sizing
Emphasizing risk control and interpreting rather than just raw returns.
Batch pipeline flow
- Ingest daily market prices and macro data
- Build financial features (momentum, RSI, MACD, beta, rolling volatility, regime labels, etc.)
- Train predictive models using walk forward splits
- Generate predictions and global explainability artifacts
- Backtest the strategy and store results
- Serve metrics, predictions, equity curves, and explanations using FastAPI
- Streamlit dashboard queries the API and visualizes results
- Docker Desktop / Docker Engine
Copy the sample environment file:
cp .env.example .envdocker compose up --buildThis launches:
- PostgreSQL at localhost:5432
- FastAPI at http://localhost:8000
- Streamlit dashboard at http://localhost:8501
docker compose exec pipelines python -m pipelines.run_flowYou also have an option to enable a small cached sample of local SHAP explanations:
- in pipelines/config.py
- enable_shap_sample = True
- shap_sample_rows = 30 Stored in the shap_samples table. This is disaplyed in the Explainability tab.
Using a smaller sampled SHAP explanation avoids the cost of running a full SHAP computation.