FastAPI + React trading workspace for paper-trading execution, AI-assisted monitoring, and GitHub-friendly deployment. The project is packaged so another user can deploy it from GitHub, open a browser, fill in API keys on a settings page, and start using the dashboard without editing server-side .env files.
Paper trading only. The monitoring, candidate-pool, universe-search, and social-intelligence layers are read-only. The strategy runner is designed for Alpaca paper accounts and should not be pointed at a live brokerage account without additional risk controls.
- GitHub-ready deployment with
Dockerfile,docker-compose.yml, GitHub Actions CI, and browser-based runtime configuration. - FastAPI backend for account state, positions, orders, watchlist management, Alpaca universe search, AI monitoring snapshots, and social search.
- React dashboard with holdings, candidate pool, day/week/month trend comparison, recent orders, news summary, and research panel.
- Daily candidate-pool flow that pre-ranks technology stocks plus QQQ/SPY-style ETFs, then optionally asks OpenAI to choose the final 5 names.
- yfinance-based day-over-day, week-over-week, and month-over-month trend tracking for selected, candidate, and held symbols.
- Tavily-powered news and research summaries, plus optional X search and Chinese digest generation.
- Runtime settings page that stores deployer-provided API keys in SQLite and keeps sensitive values hidden from the browser after save.
- CLI harness in
agent-harness/for agent-style automation and scripting.
trading_platform/
├── .github/workflows/ci.yml
├── backend/
│ ├── app/
│ ├── strategy/
│ ├── tests/
│ ├── .env.example
│ └── requirements.txt
├── frontend/
│ ├── src/
│ ├── public/
│ └── package.json
├── agent-harness/
├── launcher/
├── Dockerfile
├── docker-compose.yml
├── CONTRIBUTING.md
└── LICENSE
This repository is ready for Docker-based deployment on platforms that can build from a GitHub repository.
SETTINGS_ADMIN_TOKEN
DATA_DIR
- Fork or clone the repository.
- Deploy it on any Docker-capable platform.
- Set
SETTINGS_ADMIN_TOKENon the host. - Optionally set
DATA_DIRso SQLite and runtime settings live in a persistent volume. - Open the deployed URL.
- If required keys are missing, the app opens the runtime settings page first.
- Fill in the required API keys from the browser and save.
- Return to the dashboard.
docker compose up --buildThe app supports two configuration paths:
backend/.envfor local development- the in-app runtime settings page for deployed instances
Sensitive keys are never returned to the browser after saving. The UI only reports whether a key is configured and where it came from (env, stored, or default).
ALPACA_API_KEYALPACA_SECRET_KEYPOLYGON_API_KEYTAVILY_API_KEY
OPENAI_API_KEYEnables AI final selection for the candidate pool and social digest generation.X_BEARER_TOKENEnables official X Recent Search for the social-intelligence layer.SETTINGS_ADMIN_TOKENProtects browser-based settings updates on shared or public deployments.
Runtime configuration is stored in SQLite under DATA_DIR/trading_platform.db when DATA_DIR is set. Otherwise it falls back to backend/trading_platform.db.
cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reloadcd frontend
npm install
npm run devIf you want the frontend to target a non-default backend URL:
export VITE_API_BASE_URL=http://localhost:8000The project can now run as a native desktop app instead of opening in a browser.
Run from source:
./Trading\ Raven\ Desktop.commandBuild a real .app:
./launcher/build_desktop_app.shBuild output:
output/desktop/Trading Raven Platform.app
Desktop app data is stored under:
~/Library/Application Support/Trading Raven Platform
Run from source:
Trading Raven Desktop.batBuild a Windows desktop bundle:
launcher\build_desktop_app.batBuild output:
output\desktop-windows\Trading Raven Platform\Trading Raven Platform.exe
Desktop app data is stored under:
%APPDATA%\Trading Raven Platform
- Desktop mode does not open a browser window.
- Desktop launchers install desktop-only Python dependencies (
pywebview,pyinstaller) intobackend/.venv. - Production frontend builds now default to same-origin API requests, which lets the packaged desktop app run on a dynamic local port.
- The existing browser-based launchers still work if you prefer the web workspace.
Run this only if you want the Strategy B paper-trading loop:
cd backend
source .venv/bin/activate
python -m strategy.runnerThe repository includes local launchers for Finder:
Trading Platform.appStop Trading Platform.appStart Trading Platform.commandStop Trading Platform.command
The launcher checks the backend environment, installs dependencies if needed, rebuilds the frontend when sources change, starts FastAPI on http://127.0.0.1:8000, and opens the browser automatically.
Runtime files:
- PID file:
.run/backend.pid - Backend log:
logs/backend.log
If macOS blocks the first launch, right-click the .app and choose Open.
- Shows Alpaca account metrics, current positions, historical trades, and recent orders.
- Supports watchlist management and symbol-specific news/research lookup.
- Exposes bot status plus controls for starting or stopping the paper runner.
- Uses Alpaca to expose a searchable stock universe so users can add any active tradable U.S. symbol to the watchlist.
- Combines watchlist symbols, current positions, and the AI candidate pool into one monitoring view.
- Shows relative performance versus the previous day, previous week, and previous month for each tracked symbol.
- Builds the candidate pool from a curated technology universe plus ETF proxies such as
QQQ,SPY,VOO,XLK,VGT, andSMH. - Falls back to deterministic scoring if OpenAI is unavailable.
Xis the first working provider.- Search applies common filters such as
-is:retweetand-is:reply, then ranks posts by engagement, recency, keyword overlap, and author authority. - OpenAI can optionally generate a short Chinese digest.
xiaohongshuis currently a placeholder provider only. The interface is present, but public-content search is not implemented.
GET /api/accountGET /api/positionsGET /api/tradesGET /api/orders?status=allGET /api/monitoringPOST /api/monitoring/refreshGET /api/universe?query=NVDAPOST /api/watchlistDELETE /api/watchlist/{symbol}GET /api/settings/statusPUT /api/settingsGET /api/social/providersGET /api/social/search?query=NVDA+AI&provider=x
This repo includes an agent-native CLI harness inspired by the CLI-Anything workflow.
- Source:
agent-harness/ - Entry point:
cli-anything-trading-platform
Install it into the backend environment:
cd backend
source .venv/bin/activate
cd ../agent-harness
pip install .Examples:
cli-anything-trading-platform monitoring overview --refresh
cli-anything-trading-platform monitoring candidates
cli-anything-trading-platform universe search NVDA --limit 5
cli-anything-trading-platform watchlist add ABNB
cli-anything-trading-platform bot status
cli-anything-trading-platform app start
cli-anything-trading-platform social providers
cli-anything-trading-platform social search "NVDA AI" --provider x --min-likes 20
cli-anything-trading-platform social digest "美股 AI 芯片" --provider x- Universe: 20 large-cap U.S. stocks.
- Initial buy: fixed
1000notional when the symbol drops at least2%versus the previous close. - Add-on buy: fixed
100notional for each additional2%drop, capped at 3 add-ons. - Exit rules:
- Take profit at
80absolute currency units. - Stop loss at
12%of capital committed to that position. - Forced exit after
30calendar days.
- Take profit at
- GitHub Actions workflow in
.github/workflows/ci.yml - Backend unit tests under
backend/tests/ - Frontend production build via
npm run build
See CONTRIBUTING.md for setup and contribution expectations.
MIT. See LICENSE.
-
Create a new project in Railway, link it to this GitHub repo. Railway auto-detects the
Dockerfileandrailway.json. -
Add a persistent volume at
/app/data(Railway dashboard → service → Settings → Volumes). The factor library, daily bars, and recommendation history live in SQLite at/app/data/trading_platform.db. Without the volume every redeploy wipes data. -
Set required environment variables (Settings → Variables):
ALPACA_API_KEY+ALPACA_SECRET_KEY— paper trading + price dataOPENAI_API_KEY— AI features- Optional:
POLYGON_API_KEY,TAVILY_API_KEY,ANTHROPIC_API_KEY CORS_ALLOW_ORIGINS=https://<your-railway-domain>.up.railway.app,https://yourdomain.comFACTOR_EVOLUTION_AUTOSTART— keepfalseto avoid runaway compute; user starts the loop manually via the UI
-
Railway sets
PORTautomatically. TheDockerfile'sCMDreads it. -
Healthcheck is at
/api/health(configured inrailway.json). Railway will retire unhealthy replicas automatically.
- Free tier insufficient — 512MB RAM is too tight for pandas + GP backtests. Use Hobby ($5/mo) minimum; Pro ($20/mo, 8GB) for headroom.
- Loop default off — to keep cloud CPU usage near zero until you actively use the dashboard.
- OpenAI cost — defaults are
gpt-4o-minifor high-volume calls (factor variants, Q&A) butgpt-4ofor vision (chart annotation). Override per-model env vars to tune. - yfinance ban risk — Railway shared IPs sometimes get rate-limited by Yahoo. Configure
POLYGON_API_KEYfor the primary data path; yfinance is the fallback.
- Volume mounted at
/app/data -
ALPACA_API_KEY+ALPACA_SECRET_KEYset -
OPENAI_API_KEYset -
CORS_ALLOW_ORIGINSrestricted to your domain -
/api/healthreturns 200 (Railway will block deploy otherwise) - Visit
/factorsand trigger initial data backfill via the button - Start factor evolution loop manually when ready