Skip to content

About

๐Ÿ’ฑ Invest with news debate agents, ๐Ÿค‘ algorithmic entry/exit strategies, ๐Ÿ’น execute on Alpaca, ๐Ÿ”ฎ copy trade Polymarket/Kalshi prediction markets

Topics

Resources

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

714 Commits

Folders and files

Repository files navigation


DOI Ask DeepWiki Website Documentation API Pitch Deck
GitHub Stars NPM Monthly Downloads npm version NPM Total Downloads Coverage CI status
Contributors Branches GitHub Forks GitHub Issues Open Pull Requests Merged Pull Requests GitHub Discussions Commit activity GitHub last commit Join Discord
Uptime Status Deploy to Cloudflare Workers Open in StackBlitz PRs Welcome Claude Bun TypeScript Next.js React Cloudflare Workers
Get it on Google Play

Investment Prediction Agent

AI-powered multi-agent trading system for comprehensive stock & prediction markets analysis and automated trading decisions.

๐Ÿš€ Overview

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.

โœจ Key Features

  • 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.

๐Ÿ“š Documentation

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/.

๐Ÿ“ฆ Monorepo Layout

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=investing

Coverage

npm 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

๐Ÿค– AI Agents & Strategies

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.

Analysis Team

  • 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

Research Team

  • Bull Researcher: Advocates for BUY opportunities
  • Bear Researcher: Identifies risks and thesis violations
  • Research Manager: Synthesizes debate and enforces thesis compliance

Execution Team

  • Trader: Proposes execution parameters
  • Risk Team (Risky/Safe/Neutral): Debates position sizing
  • Portfolio Manager: Final authority on all trading decisions

โ˜๏ธ Deploy to Cloudflare Workers

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 deploy

Setup notes:

  • The build is configured in apps/ai-broker-web/vite.config.ts (there is no next.config): the vinext() plugin holds the Next.js options, and @cloudflare/vite-plugin runs the server environment in workerd. apps/ai-broker-web/worker/index.ts is the Worker entry โ€” it delegates to vinext's fetch handler and adds the cron scheduled handler.
  • 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 build therefore ends with node .github/scripts/write-root-deploy-config.mjs, which mirrors the .wrangler/deploy/config.json redirect that @cloudflare/vite-plugin writes inside apps/ai-broker-web up to the repository root, so npx wrangler deploy and npx wrangler versions upload resolve the built Worker instead of failing with "Missing entry-point to Worker script or to assets directory". Pointing the Workers Builds root directory at apps/ai-broker-web is 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 database ai-broker-db), SEND_EMAIL (Email Workers), cron triggers for the /api/cron/* routes. Read them in server code with import { env } from "cloudflare:workers".
  • Page-level ISR is served from the Cloudflare edge cache (cache: { cdn: cdnAdapter() } in vite.config.ts, "cache": { "enabled": true } in wrangler.jsonc). Add data: kvDataAdapter() and a VINEXT_KV_CACHE KV 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.ts additionally falls back to a root .env.
  • Secrets: wrangler secret put BETTER_AUTH_SECRET (likewise GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, CRON_SECRET).
  • Admin area: /admin (user directory and database controls) is gated on ADMIN_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_FROM sender 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 DB binding; outside Workers (maintenance scripts, CI, drizzle-kit) the same D1 database is reached over its REST API, which needs CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_D1_TOKEN, and optionally CLOUDFLARE_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 DB binding rather than a TCP database client, and read bundled JSON through an import rather than fs. 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 -c after a build.

๐Ÿ“‚ Third Party APIs

๐Ÿงฐ Reference Bots

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

Contributors

Contributors to ai-broker-investing-agent

About

๐Ÿ’ฑ Invest with news debate agents, ๐Ÿค‘ algorithmic entry/exit strategies, ๐Ÿ’น execute on Alpaca, ๐Ÿ”ฎ copy trade Polymarket/Kalshi prediction markets

Topics

Resources

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages