ppo-portfolio-study
RL agent baseline for portfolio trading
2 min readupdated
A set of five policies based on the PPO (Proximal Policy Optimization — a reinforcement learning method) algorithm from the Stable-Baselines3 library for portfolio management in the Tradefloor/Portfolio-v0 simulator. The author trained the agents on 256 synthetic markets and tested them on 100 new ones to check whether they would outperform a simple equal-weight strategy. None of the five runs succeeded due to overly frequent trades and fees, so the release is published as a reproducible baseline for researchers.
Key features
- Five independent runs (seeds 0–4) with an
MlpPolicyarchitecture and observation normalization viaVecNormalize. - Honest negative result: the agents turn over 40–54 times their starting capital in a 20-day episode, causing transaction costs to eat up profits.
- Secure storage format: weights are saved in
policy.safetensors, and normalization statistics in JSON without using pickle. - Complete reproducibility: each folder contains exact training settings, library versions, and a launch script.
What you can do
- Use the pre-trained policies as a starting point for experiments with turnover penalties in the
Tradefloor/Portfolio-v0environment. - Compare new RL algorithms or longer training cycles against the published metrics across 100 test seeds.
Example
import gymnasium as gym
from huggingface_hub import snapshot_download
from safetensors.torch import load_file
from stable_baselines3 import PPO
import tradefloor.gym
run = snapshot_download("tradefloordev/ppo-portfolio-study", allow_patterns="ppo-seed0/*") + "/ppo-seed0"
env = gym.make("Tradefloor/Portfolio-v0")
model = PPO("MlpPolicy", env, device="cpu")
model.policy.load_state_dict(load_file(f"{run}/policy.safetensors"))
Read more
DetailsMetrics on 100 test markets: the equal-weight strategy yielded a median of +1.079%, whereas the best PPO run (seed 2) showed -0.637% and lagged behind it in 80 out of 100 cases.
Training: 200,704 steps per run (8 stocks, up to 2x leverage), about 40 minutes on a CPU (Apple Silicon).
Limitations: markets are fully simulated in tradefloor 0.12.0, and the models are not intended for live trading.










Comments