Fintrix is a modular, research-grade framework for training and evaluating reinforcement learning-based portfolio allocation strategies. It is powered by Proximal Policy Optimization (PPO) and integrates synthetic financial data generation using Denoising Diffusion Probabilistic Models (DDPM). Designed to be interpretable, extensible, and robust, Fintrix is an ideal tool for researchers, quants, and AI engineers looking to build smarter financial agents.
- Generate realistic financial data via regime-aware DDPM models
- Learn dynamic portfolio strategies that adapt to changing market regimes
- Optimize allocations using advanced reinforcement learning methods (PPO)
- Incorporate real-world constraints: transaction costs, position limits, diversification
- Provide an explainable pipeline with regime attribution, allocation diagnostics, and benchmarking
- Actor-critic architecture with clipped objective
- Supports stochastic policies and continuous action spaces (portfolio weights)
- Trains on regime-conditioned time series sequences
- Simulates different risk scenarios with volatility control
- Generates training environments that reflect real-world non-stationarity
- Real-time regime classification (bull, bear, volatile, sideways)
- Driven by rolling returns, volatility, and trend strength metrics
- Used to modulate both reward shaping and asset exposure
- Implements Kelly Criterion (multi-timeframe version)
- Dynamically adjusts exposure using market timing layer
- Enforces risk-aware soft and hard constraints (min/max allocation)
- Momentum, volatility, SMA, RSI, trend score (per asset & market)
- Correlation matrix descriptors
- Regime indicators embedded in observations
- Rebalances only when drift exceeds threshold or max holding time reached
- Transaction cost-aware allocation logic
- Penalizes overtrading and unnecessary weight shifts
- Encourages outperformance relative to index
- Penalizes volatility, drawdowns, and costs
- Promotes steady compounding rather than explosive bets
Fintrix/
├── assets/ # Charts, diagrams, performance outputs
├── config/ # Training configs and constants
├── data/ # Data loader, feature calculator, DDPM pipeline
├── ddpm/ # DDPM model, trainer, denoiser
├── env/ # Portfolio environment (Gymnasium-style)
├── market/ # Kelly sizing, market regimes, timing layer
├── models/ # PPO agent: policy & value nets
├── scripts/ # Faster execution script
├── utils/ # Plotting, logging, metrics
├── tests/ # Unit & integration tests
├── main.py # Main entry point
├── requirements.txt # Required libraries
└── README.md # This file
- Python 3.10+
git clone https://github.com/yourusername/fintrix.git
cd fintrix
conda create -n fintrix python=3.10
conda activate fintrix
pip install -r requirements.txt
python main.py
This will:
- Detect your market region
- Download historical price data
- Train a DDPM to simulate financial time series
- Generate enhanced training sets
- Train a PPO agent using synthetic + real data
- Evaluate final policy on real data only
- Output performance metrics and plots
Edit config/config.py
:
SELECTED_TICKERS = ["AAPL", "MSFT", "AMZN", "GOOGL", "JPM", "XOM"]
BENCHMARK_INDEX = "^GSPC"
START_DATE = "2010-01-01"
END_DATE = "2024-01-01"
DDPM_EPOCHS = 50
RL_EPISODES = 200
MAX_POSITION_SIZE = 0.25
REBALANCE_THRESHOLD = 0.025
pytest tests/
Includes:
test_env.py
— environment reset/step validationtest_ddpm.py
— DDPM forward shape checktest_ppo.py
— action, log-prob, value shape integrity
- Incorporate financial news and sentiment data for context-aware allocation
- Add multi-agent framework (long-short strategies)
- Integrate live broker APIs (e.g. Alpaca, Zerodha Kite)
- Support multi-objective RL (risk-adjusted vs. absolute return)
- Add experiment tracking tools (W&B, MLflow)
Fintrix is developed strictly for educational and research purposes.
Do NOT use Fintrix for live or real-money trading.
There are no guarantees of future performance, reliability, or correctness. Use entirely at your own risk.
MIT License. See LICENSE for full details.
- GitHub: github.com/pratycodes
- LinkedIn: linkedin.com/in/pratyush-baliarsingh/
- Email: pratyush.baliarsingh2004@gmail.com