fd-paper-trading MCP Server
OfficialProvides tools for accessing real-time and end-of-day market data via Polygon, including quotes and historical bars for backtesting and trading.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Part of the Wire line (寻数·柏讯) of FindData — the B2B data platform line.
fd-paper-trading
Multi-tenant paper-trading service exposed via a FastAPI REST + WebSocket API and an MCP server. Users can own multiple paper trading accounts and place orders through the API against real-time market data with simulated fills — no broker, no real capital.
Features
Multi-user auth — JWT + revocable API tokens (
fdt_prefix)Multi-account management — each user can create and manage multiple isolated paper accounts
Order execution — market and limit orders with simulated fills via a stateless pure-Python fill calculator
Position & cash ledgering — real-time P&L, average cost, realized gains
Real-time streaming — WebSocket endpoint (
/ws) pushes live quotes, order-status, and fill eventsMCP server — 19 tools (accounts, orders, positions, instrument search, bars, strategy lifecycle) on stdio and streamable HTTP. Caller identity is delegated: HTTP callers present their own
Authorizationcredential and act as themselves on a shared deployment; stdio falls back to the configured tokenMarket data —
SimulatedMarketDataProvider(deterministic, for dev/tests),PolygonMarketDataProvider(real prices, end-of-day on free tier), andFdOpenDataMarketDataProvider(real daily bars + close-derived quotes from the fd-open-data-mcp ontology)Quant strategies - dual-track authoring: fixed templates (SMA cross, RSI reversion, Bollinger breakout, MACD cross, DCA) and sandboxed custom code (
on_bar(ctx)); backtest with equity-curve stats; live paper runs that place attributed signals on your account. Per-user group limits (active strategies, daily orders, custom-code gate, symbol allowlist)Web UI — React + TypeScript SPA with professional trading dashboard featuring:
Three-column workspace: watchlist (live quotes), price chart, and order panel
Click-to-trade: select any symbol from watchlist to instantly update chart and order form
Position management: quick close/reduce actions with confirmation dialogs
Daily P&L tracking: real-time calculation from realized + unrealized components
Strategies pages: create/edit strategies (template param form or code editor), run backtests with equity curves, and monitor live paper runs + history
Typeahead symbol search, interactive charts (TradingView
lightweight-charts), and live streaming
Related MCP server: trading-mcp
Tech Stack
Backend: Python 3.12+, FastAPI + Uvicorn, SQLAlchemy 2.0 async, Alembic
Database: PostgreSQL (prod) / SQLite (tests)
Auth: JWT (
python-jose) + bcrypt + revocable API tokensExecution: stateless pure-Python fill calculator (no trading framework)
Frontend: React 18 + TypeScript + Vite, TanStack Query + Zustand, TradingView
lightweight-chartsTesting: pytest (backend), Vitest + React Testing Library (frontend), Playwright (e2e)
Quick Start
# 1. Install Python dependencies
uv sync
# 2. Configure environment
cp .env.example .env # edit DATABASE_URL, JWT_SECRET, market-data keys
# 3. Provision PostgreSQL and apply migrations
brew services start postgresql@14
createdb paper_trading
uv run alembic upgrade head
# 4. (Optional) Build the web UI so FastAPI serves it at /
cd web && npm install && npm run build && cd ..
# 5. Run the API (OpenAPI docs at http://localhost:8000/docs)
uv run fd-paper-tradingNote: On macOS with Homebrew,
postgresql@14may run on port 5433 if 5432 is occupied. AdjustDATABASE_URLin.envaccordingly.
Admin bootstrap: to manage user groups (custom-code access, symbol allowlists, limits), set
FD_ADMIN_EMAILS=you@example.comin.envand register with that email - the account is promoted to admin. Admins manage groups atPOST /api/v1/groupsand assign users atPOST /api/v1/users/{id}/group.
Real market data
Selection is one variable: MARKET_DATA_SOURCE_ID — a source id registered in
fd-open-data-mcp's price-source registry (price_sources/declarations.yaml). The
registry declares how each source is reached (access.kind), and that protocol picks
the provider class; swapping a source is a declarations edit, not a code edit.
# Registered today (all three read the platform federated view over ASTOCK_DSN):
# astock_daily 前复权 A 股日线
# akshare 平台侧 akshare 落库的同族数据
# index-seed 指数种子
export ASTOCK_DSN='…' # read-only DSN (same value as FD_OPEN_DATA_DSN)
MARKET_DATA_SOURCE_ID=astock_daily uv run fd-paper-tradingLeave MARKET_DATA_SOURCE_ID empty for the simulated provider (deterministic synthetic
quotes — no key, good for dev/tests). An id the registry does not carry fails startup
with that id named; there is no silent fallback to another provider.
The old
MARKET_DATA_PROVIDER/ASTOCK_SOURCE/ASTOCK_CALENDAR_REFSselectors were removed (their compatibility mapping expired). A process that still has any of them set fails startup naming it — remove them from.envbefore upgrading.
The ontology-backed
fd-open-dataprovider still exists (marketdata/fd_open_data.py) but cannot currently be selected through configuration: no registered source declaresaccess.kind: fd_open_data_ontology. It is reachable only by constructing it directly (tests/scripts). Its one-time ontology bootstrap —uv run python scripts/setup_fd_open_data.py— and its concept family (FD_OPEN_DATA_CONCEPT/FD_OPEN_DATA_ENTITY_TYPE/FD_OPEN_DATA_FREQUENCY, defaultnav.unit/fund/daily) apply to that provider whenever a source is registered for it. A deprecated concept degrades to a data gap, never an error.
Development
# Terminal 1: FastAPI backend on :8000
uv run fd-paper-trading
# Terminal 2: Vite dev server on :5173 (proxies /api and /ws to backend)
cd web && npm install && npm run devProduction
# Build the SPA and serve everything from FastAPI on a single origin
cd web && npm run build
uv run fd-paper-trading # SPA + API + /ws all at http://localhost:8000/Architecture
┌─────────────────────────────────────────────────────────┐
│ Web UI (React + Vite + TypeScript) │
│ - TanStack Query for data fetching │
│ - Zustand for state management │
│ - TradingView lightweight-charts for charting │
│ - WebSocket client for real-time streaming │
└────────────────────┬────────────────────────────────────┘
│ REST (/api/v1) + WebSocket (/ws)
┌────────────────────▼────────────────────────────────────┐
│ FastAPI Backend │
│ - Auth (JWT + API tokens) │
│ - Account management │
│ - Order placement & cancellation │
│ - Position & cash ledgering │
│ - Market data API │
└────────────────────┬────────────────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│PostgreSQL│ │ Filling │ │ Market │
│(ledger) │ │ (fills) │ │ Data │
└──────────┘ └──────────┘ └──────────┘Execution model (v1): Fills are computed by a stateless pure-Python calculator (one quote + one order in, fill outcome out). Account state lives in the database, isolated by account_id.
Trading Dashboard
The web UI provides a professional trading workspace optimized for active trading:
┌───────────────────────────────────────────────────────────────┐
│ Watchlist (left) │ Price Chart │ Order Ticket (right) │
├──────────────────┼──────────────┼─────────────────────────────┤
│ AAPL $175.50▲│ │ Side: [Buy ▼] Sell │
│ TSLA $250.20▼│ │ Type: [Market ▼] Limit │
│ NVDA $890.10▲│ [graph] │ Qty: [100] Limit:$175 │
│ SPY $450.00▶│ │ │
│ QQQ $400.25▶│ │ [BUY AAPL] [SELL AAPL] │
│ Total PnL: (+$127)│ │
├──────────────────┴──────────────┴─────────────────────────────┤
│ Positions Table (quick close/reduce buttons on each row) │
└───────────────────────────────────────────────────────────────┘Key features:
Watchlist: Live quotes for tracked symbols (AAPL, TSLA, NVDA, SPY, QQQ), updated via WebSocket
Click-to-trade: Click any symbol in the watchlist to instantly update the chart and order panel
Order panel: Always-visible order entry form bound to the selected symbol
Position actions: Quick close/reduce buttons with confirmation dialogs
Daily P&L: Real-time calculation from realized gains + unrealized mark-to-market
Note: Daily P&L is indicative (frontend-calculated) and may differ slightly from backend calculations. Mobile-responsive layout and user-configurable watchlists are planned for future releases.
Commands
# Backend
uv run pytest # all backend tests (in-memory SQLite)
uv run pytest tests/unit/ # unit tests only
uv run pytest tests/e2e/ # end-to-end flows only
uv run alembic upgrade head # apply database migrations
uv run alembic downgrade -1 # rollback last migration
# Frontend
cd web && npm test # Vitest component tests
cd web && npx playwright test # Playwright e2e tests
cd web && npm run build # production build
cd web && npm run dev # dev server with hot reloadAPI Overview
Method | Path | Description |
POST |
| Register a user |
POST |
| Obtain a JWT access token |
POST |
| Create a revocable API token |
GET |
| List API tokens |
DELETE |
| Revoke an API token |
GET |
| List your accounts |
POST |
| Create a paper account |
GET |
| Account summary (balance, equity, counts) |
POST |
| Deposit / withdraw (signed amount) |
POST |
| Reset account (cancel orders, flatten, restore balance) |
GET |
| List open positions |
GET |
| List orders (optional |
POST |
| Place a market/limit order (simulated fill, returns 202) |
DELETE |
| Cancel an open order |
GET |
| Query a single order |
GET |
| Search instruments by symbol/name |
GET |
| Historical OHLCV bars ( |
WS |
| Stream quotes + order/fill events (auth in first message) |
Authentication: Authorization: Bearer <jwt> or Authorization: Bearer <api-token> (tokens start with fdt_).
WebSocket: Send {"type":"auth","token":"<jwt>"} as the first message, then {"type":"subscribe","symbol":"AAPL"} / {"type":"unsubscribe","symbol":"AAPL"}.
Errors: Standardized format: {"error": {"code": "...", "message": "...", "fields": [...]}}.
Contributing
Fork the repository
Create a feature branch:
git checkout -b feature/your-featureMake your changes and add tests
Run the test suite:
uv run pytest && cd web && npm testCommit with a descriptive message:
git commit -m "Add your feature"Push to your fork:
git push origin feature/your-featureOpen a Pull Request
Please ensure your code follows the existing style and all tests pass before submitting.
License
MIT — see LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Unified financial infrastructure connecting AI agents directly to trade live/demo brokerage accounts, Web3 non-custodial wallets, real-time market data across equities, ETFs, crypto, forex, options, DeFi swaps, and prediction markets, institutional research feeds, and algorithmic strategy backtesters.
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Mine, validate and paper-trade quantitative trading strategies. The engine runs on your machine.
Honest backtests and paper trading for US options and equities, driven by your agent.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables agents to generate alpha signals, retrieve market snapshots, compute portfolio risk, validate and submit paper orders, and trigger a kill switch, all under deterministic pre-trade risk controls and audit logging.5-
- FlicenseNot gradedqualityCmaintenanceEnables natural-language paper trading with per-user JWT authentication, allowing simulated market quotes, buy/sell orders, portfolio tracking, and order history through Claude.-
- FlicenseNot gradedqualityBmaintenanceEnables local AI agents to connect to KH paper trading accounts via stdio MCP, supporting stock and option orders, account history, and competition standings.43 npm-

FinzDataofficial
AlicenseAqualityBmaintenancePoint-in-time market data and backtests for AI agents, 40 tools: 16,000+ US stocks since 2000 incl. delisted, 5,100+ ETFs, ticks, 139 futures markets, options GEX and chains, VIX, 123 indexes, 79 FX pairs, 512 crypto pairs, fundamentals as filed, 13F, COT since 1986, 22,700+ macro series with every vintage, Global Macro Pulse, congressional trades. Deflated-Sharpe backtests. No key to start.1160 PyPIMIT