SkillAgentSearch skills...

FinRL

FinRLยฎ: Financial Reinforcement Learning. ๐Ÿ”ฅ

Install / Use

/learn @AI4Finance-Foundation/FinRL

README

FinRL: Financial Reinforcement Learning X LinkedIn

<div align="center"> <img align="center" src=figs/logo_transparent_background.png width="55%"/> </div>

Downloads Downloads Join Discord Python 3.6 PyPI Documentation Status License

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.

Visitors Discord

Outline

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 | |
View on GitHub
GitHub Stars14.3k
CategoryFinance
Updated1h ago
Forks3.2k

Languages

Jupyter Notebook

Security Score

100/100

Audited on Mar 22, 2026

No findings