Polymarket strategy trading system MVP built with Next.js App Router + TypeScript + Prisma + PostgreSQL.
- Market discovery: Gamma API
- Public trade/position reads: Data API
- Orderbook / quote / order execution: CLOB API
- Trading auth: official
@polymarket/clob-client - Live trading account scope:
EOAonly in this MVP
- Dashboard with realtime market snapshot vs strategy state separation
- Market discovery and search
- Market detail with orderbook and manual limit order form
- Three server-side strategies:
- Threshold breakout
- Spread / top-of-book imbalance
- Two-sided range quoting
- Dry-run signal logging
- Live order submission when server credentials are configured
- Orders / trades / positions views with source labels
- Global risk controls, kill switch, cancel-all button, audit logs
- System settings page with server-only secret boundary display
- Copy
.env.exampleto.env. - Start PostgreSQL and update
DATABASE_URL. - Run
npm install. - Run
npm run prisma:generate. - Run
npm run prisma:push. - Run
npm run dev.
- Optional: copy
.env.exampleto.envand fill in real secrets if needed. - Run
docker compose up --build. - Open
http://localhost:3000.
Notes:
- Compose starts both the app and PostgreSQL.
- If
.envis missing, built-in defaults are used so the project can still boot. docker composeuses the internal database hostdb. If your.envcontainsDATABASE_URL=...localhost..., that is only for non-Docker local runs and will not be used by Compose.- If you want to override the database URL for Docker, set
DOCKER_DATABASE_URL, notDATABASE_URL. - The default admin token is
change-me-before-production. Override it before exposing the app anywhere.
Set these server-only variables before using live CLOB order submission:
POLYMARKET_PRIVATE_KEYPOLYMARKET_TRADER_ADDRESSPOLYMARKET_CHAIN_ID=137POLYMARKET_SIGNATURE_TYPE=0
npm run prisma:generatenpm run lintnpm run buildnpm test(vitest watch mode)npm run test:run(single run)npm run test:e2e(playwright)
- Realtime quotes use WebSocket market channels with automatic reconnection; HTTP polling is used as fallback.
- Tag filter query parameters are not wired yet because they still need one more documentation check.
- Allowance / approval setup for first live trade is not automated in this MVP.
POLY_PROXYandPOLY_GNOSIS_SAFEaccount modes are intentionally excluded.