FinRL®: Financial Reinforcement Learning. 🔥
See the code
[!IMPORTANT] FinRL-X is the next-generation evolution of FinRL, designed for AI-native, modular, and production-oriented quantitative trading.
- This repository (
FinRL) preserves the original end-to-end educational and research framework.- For the latest architecture, live trading deployment, and production-focused development, please use
FinRL-X / FinRL-Trading.
FinRL® is widely recognized as the first open-source framework for financial reinforcement learning. This repository contains the original FinRL library for education, benchmarking, and research prototyping.
For the next-generation AI-native and production-oriented trading stack, please visit FinRL-X / FinRL-Trading.
| Generation | Positioning | Target Users | Repository | Description |
|---|---|---|---|---|
| FinRL-Meta | Market Environments | Practitioners | FinRL-Meta | Gym-style financial market environments and benchmarks |
| FinRL | Classic End-to-End Framework | Learners, Developers, Researchers | FinRL | Original train-test-trade pipeline for financial reinforcement learning |
| ElegantRL | Algorithm Layer | Researchers and Experts | ElegantRL | Lightweight and elegant DRL algorithms |
| FinRL-X | Next Generation / Production | Professional traders, institutions, hedge funds | FinRL-Trading | AI-native modular infrastructure for deployment-aware quantitative trading |
Recommended for new users: Start with FinRL-X / FinRL-Trading if you are building modern or production-oriented trading systems.
| Capability | FinRL (Stage 1.0) | FinRL-X (Stage 3.0) |
|---|---|---|
| Paradigm | Deep Reinforcement Learning | AI-Native (ML + DRL + LLM-ready) |
| Architecture | Three-layer coupled monolith | Fully decoupled modular layers |
| Strategies | DRL agents (A2C, DDPG, PPO, SAC, TD3) | ML selection + DRL timing + extensible base |
| Data Layer | 14 manually-wired processors | Auto-select: Yahoo Finance → FMP → WRDS |
| Backtesting | Custom hand-rolled evaluation loops | Professional bt library engine |
| Live Trading | Basic Alpaca support | Full multi-account integration + risk controls |
| Configuration | config.py + config_tickers.py | Type-safe Pydantic + .env multi-env |
| Risk Management | Gym environment constraints only | Order · portfolio · strategy-level controls |
| Target Users | Researchers & students | Quants, institutions, production deployments |
| Paper | arXiv:2011.09607 | arXiv:2603.21330 |
FinGPT: an open-source project for financial large language models, designed for research and real-world FinTech applications.
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:
FinRL is the original open-source framework for financial reinforcement learning, organized around three core layers:
For a trading task, an agent interacts with a market environment and learns sequential decision-making policies.
This repository focuses on the classic FinRL workflow for education, experimentation, and research prototyping.
For the next-generation production-oriented stack, including modular deployment and AI-native trading infrastructure, please visit FinRL-X / FinRL-Trading.
Videos FinRL at AI4Finance Youtube Channel.
This tutorial demonstrates the original FinRL workflow for educational and research purposes. For the latest production-oriented pipeline, please use FinRL-X / FinRL-Trading.
git clone https://github.com/AI4Finance-Foundation/FinRL.git
cd FinRL
python3 -m venv venv
source venv/bin/activate
pip install -e .
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.
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
| 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 |
| FXMacroData | FX spot rates and macro announcements | Daily and event-time | Account-specific | FX rates, release calendars, forecasts, official macro announcements | OHLCV-shaped FX rates and macro event features |
| 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 |
OHLCV: open, high, low, and close prices; volume. adjusted_close: adjusted close price
Technical indicators: 'macd', 'boll_ub', 'boll_lb', 'rsi_30', 'dx_30', 'close_30_sma', 'close_60_sma'. Users also can add new features.
| Title | Conference/Journal | Link | Citations | Year |
|---|---|---|---|---|
| Dynamic Datasets and Market Environments for Financial Reinforcement Learning | Machine Learning - Springer Nature | paper code | 51 | 2024 |
| FinRL-Meta: FinRL-Meta: Market Environments and Benchmarks for Data-Driven Financial Reinforcement Learning | NeurIPS 2022 | paper code | 136 | 2022 |
| FinRL: Deep reinforcement learning framework to automate trading in quantitative finance | ACM International Conference on AI in Finance (ICAIF) | paper | 212 | 2021 |
| FinRL: A deep reinforcement learning library for automated stock trading in quantitative finance | NeurIPS 2020 Deep RL Workshop | paper | 275 | 2020 |
| Deep reinforcement learning for automated stock trading: An ensemble strategy | ACM International Conference on AI in Finance (ICAIF) | paper code | 426 | 2020 |
| Practical deep reinforcement learning approach for stock trading | NeurIPS 2018 Workshop on Challenges and Opportunities for AI in Financial Services | paper code | 303 | 2018 |
For the next-generation AI-native modular trading infrastructure, see FinRL-X / FinRL-Trading.
@inproceedings{yang2026finrlx,
title = {FinRL-X: An AI-Native Modular Infrastructure for Quantitative Trading},
author = {Yang, Hongyang and Zhang, Boyu and She, Yang and Liao, Xinyu and Zhang, Xiaoli},
booktitle = {Proceedings of the 2nd International Workshop on Decision Making and Optimization in Financial Technologies (DMO-FinTech)},
year = {2026},
note = {Workshop at PAKDD 2026}
}
If you use the original FinRL framework, please cite the FinRL papers:
@article{finrl2020,
author = {Liu, Xiao-Yang and Yang, Hongyang and Chen, Qian and Zhang, Runjia and Yang, Liuqing and Xiao, Bowen and Wang, Christina Dan},
title = {{FinRL}: A deep reinforcement learning library for automated stock trading in quantitative finance},
journal = {Deep RL Workshop, NeurIPS 2020},
year = {2020}
}
Welcome to AI4Finance community!
Please check Contributing Guidelines.
Thanks to all contributors who have helped build FinRL.
MIT License
Trademark Notice
FinRL and the FinRL logo are trademarks of FinRL LLC. Use of these marks by the AI4Finance Foundation is permitted under license. The open-source license for this repository does not grant any right to use the FinRL name, logo, or related trademarks without prior written permission from FinRL LLC, except as permitted by applicable law.
Disclaimer: We are sharing codes for academic purposes under the MIT license. Nothing herein constitutes financial advice or a recommendation to trade real money. Users are solely responsible for any financial decisions made using this software. Consult a qualified professional before deploying capital.
(top 24 of 43)
602 followers · starred Mar 2026
169 followers · starred Mar 2021
2,207 followers · starred Mar 2022
148 followers · starred Jul 2021
FinRL®: Financial Reinforcement Learning. 🔥
See the code
[!IMPORTANT] FinRL-X is the next-generation evolution of FinRL, designed for AI-native, modular, and production-oriented quantitative trading.
- This repository (
FinRL) preserves the original end-to-end educational and research framework.- For the latest architecture, live trading deployment, and production-focused development, please use
FinRL-X / FinRL-Trading.
FinRL® is widely recognized as the first open-source framework for financial reinforcement learning. This repository contains the original FinRL library for education, benchmarking, and research prototyping.
For the next-generation AI-native and production-oriented trading stack, please visit FinRL-X / FinRL-Trading.
| Generation | Positioning | Target Users | Repository | Description |
|---|---|---|---|---|
| FinRL-Meta | Market Environments | Practitioners | FinRL-Meta | Gym-style financial market environments and benchmarks |
| FinRL | Classic End-to-End Framework | Learners, Developers, Researchers | FinRL | Original train-test-trade pipeline for financial reinforcement learning |
| ElegantRL | Algorithm Layer | Researchers and Experts | ElegantRL | Lightweight and elegant DRL algorithms |
| FinRL-X | Next Generation / Production | Professional traders, institutions, hedge funds | FinRL-Trading | AI-native modular infrastructure for deployment-aware quantitative trading |
Recommended for new users: Start with FinRL-X / FinRL-Trading if you are building modern or production-oriented trading systems.
| Capability | FinRL (Stage 1.0) | FinRL-X (Stage 3.0) |
|---|---|---|
| Paradigm | Deep Reinforcement Learning | AI-Native (ML + DRL + LLM-ready) |
| Architecture | Three-layer coupled monolith | Fully decoupled modular layers |
| Strategies | DRL agents (A2C, DDPG, PPO, SAC, TD3) | ML selection + DRL timing + extensible base |
| Data Layer | 14 manually-wired processors | Auto-select: Yahoo Finance → FMP → WRDS |
| Backtesting | Custom hand-rolled evaluation loops | Professional bt library engine |
| Live Trading | Basic Alpaca support | Full multi-account integration + risk controls |
| Configuration | config.py + config_tickers.py | Type-safe Pydantic + .env multi-env |
| Risk Management | Gym environment constraints only | Order · portfolio · strategy-level controls |
| Target Users | Researchers & students | Quants, institutions, production deployments |
| Paper | arXiv:2011.09607 | arXiv:2603.21330 |
FinGPT: an open-source project for financial large language models, designed for research and real-world FinTech applications.
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:
FinRL is the original open-source framework for financial reinforcement learning, organized around three core layers:
For a trading task, an agent interacts with a market environment and learns sequential decision-making policies.
This repository focuses on the classic FinRL workflow for education, experimentation, and research prototyping.
For the next-generation production-oriented stack, including modular deployment and AI-native trading infrastructure, please visit FinRL-X / FinRL-Trading.
Videos FinRL at AI4Finance Youtube Channel.
This tutorial demonstrates the original FinRL workflow for educational and research purposes. For the latest production-oriented pipeline, please use FinRL-X / FinRL-Trading.
git clone https://github.com/AI4Finance-Foundation/FinRL.git
cd FinRL
python3 -m venv venv
source venv/bin/activate
pip install -e .
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.
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
| 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 |
| FXMacroData | FX spot rates and macro announcements | Daily and event-time | Account-specific | FX rates, release calendars, forecasts, official macro announcements | OHLCV-shaped FX rates and macro event features |
| 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 |
OHLCV: open, high, low, and close prices; volume. adjusted_close: adjusted close price
Technical indicators: 'macd', 'boll_ub', 'boll_lb', 'rsi_30', 'dx_30', 'close_30_sma', 'close_60_sma'. Users also can add new features.
| Title | Conference/Journal | Link | Citations | Year |
|---|---|---|---|---|
| Dynamic Datasets and Market Environments for Financial Reinforcement Learning | Machine Learning - Springer Nature | paper code | 51 | 2024 |
| FinRL-Meta: FinRL-Meta: Market Environments and Benchmarks for Data-Driven Financial Reinforcement Learning | NeurIPS 2022 | paper code | 136 | 2022 |
| FinRL: Deep reinforcement learning framework to automate trading in quantitative finance | ACM International Conference on AI in Finance (ICAIF) | paper | 212 | 2021 |
| FinRL: A deep reinforcement learning library for automated stock trading in quantitative finance | NeurIPS 2020 Deep RL Workshop | paper | 275 | 2020 |
| Deep reinforcement learning for automated stock trading: An ensemble strategy | ACM International Conference on AI in Finance (ICAIF) | paper code | 426 | 2020 |
| Practical deep reinforcement learning approach for stock trading | NeurIPS 2018 Workshop on Challenges and Opportunities for AI in Financial Services | paper code | 303 | 2018 |
For the next-generation AI-native modular trading infrastructure, see FinRL-X / FinRL-Trading.
@inproceedings{yang2026finrlx,
title = {FinRL-X: An AI-Native Modular Infrastructure for Quantitative Trading},
author = {Yang, Hongyang and Zhang, Boyu and She, Yang and Liao, Xinyu and Zhang, Xiaoli},
booktitle = {Proceedings of the 2nd International Workshop on Decision Making and Optimization in Financial Technologies (DMO-FinTech)},
year = {2026},
note = {Workshop at PAKDD 2026}
}
If you use the original FinRL framework, please cite the FinRL papers:
@article{finrl2020,
author = {Liu, Xiao-Yang and Yang, Hongyang and Chen, Qian and Zhang, Runjia and Yang, Liuqing and Xiao, Bowen and Wang, Christina Dan},
title = {{FinRL}: A deep reinforcement learning library for automated stock trading in quantitative finance},
journal = {Deep RL Workshop, NeurIPS 2020},
year = {2020}
}
Welcome to AI4Finance community!
Please check Contributing Guidelines.
Thanks to all contributors who have helped build FinRL.
MIT License
Trademark Notice
FinRL and the FinRL logo are trademarks of FinRL LLC. Use of these marks by the AI4Finance Foundation is permitted under license. The open-source license for this repository does not grant any right to use the FinRL name, logo, or related trademarks without prior written permission from FinRL LLC, except as permitted by applicable law.
Disclaimer: We are sharing codes for academic purposes under the MIT license. Nothing herein constitutes financial advice or a recommendation to trade real money. Users are solely responsible for any financial decisions made using this software. Consult a qualified professional before deploying capital.
(top 24 of 43)
602 followers · starred Mar 2026
169 followers · starred Mar 2021
2,207 followers · starred Mar 2022
148 followers · starred Jul 2021