v3.1.0 · Open Source · Apache 2.0

Quantitative
Research
Framework

Signals · Backtesting · Sentiment · Bayesian Optimization.
Built for finance researchers and aspiring quants.
Zero paid APIs. Fully offline-capable.

Market Data Indicators Signals Backtest Optimize Report

View on GitHub Quick Start

7 stars · Python · Made in Algeria 🇩🇿

Five Modes, One Unified Framework

📊
Portfolio
Analysis
Backtest
Engine
🔍
Watchlist
Scanner
🧠
Strategy
Optimizer
🗄
Warehouse
Manager

Every Layer of the
Research Pipeline

01
Signals Engine
13-rule scoring system producing BUY / HOLD / SELL signals. ADX regime filter blocks entries in choppy markets. ATR × 2.5 dynamic stop loss adapts to each stock's volatility.
13 Rules · ATR Exits
02
Backtesting Engine
Walk-forward simulation with zero look-ahead bias. Gap-aware exits, dynamic position sizing (15–35%), cooldown logic, and full R-Multiple tracking across any date range.
Walk-Forward · No Bias
03
Strategy Optimizer
Bayesian optimization via Optuna across 26 signal parameters. 100 trials with TPE search. Auto-applies best parameters to signals.py with timestamped backup.
Optuna · 26 Params
04
Watchlist Scanner
Scans 250+ tickers in parallel and ranks by signal strength. Exports to CSV. Configurable minimum score threshold and result count.
250+ Tickers · Parallel
05
Sentiment Analysis
VADER NLP with custom financial keyword boosting. Time-weighted scoring with 72h decay. Tail risk detection triggers automatic score adjustment on strong negative headlines.
VADER · Time-Weighted
06
PDF Report
Professional executive summary via ReportLab. Signal badge, indicator table, algorithm trigger breakdown, sentiment section, and 5 embedded technical charts.
ReportLab · 5 Charts

13-Rule
Scoring
System

RulePoints
Price vs MA200 (trend)±2
Golden / Death Cross±1
ADX Trend Strength−3 / +1
RSI / Price Divergence±3
Double Oversold / Overbought±4
MA200 Support Test+1
Bear Market Deep Penalty−2
Stochastic Crossover±1
MACD Crossover±2
Bollinger Band Touch±2
Volume Confirmation±2
Volatility Filter (ATR%)±1–3
Market Regime (S&P 500)0 / −3

Signal
Classification

STRONG BUY Score ≥ 8 + bullish trend → 35% allocation
BUY Score ≥ 6 → 22% allocation
HOLD Between thresholds → 0% (no entry)
SELL Score ≤ −6 → exit position
STRONG SELL Score ≤ −10 + bearish trend
Score ≥ 8 + bullish → 1 : 3.0 R/R
Score ≥ 6 + bullish → 1 : 2.5 R/R
Default → 1 : 2.3 R/R
Stop = Price ± (2.5 × ATR14)

Bayesian Search Across
26 Dimensions

100
Optuna Trials
26
Parameters
7
Stock Basket
TPE
Search Method
01
Random Exploration
First 20 trials sample the parameter space randomly — BUY_THRESHOLD, ATR_mult, RSI levels, ADX, signal weights...
02
TPE Bayesian Search
Trials 21–100 use Tree-structured Parzen Estimation. Each trial is smarter than the last, focusing on regions that maximize Sharpe × WinRate / |MaxDD|.
03
Auto-Apply
Best parameters saved to best_params.json and applied directly to signals.py with a timestamped backup. Run with --apply flag.
python strategy_optimizer.py          # run 100 Bayesian trials
python strategy_optimizer.py --apply  # apply best_params.json → signals.py

Up and Running in
Four Commands

# 1 · Clone the repository
git clone https://github.com/youcefbt-dz/MarketLab.git
cd MarketLab

# 2 · Install dependencies
pip install -r requirements.txt

# 3 · Build local data warehouse (250+ symbols)
python stock_warehouse.py

# 4 · Run MarketLab
python main.py

# Optional: Bayesian optimizer
python strategy_optimizer.py --apply

What's Next

ATR-based dynamic stop loss
v2.1
Local data warehouse — 250+ symbols, ~1.8M rows
v2.8
Parallel watchlist scanner
v2.8
Black Box reliability logger
v2.4
Bayesian strategy optimizer (Optuna · 26 params)
v3.0
ADX filter + Bear market penalty
v3.1
Trailing stop + partial exit
upcoming
Swing trading module (shorter timeframes)
upcoming
Crypto module (CCXT integration)
upcoming
React dashboard for live signal monitoring
upcoming