Optimize Portfolio Allocation using FinRL
Make dynamic decisions: where to trade, what price, what quantity...
Created on July 2|Last edited on July 6
Comment
Problem:
Goal: Model the stock trading process as a Markov Decision Process (MDP).
Trading goal is formulated as a maximization problem.
Solution: Reinforcement Learning Trading Strategy
It robustly adjusts to different market conditions.
Components of RL Environment:
- Action: portfolio weight of each stock [0,1]
- State: metrics: {MACD, RSI, CCI, ADX}
- Reward function: cumulative portfolio value.
- Environment: portfolio allocation for Dow 30 constituents (Technical Indicators, Stock Price, Balance, Shares)
Assumption: No transaction cost is taken into account
- Data Source: FinRL uses a YahooDownloader class to extract data.Run set1
- Preprocessing: FinRL FeatureEngineer class to preprocess data.
- Perform Feature Engineering: covariance matrix + technical indicators
- Covariance matrix is a good feature because portfolio managers use it to quantify the risk (standard deviation) associated with a particular portfolio.
- Model Training:
- We use A2C for portfolio allocation, because it is stable, cost-effective, faster and works better with large batch sizes.
- Trading: Assume that we have $1,000,000 initial capital at 2019/01/01. We use the A2C model to perform portfolio allocation of the Dow 30 stocks.
- Run set23
- Backtesting Performance: FinRL uses a set of functions to do the backtesting with Quantopian pyfolio.

Stats for Index (DJIA) performance.
Cumulative Returns & Rewards
Run set
2
Performance Evaluation
The performance of the trading agent is evaluated using Sharpe ratio and compared with AAPL ticker
Run set
23
References
Add a comment