Skip to content

olonok69/QUANT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Quant Lab Banner

Quant Lab

Algorithmic Trading & Machine Learning Research

Python TensorFlow scikit-learn Jupyter License

A comprehensive collection of quantitative finance research spanning classical trading strategies, deep learning models for price prediction, ensemble ML methods, and modern LLM-powered financial analysis.


Table of Contents


Overview

This repository serves as a quantitative finance research lab β€” a curated collection of Jupyter notebooks and Python scripts covering the full spectrum of algorithmic trading and financial machine learning. From classical technical analysis strategies backtested with industry-standard frameworks, to cutting-edge deep learning price predictors and LLM-augmented financial agents.

Key Highlights

  • 15+ trading strategies implemented and backtested across multiple frameworks
  • Reinforcement Learning agent (Q-learning) for autonomous buy/sell/hold decisions
  • Deep Learning pipelines β€” LSTM, RNN, and DNN models for price prediction
  • Ensemble ML methods β€” Random Forest, Gradient Boosting, AdaBoost with SHAP explainability
  • RAG-powered financial analysis using LangChain/LangGraph with OpenAI & Google Gemini
  • Risk analytics including Value at Risk (VaR) and Conditional VaR (CVaR)

Repository Structure

πŸ“¦ QUANT
β”œβ”€β”€ πŸ€– Predicting_Stock_Prices_using_Reinforcement_Learning.ipynb
β”‚
β”œβ”€β”€ 🧠 ML/RAG/                          # Modern AI-powered analysis
β”‚   β”œβ”€β”€ yfinance.ipynb                   # Fundamental analysis with yfinance
β”‚   └── bollinger z-score/
β”‚       β”œβ”€β”€ Bollinger_bands.ipynb        # Bollinger Bands strategy
β”‚       β”œβ”€β”€ RAG_Langgrap_z-score.ipynb   # LangGraph RAG agent for Z-score analysis
β”‚       └── requirements.txt
β”‚
β”œβ”€β”€ πŸ“Š quantopian/                       # Classical algorithmic trading
β”‚   β”œβ”€β”€ Backtesting *.ipynb              # Zipline & Pandas backtesting suite
β”‚   β”œβ”€β”€ backtrader_*_strategy.py         # Backtrader strategy implementations
β”‚   β”œβ”€β”€ Backtrader_*.ipynb               # ConnorsRSI, Donchian, Dual MA
β”‚   β”œβ”€β”€ Dual Moving Average *.ipynb      # SMA crossover strategies
β”‚   β”œβ”€β”€ Zipline *.ipynb                  # Zipline examples with Pyfolio
β”‚   β”œβ”€β”€ VaR and CVaR.ipynb              # Risk measurement
β”‚   β”œβ”€β”€ Linear Regression.ipynb          # Statistical modeling
β”‚   └── Pipeline algorithm.ipynb         # Factor pipeline
β”‚
└── 🌲 QUANTRA/                          # ML & DL coursework
    β”œβ”€β”€ Decision Trees/                  # Ensemble methods & tree models
    β”‚   β”œβ”€β”€ Classification Tree *.ipynb  # Classification with SHAP
    β”‚   β”œβ”€β”€ Regression Tree.ipynb        # Price regression
    β”‚   β”œβ”€β”€ Random Forest.ipynb          # Ensemble learning
    β”‚   β”œβ”€β”€ Gradient Boosting.ipynb      # Sequential ensembles
    β”‚   β”œβ”€β”€ AdaBoosting.ipynb            # Adaptive boosting
    β”‚   β”œβ”€β”€ Bagging.ipynb                # Bootstrap aggregating
    β”‚   β”œβ”€β”€ Cross Validation.ipynb       # Model validation
    β”‚   └── Hyperparameter Tuning.ipynb  # Grid/random search
    β”‚
    β”œβ”€β”€ Neural Networks for trading/     # Deep learning models
    β”‚   β”œβ”€β”€ LSTM Based Strategy.ipynb    # LSTM trading strategy
    β”‚   β”œβ”€β”€ LSTM- Price Prediction.ipynb # LSTM price forecasting
    β”‚   β”œβ”€β”€ Deep Neural Network *.ipynb  # DNN prediction model
    β”‚   β”œβ”€β”€ RNN- Example.ipynb           # Recurrent networks
    β”‚   β”œβ”€β”€ Neural Network.ipynb         # sklearn MLPClassifier
    β”‚   β”œβ”€β”€ Cross Validation in Keras.ipynb
    β”‚   └── Keras_CV.py                  # DNN builder utility
    β”‚
    └── Sentimental Analisys/            # Market sentiment
        β”œβ”€β”€ TRIN strategy.ipynb          # Arms Index strategy
        └── plot_anomaly_comparison.ipynb # Anomaly detection

πŸ“ˆ Trading Strategies

