market-microstructure

market-microstructure is a skill for Claude Code, Codex from HKUDS/Vibe-Trading. It costs 55 tokens per session (3,257 once invoked), scanned A, original, MIT.

A framework for studying how orders, trades, and available liquidity move prices. It covers bid-ask spreads, order-flow toxicity, price impact, and limit-order books, which show pending buy and sell orders.

In plain words
What is it for?
Use it to estimate trading costs, plan large-order execution such as TWAP or VWAP, assess liquidity risk, and examine China A-share auctions and block trades.
Why use it?
It helps estimate the real cost and market impact of trading instead of assuming every trade has the same fee and liquidity.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to estimate trading costs, plan large-order execution such as TWAP or VWAP, assess liquidity risk, and examine China A-share auctions and block trades.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hkuds/vibe-trading/market-microstructure
About the project

Vibe-Trading is a personal trading agent that gives an AI system tools for market analysis, algorithmic trading, backtesting, and related workflows. It is for users who want an agent to research and evaluate trading strategies or manage simulated and other trading activities. The catalogue contains skills that expose these trading capabilities to compatible agents.

HKUDS/Vibe-Trading · 33,177 stars · on GitHub · vibetrading.wiki

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add HKUDS/Vibe-Trading --skill market-microstructure
Clone the repo
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for market-microstructure

