Skip to content
Anomaly Detector logo

Anomaly Detector

Detects execution issues, slippage, and market anomalies in real-time for quality monitoring

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Anomaly Detector Skill

Real-time anomaly detection for execution quality, slippage, and market manipulation.

Overview

This skill provides:

  • Execution slippage monitoring
  • Price gap detection
  • Volume anomalies identification
  • Spread widening alerts
  • Order fill quality assessment
  • Market manipulation detection

Anomaly Detection Algorithms

1. Statistical Methods

  • Z-Score Analysis: Identify outliers beyond N standard deviations
  • Moving Average Deviation: Compare to MA with dynamic bands
  • Quantile-based Detection: Flag values in extreme percentiles

2. Machine Learning Models

  • Isolation Forest: Unsupervised anomaly detection
  • LSTM Autoencoders: Sequential pattern recognition
  • One-Class SVM: Boundary detection for normal behavior

3. Rule-Based Systems

  • Threshold Rules: Hard limits on key metrics
  • Pattern Matching: Known manipulation patterns
  • Time-Series Rules: Temporal consistency checks

Tools

1. detect_execution_anomalies

Analyzes execution quality and detects slippage issues.

Parameters:

  • order_id (required): Order identifier
  • expected_price (required): Expected execution price
  • actual_fill_price (required): Actual fill price
  • quantity (required): Shares traded
  • order_type (required): "market" or "limit"
  • timestamp (required): Execution timestamp (ISO format)

Returns:

{
  "success": true,
  "analysis": {
    "order_id": "abc123",
    "slippage": {
      "amount": 0.15,
      "percentage": 0.097,
      "severity": "normal",
      "threshold_exceeded": false
    },
    "execution_quality": {
      "score": 92,
      "grade": "A",
      "comparison_to_vwap": -0.02,
      "comparison_to_midpoint": 0.01
    },
    "cost_analysis": {
      "expected_cost": 5000.00,
      "actual_cost": 5007.50,
      "slippage_cost": 7.50,
      "commission": 0.00,
      "total_cost": 5007.50
    },
    "anomalies_detected": false,
    "warnings": []
  },
  "benchmarks": {
    "typical_slippage_range": [0.05, 0.10],
    "market_conditions": "normal",
    "liquidity_level": "high"
  }
}

Usage:

python scripts/​anomaly_detector.py detect_execution_anomalies \
    --order-id abc123 \
    --expected-price 155.00 \
    --actual-fill-price 155.15 \
    --quantity 100 \
    --order-type market

2. detect_price_gaps

Identifies significant price gaps and discontinuities.

Parameters:

  • symbol (required): Trading symbol
  • lookback_periods (optional): Periods to analyze (default: 100)
  • gap_threshold_pct (optional): Gap significance threshold (default: 1.0)

Returns:

{
  "success": true,
  "symbol": "AAPL",
  "gaps_detected": [
    {
      "timestamp": "2025-11-25T09:30:00Z",
      "type": "gap_up",
      "gap_size_pct": 2.35,
      "prev_close": 150.00,
      "open": 153.53,
      "gap_size_dollars": 3.53,
      "filled": false,
      "volume_ratio": 2.8,
      "catalyst": "Earnings beat expectations",
      "significance": "high",
      "trading_implications": "Strong momentum, expect continuation"
    }
  ],
  "gap_statistics": {
    "total_gaps_30d": 5,
    "gap_fill_rate": 0.60,
    "avg_gap_size": 1.25,
    "largest_unfilled_gap": 2.35
  }
}

3. monitor_spread_conditions

Monitors bid-ask spreads for liquidity issues.

Parameters:

  • symbols (required): Array of symbols to monitor
  • alert_threshold_pct (optional): Spread % threshold for alerts (default: 0.5)

Returns:

{
  "success": true,
  "spread_analysis": {
    "AAPL": {
      "bid": 154.98,
      "ask": 155.02,
      "spread": 0.04,
      "spread_pct": 0.026,
      "spread_bps": 2.6,
      "status": "normal",
      "liquidity_score": 98,
      "anomalies": []
    }
  },
  "alerts": [],
  "market_conditions": {
    "overall_liquidity": "high",
    "volatility_regime": "low",
    "risk_level": "low"
  }
}

