Case study 25 / 26
ML Trading Bot
A sentiment-driven trading strategy: FinBERT reads recent headlines, and only near-certain signals become bracket orders.
- Status
- Experimental
- Period
- 2026
- Domain
- ai · experiments
- Language
- Python
- Last push
- 01 APR 2026
- License
- NOASSERTION
- Source of claims
- tradingbot.py, finbert_utils.py, requirements.txt
A Lumibot strategy that pulls the last three days of news for a symbol from Alpaca, scores the headlines with FinBERT, and acts only when sentiment confidence exceeds 99.9% — entering through bracket orders with fixed take-profit and stop-loss levels. Configured for paper trading and historical backtests.
01/The problem
Can headline sentiment alone drive a disciplined strategy? The experiment is deliberately narrow: one symbol, one signal, strict risk rules.
02/The system
A Lumibot strategy that pulls the last three days of news for a symbol from Alpaca, scores the headlines with FinBERT, and acts only when sentiment confidence exceeds 99.9% — entering through bracket orders with fixed take-profit and stop-loss levels. Configured for paper trading and historical backtests.
- Alpaca news to FinBERT
- FinBERT to Signal gate
- Price data to Sizing
- Signal gate to Bracket order
- Sizing to Bracket order
03/Implementation
- 01Runs once per day (24-hour sleep time) on SPY by default.
- 02Fetches the past three days of headlines for the symbol from the Alpaca news API.
- 03FinBERT (ProsusAI/finbert) scores all headlines; logits are summed across headlines before a softmax, giving one sentiment and confidence.
- 04Positive above 0.999 → buy bracket with take profit at +20% and stop loss at −5%. Negative above 0.999 → sell bracket with mirrored levels.
- 05Position size is 5% of available cash divided by the last price, minimum one share; the opposite position is closed before reversing.
- 06Backtested on Yahoo Finance data from April 2025 to March 2026; broker credentials default to paper trading.
04/Engineering
Aggregate before deciding
Summing logits across every headline produces one decision per day instead of reacting to individual stories.
Risk defined at entry
Every order is a bracket, so exit levels exist before the position does.
GPU-optional inference
FinBERT runs on CUDA when available and falls back to CPU.
05/Interface
No product screenshots are published for this project. The visual above is a code-driven representation of how it behaves, built from the repository source — not a screenshot.
06/Tech stack
- Python
- Lumibot
- Alpaca API
- FinBERT
- PyTorch
- Transformers
- Yahoo Finance
07/Result
Verified outcomes
- An experiment, not a track record. No performance figures are presented here.
Known limitations
- Single symbol and single signal; no technical indicators.
- Not investment advice and not validated for live trading.
08/Links
Next case study
dotenv-doctor →