Strategy Framework Description
Dual Moving Average Crossover Zipline, Backtrader Classic SMA crossover signals applied to AAPL and other equities
ConnorsRSI Backtrader Composite momentum indicator combining RSI, streak length, and percent rank
Donchian Channels Backtrader Breakout strategy using configurable lookback channel highs/lows
Bollinger Bands / Z-Score Custom + RAG Mean-reversion strategy with statistical Z-score thresholds
TRIN (Arms Index) Custom Market breadth indicator using NYSE advancing/declining volume
Pipeline Factor Model Quantopian-style Multi-factor alpha pipeline with Alphalens analysis

🌲 Machine Learning for Trading

Decision Trees & Ensemble Methods

Full pipeline from basic classification trees to advanced ensemble methods with model interpretability.

  • Classification Trees β€” Binary decision models with class weight tuning and SHAP explainability
  • Regression Trees β€” Non-linear price regression for continuous target prediction
  • Bagging β€” Bootstrap aggregation for variance reduction
  • Random Subspace β€” Feature-space sampling for diversity
  • Random Forest β€” Combined bagging + random subspace ensemble
  • AdaBoost β€” Adaptive sequential boosting with sample reweighting
  • Gradient Boosting β€” Iterative residual minimization ensemble
  • Cross Validation β€” K-fold validation for robust model evaluation
  • Hyperparameter Tuning β€” Grid and random search optimization

🧠 Deep Learning Models

Neural Networks for Price Prediction & Trading

Model Purpose Key Details
LSTM Price prediction & trading strategy Sequence modeling on AMZN historical data
RNN Close price prediction Recurrent architecture for time-series
DNN Trading strategy signals Deep feedforward network (Keras Sequential)
MLPClassifier Signal classification scikit-learn neural network for trade signals
RL Q-Learning Agent Autonomous trading Epsilon-greedy policy with DNN Q-function approximation

Reinforcement Learning

The root-level notebook implements a Q-learning agent that learns optimal trading actions (Buy / Sell / Hold) through interaction with historical market data. The agent uses a deep neural network to approximate the Q-value function with epsilon-greedy exploration.

State β†’ [DNN Q-Network] β†’ Q(s, buy), Q(s, sell), Q(s, hold) β†’ Action
                ↑
        Experience Replay + Target Updates

πŸ’¬ LLM-Powered Analysis (RAG)

Retrieval-Augmented Generation pipelines for intelligent financial research.

  • LangGraph Agent β€” Multi-tool agentic workflow with tool-calling capabilities for fundamental and technical analysis
  • Bollinger Z-Score RAG β€” LLM-augmented statistical analysis combining Bollinger Bands with AI-driven interpretation
  • yfinance Fundamental RAG β€” Balance sheet, income statement, and cash flow analysis powered by LLMs
  • Supported LLM backends β€” OpenAI GPT, Google Gemini, Vertex AI

Tech Stack (RAG Pipeline)

LangChain β†’ LangGraph β†’ [OpenAI / Google Gemini] β†’ Tool Calls β†’ yfinance / fmpsdk
                                                         ↓
                                                  Financial Reports + Analysis

⚠️ Risk Management

  • Value at Risk (VaR) β€” Monte Carlo simulation for portfolio loss estimation at confidence levels
  • Conditional VaR (CVaR) β€” Expected Shortfall: average loss exceeding the VaR threshold
  • Statistical Foundations β€” Discrete & continuous random variable analysis for financial modeling

πŸ›  Tech Stack

Category Technologies
Languages Python 3.8+
Backtesting Backtrader, Zipline, Pyfolio, Alphalens
Deep Learning TensorFlow, Keras (LSTM, RNN, Dense)
Machine Learning scikit-learn, SHAP, XGBoost
LLM / RAG LangChain, LangGraph, OpenAI API, Google Gemini, Vertex AI
Data & Finance Pandas, NumPy, SciPy, yfinance, Quandl, fmpsdk
Visualization Matplotlib, Plotly
Environment Jupyter, Google Colab, Streamlit

πŸš€ Getting Started

Prerequisites

python >= 3.8
pip install jupyter numpy pandas matplotlib

Backtesting Stack

pip install backtrader zipline-reloaded pyfolio-reloaded alphalens-reloaded
pip install yfinance quandl

Machine Learning & Deep Learning

pip install scikit-learn tensorflow keras shap

RAG / LLM Pipeline

pip install langchain langchain-openai langchain-google-genai langgraph
pip install tavily-python python-dotenv streamlit

Run Notebooks

jupyter notebook
# or
jupyter lab

Note: Some notebooks require API keys (OpenAI, Google, Tavily, Financial Modeling Prep). Create a .env file with the required credentials for the RAG pipelines.


License

This project is provided for educational and research purposes. Feel free to use, modify, and learn from the code.


Built with curiosity at the intersection of Finance, Machine Learning, and Artificial Intelligence.

Reinforcement Learning Β· LSTM Β· Random Forests Β· Bollinger Bands Β· ConnorsRSI Β· Donchian Channels Β· VaR/CVaR Β· LangGraph RAG Β· Backtrader Β· Zipline

About

A comprehensive collection of quantitative finance research spanning classical trading strategies, deep learning models for price prediction, ensemble ML methods, and modern LLM-powered financial analysis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors