Market Microstructure & Manipulation Detection

by apifyforge

181 downloads Not rated yet MIT

About

Market microstructure analysis and manipulation detection via an MCP server that orchestrates 14 financial data actors in parallel.

Details

License
MIT

Explore

- Queue-reactive Hawkes process estimation — multi-dimensional intensity lambda_d(t) = mu_d + sum alpha_{dd'} exp(-beta(t-s)) estimated via EM algorithm with E/M-step iteration; branching ratio computed as spectral radius of the alpha/beta matrix via power iteration (100 iterations to convergence)
- Bayesian Online Changepoint Detection (BOCPD) — maintains run length posterior P(r_t | x_{1:t}) with normal-inverse-gamma conjugate prior and constant hazard function; classifies detected changepoints into 4 manipulation patterns: layering, spoofing, wash trading, momentum ignition
- Spectral transfer entropy — directed information flow TE(f) = 1/(4pi) ln(S_Y(f)/S_{Y|X}(f)) computed from AR spectral estimates across asset pairs; identifies which markets lead and which follow
- Johansen VECM with Hasbrouck information share — price discovery attribution via Cholesky decomposition of the innovation covariance matrix from a vector error correction model
- MRR spread decomposition — Madhavan-Richardson-Roomans model separates bid-ask spread into adverse selection, inventory cost, and order processing components; Kyle lambda computed via OLS regression on signed order flow
- Roll measure and Amihud illiquidity — Roll measure derived from return autocovariance; Amihud ratio measures price impact per unit of trading volume
- Event study CAR methodology — Cumulative Abnormal Return computed in [-5, +30] event window around insider and congressional transactions; t-statistics for significance; HHI-based information share concentration
- LASSO-penalized Granger causality — coordinate descent with soft-thresholding selects relevant VAR lags; debiased coefficients with confidence intervals; F-statistics for Granger causality test
- Student-t Hidden Markov Model — 4-state HMM (calm, volatile, crisis, recovery) with fat-tail Student-t emissions; EM forward-backward algorithm for parameter estimation; Viterbi algorithm for MAP path decoding
- Extensive-form game theory — regulator vs. manipulator modeled as zero-sum game; Nash equilibrium computed via fictitious play (200 iterations); outputs optimal budget allocation, game value, detection probability, and deterrence effect
- Gauss elimination linear solver — partial pivoting for numerically stable solutions in OLS and game-theory computations
- 14 parallel data sources — Finnhub, CoinGecko, SEC EDGAR, SEC insider, congressional tracker, exchange rates, ECB, FRED, BLS, Federal Register, Hacker News, website monitor, CFPB, exchange rate history

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Market Microstructure & Manipulation Detection
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Add to your MCP client (Claude Desktop, Cursor, Windsurf):

{
  "mcpServers": {
    "market-microstructure-manipulation-mcp": {
      "url": "https://ryanclinton--market-microstructure-manipulation-mcp.apify.actor/mcp"
    }
  }
}

---

Market microstructure analysis and manipulation detection via an MCP server that orchestrates 14 financial data actors in parallel. Built for quantitative researchers, compliance teams, and algorithmic traders who need production-grade econometric methods — Hawkes processes, BOCPD, spectral transfer entropy, Granger causality, and game-theoretic surveillance optimization — without managing infrastructure.

Connect any MCP-compatible AI client to analyze order book dynamics, detect spoofing and layering, measure cross-asset information flow, decompose bid-ask spreads, identify abnormal insider flows, discover causal manipulation networks, classify market regimes, and optimize surveillance resource allocation. All eight tools run against live data assembled from Finnhub, SEC EDGAR, SEC insider filings, congressional stock disclosures, CoinGecko, ECB rates, FRED, BLS, and more.

simulate_order_book_dynamics

$0.045

detect_spoofing_manipulation

$0.050

measure_cross_asset_information

$0.040

decompose_spread_components

$0.035

identify_insider_abnormal_flow

$0.045

discover_manipulation_causality

$0.040

classify_market_regimes

$0.035

optimize_surveillance_strategy

$0.040

Parameter

Type

query

string

max_results

number

hazard_lambda

number

| Tool | Price | Actors | Description |
|------|-------|--------|-------------|
| simulate_order_book_dynamics | $0.045 | 4 | Hawkes process estimation with branching ratio, criticality index, and queue imbalance |
| detect_spoofing_manipulation | $0.050 | 6 | BOCPD spoofing detection with manipulation pattern classification and confidence scores |
| measure_cross_asset_information | $0.040 | 5 | Spectral transfer entropy and Hasbrouck information share from Johansen VECM |
| decompose_spread_components | $0.035 | 3 | MRR spread decomposition: adverse selection, inventory, order processing, Kyle lambda |
| identify_insider_abnormal_flow | $0.045 | 4 | CAR event study [-5,+30] for insider and congressional trades with t-statistics |
| discover_manipulation_causality | $0.040 | 5 | LASSO Granger causality network with F-statistics, p-values, and debiased coefficients |
| classify_market_regimes | $0.035 | 4 | Student-t HMM with Viterbi path: calm, volatile, crisis, recovery classification |
| optimize_surveillance_strategy | $0.040 | 8 | Extensive-form game theory: Nash equilibrium surveillance budget allocation |

Each tool accepts the same two parameters, passed at call time from your MCP client:

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| query | string | Yes | — | Market query: ticker, asset class, sector, or company name (e.g., "AAPL", "crypto", "energy sector", "Nancy Pelosi") |
| max_results | number | No | 40–50 | Maximum results to fetch per actor. Available on simulate_order_book_dynamics and measure_cross_asset_information. Reduce for faster, lower-cost queries. |
| hazard_lambda | number | No | 100 | Expected run length between changepoints for BOCPD. Available on detect_spoofing_manipulation. Higher values produce fewer, higher-confidence changepoints. |

curl -X POST "https://market-microstructure-manipulation-mcp.apify.actor/mcp" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_APIFY_TOKEN" \
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":3}'
```

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "market microstructure & manipulation detection": {
            "market-microstructure-manipulation-mcp": {
                "url": "https://ryanclinton--market-microstructure-manipulation-mcp.apify.actor/mcp"
            }
        }
    }
}

McpServers

{
    "market-microstructure-manipulation-mcp": {
        "url": "https://ryanclinton--market-microstructure-manipulation-mcp.apify.actor/mcp"
    }
}

Market Microstructure & Manipulation MCP

> View on ApifyForge | Use on Apify Store

---

Quick Start

Add to your MCP client (Claude Desktop, Cursor, Windsurf):

{
  "mcpServers": {
    "market-microstructure-manipulation-mcp": {
      "url": "https://ryanclinton--market-microstructure-manipulation-mcp.apify.actor/mcp"
    }
  }
}

---

Market microstructure analysis and manipulation detection via an MCP server that orchestrates 14 financial data actors in parallel. Built for quantitative researchers, compliance teams, and algorithmic traders who need production-grade econometric methods — Hawkes processes, BOCPD, spectral transfer entropy, Granger causality, and game-theoretic surveillance optimization — without managing infrastructure.

Connect any MCP-compatible AI client to analyze order book dynamics, detect spoofing and layering, measure cross-asset information flow, decompose bid-ask spreads, identify abnormal insider flows, discover causal manipulation networks, classify market regimes, and optimize surveillance resource allocation. All eight tools run against live data assembled from Finnhub, SEC EDGAR, SEC insider filings, congressional stock disclosures, CoinGecko, ECB rates, FRED, BLS, and more.

What data can you access?

| Data Point | Source | Coverage |
|------------|--------|----------|
| 📈 Stock prices and financials | Finnhub | US equities, quotes, earnings, company metrics |
| 📋 SEC regulatory filings | EDGAR | 10-K, 10-Q, 8-K, enforcement actions |
| 👤 Insider transactions | SEC Form 4 | Officer and director buys, sells, option exercises |
| 🏛️ Congressional stock trades | STOCK Act tracker | Senate and House member trade disclosures |
| 🪙 Cryptocurrency markets | CoinGecko | 10,000+ coins, prices, volumes, market caps |
| 💱 Currency exchange rates | Exchange Rate Tracker | 150+ live currency pairs |
| 🇪🇺 ECB reference rates | ECB Exchange Rates | Daily EUR reference rates for FX microstructure |
| 📉 Federal Reserve indicators | FRED | FEDFUNDS, VIX, GDP, macroeconomic series |
| 📊 Labor market statistics | BLS | CPI, unemployment, PPI for regime context |
| 📰 Federal regulations | Federal Register | SEC and CFTC rulemakings and enforcement orders |
| 💬 Tech community signals | Hacker News | Market-relevant technology and finance discussion |
| 🔍 Website change monitoring | Website Change Monitor | Regulatory and corporate page updates |
| 📩 Consumer complaints | CFPB | Financial product complaint trends |
| 📅 Historical exchange rates | Exchange Rate History | Long-term FX time series for trend analysis |

Why use Market Microstructure & Manipulation MCP?

Building market surveillance infrastructure from scratch requires accessing 10+ financial APIs, implementing BOCPD, Hawkes processes, VECM cointegration, and game-theoretic LP solvers — then keeping it maintained as APIs change. Most academic implementations run locally, require Python environments, and break in production.

This MCP server handles all of that. Send a natural-language query from Claude, Cursor, or any MCP client and receive structured analytical output backed by live financial data and peer-reviewed econometric methods.

- Scheduling — run nightly manipulation scans and regime checks on a recurring schedule to detect emerging patterns
- API access — trigger runs programmatically from Python, JavaScript, or any HTTP client via the Apify API
- Parallel data fetching — up to 8 actors execute simultaneously per tool call, assembling market data in seconds rather than minutes
- Monitoring — receive Slack or email alerts when spoofing is detected or regime transitions occur via webhooks
- Integrations — connect to Zapier, Make, or any webhook-compatible service for automated surveillance notifications

Features

- Queue-reactive Hawkes process estimation — multi-dimensional intensity lambda_d(t) = mu_d + sum alpha_{dd'} exp(-beta(t-s)) estimated via EM algorithm with E/M-step iteration; branching ratio computed as spectral radius of the alpha/beta matrix via power iteration (100 iterations to convergence)
- Bayesian Online Changepoint Detection (BOCPD) — maintains run length posterior P(r_t | x_{1:t}) with normal-inverse-gamma conjugate prior and constant hazard function; classifies detected changepoints into 4 manipulation patterns: layering, spoofing, wash trading, momentum ignition
- Spectral transfer entropy — directed information flow TE(f) = 1/(4pi) ln(S_Y(f)/S_{Y|X}(f)) computed from AR spectral estimates across asset pairs; identifies which markets lead and which follow
- Johansen VECM with Hasbrouck information share — price discovery attribution via Cholesky decomposition of the innovation covariance matrix from a vector error correction model
- MRR spread decomposition — Madhavan-Richardson-Roomans model separates bid-ask spread into adverse selection, inventory cost, and order processing components; Kyle lambda computed via OLS regression on signed order flow
- Roll measure and Amihud illiquidity — Roll measure derived from return autocovariance; Amihud ratio measures price impact per unit of trading volume
- Event study CAR methodology — Cumulative Abnormal Return computed in [-5, +30] event window around insider and congressional transactions; t-statistics for significance; HHI-based information share concentration
- LASSO-penalized Granger causality — coordinate descent with soft-thresholding selects relevant VAR lags; debiased coefficients with confidence intervals; F-statistics for Granger causality test
- Student-t Hidden Markov Model — 4-state HMM (calm, volatile, crisis, recovery) with fat-tail Student-t emissions; EM forward-backward algorithm for parameter estimation; Viterbi algorithm for MAP path decoding
- Extensive-form game theory — regulator vs. manipulator modeled as zero-sum game; Nash equilibrium computed via fictitious play (200 iterations); outputs optimal budget allocation, game value, detection probability, and deterrence effect
- Gauss elimination linear solver — partial pivoting for numerically stable solutions in OLS and game-theory computations
- 14 parallel data sources — Finnhub, CoinGecko, SEC EDGAR, SEC insider, congressional tracker, exchange rates, ECB, FRED, BLS, Federal Register, Hacker News, website monitor, CFPB, exchange rate history

Use cases for market microstructure analysis

Quantitative research and HFT strategy evaluation

Quantitative researchers testing high-frequency strategies need to understand order book dynamics before going live. The simulate_order_book_dynamics tool estimates Hawkes process parameters from real market data, returning the branching ratio and criticality index. A branching ratio approaching 1.0 signals a market near self-excitation criticality — a regime where HFT strategies face reflexivity risk. This replaces weeks of custom data pipeline work with a single tool call.

Compliance and market surveillance

Compliance teams at broker-dealers and exchanges need continuous spoofing and layering surveillance. The detect_spoofing_manipulation tool applies BOCPD to detect changepoints in order flow, classifies them by manipulation type, and returns confidence-scored alerts. Feeding these outputs into a daily webhook delivers an automated surveillance pipeline without proprietary surveillance system costs.

Regulatory economics and enforcement research

…

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.