README.md
[![agentmods](https://agentmods.dev/badge/skills/hkuds/vibe-trading/market-microstructure/github.svg)](https://agentmods.dev/skills/hkuds/vibe-trading/market-microstructure)
Your own site
<a href="https://agentmods.dev/skills/hkuds/vibe-trading/market-microstructure"><img src="https://agentmods.dev/badge/skills/hkuds/vibe-trading/market-microstructure/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for market-microstructure

Your own site · 80×15
<a href="https://agentmods.dev/skills/hkuds/vibe-trading/market-microstructure"><img src="https://agentmods.dev/badge/skills/hkuds/vibe-trading/market-microstructure.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,257 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. ✓ AI security review Fable 5.1 · 6 Sept 2026 📄 Read the review Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium analysis-evasion · line 1
    Suspicious Unicode normalization or mixed-script content
    Fix: Review the flagged content for security risks. Ensure no credentials, secrets, or sensitive data are exposed.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00055 $0.03257
Opus 5 $0.00028 $0.01629
Sonnet 5 $0.00011 $0.00651
Haiku 4.5 $0.00006 $0.00326

Measured 11d ago against content hash 35dbbb3a9a53, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

market-microstructure scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

agent/src/skills/market-microstructure/SKILL.md · 308 lines

How it starts

The opening of the file, as written. The whole thing — 308 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Market Microstructure

Overview

Study the micro-level mechanisms of price formation: who is trading, how they are trading, and how trades affect prices. For quantitative strategies, this matters because it improves transaction-cost estimation, identifies informed trading, and optimizes execution.

Applicable scenarios:

  • Precise estimation of strategy trading costs (instead of simply assuming a flat 0.1% fee)
  • Designing large-order execution strategies (TWAP / VWAP / IS)
  • Detecting order-flow toxicity (avoid time windows dominated by informed traders)
  • Quantifying liquidity risk (flash-crash warning)
  • Capturing China A-share-specific microstructure features (call auction / closing auction / block trades)

Core Concepts

Bid-Ask Spread

Three measurements:

Metric Formula Meaning
Quoted spread Ask - Bid Best spread shown in the limit order book
Effective spread `2 × trade price - mid price
Realized spread 2 × direction × (trade price - mid price 5min later) True market-maker profit
China A-share example:
  Instrument: 600519.SH Kweichow Moutai
  Best bid: 1680.00  Best ask: 1680.50
  Quoted spread: 0.50 RMB = 0.03%

  Instrument: 000001.SZ Ping An Bank
  Best bid: 11.05  Best ask: 11.06
  Quoted spread: 0.01 RMB = 0.09%

Spread decomposition (Roll):
  Spread = adverse-selection cost + inventory cost + order-processing cost
  In China A-shares: adverse selection accounts for 60-70% (mixture of retail and informed traders)

Spread drivers:
  - Larger market cap -> smaller spread (Moutai 0.03% vs small-cap 0.5%)
  - Higher volatility -> wider spread (market-maker risk premium)
  - Higher volume -> narrower spread (greater competition)
  - Higher information asymmetry -> wider spread (adverse selection)

Order-Flow Toxicity Metrics

VPIN (Volume-Synchronized Probability of Informed Trading):

Principle: replace clock time with volume time to measure the probability of informed trading

Calculation steps:
  1. Bucket trades by fixed volume (Volume Bucket)
     Bucket size V = average daily volume / 50 (about 5-10 minutes per bucket)

  2. Classify buy and sell volume in each bucket (Bulk Volume Classification):
     buy_volume = V × Φ(ΔP / σ)  (standard normal CDF)
     sell_volume = V - buy_volume

  3. Compute order-flow imbalance:
     OI_i = |buy_volume_i - sell_volume_i|

  4. VPIN = Σ(OI_i) / (n × V)  (n=50-bucket rolling window)

Interpretation:
  VPIN < 0.3 -> normal, low informed-trading share
  VPIN 0.3-0.5 -> caution, informed trading rising
  VPIN > 0.5 -> dangerous, high probability that major information is about to be released

China A-share usage:
  A sudden VPIN spike in a stock may foreshadow:
  - insider trading ahead of a major announcement
  - institutional position building / distribution
  Before the 2015 China A-share flash crashes, VPIN stayed above 0.6 for a prolonged period

Read the full file on GitHub · 308 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 308 lines · 55 tokens per session scan A 35dbbb3a9a53

Subscribe to this mod's changes

market-microstructure is a skill published in the GitHub repository HKUDS/Vibe-Trading (33,177 stars, last pushed today), licensed MIT. It adds 55 tokens to every session and 3,257 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

hyperliquid

Use when backtesting, deploying, checking funding readiness, or debugging a Hyperliquid strategy through Superior Trade Unified API — writing Freqtrade configs and strategy code, running sweeps, checking managed-wallet balances, trading HIP-3 perps, or diagnosing a deployment that will not start or trade.

Superior-Trade/superior-skills · 64 tokens

polymarket

Use when the user wants to trade, research, or backtest Polymarket prediction markets through Superior Trade — finding markets by slug or event URL, placing a single immediate market order, writing NautilusTrader strategies, running filled-data backtests, funding pUSD, or deploying and monitoring a live Polymarket…

Superior-Trade/superior-skills · 68 tokens

backtesting

Use when running, interpreting, or designing backtests on Superior Trade — anything about backtest windows, trade-count thresholds, exit-reason mix, parameter sweeps, walk-forward validation, zero-trade diagnosis, compute-cost estimation, or "is this backtest result trustworthy?". Pair with the relevant strategy…

Superior-Trade/superior-skills · 73 tokens

basis-arb

Use when the user asks for spot-perp basis trade, basis arbitrage, cash-and-carry, perp discount, or any setup that reads the spot–perp basis as a positioning signal. Long-perp leg only — pure two-leg basis arb requires a paired spot short (or long) which Freqtrade can't run cleanly. The strategy below captures the…

Superior-Trade/superior-skills · 87 tokens

fees-optimizations

Use when the user asks about fees, fee optimization, slippage, maker vs taker, post-only or ALO orders, fee tiers, builder code fees, effective spread, order pricing, lowering trading costs, or why a live Hyperliquid Freqtrade strategy underperforms its backtest. Also use proactively for high-turnover designs (5m or…

Superior-Trade/superior-skills · 94 tokens

aerodrome

Use when creating, validating, backtesting, deploying, sizing, or troubleshooting Aerodrome/Base spot trading strategies through the Superior Trade API, especially Freqtrade configs using exchange.name "aerodrome", AERO/USDC or CHECK/USDC pairs, AMM market swaps, wallet/gas balance checks, no-orderbook pricing, or…

Superior-Trade/superior-skills · 83 tokens