A learn-by-doing trading education tool. An AI agent scans 100+ instruments daily, applies 5 real strategies, and manages a $500 paper portfolio — so you can study how markets work and validate strategies with zero risk before trading real money. Built for beginners who want to understand trading through hands-on simulation rather than theory alone.
Insights are delivered via Telegram and a Streamlit dashboard. Runs locally or on Google Cloud Run.
┌─────────────┐ webhook ┌──────────────────┐
│ Telegram │◄─────────────►│ Cloud Run │
│ (phone) │ │ Service (bot) │
└─────────────┘ └────────┬─────────┘
│ reads via GitHub API
┌─────────────┐ git pull ┌───────▼──────────┐
│ Laptop │◄─────────────│ GitHub Repo │
│ (optional) │──────────────►│ (code + data) │
└──────┬──────┘ git push └───────▲──────────┘
│ │ git push
│ localhost:7497 ┌──────┴───────────┐
┌──────▼──────┐ triggers │ Cloud Run │
│ IBKR TWS │ ┌──────────►│ Job (pipeline) │
│ (desktop) │ │ └──────────────────┘
└─────────────┘ │
┌─────────────┐ │
│ Cloud │──┘ also sends reminders 30 min before
│ Scheduler │
└─────────────┘
- New traders who want to learn how markets work without risking real money
- Strategy learners who want to see how trend following, mean reversion, breakout, momentum, and defensive strategies perform in different market conditions
- Anyone curious about trading who wants daily AI-generated market analysis delivered to their phone
The agent runs a $500 paper portfolio automatically. After 30 days of simulated results, the dashboard shows a "Go Live Readiness" checklist to help you decide if you're ready for real trading.
- Paper trading simulation — $500 virtual portfolio with daily P&L tracking, ROI, and strategy accuracy
- Go Live Readiness — 30-day evaluation checklist before committing real money
- Market regime detection — SPY/VIX-based regime classification (trending, ranging, volatile)
- 100+ instrument scanning — stocks, ETFs, indices, forex, crypto, commodities
- 5 trading strategies — trend following, mean reversion, breakout, momentum, defensive
- Multi-layer risk profiling — position, portfolio, market, behavioral, and strategy dimensions
- AI analysis — Gemini-powered daily summaries, trade analysis, and Q&A
- Crypto intelligence — fear & greed, funding rates, whale activity, DeFi metrics
- Stock extras — earnings calendar, sector performance, market breadth, insider activity
- After-hours analysis — earnings gaps, pre-market movers, crypto overnight signals
- Telegram bot — interactive menu with all data accessible from your phone
- AI Q&A — ask questions about your portfolio and get Gemini-powered answers
- Streamlit dashboard — visual portfolio tracking with daily gains, strategy accuracy, and learning tips
- Cloud deployment — runs 24/7 on Cloud Run with scheduled pipeline executions
- Pipeline reminders — Telegram notification 30 min before runs so you can run locally with IBKR
- Configurable modules — enable/disable crypto, stocks extras, after-hours via preferences
git clone <your-repo-url>
cd ai-trading-agent
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .env
# Edit .env with your API keyspython setup_wizard.pyThe wizard will ask about modules, deployment mode, and schedule — then generate config/preferences.yaml.
# Single run with Capital.com broker
python main.py --once --broker capital
# Run with both brokers (needs IBKR TWS running on port 7497)
python main.py --once
# Run and push data to GitHub
python main.py --once --pushpython telegram_bot.pyOpen Telegram, find your bot, and send /start.
IBKR (Interactive Brokers) requires TWS or IB Gateway running on your laptop — it connects via localhost:7497. Cloud Run cannot access it.
Capital.com has a REST API — works from anywhere (local or cloud).
| Local run (laptop) | Cloud Run Job | |
|---|---|---|
| IBKR data | Full US equities, real volume, scanner presets | Not available |
| Capital.com | Indices, forex, crypto, commodities, 12 stocks | Same |
| When it runs | Manually, when laptop + TWS are open | Scheduled, always |
| Data quality | Best (both brokers combined) | Good (Capital.com only) |
To get the best of both worlds, the system sends you a Telegram reminder 30 minutes before each scheduled pipeline run:
- 8:30 AM ET — You get a reminder: "Pipeline runs in 30 min"
- If you're at your laptop with TWS open, run locally:
This uses IBKR + Capital.com and pushes the richer data to GitHub.
python main.py --once --push
- If you're away — do nothing. At 9:00 AM, the cloud job runs automatically with Capital.com data.
- Either way, the Telegram bot and your local machine can read the latest data.
The cloud job always runs at the scheduled time. If you already ran locally and pushed, the cloud job's Capital-only data will overwrite your richer IBKR+Capital data. To avoid this, you'd need to manually pause the scheduler for that run (or just accept the overwrite — the difference is only in IBKR scanner data).
Whether the pipeline runs locally or in the cloud, data ends up on GitHub:
# Pull latest data (from cloud runs or your own pushes)
git pull| Menu | Sub-items |
|---|---|
| Daily Briefing | Market Regime, AI Summary, Risk Assessment, After-Hours Intel |
| Stocks | Today's Signals, Earnings Calendar, Market Breadth, Sector Performance, Insider Activity |
| Crypto | Fear & Greed, BTC/ETH Overview, DeFi & Gas, Whale Activity, Overnight Signals |
| Portfolio | Open Positions, Performance Summary, Analytics, Trade History |
| Ask AI | Free-text Q&A powered by Gemini with live portfolio context |
| System | API Health, Run Pipeline |
The Crypto menu is hidden when the crypto module is disabled.
Run python setup_wizard.py to configure:
| Setting | Options | Default |
|---|---|---|
| Stocks module | on/off | On |
| Crypto module | on/off | Off |
| After-hours module | on/off | On |
| Deployment mode | local/cloud | Local |
| Push data after run | yes/no | No (local), Yes (cloud) |
| GitHub repo | URL | — |
| GCP project | ID | — |
| Timezone | any | US/Eastern |
| Morning run | HH:MM | 09:00 |
| Afternoon run | HH:MM | 15:00 |
Re-run the wizard any time — it shows current values in brackets.
- gcloud CLI installed and authenticated
- A GCP project (the script can create one)
- GitHub repo with this code pushed
# Set required environment variables (or the script will prompt)
export GCP_PROJECT=your-project-id
export GCP_REGION=us-central1
export GITHUB_REPO=username/repo-name
# Source your .env for secrets
source .env
# Run the deployment script
chmod +x cloud/deploy.sh
./cloud/deploy.shThe script will:
- Enable required GCP APIs
- Store secrets in Secret Manager
- Build and push the container image
- Deploy the Telegram bot as a Cloud Run Service (webhook mode)
- Create Cloud Run Jobs (pipeline + reminder)
- Set up Cloud Scheduler for automated runs and reminders
- Register the Telegram webhook
| Component | GCP Resource | Trigger |
|---|---|---|
| Telegram bot | Cloud Run Service | Webhook (always running, min 1 instance) |
| Pipeline | Cloud Run Job | Cloud Scheduler or manual |
| Reminder | Cloud Run Job | Cloud Scheduler (30 min before pipeline) |
gcloud run jobs execute trading-agent-pipeline --region=us-central1Generated by the setup wizard. Controls which modules run and deployment behavior.
modules:
stocks: true
crypto: false
after_hours: true
deployment:
mode: local
push_data_after_run: false
github_repo: ''
gcp_project: ''
gcp_region: us-central1
telegram:
mode: polling
schedule:
timezone: US/Eastern
morning_run: '09:00'
afternoon_run: '15:00'| File | Purpose |
|---|---|
config/strategies.yaml |
Strategy definitions, regime rules, entry/exit conditions |
config/paper_trader.yaml |
Starting balance, risk per trade, max positions |
config/risk_profiler.yaml |
Risk dimension weights, thresholds, hard blocks |
config/scoring.yaml |
Technical/sentiment/volume weights |
config/watchlist.yaml |
Instruments to scan per broker |
config/dashboard.yaml |
Streamlit dashboard settings |
| Schedule | Time (ET) | Days | What |
|---|---|---|---|
| Morning reminder | 8:30 AM | Mon–Fri | Telegram: "run locally with IBKR?" |
| Morning pipeline | 9:00 AM | Mon–Fri | Full scan before US market open |
| Afternoon reminder | 2:30 PM | Mon–Fri | Telegram: "run locally with IBKR?" |
| Afternoon pipeline | 3:00 PM | Mon–Fri | Update before US market close |
| Crypto morning | 8:00 AM | Daily | Crypto intelligence update |
| Crypto evening | 8:00 PM | Daily | Crypto overnight signals |
All times are US/Eastern. Cloud Scheduler handles timezone conversion.
Crypto runs don't have reminders because IBKR doesn't add crypto data — Capital.com covers BTCUSD/ETHUSD.
Pipeline Run (main.py)
│
├── Regime Detection (SPY/VIX via IBKR, or US500 via Capital.com)
├── Market Scanning (IBKR scanners + Capital.com watchlist)
├── Scoring (technical + sentiment + volume)
├── Strategy Matching (5 strategies)
├── Risk Profiling (5 dimensions)
├── Paper Trading (auto entry/exit)
├── Intelligence Collection
│ ├── Crypto (fear/greed, funding, whales) — if enabled
│ ├── Stocks (earnings, breadth, sectors) — if enabled
│ └── After-Hours (gaps, pre-market) — if enabled
├── AI Analysis (Gemini summaries)
└── Output
├── data/findings/YYYY-MM-DD.json
├── data/findings/YYYY-MM-DD.md
├── data/paper/open_positions.json
├── data/paper/performance.json
├── data/paper/portfolio_analytics.json
└── git push (if --push flag or cloud mode)
│
▼
GitHub Repo (shared data store)
│
┌───────┴────────┐
▼ ▼
Telegram Bot Laptop
(Cloud Run) (git pull)
# Run pipeline once (Capital.com only)
python main.py --once --broker capital
# Run pipeline once (both brokers — needs IBKR TWS)
python main.py --once
# Run and push data to GitHub
python main.py --once --push
# Dry run (use cached data, no API calls)
python main.py --once --dry-run
# Check regime only
python main.py --regime-only --broker capital
# Update paper positions only
python main.py --paper-update --broker capital
# Send a pipeline reminder to Telegram
python main.py --remind
# Schedule daily runs locally
python main.py --schedule 09:00 --broker capital
# Run backtest
python main.py --backtest --start 2025-01-01 --end 2025-02-01 --broker capital
# Start Telegram bot (local, polling mode)
python telegram_bot.py
# Run setup wizard
python setup_wizard.py.envis gitignored — never committedconfig/preferences.yamlis gitignored — only.exampleis tracked- Cloud secrets stored in GCP Secret Manager
- Telegram bot only responds to the configured
TELEGRAM_CHAT_ID - Capital.com forced to demo mode (
CAPITAL_DEMO=true) - IBKR blocked from live port (7496 → 7497)
- GitHub token used for private repo access only (read/write data)
data/paper/anddata/findings/are tracked in git (portfolio state and daily results)data/cache/anddata/reports/are gitignored (temporary/regenerable)
Bot doesn't respond to messages
- Check
TELEGRAM_BOT_TOKENandTELEGRAM_CHAT_IDin.env - Ensure your chat ID matches (send a message to
@userinfoboton Telegram)
Pipeline fails with "No data"
- Ensure broker API keys are set and the broker is running (IBKR TWS or Capital.com demo)
- Try
--dry-runto test with cached data
Cloud Run bot not receiving messages
- Check the webhook is set:
curl https://api.telegram.org/bot<TOKEN>/getWebhookInfo - Verify the service URL is correct and accessible
Crypto data missing
- Crypto module may be disabled — check
config/preferences.yamlor re-runpython setup_wizard.py
Git push fails
- Ensure you have push access to the repo
- For cloud: verify
GITHUB_TOKENhas repo write permissions
Reminder not arriving
- Check Cloud Scheduler is active:
gcloud scheduler jobs list --project=YOUR_PROJECT - Verify
TELEGRAM_BOT_TOKENandTELEGRAM_CHAT_IDsecrets are set in the reminder job
Cloud job runs after I already ran locally
- This is expected — the cloud job always runs on schedule. Your local push will be overwritten with Capital-only data. If this bothers you, pause the scheduler job for that run via the GCP Console.