renee-jia
trading-bot
Python

Multi-agent macro trading bot: multi-factor stock scoring, momentum portfolio construction, backtesting vs SPY/Nasdaq, and live Alpaca execution.

Last updated Jun 30, 2026
103
Stars
15
Forks
0
Issues
0
Stars/day
Attention Score
84
Language breakdown
Python 97.8%
Shell 1.9%
Dockerfile 0.3%
โ–ธ Files click to expand
README

๐Ÿค– Multi-Agent Quantitative Trading System

A macro buy-and-hold engine that orchestrates a team of specialized analysis agents โ€” technical, trend, macro, sentiment, and quantitative alpha โ€” into a single 0โ€“100 conviction score, then sizes and executes a live portfolio through Alpaca.

Python Broker Status License


๐Ÿ“ˆ Live Paper-Trading Performance

Real money-weighted Alpaca paper account, auto-generated from the broker API.
Account opened 2026-03-13. Snapshot 2026-06-04. Past performance โ‰  future results.

| | Return (since inception) | |---|---:| | ๐Ÿค– This strategy (paper) | +53.6% | | S&P 500 (SPY) | +13.5% | | Nasdaq-100 (QQQ) | +24.8% |

Starting capital $100,000 โ†’ peak equity $159,560, max drawdown โˆ’8.4%, 32 open positions concentrated in semis/AI (MRVL +33%, ARM +18%, SNDK +12%).

๐Ÿ“Š Full breakdown + equity curve โ†’ docs/PAPERTRADING.md (refresh anytime with python scripts/fetchpaper_performance.py)


๐Ÿงช Backtest โ€” Strategy vs S&P 500 & Nasdaq-100

Per-calendar-year, point-in-time backtest with T+1 execution and 5 bps/side transaction costs (the same weighting code the live bot trades):

| Year | ๐Ÿค– Strategy | S&P 500 | Nasdaq-100 | |------|------------:|--------:|-----------:| | 2022 | โˆ’45.4% | โˆ’18.6% | โˆ’33.2% | | 2023 | +92.4% | +26.7% | +55.9% | | 2024 | +60.1% | +25.6% | +27.7% | | 2025 | +24.2% | +18.0% | +21.0% | | 2026 (YTD) | +26.6% | +10.7% | +21.5% |

โš ๏ธ Honesty note: the universe is today's survivors held back through time (survivorship bias), so treat the raw alpha as an upper bound. The strategy is a high-beta amplifier โ€” it shines in up years and overshoots drawdowns in down years (see 2022). The full, self-critical analysis is in docs/BACKTEST_RESULTS.md โ€” including the strategy's edge over its own basket, which is small and noisy. We publish the warts on purpose.

๐Ÿง  Multi-Agent Architecture

The score for every stock is produced by a panel of independent analysis agents, each looking at the market through a different lens, then fused by a weighted scorer:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   Market data โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚        DATA LAYER           โ”‚  yfinance: 2y daily + 1y hourly
   (prices, news, SPY)   โ”‚  data_fetcher / discovery   โ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                     ANALYSIS AGENTS                            โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ ๐Ÿ“ Technical  โ”‚ ๐Ÿ“Š Trend      โ”‚ ๐ŸŒ Macro     โ”‚ ๐Ÿ“ฐ Sentiment   โ”‚
        โ”‚ SMA/RSI/MACD  โ”‚ rel-strength  โ”‚ regime &     โ”‚ news headline  โ”‚
        โ”‚ ADX/Boll/OBV  โ”‚ vs SPY        โ”‚ risk on/off  โ”‚ lexicon+decay  โ”‚
        โ”‚   (35%)       โ”‚   (30%)       โ”‚              โ”‚   (15%)        โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚           ๐Ÿ”’ Quantitative Alpha โ€” 30 factors (20%)             โ”‚  โ† core/ (private)
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ–ผ
                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                         โ”‚   ๐Ÿ”’ SCORER  โ†’  0โ€“100 score โ”‚  confidence- & regime-adjusted
                         โ”‚   ๐Ÿ”’ STRATEGY โ†’ target wts  โ”‚  top-10 momentum, max 25%/name
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ–ผ
                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                         โ”‚  Alpaca executor + report   โ”‚  T+1 rebalance, email digest
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Plus a layer of Claude research agents (in .claude/skills/) that enrich the macro view โ€” market-news-analyst, scenario-analyzer, market-environment-analysis, earnings-calendar, and economic-calendar-fetcher.

