AI-assisted daily trading system with a mandatory human approval gate. Analyzes your watchlist every morning, sends trade proposals to Telegram with one-tap ✅/❌ buttons, and fires approved orders via the Alpaca API — complete with stop-loss and take-profit on every position.
⚠️ Paper trade first. This bot defaults to Alpaca's paper trading environment. Validate signal quality for 30–60 days before enabling live trading.
Market data (Alpaca/Polygon)
↓
Technical analysis engine
RSI · MACD · Bollinger Bands · MA cross · Volume
↓
Optional LLM context (Claude API)
↓
Telegram digest → YOU approve/reject (⏰ 30-min window)
↓
Bracket order: entry + stop-loss + take-profit
↓
EOD P&L report → Telegram
git clone https://github.com/shehanmakani/tradebot.git
cd tradebot
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtcp .env.example .env
# Edit .env with your keys (see setup guide below)python get_chat_id.py
# Follow the prompt — add the ID to .env as TELEGRAM_CHAT_IDpython main.py --paper-testpython main.py- Sign up at alpaca.markets
- Go to Paper Trading → API Keys → Generate
- Add
ALPACA_API_KEYandALPACA_SECRET_KEYto.env - Keep
LIVE_TRADING=falseuntil you're satisfied with paper results
- Open Telegram → search @BotFather → send
/newbot - Follow prompts → copy the token → add as
TELEGRAM_BOT_TOKENin.env - Send your bot any message (e.g. "hello")
- Run
python get_chat_id.py→ copy the ID → add asTELEGRAM_CHAT_ID
Enriches proposals with Claude-generated narrative context.
- Get an Anthropic API key
- Add as
ANTHROPIC_API_KEYin.env - Set
USE_LLM_CONTEXT=true
Add this to your crontab (crontab -e) to run automatically:
# Analysis + approval digest at 8:30am ET (adjust for your timezone)
30 8 * * 1-5 /path/to/.venv/bin/python /path/to/tradebot/main.py >> /path/to/tradebot/logs/cron.log 2>&1
# EOD P&L report at 4:15pm ET
15 16 * * 1-5 /path/to/.venv/bin/python /path/to/tradebot/main.py --eod-report >> /path/to/tradebot/logs/cron.log 2>&1Edit config.py to customize:
| Setting | Default | Description |
|---|---|---|
WATCHLIST |
12 tickers | Tickers to analyze daily |
MAX_POSITION_PCT |
5% | Max portfolio allocation per trade |
MAX_DAILY_TRADES |
5 | Hard cap on orders per day |
STOP_LOSS_PCT |
4% | Stop-loss on every order |
TAKE_PROFIT_PCT |
8% | Take-profit on every order |
DAILY_LOSS_LIMIT_PCT |
2% | Halt trading if portfolio drops this much in a day |
MIN_SCORE_TO_TRADE |
60 | Minimum signal score (0–100) to propose a trade |
APPROVAL_DEADLINE_MIN |
30 | Minutes before unapproved proposals expire |
Each ticker receives a composite score (0–100) across four signal families:
| Signal | Max pts | Bullish condition | Bearish condition |
|---|---|---|---|
| RSI | 30 | RSI < 30 (oversold) | RSI > 70 (overbought) |
| MACD | 25 | Histogram crosses above 0 | Histogram crosses below 0 |
| Bollinger Bands | 20 | Price near lower band | Price near upper band |
| Moving averages | 15 | MA20 > MA50 | MA20 < MA50 |
| Volume confirmation | 10 | Spike in direction of signal | — |
Only proposals scoring ≥ MIN_SCORE_TO_TRADE (default 60) are sent to Telegram.
python -m pytest tests/ -vTests run entirely on synthetic data — no API keys required.
This software is for educational and research purposes. Automated trading involves substantial risk of loss. Past signal performance does not guarantee future results. Always paper trade before using real capital. The authors are not financial advisors.
tradebot/
├── main.py # Pipeline orchestrator
├── config.py # All settings
├── requirements.txt
├── get_chat_id.py # One-time Telegram setup helper
├── .env.example # Copy to .env and fill in keys
├── core/
│ ├── analyzer.py # Technical analysis + scoring
│ ├── broker.py # Alpaca API integration
│ └── llm_context.py # Optional Claude enrichment
├── approvals/
│ └── telegram_gate.py # Telegram approval bot
├── data/
│ └── trade_log.py # JSON trade history
├── logs/
│ └── trades/ # Daily proposal + execution logs
└── tests/
└── test_analyzer.py # Unit tests (no API keys needed)
Built by @shehanmakani