/risk
Unified risk engine with VaR, stress testing, volatility regimes, and automated controls
$ npx -y skills add alsk1992/CloddsBot --skill risk --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition โ
- You can call itInvoke it directly when you want it.
- Slash command
/risk
Context preview
The summary Claude sees to decide when to auto-load this skill.
Unified risk engine with VaR, stress testing, volatility regimes, and automated controls
SKILL.md
risk.SKILL.mdname: risk
description: "Unified risk engine with VaR, stress testing, volatility regimes, and automated controls"
emoji: "๐"
Risk - Complete API Reference
Full risk management engine: circuit breakers, loss limits, Value-at-Risk, volatility regime detection, stress testing, and kill switches.
---
Chat Commands
View Risk Status
/risk Current risk status
/risk status Detailed status with portfolio metrics
/risk limits View all limits
/risk dashboard Real-time risk metrics (VaR, regime, HHI, etc.)
Risk Analytics
/risk var Value-at-Risk and CVaR numbers
/risk regime Current volatility regime and size multiplier
/risk stress [scenario] Run stress test (flash_crash, black_swan, etc.)
**Available stress scenarios:** `flash_crash`, `liquidity_crunch`, `platform_down`, `correlation_spike`, `black_swan`
Configure Limits
/risk set max-loss 1000 Max daily loss ($)
/risk set max-loss-pct 10 Max daily loss (%)
/risk set max-drawdown 20 Max drawdown (%)
/risk set max-position 25 Max single position (%)
/risk set max-trades 50 Max trades per day
/risk set consecutive-losses 5 Stop after N losses
Circuit Breaker
/risk trip "manual stop" Manually trip breaker
/risk reset Reset after cooldown
/risk kill Emergency stop all trading
/risk check 500 Check if a $500 trade is allowed
---
TypeScript API Reference
Unified Risk Engine
The risk engine is the single entry point for all pre-trade validation. It orchestrates 10 checks in order:
1. Kill switch (SafetyManager) 2. Circuit breaker (execution-level) 3. Max order size 4. Exposure limits 5. Daily loss limit 6. Max drawdown 7. Position concentration 8. VaR limit 9. Volatility regime 10. Kelly sizing recommendation
import { createRiskEngine } from 'clodds/risk';
const engine = createRiskEngine(
{
varLimit: 500, // Reject trades if portfolio VaR > $500
varConfidence: 0.95,
varWindowSize: 100,
volatilityConfig: {
lookbackWindow: 30,
haltOnExtreme: true, // Stop trading in extreme volatility
},
},
{
riskContext, // From trading/risk.ts
safetyManager, // From trading/safety.ts
circuitBreaker, // From execution/circuit-breaker.ts
kellyCalculator, // From trading/kelly.ts
getPositions: () => positions,
getPositionValues: () => positions.map(p => p.value),
}
);Validate a Trade
const decision = engine.validateTrade({
userId: 'user-123',
platform: 'polymarket',
marketId: 'market-456',
outcome: 'YES',
side: 'buy',
size: 500,
price: 0.65,
estimatedEdge: 0.05, // 5% edge
confidence: 0.8,
category: 'politics',
});
if (decision.approved) {
// Use adjustedSize โ may be smaller than requested (Kelly + regime)
await executeTrade(decision.adjustedSize);
console.log(`Regime: ${decision.regime}`);
console.log(`Warnings: ${decision.warnings}`);
} else {
console.log(`Blocked: ${decision.reason}`);
// Check which step failed:
for (const check of decision.checks) {
console.log(` ${check.name}: ${check.passed ? 'PASS' : 'FAIL'} โ ${check.message}`);
}
}Record Trade P&L (feeds VaR + volatility)
engine.recordPnL({
pnlUsd: -45.20,
pnlPct: -0.09,
positionId: 'polymarket:market-456:YES',
timestamp: new Date(),
});Portfolio Risk Snapshot
const risk = engine.getPortfolioRisk();
console.log(`Total value: $${risk.totalValue}`);
console.log(`VaR (95%): $${risk.var95}`);
console.log(`VaR (99%): $${risk.var99}`);
console.log(`CVaR (95%): $${risk.cvar95}`);
console.log(`Regime: ${risk.regime}`);
console.log(`Drawdown: ${risk.drawdownPct}%`);Value-at-Risk
import { createVaRCalculator, calculateVaR, calculateCVaR } from 'clodds/risk';
// Full calculator with rolling window
const calc = createVaRCalculator({ windowSize: 100, confidenceLevel: 0.95 });
calc.addObservation({ pnlUsd: -50, pnlPct: -0.05, timestamp: new Date() });
const result = calc.calculateAt(0.99);
console.log(`VaR (99%): $${result.historicalVaR}`);
console.log(`CVaR (99%): $${result.cvar}`);
// Quick one-liners
const var95 = calculateVaR(pnlArray, 0.95);
const cvar95 = calculateCVaR(pnlArray, 0.95);Volatility Regime Detection
import { createVolatilityDetector, detectRegime } from 'clodds/risk';
const detector = createVolatilityDetector({
lookbackWindow: 30,
haltOnExtreme: false,
regimeMultipliers: { low: 1.2, normal: 1.0, high: 0.5, extreme: 0.25 },
});
detector.addObservation(0.03); // 3% P&L
const snapshot = detector.detect();
console.log(`Regime: ${snapshot.regime}`); // 'low' | 'normal' | 'high' | 'extreme'
console.log(`Size multiplier: ${snapshot.sizeMultiplier}x`);
console.log(`Should halt: ${snapshot.shouldHalt}`);
// One-shot from array
const regime = detectRegime(recentPnLPcts);Stress Testing
import { runStressTest, runAllScenarios, getAvailableScenarios } from 'clodds/risk';
const result = runStressTest(positions, 'flash_crash');
console.log(`Estimated loss: $${result.estimatedLoss} (${result.estimatedLossPct}%)`);
console.log(`Severity: ${result.severity}`);
console.log(`Recommendations: ${result.recommendations.join(', ')}`);
// Run all scenarios at once
const all = runAllScenarios(positions); // sorted by severity
// Override scenario parameters
const custom = runStressTest(positions, 'flash_crash', {
scenarios: { flash_crash: { lossPct: 30, description: 'Severe crash' } },
});Risk Dashboard
import { getRiskDashboard } from 'clodds/risk';
const dashboard = engine.geRead more
name: risk description: "Unified risk engine with VaR, stress testing, volatility regimes, and automated controls" emoji: "๐"
Risk - Complete API Reference
Full risk management engine: circuit breakers, loss limits, Value-at-Risk, volatility regime detection, stress testing, and kill switches.
---
Chat Commands
View Risk Status
/risk Current risk status /risk status Detailed status with portfolio metrics /risk limits View all limits /risk dashboard Real-time risk metrics (VaR, regime, HHI, etc.)
Risk Analytics
/risk var Value-at-Risk and CVaR numbers /risk regime Current volatility regime and size multiplier /risk stress [scenario] Run stress test (flash_crash, black_swan, etc.)
**Available stress scenarios:** `flash_crash`, `liquidity_crunch`, `platform_down`, `correlation_spike`, `black_swan`
Configure Limits
/risk set max-loss 1000 Max daily loss ($) /risk set max-loss-pct 10 Max daily loss (%) /risk set max-drawdown 20 Max drawdown (%) /risk set max-position 25 Max single position (%) /risk set max-trades 50 Max trades per day /risk set consecutive-losses 5 Stop after N losses
Circuit Breaker
/risk trip "manual stop" Manually trip breaker /risk reset Reset after cooldown /risk kill Emergency stop all trading /risk check 500 Check if a $500 trade is allowed
---
TypeScript API Reference
Unified Risk Engine
The risk engine is the single entry point for all pre-trade validation. It orchestrates 10 checks in order:
1. Kill switch (SafetyManager) 2. Circuit breaker (execution-level) 3. Max order size 4. Exposure limits 5. Daily loss limit 6. Max drawdown 7. Position concentration 8. VaR limit 9. Volatility regime 10. Kelly sizing recommendation
import { createRiskEngine } from 'clodds/risk';
const engine = createRiskEngine(
{
varLimit: 500, // Reject trades if portfolio VaR > $500
varConfidence: 0.95,
varWindowSize: 100,
volatilityConfig: {
lookbackWindow: 30,
haltOnExtreme: true, // Stop trading in extreme volatility
},
},
{
riskContext, // From trading/risk.ts
safetyManager, // From trading/safety.ts
circuitBreaker, // From execution/circuit-breaker.ts
kellyCalculator, // From trading/kelly.ts
getPositions: () => positions,
getPositionValues: () => positions.map(p => p.value),
}
);Validate a Trade
const decision = engine.validateTrade({
userId: 'user-123',
platform: 'polymarket',
marketId: 'market-456',
outcome: 'YES',
side: 'buy',
size: 500,
price: 0.65,
estimatedEdge: 0.05, // 5% edge
confidence: 0.8,
category: 'politics',
});
if (decision.approved) {
// Use adjustedSize โ may be smaller than requested (Kelly + regime)
await executeTrade(decision.adjustedSize);
console.log(`Regime: ${decision.regime}`);
console.log(`Warnings: ${decision.warnings}`);
} else {
console.log(`Blocked: ${decision.reason}`);
// Check which step failed:
for (const check of decision.checks) {
console.log(` ${check.name}: ${check.passed ? 'PASS' : 'FAIL'} โ ${check.message}`);
}
}Record Trade P&L (feeds VaR + volatility)
engine.recordPnL({
pnlUsd: -45.20,
pnlPct: -0.09,
positionId: 'polymarket:market-456:YES',
timestamp: new Date(),
});Portfolio Risk Snapshot
const risk = engine.getPortfolioRisk();
console.log(`Total value: $${risk.totalValue}`);
console.log(`VaR (95%): $${risk.var95}`);
console.log(`VaR (99%): $${risk.var99}`);
console.log(`CVaR (95%): $${risk.cvar95}`);
console.log(`Regime: ${risk.regime}`);
console.log(`Drawdown: ${risk.drawdownPct}%`);Value-at-Risk
import { createVaRCalculator, calculateVaR, calculateCVaR } from 'clodds/risk';
// Full calculator with rolling window
const calc = createVaRCalculator({ windowSize: 100, confidenceLevel: 0.95 });
calc.addObservation({ pnlUsd: -50, pnlPct: -0.05, timestamp: new Date() });
const result = calc.calculateAt(0.99);
console.log(`VaR (99%): $${result.historicalVaR}`);
console.log(`CVaR (99%): $${result.cvar}`);
// Quick one-liners
const var95 = calculateVaR(pnlArray, 0.95);
const cvar95 = calculateCVaR(pnlArray, 0.95);Volatility Regime Detection
import { createVolatilityDetector, detectRegime } from 'clodds/risk';
const detector = createVolatilityDetector({
lookbackWindow: 30,
haltOnExtreme: false,
regimeMultipliers: { low: 1.2, normal: 1.0, high: 0.5, extreme: 0.25 },
});
detector.addObservation(0.03); // 3% P&L
const snapshot = detector.detect();
console.log(`Regime: ${snapshot.regime}`); // 'low' | 'normal' | 'high' | 'extreme'
console.log(`Size multiplier: ${snapshot.sizeMultiplier}x`);
console.log(`Should halt: ${snapshot.shouldHalt}`);
// One-shot from array
const regime = detectRegime(recentPnLPcts);Stress Testing
import { runStressTest, runAllScenarios, getAvailableScenarios } from 'clodds/risk';
const result = runStressTest(positions, 'flash_crash');
console.log(`Estimated loss: $${result.estimatedLoss} (${result.estimatedLossPct}%)`);
console.log(`Severity: ${result.severity}`);
console.log(`Recommendations: ${result.recommendations.join(', ')}`);
// Run all scenarios at once
const all = runAllScenarios(positions); // sorted by severity
// Override scenario parameters
const custom = runStressTest(positions, 'flash_crash', {
scenarios: { flash_crash: { lossPct: 30, description: 'Severe crash' } },
});Risk Dashboard
import { getRiskDashboard } from 'clodds/risk';
const dashboard = engine.geOpen Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes instantly, manages risk while you sleep. Agent commerce protocol for machine-to-machine payments. Self-hosted. Built on Claude.
Repo: alsk1992/CloddsBot
Other skills on cloddsbot.
- /acp
Enable agent-to-agent commerce with on-chain escrow, cryptographic agreements, and service discovery.
Open skill - /agentbets
AgentBets - AI-native prediction markets on Solana
Open skill - /ai-strategy
AI Strategy - natural language to trades
Open skill - /alerts
Create and manage price alerts for prediction markets
Open skill - /analytics
Performance attribution, trade analytics, and strategy optimization
Open skill - /arbitrage
Automated cross-platform arbitrage detection and monitoring
Open skill