๐Ÿ”’ The proprietary signal engine โ€” the 30 alpha factors, the scorer, and the position-sizing strategy โ€” lives in a private core/ package that is not included in this repository. Everything else (the harness, analyzers, backtester, executor) is open.

๐ŸŽฏ Scoring Model

| Agent | Weight | Signals | |-------|:------:|---------| | ๐Ÿ“ Technical | 35% | SMA 50/200, RSI, MACD, ADX, Bollinger, OBV | | ๐Ÿ“Š Trend | 30% | Relative strength vs SPY, market regime | | ๐Ÿ”’ Alpha | 20% | 30 quantitative factors (WorldQuant-style) | | ๐Ÿ“ฐ Sentiment | 15% | News headline analysis with recency decay |

Scores are confidence-adjusted and regime-aware (conservative in bear markets, a slight boost in bull markets).

| Score | Recommendation | Grade | |:-----:|----------------|:-----:| | 75+ | Strong Buy | A | | 60โ€“74 | Buy | B / B+ | | 45โ€“59 | Hold | C / C+ | | 30โ€“44 | Reduce | D | | <30 | Avoid | F |


๐Ÿš€ Quick Start

The private core/ package is required to run end-to-end. Without it the harness imports the scorer/strategy/alpha modules from core/ and will fail โ€” by design, the alpha is not published.
python -m venv .venvtrading && source .venvtrading/bin/activate
pip install -r requirements.txt
cp .env.example .env            # then fill in your Alpaca keys

Analyze the full universe (157 US equities)

python main.py

Specific tickers, top 10, skip news for speed

python main.py --tickers AAPL,NVDA,MSFT --top 10 --quick

Daily report + paper trade

python daily_report.py --trade

Backtest vs SPY (a single recent year, verbose)

python backtest_strategy.py --tickers AAPL,MSFT,NVDA,GOOGL,AMZN,META,AVGO,TSLA,AMD,CRM,ORCL,ADBE

Multi-year sweep vs SPY & Nasdaq

python backtest_years.py

CLI options (main.py)

--tickers AAPL,MSFT    Analyze specific stocks (default: full universe)
--top N                Show top N results only
--quick                Skip news sentiment (faster)
--no-alpha             Skip alpha factor computation (faster)
--output-dir DIR       Report output directory (default: reports/)
--no-report            Console output only, skip report file

๐Ÿ“ Repository Layout

main.py  daily_report.py        Entry points (CLI + daily runner)
data_fetcher.py                 Prices, news, benchmarks (yfinance)
technical_analyzer.py           Trend / momentum / volume / volatility
trend_analyzer.py               Relative strength vs SPY, market regime
macro_analyzer.py               Market regime & risk-on/off
sentiment_analyzer.py           News headline sentiment
stock_discovery.py              Weekly universe expansion
report_generator.py             Markdown report output
email_sender.py                 Email digest
alpaca_trader.py                Paper/live execution via Alpaca
backtest_strategy.py            Strategy vs buy-and-hold (single window)
backtest_years.py               Per-year sweep vs SPY & Nasdaq
core/             ๐Ÿ”’ PRIVATE    custom_alphas ยท scorer ยท strategy ยท configs
docs/                           STRATEGY ยท BACKTESTRESULTS ยท PAPERTRADING
scripts/                        fetchpaperperformance.py
.claude/skills/                 Claude research agents

โš™๏ธ Deployment

  • Local daily agent (macOS): ./setupdaily.sh install renders a git-ignored launchd plist from *.plist.template and schedules dailyreport.py for 8 AM on trading days.
  • Container: docker build -t trading-bot . โ€” secrets are injected at runtime (--env), never baked into the image.

๐Ÿ” Security & Privacy

  • Secrets live only in .env (git-ignored). No API keys, passwords, or personal emails are tracked โ€” see .env.example for the required variables.
  • The launchd plist is rendered locally and git-ignored; only the placeholder *.plist.template is tracked.
  • The proprietary core/ algorithm is git-ignored and absent from this public repo.

โš ๏ธ Disclaimer

This project is for research and educational purposes only. It is not investment advice. Markets carry risk; past and backtested performance does not guarantee future results. Trade live money at your own risk.

๐Ÿ“„ License

MIT for the published harness. The private core/ signal engine is not licensed for use or distribution.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท renee-jia/trading-bot ยท Updated daily from GitHub