FinRL
FinRLยฎ: Financial Reinforcement Learning. ๐ฅ
Install / Use
/learn @AI4Finance-Foundation/FinRLREADME
FinRL: Financial Reinforcement Learning

<div align="center">
<img align="center" src=figs/logo_transparent_background.png width="55%"/>
</div>
Financial reinforcement learning (FinRLยฎ) is the first open-source framework for financial reinforcement learning.
| Dev Roadmap | Stage | Users | Project | Description | |----|----|----|----|----| | 0.0 (Preparation) | Entry | Practitioners | FinRL-Meta| gym-style market environments | | 1.0 (Proof-of-Concept)| End-to-End | Developers | this repo | automatic pipeline | | 2.0 (Professional) | Advanced | Researchers and Experts | ElegantRL | algorithms | | 3.0 (Production) | Production | Institutions and Hedge Funds | FinRL-X | An AI-Native deployment |
FinGPT: an open-source project for financial large language models, designed for research and real-world FinTech applications.
Outline
- Overview
- File Structure
- Supported Data Sources
- Installation
- Status Update
- Tutorials
- Publications
- News
- Citing FinRL
- Join and Contribute
- LICENSE
Project Contributors
FinRLยฎ is an open-source financial reinforcement learning framework developed by contributors from the AI4Finance community and maintained by the AI4Finance Foundation.
Key contributors include:
- Hongyang (Bruce) Yang โ research and development on financial reinforcement learning frameworks, market environments, and quantitative trading applications
- [other contributorsโฆ]
Overview
FinRL has three layers: market environments, agents, and applications. For a trading task (on the top), an agent (in the middle) interacts with a market environment (at the bottom), making sequential decisions.
<div align="center"> <img align="center" src=figs/finrl_framework.png> </div>Videos FinRL at AI4Finance Youtube Channel.
FinRL Stock Trading 2026 Tutorial
Step 1: Clone the Repository
git clone https://github.com/AI4Finance-Foundation/FinRL.git
cd FinRL
Step 2: Create and Activate Virtual Environment
python3 -m venv venv
source venv/bin/activate
Step 3: Install FinRL
pip install -e .
Step 4: Run the Scripts
1. Data Download & Preprocessing
python examples/FinRL_StockTrading_2026_1_data.py
This script downloads DOW 30 stock data from Yahoo Finance, adds technical indicators (MACD, RSI, etc.), VIX, and turbulence index, then splits the data into training set (2014โ2025) and trading set (2026-01-01 to 2026-03-20), saving them as train_data.csv and trade_data.csv.
2. Train DRL Agents
python examples/FinRL_StockTrading_2026_2_train.py
This script trains 5 DRL agents (A2C, DDPG, PPO, TD3, SAC) using Stable Baselines 3 on the training data. Trained models are saved to the trained_models/ directory.
3. Backtest
python examples/FinRL_StockTrading_2026_3_Backtest.py
This script loads the trained agents, runs them on the trading data, and compares their performance against two baselines: Mean Variance Optimization (MVO) and the DJIA index. Results are printed to the console and a plot is saved as backtest_result.png.
File Structure
The main folder finrl has three subfolders applications, agents, meta. We employ a train-test-trade pipeline with three files: train.py, test.py, and trade.py.
FinRL
โโโ finrl (main folder)
โ โโโ applications
โ โโโ Stock_NeurIPS2018
โ โโโ imitation_learning
โ โโโ cryptocurrency_trading
โ โโโ high_frequency_trading
โ โโโ portfolio_allocation
โ โโโ stock_trading
โ โโโ agents
โ โโโ elegantrl
โ โโโ rllib
โ โโโ stablebaseline3
โ โโโ meta
โ โโโ data_processors
โ โโโ env_cryptocurrency_trading
โ โโโ env_portfolio_allocation
โ โโโ env_stock_trading
โ โโโ preprocessor
โ โโโ data_processor.py
โ โโโ meta_config_tickers.py
โ โโโ meta_config.py
โ โโโ config.py
โ โโโ config_tickers.py
โ โโโ main.py
โ โโโ plot.py
โ โโโ train.py
โ โโโ test.py
โ โโโ trade.py
โ
โโโ examples
โโโ unit_tests (unit tests to verify codes on env & data)
โ โโโ environments
โ โโโ test_env_cashpenalty.py
โ โโโ downloaders
โ โโโ test_yahoodownload.py
โ โโโ test_alpaca_downloader.py
โโโ setup.py
โโโ requirements.txt
โโโ README.md
Supported Data Sources
|Data Source |Type |Range and Frequency |Request Limits|Raw Data|Preprocessed Data| | ---- | ---- | ---- | ---- | ---- | ---- | |Akshare| CN Securities| 2015-now, 1day| Account-specific| OHLCV| Prices&Indicators| |Alpaca| US Stocks, ETFs| 2015-now, 1min| Account-specific| OHLCV| Prices&Indicators| |Baostock| CN Securities| 1990-12-19-now, 5min| Account-specific| OHLCV| Prices&Indicators| |Binance| Cryptocurrency| API-specific, 1s, 1min| API-specific| Tick-level daily aggregated trades, OHLCV| Prices&Indicators| |CCXT| Cryptocurrency| API-specific, 1min| API-specific| OHLCV| Prices&Indicators| |EODhistoricaldata| US Securities| Frequency-specific, 1min| API-specific | OHLCV | Prices&Indicators| |IEXCloud| NMS US securities|1970-now, 1 day|100 per second per IP|OHLCV| Prices&Indicators| |JoinQuant| CN Securities| 2005-now, 1min| 3 requests each time| OHLCV| Prices&Indicators| |QuantConnect| US Securities| 1998-now, 1s| NA| OHLCV| Prices&Indicators| |RiceQuant| CN Securities| 2005-now, 1ms| Account-specific| OHLCV| Prices&Indicators| Sinopac | Taiwan securities | 2023-04-13~now, 1min | Account-specific | OHLCV | Prices&Indicators| |Tushare| CN Securities, A-share| -now, 1 min| Account-specific| OHLCV| Prices&Indicators| |WRDS| US Securities| 2003-now, 1ms| 5 requests each time| Intraday Trades|Prices&Indicators| |YahooFinance| US Securities| Frequency-specific, 1min| 2,000/hour| OHLCV | Prices&Indicators|
<!-- |Data Source |Type |Max Frequency |Raw Data|Preprocessed Data| | ---- | ---- | ---- | ---- | ---- | | AkShare | CN Securities | 1 day | OHLCV | Prices, indicators | | Alpaca | US Stocks, ETFs | 1 min | OHLCV | Prices, indicators | | Alpha Vantage | Stock, ETF, forex, crypto, technical indicators | 1 min | OHLCV & Prices, indicators | | Baostock | CN Securities | 5 min | OHLCV | Prices, indicators | | Binance | Cryptocurrency | 1 s | OHLCV | Prices, indicators | | CCXT | Cryptocurrency | 1 min | OHLCV | Prices, indicators | | currencyapi | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | currencylayer | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | EOD Historical Data | US stocks, and ETFs | 1 day | OHLCV | Prices, indicators | | Exchangerates | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | findatapy | CN Securities | 1 day | OHLCV | Prices, indicators | | Financial Modeling prep | US stocks, currencies, crypto | 1 min | OHLCV | Prices, indicators | |