A Python-based trading bot with a real-time web dashboard for monitoring and managing your Robinhood portfolio.
.env file is missing# Clone the repository (or download the files)
git clone <your-repo-url>
cd robinhood-trading-bot
pip install -r requirements.txt
Or install packages individually:
pip install flask robin-stocks python-dotenv pandas
python Trading_Bot_Dashboard.py
That’s it! The dashboard will open automatically in your browser.
On first run, you’ll see a setup page. Enter your Robinhood credentials:
Your credentials are stored locally in a .env file and never sent anywhere.
Note: You may need to complete 2FA verification on first login.
After credentials are set, you’ll see the Strategy Selection screen:
The bot includes 6 pre-configured strategies optimized for different market conditions:
| Preset | Condition | ETFs | Strategy |
|---|---|---|---|
| 🚀 Bullish Growth | Rising markets | QQQ, VGT, SMH, XLK, SOXX | Aggressive growth, larger positions |
| 🛡️ Bearish Defense | Declining markets | SH, GLD, TLT, XLU, VPU | Defensive/inverse ETFs, smaller positions |
| ⚡ High Volatility | Turbulent markets | SPLV, USMV, VYM, SCHD, XLP | Low-vol ETFs, tight position sizing |
| 📊 Sideways Income | Flat markets | VYM, SCHD, HDV, DVY, JEPI | Dividend focus, income generation |
| 📈 Market Recovery | Recovering markets | VTI, SPY, IWM, XLF, VB | Broad market + small caps |
| 🎯 Correction Mode | Pullback markets | VOO, QQQ, VTI, SCHG, VUG | Quality ETFs for dip-buying |
The bot analyzes:
robinhood-trading-bot/
├── Trading_Bot_Dashboard.py # Main application (all-in-one)
├── requirements.txt # Python dependencies
├── .env # Credentials (auto-created)
├── bot_settings.json # User settings (auto-created)
└── README.md # This file
http://127.0.0.1:5000
| Page | URL | Description |
|---|---|---|
| Dashboard | / |
Main portfolio view with controls |
| Strategy Select | /select-strategy |
Choose trading strategy |
| Settings | /settings |
Configure stocks and parameters |
| Setup | /setup |
Credential configuration |
On startup, select from market-optimized presets or your saved strategy.
Edit bot_settings.json directly:
{
"stocks": ["QQQ", "SPY", "NVDA", "AAPL", "MSFT"],
"trading_buffer": 0.02,
"sma_window": 12,
"max_cash_per_stock": 0.25,
"min_shares_to_buy": 1,
"check_interval": 30,
"preset_applied": "bullish"
}
| Setting | Default | Description |
|---|---|---|
stocks |
Varies by preset | Stock/ETF symbols to monitor |
trading_buffer |
0.015 - 0.035 | Price deviation from SMA to trigger trades |
sma_window |
8 - 15 | Number of data points for SMA calculation |
max_cash_per_stock |
0.12 - 0.30 | Max portfolio % per single trade |
min_shares_to_buy |
1 | Minimum shares to execute a buy |
check_interval |
20 - 60 | Seconds between price checks |
The bot uses a Simple Moving Average (SMA) strategy:
With trading_buffer = 0.02 (2%):
The bot runs in paper trading mode by default. Trades are logged but not executed.
To enable live trading, uncomment the trade execution code in Trading_Bot_Dashboard.py:
# Find these sections and uncomment:
# rh.orders.order_buy_limit(...)
# rh.orders.order_sell_limit(...)
The bot only operates during market hours (9:30 AM - 4:00 PM ET). Outside these hours, it waits automatically.
.env.env to version control.gitignore file excludes sensitive files.env fileIf you use 2FA on Robinhood:
If port 5000 is busy, modify the last line in Trading_Bot_Dashboard.py:
app.run(host='0.0.0.0', port=5001, debug=False) # Change 5000 to 5001
pip install -r requirements.txthttp://127.0.0.1:5000 directly in your browserTo go directly to dashboard without strategy selection:
http://127.0.0.1:5000/?skip_strategy=1
Double-click run_dashboard.bat to start the bot, or create one:
@echo off
cd /d "%~dp0"
python Trading_Bot_Dashboard.py
| Endpoint | Method | Description |
|---|---|---|
/api/status |
GET | Current bot state and portfolio data |
/api/settings |
GET/POST | Read or update settings |
/api/market-condition |
GET | Detect current market condition |
/api/apply-strategy |
POST | Apply a strategy preset |
/api/presets |
GET | Get all available presets |
/api/bot/start |
POST | Start the trading bot |
/api/bot/stop |
POST | Stop the trading bot |
/api/refresh |
GET | Refresh data from Robinhood |
/api/setup/credentials |
POST | Save Robinhood credentials |
/api/shutdown |
POST | Shutdown the server |
This software is for educational purposes only.
MIT License - Feel free to modify and distribute.
Contributions are welcome! Please feel free to submit issues or pull requests.