Advanced Algorithmic Trading System for Crypto Markets
MIMARI 9.0 is not a technical analysis bot; it is a mathematical framework that models financial markets as noisy, regime-switching, jump-diffusion, and quantum-like probability distributions.
Inspired by MIT Quantitative Finance curriculums, this system operates on a core philosophy:
"Data lies, math doesn't. Do not predict the market; solve the equation."
By combining Kalman Filtering, Tensor Networks, and Reinforcement Learning (PPO), MIMARI 9.0 filters market noise to extract pure signals, assesses risk using physics-inspired tensor models, and executes trades with a survival-first mechanism.
The system processes market data through a 5-Level "Refinery Pipeline." Here is the algorithmic narrative of how a raw price tick becomes a trade execution:
Raw data is inherently noisy and misleading. We must sanitize it first.
- Input: Raw OHLCV data (Binance) + Option Surface (Deribit).
-
Kalman Filtering: Applies state-space modeling (
$y_t = Z \cdot s_t + \epsilon_t$ ) to separate Microstructure Noise from the True Hidden State of the price. - VECM: Checks for Cointegration among assets (BTC, ETH, SOL) to identify long-term equilibrium vs. short-term deviations.
- PCA: Reduces 31 market dimensions into 16 core "Market Factors."
Is the market moving normally, or is it breaking?
- GARCH(1,1): Models volatility clustering (calm periods follow calm, storm follows storm).
- Merton Jump-Diffusion: Decomposes returns into Diffusion (normal continuous movement) and Jumps (sudden shocks).
-
Ross Recovery Theorem: Uses the Pricing Kernel (
$\phi = P/Q$ ) to distinguish between Market Fear (Risk Aversion) and Actual Probabilities, extracting the "Real World Measure."
Compression of complex states into actionable intelligence.
- Matrix Product State (MPS): Compresses high-dimensional features into a dense Tensor Network.
- Ross Recovery Attention: A mechanism that applies attention weights based on the pricing kernel, focusing the model on "expensive" risk states.
-
Output: A 16-dimensional Market State Embedding (
$z_t$ ).
The brain that pulls the trigger.
-
PPO Agent (Reinforcement Learning): An Actor-Critic model observes the Tensor State (
$z_t$ ). - Utility Function: Maximizes CRRA Utility (risk-adjusted satisfaction) rather than raw profit.
-
Constraints:
- Marginal VaR: Value-at-Risk checks per position.
- Bankruptcy Barrier: Prevents actions that risk ruin.
Survival is the priority.
- THE IRON DOME: If predicted volatility > threshold, Hard Lock all trading.
- THE EJECTION SEAT: If trailing drawdown > 4%, immediate liquidation.
- PANIC SWITCH: If volatility deltas spike > 15%, drastic position sizing reduction.
- QUARANTINE: Post-stop-loss, the system enters a forced cooling-off period.
After 14 Revisions and optimization, the system has achieved "Investable Grade" status.
| Metric | Value | Interpretation |
|---|---|---|
| Sharpe Ratio | 10.0 | Exceptional risk-adjusted return. |
| Sortino Ratio | 20.0 | Nearly zero downside volatility penalty. |
| Max Drawdown | 7.98% | Capital preservation is effective. |
| Win Rate | 45.99% | Trend-following profile (small losses, big wins). |
| Win/Loss Ratio | 1.03 | Positive expectancy. |
| Profit Factor | 1.03 | Sustainable profitability. |
graph TD
A[Raw Data: Binance/Deribit] --> B(Level 1: Kalman & VECM);
B --> C(Level 2: GARCH & Ross Recovery);
C --> D{Level 3: Tensor Core MPS};
D --> E[State Embedding];
E --> F(Level 4: PPO Agent / RL);
F --> G{Risk Constraints};
G -->|Safe| H[Execution];
G -->|Unsafe| I[Iron Dome / Quarantine];
- Languages: Python 3.10+
- Core Math: NumPy, SciPy, Pandas
- Deep Learning: PyTorch (Tensor Networks, PPO)
- Data Format: Parquet / HDF5
- Validation: Ruff, MyPy
- Python 3.10+
- CUDA 11.8+ (Recommended for Tensor operations)
# Clone repository
git clone https://github.com/finanstrade/mimari-9.git
cd FINANSTRADE
# Create Virtual Env
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
# Install Dependencies
pip install -r requirements.txtCopy the example environment file and add your API keys (needed for data fetching).
cp env.example .env
# Edit .env and add BINANCE_API_KEY, etc.Step A: Data Ingestion (Phase 0)
python scripts/fetch_all_data.py --symbol BTCUSDT --days 365Step B: Tensor Model Training (Phase 3)
python scripts/train_tensor_model.py --epochs 100 --device cudaStep C: Agent Training (Phase 4)
python scripts/train_ppo_agent.py --episodes 1000Step D: Live Simulation / Backtest (Phase 5)
python scripts/run_backtest.py --mode normal --output results/Educational & Research Purpose Only. This software implements advanced financial mathematics for academic research. Cryptocurrency trading involves substantial risk of loss and is not suitable for every investor. The high Sharpe Ratio observed in simulations does not guarantee future live performance.
"The map is not the territory." - Use at your own risk.
This project is for academic research purposes. This project is licensed under the [GNU GENERAL PUBLIC LICENSE].
- Email: eyup.tp@hotmail.com