Skip to content

bigkrys/TradingDesk

Repository files navigation

TradeDesk turns market scans and multi-agent debate into position-aware decisions with SPY-benchmarked track records

Self-hosted · US + Hong Kong equities · Human in the loop · MIT

TradeDesk is a self-hosted research workstation for investors who want more than an AI-generated BUY or SELL. It streams multi-agent analysis live, adapts recommendations to your actual position, and checks every completed decision against what happened next.

Important

TradeDesk is for research and education only. It does not connect to a broker or execute orders.

See the research floor in action

Eight AI workstations streaming a live analysis for DELL

The demo shows the eight-stage lite engine moving from market data through fundamentals, technicals, news, bull/bear debate, trader decision, and risk review. Each stage is persisted, streamed over WebSocket, and available for replay.

From AI opinion to measurable evidence

Position-aware Auditable Built for the daily workflow
A verdict knows whether you already hold the ticker and at what cost, so BUY/HOLD/SELL has practical meaning. Decision-time prices are saved, then 7/30/90-day returns are backfilled and 30-day alpha is compared with SPY. A pre-market job reviews open holdings, scans both markets, analyzes top candidates, and updates past results.

The core loop is deliberately simple:

US + HK market data
        ↓
quantitative scan → multi-agent research → position-aware decision
                                              ↓
                              paper fill + decision-time snapshot
                                              ↓
                              7 / 30 / 90-day outcome vs SPY

The point is not to make an AI sound confident. It is to create a decision record that can prove—or disprove—its usefulness over time.

What is included

  • Three analysis engines. Use the fast eight-stage lite pipeline, a five-investor personas debate, or the full TradingAgents graph.
  • US and Hong Kong coverage. Symbols such as NVDA, 700, and 0700.HK resolve through one input flow; HK values stay in HKD while portfolio totals convert to USD.
  • A two-stage market funnel. Quantitative ranking narrows the S&P 500 and a curated HK large-cap universe before spending LLM tokens.
  • Market context, not isolated tickers. Sector-neutral ranking, sector rotation, global indices, fundamentals, and fault-tolerant CN/EN news feeds sit beside each analysis.
  • Portfolio and behavior feedback. Track paper decisions against SPY, maintain real trades with FIFO and fees, and attribute losses to behavior tags such as chasing or panic-selling.
  • Fail-soft data access. Quotes and candles use Tencent Finance first with Yahoo fallback; optional TradingAgents analyses fall back to lite when unavailable.

Quick start

You need Node.js 20+, Python 3.11+, and Docker.

# 1. Start PostgreSQL
docker compose up -d

# 2. Create local configuration files
cp web/.env.example web/.env
cp realtime/.env.example realtime/.env
cp analysis-svc/.env.example analysis-svc/.env

# 3. Add an LLM key to analysis-svc/.env, then install app dependencies
npm install
npm run db:push

# 4. Create the Python environment
cd analysis-svc
python3 -m venv .venv
./.venv/bin/pip install -r requirements.txt
cd ..

# 5. Start the web app, realtime broker, and analysis service
npm run dev

Open http://localhost:3000, add a ticker, and choose 分析 or 🎩 投资人团. A completed BUY is recorded in the paper portfolio with the same-moment SPY price.

Service Local address Responsibility
Web localhost:3000 Next.js UI, API routes, Drizzle ORM
Realtime localhost:8080 Quote fan-out and analysis progress
Analysis localhost:8000 FastAPI data, scanning, engines, scheduler

Choose an analysis engine

Engine Best for How it works
lite Fast, routine research Eight stages: data → fundamentals → technicals → news → bull/bear → trader → risk
personas Comparing investment philosophies Graham, Buffett, Lynch, Wood, and Burry archetypes interpret metrics calculated in Python, then a PM and risk manager decide
tradingagents A deeper external agent graph Wraps the full TradingAgents framework; US tickers only, with automatic fallback to lite

Set ENGINE in analysis-svc/.env, or select an engine from the UI where available. To enable the optional full graph:

pip install git+https://github.com/TauricResearch/TradingAgents.git

Architecture

flowchart LR
    Browser["Next.js dashboard"] <-->|"REST + callbacks"| API["FastAPI analysis service"]
    Browser <-->|"quotes + progress"| WS["Node WebSocket broker"]
    API -->|"publish events"| WS
    Browser --> DB[("PostgreSQL")]
    API --> Data["Tencent / Yahoo / RSS"]
    API --> LLM["Anthropic / OpenAI / DeepSeek"]
Loading

The TypeScript app owns the interface and persisted workflow, the Node service handles realtime fan-out, and the Python service owns market data and pluggable analysis engines. Inter-service callbacks use a shared INTERNAL_TOKEN.

Configuration reference
File Important keys
web/.env DATABASE_URL, ANALYSIS_SVC_URL, REALTIME_URL, NEXT_PUBLIC_WS_URL, INTERNAL_TOKEN, DAILY_ENGINE, DAILY_TOP_N
realtime/.env PORT, ANALYSIS_SVC_URL, INTERNAL_TOKEN, QUOTE_INTERVAL_MS
analysis-svc/.env provider API key, LLM_PROVIDER, ENGINE, REPORT_LANG, DAILY_RUN, DAILY_RUN_AT, WEB_URL, INTERNAL_TOKEN

Use the same INTERNAL_TOKEN in all three files. Local service URLs intentionally use 127.0.0.1: Node may resolve localhost to IPv6 while uvicorn binds IPv4.

The UI is Chinese because it is the maintainer's daily driver. Set REPORT_LANG to control the generated report language.

Implementation map
Read this Start here
Live eight-stage analysis and trading-floor UI analysis-svc/app/pipeline.py, web/src/components/OfficeScene.tsx
Quantitative investor personas analysis-svc/app/signals.py, analysis-svc/app/personas.py
Engine adapter and fallback behavior analysis-svc/app/engines/
Decision tracking and SPY benchmark web/src/db/schema.ts, web/src/app/api/internal/daily-run/route.ts
Daily holdings review web/src/components/HoldingsReview.tsx, web/src/app/api/internal/daily-run/route.ts
Dual-market screener analysis-svc/app/scanner.py, web/src/components/ScannerCard.tsx
FIFO journal and mixed-currency portfolio web/src/lib/fifo.ts, web/src/app/api/journal/positions/route.ts
Network diagnostics and dev preflight analysis-svc/app/netcheck.py, scripts/dev-doctor.sh

Design boundaries

  • Verification before trust. Signals are saved with prices and checked later; confidence alone is not evidence.
  • Numbers before narratives. The persona engine computes its valuation and quality signals before an LLM interprets them.
  • Human approval stays final. TradeDesk researches, records, and reviews; it never submits an order.
  • Components fail independently. Data providers and analysis engines have explicit fallbacks so one outage does not erase the workflow.

Acknowledgements

TradeDesk draws inspiration from TradingAgents, ai-hedge-fund, Vibe-Trading, and Vibe-Research.

License

MIT © 2026 krys

About

Self-hosted AI trading research workstation (US/HK): multi-agent & investor-persona analysis with live WebSocket streaming, and an auto-verified AI decision track record.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors