Trading Tools v2
Codebase: /opt/tradingtools-v2
Architecture: pnpm monorepo — packages/ (ingest, confirm, executor, enrichment, tpsl, perfmon, router, shared) + apps/control-api
Trading Tools v2 is a headless internal system and the production copy-trading engine
(since the 2026-05-31 cutover, replacing /opt/copytrading). There is no public-facing API —
all user interaction goes through the Insiders backend as a proxy.
Architecture overview
| Package | Role |
|---|---|
packages/ingest | Trade event ingestion from Polymarket (also runs bookfeed → mark.prices) |
packages/enrichment | Read-only ClickHouse → Redis cache builder |
packages/executor | Executes copy trades on behalf of followers |
packages/confirm | Confirms trade execution on-chain |
packages/tpsl (GUARD) | Manages TP/SL triggers on positions |
packages/perfmon | Session PnL monitoring, auto-pause |
packages/router | Routes events between packages |
packages/shared | Shared types, DB client, utils |
apps/control-api | HTTP control surface :9110 |
control-api · :9110
Source: /opt/tradingtools-v2/apps/control-api/src/index.ts
Exposed at tradingv2.polyinsiders.com (nginx enabled 2026-06-01), token-gated with a
shared Authorization: Bearer <CONTROL_API_TOKEN>. All routes documented in detail under:
- Copy Trading Routes — subscription management
- TPSL Routes — TP/SL triggers (GUARD)
Quick reference
| Method | Path | Category |
|---|---|---|
| POST | /subscriptions | Subscription |
| GET | /subscriptions?followerProxy=0x… | Subscription |
| GET | /subscriptions/:id | Subscription |
| GET | /subscriptions/:id/fills | Subscription |
| PATCH | /subscriptions/:id | Subscription |
| POST | /subscriptions/:id/pause | Subscription |
| POST | /subscriptions/:id/resume | Subscription |
| DELETE | /subscriptions/:id | Subscription |
| POST | /subscriptions/funding | Internal |
| POST | /subscriptions/:id/perf-action | Internal |
| POST | /triggers | TPSL (GUARD) |
| PATCH | /triggers/:id | TPSL (GUARD) |
| DELETE | /triggers/:id | TPSL (GUARD) |
| GET | /triggers?wallet=0x… | TPSL (GUARD) |
| GET | /triggers/:id | TPSL (GUARD) |
| GET | /health | Infra |
| GET | /ready | Infra |
Database
Schema: /opt/tradingtools-v2/db/schema.prisma
Engine: PostgreSQL · Job queue: BullMQ + Redis
Key docs in codebase
| File | Contents |
|---|---|
docs/control_api_wire_spec_v1.md | Full wire-true API spec (captured live 2026-05-30) |
docs/tpsl_control_api_v1.md | GUARD TPSL full schema |
docs/exec_handover_2026-05-29.md | Executor handover notes |
docs/v1_subs_migration_plan_v1.md | V1→V2 subscription migration plan |
docs/insiders_api_shapes.md | Insiders API request/response shapes |
TRADINGTOOLS_V2_ARCHITECTURE.md | System architecture overview |