Vincent - Trading Engine
Strategy-driven automated trading for Polymarket and HyperLiquid. Use this skill when users want to create trading strategies, set stop-loss/take-profit/trailing stop rules, or manage automated trading. Triggers on "trading strategy", "stop loss", "take profit", "trailing stop", "automated trading", "trading engine", "trade rules", "strategy monitor".
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install skilldb:glitch003~vincent-trading-enginecURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/skilldb%3Aglitch003~vincent-trading-engine/file -o vincent-trading-engine.mdGit 仓库获取源码
git clone https://github.com/openclaw/skills/commit/c50f4092444194a6db961896f81aa1517aa7edb4# Vincent Trading Engine - Strategy-Driven Automated Trading
Use this skill to create and manage automated trading strategies for Polymarket prediction markets and HyperLiquid perpetuals/spot. The Trading Engine combines driver-based monitoring (web search, Twitter, newswire, price feeds) with a signal pipeline and LLM-powered decision-making to automatically trade based on your thesis. It also includes standalone stop-loss, take-profit, and trailing stop rules that work without the LLM.
All commands use the `@vincentai/cli` package.
## How It Works
**The Trading Engine is a unified system with two modes:**
1. **LLM-Powered Strategies** — Create a versioned strategy with a structured thesis, weighted drivers (web search keywords, Twitter accounts, newswire topics, price triggers), and an escalation policy. When drivers detect new information, signals are scored and batched. When the escalation threshold is met, an LLM (Claude via OpenRouter) evaluates the signals against your thesis and decides whether to trade, update the thesis, set protective orders, or alert you.
2. **Standalone Trade Rules** — Set stop-loss, take-profit, and trailing stop rules on positions. These execute automatically when price conditions are met — no LLM involved.
**Architecture:**
- Integrated into the Vincent backend (no separate service to run)
- Strategy endpoints under `/api/skills/polymarket/strategies/...`
- Trade rule endpoints under `/api/skills/polymarket/rules/...`
- HyperLiquid rules use `venue: "hyperliquid"` and route through the HL adapter
- Uses the same API key as the Polymarket or HyperLiquid skill (depending on venue)
- All trades go through Vincent's policy-enforced pipeline
- LLM costs are metered and deducted from the user's credit balance
- Every LLM invocation is recorded with full audit trail (tokens, cost, actions, duration)
## Security Model
- **LLM cannot bypass policies** — all trades go through the venue's policy-enforced skill (`polymarketSkill.placeBet()` or `hyperliquidSkill.trade()`) which enforces spending limits, approval thresholds, and allowlists
- **Backend-side LLM key** — the OpenRouter API key never leaves the server. Agents and users cannot invoke the LLM directly
- **Credit gating** — no LLM invocation without sufficient credit balance
- **Tool constraints** — the LLM's available tools are controlled by the strategy's `config.tools` settings. If `canTrade: false`, the trade tool is not provided
- **Rate limiting** — max concurrent LLM invocations is capped to prevent runaway costs
- **Audit trail** — every invocation is recorded with full prompt, response, actions, cost, and duration
- **No private keys** — the Trading Engine uses the Vincent API for all trades. Private keys stay on Vincent's servers
## Part 1: LLM-Powered Strategies
### Core Concepts
- **Instrument**: A tradeable asset on a venue. Defined by `id`, `type` (stock, perp, swap, binary, option), `venue`, and optional constraints (leverage, margin, liquidity, fees).
- **Thesis**: Your directional view — `estimate` (target price/value), `direction` (long/short/neutral), `confidence` (0–1), and `reasoning`.
- **Driver**: A named information source that feeds the signal pipeline. Each driver has a `weight`, `direction` (bullish/bearish/contextual), and `monitoring` config (entities, keywords, embedding anchor, sources, polling interval).
- **Escalation Policy**: Controls when the LLM is woken up. `signalScoreThreshold` (minimum score to batch), `highConfidenceThreshold` (score that triggers immediate wake), `maxWakeFrequency` (e.g. "1 per 15m"), `batchWindow` (e.g. "5m").
- **Trade Rules**: Entry rules (min edge, order type), exit rules (thesis invalidation triggers), auto-actions (stop-loss, take-profit, trailing stop, price delta triggers), and sizing rules (method, max position, portfolio %, max trades/day).
### Signal Pipeline
Strategies process information through a 6-layer pipeline:
1. **Ingest** — Raw data from driver sources (web search, Twitter, newswire, price feeds, RSS, Reddit, on-chain, filings, options flow)
2. **Filter** — Deduplication and relevance filtering. Drops signals already seen or below quality threshold
3. **Score** — Each signal is scored (0–1) based on driver weight, embedding similarity to the anchor, and entity/keyword matches
4. **Escalate** — Scored signals are batched according to the escalation policy. Low-score signals accumulate in a batch window; high-confidence signals trigger immediate LLM wake
5. **LLM** — The LLM evaluates batched signals against the current thesis. It can update the thesis, issue trade decisions, update driver states, or take no action
6. **Execute** — Trade decisions pass through policy enforcement and are routed to the appropriate venue adapter for execution
### Strategy Lifecycle
Strategies follow a versioned lifecycle: `DRAFT` → `ACTIVE` → `PAUSED` → `ARCHIVED`
- **DRAFT**: Can be edited. Not yet monitoring or invoking the LLM.
- **ACTIVE**: Drivers are running. New signals trigger the pipeline.
- **PAUSED**: Monitoring is stopped. Can be resumed.
- **ARCHIVED**: Permanently stopped. Cannot be reactivated.
To iterate on a strategy, duplicate it as a new version (creates a new DRAFT with incremented version number and the same config).
### Create a Strategy
```bash
npx @vincentai/cli@latest trading-engine create-strategy \
--key-id <KEY_ID> \
--name "BTC Momentum" \
--config '{
"instruments": [
{ "id": "btc-usd-perp", "type": "perp", "venue": "polymarket" },
{ "id": "BTC", "type": "perp", "venue": "hyperliquid" }
],
"thesis": {
"estimate": 105000,
"direction": "long",
"confidence": 0.7,
"reasoning": "ETF inflows accelerating, halving supply shock imminent"
},
"drivers": [
{
"name": "ETF Flow Monitor",
"weight": 2.0,
"direction": "bullish",
"monitoring": {
"entities": ["BlackRock", "Fidelity"],
"keywords": ["bitcoin ETF", "BTC inflow"],
"embeddingAnchor": "Bitcoin ETF institutional inflows",
"sources": ["web_search", "newswire"]
}
},
{
"name": "Crypto Twitter",
"weight": 1.0,
"direction": "contextual",
"monitoring": {
"entities": ["@BitcoinMagazine", "@saborskycnbc"],
"keywords": ["bitcoin", "BTC"],
"sources": ["twitter"]
}
}
],
"escalation": {
"signalScoreThreshold": 0.3,
"highConfidenceThreshold": 0.8,
"maxWakeFrequency": "1 per 15m",
"batchWindow": "5m"
},
"tradeRules": {
"entry": { "minEdge": 0.05, "orderType": "limit", "limitOffset": 0.01 },
"autoActions": { "stopLoss": -0.10, "takeProfit": 0.25, "trailingStop": -0.05 },
"exit": { "thesisInvalidation": ["ETF outflows exceed $500M/week"] },
"sizing": {
"method": "edgeScaled",
"maxPosition": 500,
"maxPortfolioPct": 20,
"maxTradesPerDay": 5,
"minTimeBetweenTrades": "30m"
}
},
"notifications": {
"onTrade": true,
"onThesisChange": true,
"channel": "none"
}
}'
```
**Parameters:**
- `--name`: Strategy name
- `--config`: Full strategy config JSON (see Core Concepts above for structure)
- `--data-source-secret-id`: Optional DATA_SOURCES secret ID for driver monitoring API calls
- `--poll-interval`: Polling interval in minutes for driver monitoring (default: 15)
### List Strategies
```bash
npx @vincentai/cli@latest trading-engine list-strategies --key-id <KEY_ID>
```
### Get Strategy Details
```bash
npx @vincentai/cli@latest trading-engine get-strategy --key-id <KEY_ID> --strategy-id <STRATEGY_ID>
```
### Update a Strategy
Update a DRAFT strategy. Pass only the fields you want to change — config is a partial object.
```bash
npx @vincentai/cli@latest trading-engine update-strategy --key-id <KEY_ID> --strategy-id <STRATEGY_ID> \
--name "Updated Name" --config '{ "the