strategy
Build and manage custom trading strategies with natural language
What this skill does
# Strategy - Complete API Reference
Create custom trading strategies using natural language or templates, then deploy to live trading.
---
## Chat Commands
### Create Strategy
```
/strategy create "Buy when price drops 5% in 1 hour"
/strategy create momentum --lookback 14 --threshold 2%
/strategy from-template mean-reversion
```
### Manage Strategies
```
/strategies List all strategies
/strategy <name> View strategy details
/strategy edit <name> Modify strategy
/strategy delete <name> Remove strategy
```
### Activate/Deactivate
```
/strategy activate <name> Start running strategy
/strategy deactivate <name> Stop strategy
/strategy pause <name> Pause temporarily
/strategy resume <name> Resume paused strategy
```
### Test & Validate
```
/strategy test <name> --dry-run Test without real trades
/strategy backtest <name> Run backtest
/strategy validate <name> Check for errors
```
---
## TypeScript API Reference
### Create Strategy Builder
```typescript
import { createStrategyBuilder } from 'clodds/strategy';
const builder = createStrategyBuilder({
// Validation
requireDryRun: true,
validateParameters: true,
// Storage
storage: 'sqlite',
dbPath: './strategies.db',
});
```
### Natural Language Strategy
```typescript
// Create from natural language
const strategy = await builder.fromNaturalLanguage({
description: `
Buy YES on any market when:
- Price drops more than 5% in the last hour
- Volume is above average
- Spread is less than 2%
Sell when:
- Price recovers 3% from entry
- Or after 24 hours (timeout)
Risk: Max 5% of portfolio per trade
`,
name: 'dip-buyer',
});
console.log(`Created: ${strategy.name}`);
console.log(`Conditions: ${strategy.conditions.length}`);
```
### Template-Based Strategy
```typescript
// Momentum strategy
const momentum = await builder.fromTemplate('momentum', {
lookbackPeriod: 14,
entryThreshold: 0.02,
exitThreshold: 0.01,
stopLoss: 0.05,
takeProfit: 0.10,
maxPositionPct: 10,
});
// Mean reversion strategy
const meanReversion = await builder.fromTemplate('mean-reversion', {
lookbackPeriod: 20,
deviationThreshold: 2, // Standard deviations
exitOnMean: true,
stopLoss: 0.08,
});
// Arbitrage strategy
const arbitrage = await builder.fromTemplate('arbitrage', {
minSpread: 0.02,
platforms: ['polymarket', 'kalshi'],
maxSlippage: 0.01,
});
// Breakout strategy
const breakout = await builder.fromTemplate('breakout', {
rangePeriod: '7d',
breakoutThreshold: 0.05,
confirmationVolume: 1.5, // 1.5x average volume
});
```
### Custom Strategy Code
```typescript
// Full custom strategy
const custom = await builder.create({
name: 'my-custom-strategy',
description: 'Buy low-priced markets with high volume',
// Entry conditions (all must be true)
entryConditions: [
{ type: 'price', operator: '<', value: 0.30 },
{ type: 'volume24h', operator: '>', value: 50000 },
{ type: 'spread', operator: '<', value: 0.02 },
],
// Exit conditions (any triggers exit)
exitConditions: [
{ type: 'profit', operator: '>=', value: 0.15 },
{ type: 'loss', operator: '>=', value: 0.10 },
{ type: 'holdTime', operator: '>=', value: '48h' },
],
// Risk management
risk: {
maxPositionPct: 5,
stopLoss: 0.10,
takeProfit: 0.20,
maxConcurrentPositions: 5,
},
// Execution
execution: {
orderType: 'limit',
limitBuffer: 0.005,
retries: 3,
},
});
```
### Validate Strategy
```typescript
const validation = await builder.validate(strategy);
if (validation.valid) {
console.log('✅ Strategy is valid');
} else {
console.log('❌ Validation errors:');
for (const error of validation.errors) {
console.log(` - ${error}`);
}
}
// Warnings (not blocking)
for (const warning of validation.warnings) {
console.log(`⚠️ ${warning}`);
}
```
### Activate Strategy
```typescript
// Start with dry-run first (required)
await builder.activate(strategy.name, {
dryRun: true,
notifyOnTrade: true,
});
// After validation, go live
await builder.activate(strategy.name, {
dryRun: false,
capital: 5000, // Allocate $5000
});
```
### Monitor Strategy
```typescript
const status = await builder.getStatus(strategy.name);
console.log(`Status: ${status.status}`); // 'active' | 'paused' | 'stopped'
console.log(`Trades: ${status.trades}`);
console.log(`P&L: $${status.pnl}`);
console.log(`Win Rate: ${status.winRate}%`);
console.log(`Active Positions: ${status.activePositions}`);
console.log(`Last Signal: ${status.lastSignal}`);
```
### List Strategies
```typescript
const strategies = await builder.list();
for (const s of strategies) {
console.log(`${s.name}: ${s.status}`);
console.log(` Type: ${s.template || 'custom'}`);
console.log(` P&L: $${s.pnl}`);
console.log(` Trades: ${s.trades}`);
}
```
---
## Built-in Templates
| Template | Description |
|----------|-------------|
| `momentum` | Follow price trends |
| `mean-reversion` | Buy dips, sell rallies |
| `arbitrage` | Cross-platform spreads |
| `breakout` | Range breakout entries |
| `pairs` | Correlated market pairs |
| `news-reactive` | React to news events |
| `volume-spike` | Trade on volume surges |
---
## Condition Types
| Type | Description | Example |
|------|-------------|---------|
| `price` | Current price | `< 0.30` |
| `volume24h` | 24h volume | `> 50000` |
| `spread` | Bid-ask spread | `< 0.02` |
| `profit` | Unrealized profit | `>= 0.15` |
| `loss` | Unrealized loss | `>= 0.10` |
| `holdTime` | Time in position | `>= 48h` |
| `priceChange` | Price change % | `< -0.05` (5% drop) |
---
## Best Practices
1. **Always dry-run first** — Test before real money
2. **Start small** — Low capital until proven
3. **Set stop-losses** — Protect against bad trades
4. **Monitor actively** — Check strategy performance
5. **Iterate** — Improve based on results
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.