agiprolabs/claude-trading-skills/market-microstructure-traditional
Claude Code and agent skill by agiprolabs/claude-trading-skills
- community
Checking that the SKILL.md file is still in the repository.
Traditional market microstructure concepts applied to crypto — order book dynamics, market making theory, price formation models, execution quality measurement, and CEX vs DEX structural differences
Install
npx vskill@latest install agiprolabs/claude-trading-skills/market-microstructure-traditionalSKILL.md
Market Microstructure (Traditional)
Market microstructure studies how orders become trades and how trades become prices. Understanding these mechanics is essential for execution optimization, market making, and detecting informed flow. This skill covers limit order book (LOB) theory as applied to crypto markets on centralized exchanges, and compares LOB mechanics to the AMM-based structure of DEXes.
Core Concepts
| Concept | What It Tells You | |
|---|---|---|
| Bid-ask spread | Cost of immediacy — how much you pay to trade now vs later | |
| Price impact | How your order moves the market price | |
| Order book imbalance | Short-term directional predictor from queue sizes | |
| Adverse selection | Risk of trading against informed counterparties | |
| Inventory risk | Market maker exposure from accumulated positions | |
| Execution quality | How well your fills compare to a benchmark |
Bid-Ask Spread Decomposition
The bid-ask spread is not a single thing. It decomposes into three components (Roll, 1984; Glosten & Harris, 1988):
- Adverse selection — compensation for trading against informed traders
- Inventory holding — compensation for carrying risk
- Order processing — fixed costs of providing liquidity (fees, infrastructure)
Spread Measures
The effective spread matters most for execution quality. The difference between effective and realized spread measures adverse selection — what the market maker loses to informed flow.
Price Formation Models
Glosten-Milgrom (1985)
A sequential trade model where the market maker sets bid and ask prices to break even against a mix of informed and uninformed traders.
- Market maker quotes reflect expected value conditional on trade direction
- Spread exists purely due to adverse selection
- Prices converge to true value as information is revealed through trades
Key insight: the spread is wider when:
- Probability of informed trading (PIN) is higher
- Information asymmetry is larger
- Uninformed trading volume is lower
Kyle's Lambda (1985)
Kyle models a single informed trader, noise traders, and a market maker. The market maker sets price as a linear function of net order flow:
Lambda (λ) measures permanent price impact per unit of signed volume. Higher lambda = less liquid market. Lambda is estimated by regressing price changes on signed volume:
See references/price_formation.md for full model derivations and the PIN model for measuring informed trading probability.
Price Impact Models
Temporary vs Permanent Impact (Almgren-Chriss)
When executing a large order:
- Temporary impact — price displacement that reverts after your order.
Caused by consuming standing liquidity.
- Permanent impact — information content of your trade that moves the
equilibrium price. Does not revert.
Typical alpha values: 0.5-0.7 (square root impact is a robust empirical finding).
Square Root Impact Law
Empirically, price impact scales as the square root of order size relative to daily volume:
Order Book Imbalance
The ratio of bid-side to ask-side depth near the top of the book predicts short-term price direction:
Imbalance at levels 1-5 is a strong short-term predictor (Cont et al., 2014). Deeper levels add predictive power but decay quickly.
Trade Arrival Processes
Poisson Process
Simplest model: trades arrive at a constant rate λ. Inter-arrival times are exponentially distributed. Useful as a baseline but too simple for real order flow.
Hawkes Process
Self-exciting point process where each trade increases the probability of subsequent trades. Captures clustering in order flow:
- mu: baseline arrival rate
- alpha: excitation magnitude (how much each event boosts intensity)
- beta: decay rate (how fast excitation fades)
- alpha/beta < 1: stationarity condition (branching ratio)
The branching ratio α/β measures the fraction of trades that are reactions rather than innovations. Typical values: 0.5-0.8 in crypto markets (high reactivity).
Market Maker Economics
A market maker profits from the spread but faces three risks:
- Adverse selection — losing to informed traders
- Inventory risk — accumulated directional exposure
- Competition — other MMs narrowing the spread
Avellaneda-Stoikov Model
The optimal bid and ask quotes for a market maker with inventory q:
Where:
q: current inventory (positive = long)gamma: risk aversion parametersigma: volatilityT: time remainingk: order arrival rate parameter
Key insight: the reservation price skews away from inventory — a long market maker lowers their price to encourage sells.
Execution Quality Measurement
VWAP Benchmark
Volume-Weighted Average Price is the standard benchmark for passive execution:
Implementation Shortfall
Measures total cost of executing vs the decision price (Perold, 1988):
Decomposes into:
- Delay cost: price drift between decision and first fill
- Market impact: price move caused by your order
- Timing cost: cost of breaking the order into slices
- Opportunity cost: value of unfilled portions
See references/execution_quality.md for complete methodology.
CEX Order Book vs DEX AMM
| Dimension | CEX (LOB) | DEX (AMM) | |
|---|---|---|---|
| Price discovery | Limit orders express willingness to trade | Algorithmic curve (x·y=k) | |
| Spread | Set by competing market makers | Determined by pool depth and fee tier | |
| Depth | Visible order book | Implicit from TVL and curve shape | |
| Adverse selection | MMs reprice on information | LPs suffer impermanent loss | |
| Execution | Price-time priority | First-come via block inclusion | |
| Latency | Microseconds | Block time (400ms Solana, 12s Ethereum) | |
| MEV | Front-running is harder (colocated MMs) | Sandwich attacks are endemic | |
| Fees | Maker/taker (often maker rebate) | Fixed tier (e.g., 5, 30, 100 bps) |
When to use CEX: large orders, latency-sensitive strategies, tight spreads needed, BTC/ETH/major pairs.
When to use DEX: long-tail tokens, censorship resistance, composability with DeFi, transparent execution.
See references/cex_vs_dex.md for detailed structural comparison.
Maker/Taker Fee Structures
CEX fee tiers create incentive asymmetries:
| Tier | Maker Fee | Taker Fee | Net Spread Required | |
|---|---|---|---|---|
| VIP 0 | 0.10% | 0.10% | 20 bps to break even | |
| VIP 5 | 0.02% | 0.05% | 7 bps to break even | |
| VIP 9 | -0.005% | 0.03% | 2.5 bps + rebate income |
At high tiers, maker rebates mean market makers are paid to provide liquidity. This fundamentally changes strategy economics:
Files
References
references/price_formation.md— Glosten-Milgrom, Kyle model, PIN model, spread decompositionreferences/execution_quality.md— VWAP, TWAP, implementation shortfall, slippage decompositionreferences/cex_vs_dex.md— Structural comparison of LOB vs AMM, hybrid models, routing decisions
Scripts
scripts/spread_analysis.py— Analyze bid-ask spreads, compute effective/realized/quoted spread from trade data (--demo mode with synthetic order book)scripts/market_maker_sim.py— Market maker simulation with inventory management and P&L (--demo mode with synthetic price path)
Dependencies
Related Skills
- market-microstructure — On-chain DEX microstructure (AMM-specific)
- slippage-modeling — Execution cost estimation and modeling
- liquidity-analysis — Pool and order book depth analysis
- order-execution — Practical execution algorithms
- mev-analysis — MEV risk in on-chain execution
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/market-microstructure-traditional/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/agiprolabs/claude-trading-skills/market-microstructure-traditional)