AI-powered multi-agent trading system for comprehensive stock & prediction markets analysis and automated trading decisions.
Auto Investment Broker combines specialized LLM agents to analyze markets, debate strategies, and execute trades. It features real-time data processing, a "Bull vs. Bear" debate engine, and a modern dashboard for visualization.
- Multi-Agent Architecture: LLM agents including Fundamentals, News, Technical, and Risk Managers.
- Top Traders Leaderboard: Real-time tracking of top performers from ZuluTrade and Polymarket.
- Interactive Dashboard: Modern UI with specific agent reports, history tracking, and technical charts.
- "Bull vs. Bear" Debates: Automated debates to assess risk and reward before every trade.
Full documentation lives at autoinvestment.broker/docs
| Section | What's in it |
|---|---|
| Getting Started | Quick Start ยท Architecture ยท Configuration |
| Deployment | Deployment guide ยท Database ยท Scheduled jobs ยท Troubleshooting |
| Trading | Algorithmic strategies ยท Technical indicators ยท Fundamentals ยท Correlations ยท Brokers |
| Agents | Debate agents & prompts ยท Research paper |
| Reference | Workspace packages ยท Investment dictionary ยท Risk disclosure |
Engineering notes that are not part of the published docs live in
devdocs/.
The repo is a Turborepo workspace. Every command below can be run
from the repo root, and turbo fans it out to the workspaces that define it.
.
โโโ apps/
โ โโโ ai-broker-web/ # Next.js app (UI, API routes, docs, D1 schema & migrations)
โโโ packages/
โ โโโ investing/ # Trading agents, market data, prediction markets
โ โโโ ai-broker-api-client/ # Generated API client
โ โโโ fin-data-api/ # Financial data API service
โ โโโ mcp-server/ # MCP server generated from the OpenAPI spec
โโโ devdocs/ # Internal engineering notes
โโโ third-party-trading-bots/ # Vendored reference bots (see its README)
โโโ turbo.json # Task graph & caching
โโโ tsconfig.base.json # Shared TypeScript compiler options
โโโ README.md
โโโ CHANGELOG.md
โโโ LICENSE.md
npm install # installs every workspace
npm run dev # turbo run dev
npm run build # turbo run build (packages first, then the app)
npm run test # turbo run test
npm run test:coverage # turbo run test:coverage, then merge into coverage/lcov.info
# Scope a command to a single workspace
npx turbo run build --filter=ai-broker-web
npx turbo run test --filter=investingnpm run test:coverage runs each workspace's suite with coverage on (Vitest for the app,
investing and the API client; Jest for fin-data-api) and merges the
per-workspace LCOV reports into coverage/lcov.info with repository-root-relative paths.
CI runs the same command on every pull request in
.github/workflows/test.yml and uploads that single report to
Codecov. The upload needs a
CODECOV_TOKEN repository or organization secret. Thresholds, the per-workspace component
breakdown, and the paths excluded from coverage (vendored bots, generated SDKs, migrations) live
in codecov.yml; the project and patch checks are informational, so a coverage dip
never blocks a merge on its own.
Each workspace documents itself:
| Workspace | README |
|---|---|
| The app | apps/ai-broker-web |
| Trading agents & market data | packages/investing |
| Financial data API | packages/fin-data-api |
| Generated API client | packages/ai-broker-api-client |
| MCP server | packages/mcp-server |
| Cron routes | apps/ai-broker-web/app/api/cron |
| Engineering notes | devdocs |
| Agent/Team | Role |
|---|---|
| Analyst Team | Gathers data: Fundamentals, Sentiment (Social), News, & Technical Analysis. |
| Researcher Team | Conducts "Bull vs. Bear" debates; assesses risk. |
| Trader Agent | Synthesizes reports to propose trades. |
| Portfolio Manager | Final decision maker; manages risk and position sizing. |
- Market Analyst: Technical analysis and liquidity assessment
- Sentiment Analyst: Social media sentiment and "undiscovered" status
- News Analyst: Recent events, catalysts, and jurisdiction risks
- Fundamentals Analyst: Financial scoring and valuation
- Bull Researcher: Advocates for BUY opportunities
- Bear Researcher: Identifies risks and thesis violations
- Research Manager: Synthesizes debate and enforces thesis compliance
- Trader: Proposes execution parameters
- Risk Team (Risky/Safe/Neutral): Debates position sizing
- Portfolio Manager: Final authority on all trading decisions
The full guide โ creating the D1 database, secrets, Git-connected builds, custom domains, rollbacks, and a deployment checklist โ is at docs.autoinvestment.broker/docs/deployment.
The app runs on Cloudflare Workers via vinext โ the Next.js API surface reimplemented as a Vite plugin โ with D1 as the database, better-auth for authentication, and Email Workers for transactional email (verification, password reset, invitations).
# Local dev (vinext dev server; the server runs in workerd, so D1 & email
# bindings from wrangler.jsonc are live)
npm run dev
# Apply drizzle migrations to D1
npm run db:migrate:local # local miniflare D1
npm run db:migrate:remote # production D1 (ai-broker-db)
# Preview the production worker locally
npm run preview
# Deploy
npm run deploySetup notes:
- The build is configured in
apps/ai-broker-web/vite.config.ts(there is nonext.config): thevinext()plugin holds the Next.js options, and@cloudflare/vite-pluginruns the server environment in workerd.apps/ai-broker-web/worker/index.tsis the Worker entry โ it delegates to vinext's fetch handler and adds the cronscheduledhandler. - Git-connected deploys (Workers Builds) run both the build command and the deploy command from the repository root, which has no Wrangler configuration of its own.
npm run buildtherefore ends withnode .github/scripts/write-root-deploy-config.mjs, which mirrors the.wrangler/deploy/config.jsonredirect that@cloudflare/vite-pluginwrites insideapps/ai-broker-webup to the repository root, sonpx wrangler deployandnpx wrangler versions uploadresolve the built Worker instead of failing with "Missing entry-point to Worker script or to assets directory". Pointing the Workers Builds root directory atapps/ai-broker-webis the alternative, but then the workspace packages it depends on are no longer built. - Bindings are declared in
apps/ai-broker-web/wrangler.jsonc:DB(D1 databaseai-broker-db),SEND_EMAIL(Email Workers), cron triggers for the/api/cron/*routes. Read them in server code withimport { env } from "cloudflare:workers". - Page-level ISR is served from the Cloudflare edge cache (
cache: { cdn: cdnAdapter() }invite.config.ts,"cache": { "enabled": true }inwrangler.jsonc). Adddata: kvDataAdapter()and aVINEXT_KV_CACHEKV binding if the"use cache"data cache is needed. - Environment variables for the app belong in
apps/ai-broker-web/.env(vinext reads.env*files next to the app, following Next.js precedence).drizzle.config.tsadditionally falls back to a root.env. - Secrets:
wrangler secret put BETTER_AUTH_SECRET(likewiseGOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET,CRON_SECRET). - Admin area:
/admin(user directory and database controls) is gated onADMIN_EMAILS, a comma-separated allowlist of addresses โwrangler secret put ADMIN_EMAILS. With it unset nobody is an admin, including the first registered user, so a deployment that forgets it simply has no admin rather than an open one. - Email Workers is the only mail path โ there is no third-party email provider. It requires Email Routing to be enabled on the zone, with the
EMAIL_FROMsender on a verified domain and recipient destination rules configured; without the binding, messages are logged instead of sent so local flows still complete. - Cloudflare D1 is the only database. On Workers it is the
DBbinding; outside Workers (maintenance scripts, CI,drizzle-kit) the same D1 database is reached over its REST API, which needsCLOUDFLARE_ACCOUNT_ID,CLOUDFLARE_D1_TOKEN, and optionallyCLOUDFLARE_DATABASE_ID. There is no libsql/Turso, Postgres, or local sqlite fallback. - Workers has no filesystem and no long-lived TCP: server code must reach data through the
DBbinding rather than a TCP database client, and read bundled JSON through animportrather thanfs. Adding either back is what breaks a deploy that builds cleanly. - Bundle size: the Worker is uploaded compressed and must stay under Cloudflare's 10 MB limit (3 MB on the free plan). The current server bundle is ~7 MB gzipped, so large new dependencies or bundled datasets need checking โ
find apps/ai-broker-web/dist/server -name '*.js' -not -path '*/ssr/*' | xargs cat | gzip -9 | wc -cafter a build.
- Alpaca: Broker & trading as a service.
- TradingView: TradingView PineScript automated trading.
- Polymarket: Top event predictions leaderboard & correlation with stock market.
- Finnhub: Stock market data.
- Lightweight Charts: Candlestick UI widget from TradingView
- TradingAgents: Implementation of LLM research bots (paper)
third-party-trading-bots/ vendors ten
open-source trading bots, market-data services, and exchange clients as prior
art. They are outside the turbo task graph and are never built or deployed โ
they are read for how other people size positions, batch LLM calls, model
prediction markets, and normalize venue APIs. Each subdirectory keeps its own
upstream license and README; the index
describes what each one contributes.
| Project | What it is |
|---|---|
| Kalshi-Vibe-Bot | Autonomous Kalshi binary-markets bot: local vetting, batched Gemini/Grok calls, Kelly sizing, stop-loss-only exits |
| Polymarket-BTC-15-Minute-Trading-Bot | Seven-phase NautilusTrader bot for 15-minute BTC markets with signal fusion and self-tuning weights |
| Prediction-Markets-Trading-Bot-Toolkits | Rust/Tokio execution core running ten strategies across seven venues through one adapter stack |
| ai-hedge-fund | Eighteen-agent research fund modeled on named investors; generates orders, never trades |
| debate-agents | LangGraph "bull vs. bear" debate graph โ the ancestor of this repo's debate engine |
| fin-data-api-python | OpenBB Platform core plus ~35 data providers behind one fetcher contract |
| kalshi-bot-api | PyKalshi โ typed Kalshi client with WebSocket streaming and pandas output |
| poly-bot-gabagool | TypeScript hedged-arbitrage bot for Polymarket 15-minute binaries |
| poly-bot-openclaw | OpenClaw agent framework with PnL-driven survival states and x402 machine payments |
| polymarket-exec-api | pmxt โ "the ccxt for prediction markets", one API over six venues in Python and TypeScript |

