Skip to content

Tolu2492/Predictive-Market-Analysis

Repository files navigation

End-to-End Predictive Market Analytics & Risk Dashboard

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

What this project predicts

  • 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.


Project Architecture

Batch pipeline flow

  1. Ingest daily market prices and macro data
  2. Build financial features (momentum, RSI, MACD, beta, rolling volatility, regime labels, etc.)
  3. Train predictive models using walk forward splits
  4. Generate predictions and global explainability artifacts
  5. Backtest the strategy and store results
  6. Serve metrics, predictions, equity curves, and explanations using FastAPI
  7. Streamlit dashboard queries the API and visualizes results

Local Quickstart

1) Requirements

  • Docker Desktop / Docker Engine

2) Set environment variables

Copy the sample environment file:

cp .env.example .env

3) Start the stack

docker compose up --build

This launches:

4) Run the pipeline

docker compose exec pipelines python -m pipelines.run_flow

SHAP explainability

You 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors