Home

Awesome

<div align="center"> <img align="center" width="30%" alt="image" src="https://github.com/AI4Finance-Foundation/FinGPT/assets/31713746/e0371951-1ce1-488e-aa25-0992dafcc139"> </div>

FinRL: Financial Reinforcement Learning twitter facebook google+ linkedin

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

Downloads Downloads Python 3.6 PyPI Documentation Status License

FinGPT: Open-source for open-finance! Revolutionize FinTech.

Check out our latest competition: ACM ICAIF 2023 FinRL Contest

Visitors

Financial reinforcement learning (FinRL) (Document website) is the first open-source framework for financial reinforcement learning. FinRL has evolved into an ecosystem

Dev RoadmapStageUsersProjectDesription
0.0 (Preparation)entrancepractitionersFinRL-Metagym-style market environments
1.0 (Proof-of-Concept)full-stackdevelopersthis repoautomatic pipeline
2.0 (Professional)professionexpertsElegantRLalgorithms
3.0 (Production)servicehedge fundsPodracercloud-native deployment

Outline

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>

A quick start: Stock_NeurIPS2018.ipynb. Videos FinRL at AI4Finance Youtube Channel.

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 SourceTypeRange and FrequencyRequest LimitsRaw DataPreprocessed Data
AkshareCN Securities2015-now, 1dayAccount-specificOHLCVPrices&Indicators
AlpacaUS Stocks, ETFs2015-now, 1minAccount-specificOHLCVPrices&Indicators
BaostockCN Securities1990-12-19-now, 5minAccount-specificOHLCVPrices&Indicators
BinanceCryptocurrencyAPI-specific, 1s, 1minAPI-specificTick-level daily aggegrated trades, OHLCVPrices&Indicators
CCXTCryptocurrencyAPI-specific, 1minAPI-specificOHLCVPrices&Indicators
EODhistoricaldataUS SecuritiesFrequency-specific, 1minAPI-specificOHLCVPrices&Indicators
IEXCloudNMS US securities1970-now, 1 day100 per second per IPOHLCVPrices&Indicators
JoinQuantCN Securities2005-now, 1min3 requests each timeOHLCVPrices&Indicators
QuantConnectUS Securities1998-now, 1sNAOHLCVPrices&Indicators
RiceQuantCN Securities2005-now, 1msAccount-specificOHLCVPrices&Indicators
SinopacTaiwan securities2023-04-13~now, 1minAccount-specificOHLCVPrices&Indicators
TushareCN Securities, A share-now, 1 minAccount-specificOHLCVPrices&Indicators
WRDSUS Securities2003-now, 1ms5 requests each timeIntraday TradesPrices&Indicators
YahooFinanceUS SecuritiesFrequency-specific, 1min2,000/hourOHLCVPrices&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 | | finnhub | US Stocks, currencies, crypto | 1 day | OHLCV | Prices, indicators | | Fixer | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | IEXCloud | NMS US securities | 1 day | OHLCV | Prices, indicators | | JoinQuant | CN Securities | 1 min | OHLCV | Prices, indicators | | Marketstack | 50+ countries | 1 day | OHLCV | Prices, indicators | | Open Exchange Rates | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | pandas\_datareader | US Securities | 1 day | OHLCV | Prices, indicators | | pandas-finance | US Securities | 1 day | OHLCV & Prices, indicators | | Polygon | US Securities | 1 day | OHLCV | Prices, indicators | | Quandl | 250+ sources | 1 day | OHLCV | Prices, indicators | | QuantConnect | US Securities | 1 s | OHLCV | Prices, indicators | | RiceQuant | CN Securities | 1 ms | OHLCV | Prices, indicators | | Sinopac | Taiwan securities | 1min | OHLCV | Prices, indicators | | Tiingo | Stocks, crypto | 1 day | OHLCV | Prices, indicators | | Tushare | CN Securities | 1 min | OHLCV | Prices, indicators | | WRDS | US Securities | 1 ms | Intraday Trades | Prices, indicators | | XE | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | Xignite | Exchange rate | 1 day | Exchange rate | Exchange rate, indicators | | YahooFinance | US Securities | 1 min | OHLCV | Prices, indicators | | ystockquote | US Securities | 1 day | 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.

Installation

Status Update

<details><summary><b>Version History</b> <i>[click to expand]</i></summary> <div> </div> </details>

Tutorials

A complete list at blogs

Publications

TitleConference/JournalLinkCitationsYear
Dynamic Datasets and Market Environments for Financial Reinforcement LearningMachine Learning - Springer Naturepaper code72024
FinRL-Meta: FinRL-Meta: Market Environments and Benchmarks for Data-Driven Financial Reinforcement LearningNeurIPS 2022paper code372022
FinRL: Deep reinforcement learning framework to automate trading in quantitative financeACM International Conference on AI in Finance (ICAIF)paper492021
FinRL: A deep reinforcement learning library for automated stock trading in quantitative financeNeurIPS 2020 Deep RL Workshoppaper872020
Deep reinforcement learning for automated stock trading: An ensemble strategyACM International Conference on AI in Finance (ICAIF)paper code1542020
Practical deep reinforcement learning approach for stock tradingNeurIPS 2018 Workshop on Challenges and Opportunities for AI in Financial Servicespaper code1642018

News

Citing FinRL

@article{dynamic_datasets,
    author = {Liu, Xiao-Yang and Xia, Ziyi and Yang, Hongyang and Gao, Jiechao and Zha, Daochen and Zhu, Ming and Wang, Christina Dan and Wang, Zhaoran and Guo, Jian},
    title = {Dynamic Datasets and Market Environments for Financial Reinforcement Learning},
    journal = {Machine Learning - Springer Nature},
    year = {2024}
}
@article{liu2022finrl_meta,
  title={FinRL-Meta: Market Environments and Benchmarks for Data-Driven Financial Reinforcement Learning},
  author={Liu, Xiao-Yang and Xia, Ziyi and Rui, Jingyang and Gao, Jiechao and Yang, Hongyang and Zhu, Ming and Wang, Christina Dan and Wang, Zhaoran and Guo, Jian},
  journal={NeurIPS},
  year={2022}
}
@article{liu2021finrl,
    author  = {Liu, Xiao-Yang and Yang, Hongyang and Gao, Jiechao and Wang, Christina Dan},
    title   = {{FinRL}: Deep reinforcement learning framework to automate trading in quantitative finance},
    journal = {ACM International Conference on AI in Finance (ICAIF)},
    year    = {2021}
}

@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}
}
@article{liu2018practical,
  title={Practical deep reinforcement learning approach for stock trading},
  author={Liu, Xiao-Yang and Xiong, Zhuoran and Zhong, Shan and Yang, Hongyang and Walid, Anwar},
  journal={NeurIPS Workshop on Deep Reinforcement Learning},
  year={2018}
}

We published FinRL papers that are listed at Google Scholar. Previous papers are given in the list.

Join and Contribute

Welcome to AI4Finance community!

Please check Contributing Guidances.

Contributors

Thank you!

<a href="https://github.com/AI4Finance-LLC/FinRL-Library/graphs/contributors"> <img src="https://contrib.rocks/image?repo=AI4Finance-LLC/FinRL-Library" /> </a>

LICENSE

MIT License

Disclaimer: We are sharing codes for academic purpose under the MIT education license. Nothing herein is financial advice, and NOT a recommendation to trade real money. Please use common sense and always first consult a professional before trading or investing.