4. detect_volume_anomalies

Identifies unusual volume patterns.

Parameters:

  • symbol (required): Trading symbol
  • current_volume (required): Current period volume
  • lookback_periods (optional): Historical comparison (default: 20)
  • std_dev_threshold (optional): Standard deviations for anomaly (default: 2.5)

Returns:

{
  "success": true,
  "symbol": "AAPL",
  "volume_analysis": {
    "current_volume": 5500000,
    "avg_volume": 3200000,
    "volume_ratio": 1.72,
    "std_deviations": 3.2,
    "anomaly_detected": true,
    "anomaly_type": "high_volume",
    "significance": "high"
  },
  "context": {
    "time_of_day": "09:45",
    "typical_volume_pattern": "Elevated volume common at market open",
    "potential_catalysts": [
      "Earnings announcement",
      "Market-wide surge"
    ]
  },
  "trading_implications": {
    "liquidity": "Excellent",
    "execution_quality": "Expected to be good",
    "caution_level": "Monitor for news"
  }
}

5. assess_market_manipulation_risk

Screens for potential manipulation patterns.

Parameters:

  • symbol (required): Trading symbol
  • price_data (required): Array of recent price/​volume data
  • sensitivity (optional): "low", "medium", "high" (default: "medium")

Returns:

{
  "success": true,
  "symbol": "AAPL",
  "risk_assessment": {
    "overall_risk": "low",
    "confidence": 0.85,
    "patterns_detected": []
  },
  "screening_results": {
    "spoofing": {
      "detected": false,
      "score": 0.15
    },
    "layering": {
      "detected": false,
      "score": 0.10
    },
    "wash_trading": {
      "detected": false,
      "score": 0.05
    },
    "pump_and_dump": {
      "detected": false,
      "score": 0.08
    }
  },
  "recommendation": "Safe to trade"
}

Slippage Benchmarks

Expected Slippage by Market Cap

  • Large Cap (>$10B): 0.05% - 0.10%
  • Mid Cap ($2B-$10B): 0.10% - 0.25%
  • Small Cap (<$2B): 0.25% - 0.50%

Market Condition Adjustments

  • High Volatility: 2x normal slippage
  • Low Liquidity: 3x normal slippage
  • Market Open/​Close: 1.5x normal slippage

Alert Thresholds

Severity Levels

  • INFO: Within expected range
  • WARNING: Exceeds typical by 1.5-2x
  • CRITICAL: Exceeds typical by >2x or signs of manipulation

Auto-Actions

  • WARNING: Log and notify
  • CRITICAL: Halt trading, notify immediately, save evidence

Integration Example

from claude_skills import load_skill

anomaly_skill = load_skill("anomaly_detector")

# Monitor execution quality post-trade
execution_analysis = anomaly_skill.detect_execution_anomalies(
    order_id="abc123",
    expected_price=155.00,
    actual_fill_price=155.15,
    quantity=100,
    order_type="market",
    timestamp="2025-11-25T10:15:00Z"
)

if execution_analysis["analysis"]["slippage"]["severity"] == "high":
    alert_team("High slippage detected", execution_analysis)

# Pre-trade checks
spread_check = anomaly_skill.monitor_spread_conditions(
    symbols=["AAPL"],
    alert_threshold_pct=0.3
)

if spread_check["alerts"]:
    delay_trade("Wait for spread normalization")

CLI Usage

# Detect execution anomalies
python scripts/​anomaly_detector.py detect_execution_anomalies \
    --order-id abc123 --expected-price 155.00 --actual-fill-price 155.15

# Detect price gaps
python scripts/​anomaly_detector.py detect_price_gaps --symbol AAPL

# Monitor spreads
python scripts/​anomaly_detector.py monitor_spread_conditions --symbols AAPL MSFT

# Detect volume anomalies
python scripts/​anomaly_detector.py detect_volume_anomalies \
    --symbol AAPL --current-volume 5500000

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View