Skip to content

Guide · Open source

How to use FinRL: install, run the train-test-trade pipeline

Updated · written with AI from the project's own documentation and checked against our catalogue data

FinRL is an open-source Python framework for applying deep reinforcement learning to financial trading. It provides market environments, learning agents, and a train-test-trade pipeline that simulates how an automated agent might buy and sell stocks using historical data. This guide walks through cloning the repository, installing it, and running the three example scripts so you can see the full workflow end to end.

FinRLAI4Finance-Foundation/FinRL · ★ 17k · MIT

Quick start

  1. 1Clone the repository. Run git clone on the FinRL repository and enter the FinRL folder.
  2. 2Create a virtual environment. Run python3 -m venv venv and activate it with source venv/bin/activate.
  3. 3Install in editable mode. Run pip install -e . inside the FinRL folder.
  4. 4Download and prepare data. Run the data script to fetch DOW 30 data from Yahoo Finance and create train_data.csv and trade_data.csv.
  5. 5Train the agents. Run the training script to train A2C, DDPG, PPO, TD3 and SAC agents, saved in trained_models/.
  6. 6Backtest and compare. Run the backtest script and review the console output and backtest_result.png against MVO and DJIA.

What FinRL is and what it is not

FinRL organizes its work around three layers: market environments, DRL agents, and financial applications. An agent interacts with a market environment and learns sequential decision-making policies for a trading task.

The README describes this repository as an educational and research prototyping framework. It is the original classic workflow, not the production stack. For live trading, the README directs users to FinRL-X / FinRL-Trading.

  • Good fit: learning how reinforcement learning applies to markets, prototyping and benchmarking DRL trading agents, and studying a starting train-test-backtest example on DOW 30 stock data.
  • Not a fit: live trading or production deployment, financial advice, or guaranteed returns. The README does not claim profitability.
  • Not a fit for non-programmers: setup and running scripts require Python and the command line.

What you need before installing

You need Python 3 and git. The README's Python badge shows 3.6, but it does not state the exact required version in the text provided, so check the project documentation for the version it supports before you start.

  • Python 3
  • git
  • A terminal to run commands

Install FinRL from the repository

The README's installation method is to clone the repository, create a virtual environment, and install the package in editable mode. Run these commands from a terminal in the folder where you want the project.

git clone https://github.com/AI4Finance-Foundation/FinRL.git cd FinRL python3 -m venv venv source venv/bin/activate pip install -e .

Run the data, training and backtest scripts

The classic tutorial runs in three stages. First, the data script downloads DOW 30 stock data from Yahoo Finance, adds technical indicators such as MACD and RSI, plus VIX and a turbulence index, and splits the data into a training set (2014 to 2025) and a trading set. It saves the results as train_data.csv and trade_data.csv.

Second, the training script trains five DRL agents (A2C, DDPG, PPO, TD3 and SAC) using Stable Baselines 3 and saves the models to the trained_models/ directory. Third, the backtest script loads the trained agents, runs them on the trading data, and compares them with Mean Variance Optimization (MVO) and the DJIA index.

  • Step 1, data: python examples/FinRL_StockTrading_2026_1_data.py
  • Step 2, train: python examples/FinRL_StockTrading_2026_2_train.py
  • Step 3, backtest: python examples/FinRL_StockTrading_2026_3_Backtest.py
python examples/FinRL_StockTrading_2026_1_data.py python examples/FinRL_StockTrading_2026_2_train.py python examples/FinRL_StockTrading_2026_3_Backtest.py

Read the backtest results

The backtest prints results to the console and saves a plot as backtest_result.png. Use the comparison against MVO and the DJIA as the baseline context. A trained agent beating a baseline on one historical window is a research observation, not evidence it will perform the same way in the market.

  • Check backtest_result.png for the plotted comparison.
  • Compare agents against MVO and the DJIA, not against zero.
  • Treat results as a prototype output for study.

Understand the project layout

The main folder finrl has three subfolders: applications, agents and meta. The project uses a train-test-trade pipeline built from three files: train.py, test and trade. The README text provided is truncated at this point, so check the repository for the full file list.

  • finrl/applications
  • finrl/agents
  • finrl/meta

What people use it for

  • A student running the classic example to see how a DRL agent learns trading decisions.
  • A researcher comparing several DRL algorithms against MVO and the DJIA on DOW 30 data.
  • A developer using the train-test-backtest scripts as a template for their own experiments.
  • A reader studying how market environments and agents are wired together in the finrl folders.

Frequently asked questions

Is FinRL free to use?

FinRL is released under the MIT licence, as shown on the repository. You can clone, install and run it from the source provided.

What do I need to install FinRL?

You need Python 3 and git, then the clone-and-build steps in the README. The exact required Python version is not stated in the text provided, so check the project documentation.

Can I use FinRL for live trading?

The README says this repository is for education and research prototyping. For live trading and production deployment, it directs users to FinRL-X / FinRL-Trading.

What is the difference between FinRL and FinRL-X?

FinRL is the original end-to-end educational and research framework. FinRL-X is the next-generation, production-oriented project with modular layers, live trading integration and risk controls.

What data does FinRL use in the tutorial?

The tutorial downloads DOW 30 stock data from Yahoo Finance and adds technical indicators, VIX and a turbulence index before splitting it into training and trading sets.

What are good alternatives to FinRL?

The comparable projects listed are ElegantRL, FinRL-Meta, Stable-Baselines3 and FinRL-Trading. ElegantRL and Stable-Baselines3 focus on algorithms, FinRL-Meta on market environments, and FinRL-Trading on production use.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

FinRL suits students, researchers and developers who want a readable, runnable example of deep reinforcement learning applied to stock trading, and who are comfortable with Python and the command line. It is not the right choice for live trading, financial advice or anyone expecting guaranteed returns; for those, the README points to FinRL-X / FinRL-Trading.

Install options & downloads