Back to Projects

Stock Predictor RL

End-to-end ML/RL project that aggregates MSFT 60‑minute price data and StockGeist sentiment, trains an LSTM price predictor, and evaluates trading strategies including a risk-aware rules engine and PPO reinforcement learning.

Period: May 2024Category: Machine Learning / Reinforcement Learning
PythonTensorFlow / KerasStable-Baselines3 (PPO)Gym / GymnasiumPandasNumPyscikit-learnMatplotlibVMDPyJupyter

Context

Final project for MIT 6.C011 (Modeling with Machine Learning). Explores whether incorporating social sentiment improves stock price modeling and downstream trading decisions.

The Problem

Integrating unstructured sentiment with market data and evaluating strategies with risk-aware execution is non-trivial. Traditional backtests often ignore position sizing and regime context, and CPU-bound workflows make rapid iteration difficult.

Approach

Ingested Alpha Vantage 60‑minute MSFT prices (2016–2024) and StockGeist daily message metrics. Engineered a normalized sentiment score (−1..1) weighting emotional vs non‑emotional signals. Trained an LSTM for next-step price prediction, then evaluated a rules-based strategy combining moving averages, model predictions, and sentiment with ATR-based position sizing. Prototyped PPO with Stable-Baselines3 to learn a policy and logged experiments.

Architecture

Python-based workflow with Jupyter notebooks. Data processing: Pandas/NumPy; feature engineering: custom sentiment aggregation; modeling: TensorFlow/Keras LSTM (optionally with VMD for signal decomposition); RL: Stable-Baselines3 PPO over a Gym/Gymnasium-style environment prototype; visualization with Matplotlib. Artifacts stored under `aggr_data/`, `graphs/`, `trained_models/`, with RL logs in `Training/Logs/`.

Results

Produced a reproducible dataset joining price and daily sentiment (2016–2024)

Trained and saved an LSTM model and generated evaluation plots

Implemented a rules-based trading simulation with ATR-based position sizing and sentiment gating

Explored PPO RL training and preserved multi-run logs for comparison

What I Learned

Hands-on experience integrating external APIs, engineering sentiment features, and aligning multi-frequency time series. Practical lessons in risk-aware backtesting, model evaluation pitfalls, and designing RL experiments and state/action spaces for trading. Reinforced reproducible ML practices and artifact management.

Impact Summary

Built an end-to-end pipeline that combines price data with social sentiment to train an LSTM forecaster and evaluate rule-based and PPO RL trading strategies.