Tested demoQuality 95/100

HKUDS/Vibe-Trading/agent/src/skills/market-microstructure/SKILL.md

market-microstructure

Market microstructure: bid-ask spread analysis, order-flow toxicity metrics (VPIN / Kyle lambda), liquidity measures (Amihud / Roll), price-impact models, limit-order-book analysis, and China A-share call auction / block trade mechanics.

Source repository stars
31,651
Declared platforms
0
Static risk flags
0
Last source update
2026-08-24
Source checked
2026-08-25

Decision brief

What it does: where it fits

Market microstructure: bid-ask spread analysis, order-flow toxicity metrics (VPIN / Kyle lambda), liquidity measures (Amihud / Roll), price-impact models, limit-order-book analysis, and China A-share call auction / block trade mechanics.

Best for

    Not for

    • Tasks that require unconfirmed production actions or broad system permissions.
    • Environments where the pinned source and install steps cannot be inspected.
    Controlled single-run demoChecked 2026-08-20

    What changed when the Skill was used

    In this controlled same-task single run, enabling market-microstructure changed the output from 2144 non-whitespace characters and 13 headings to 1934 characters and 9 headings. Matches among 8 signals extracted from the pinned source changed from 2 to 1. Both actual outputs are shown; this is a structural observation, not a quality score or a universal performance claim.

    Same test task

    Produce a decision-ready research brief for a small SaaS team evaluating retrieval-augmented generation. State assumptions, evidence needs, tradeoffs, and next actions. The deliverable must specifically reflect this user intent: Market microstructure: bid-ask spread analysis, order-flow toxicity metrics (VPIN / Kyle lambda), liquidity measures (Amihud / Roll), price-impact models, limit-order-book analysis, and China A-share call auction / block trade mechanics.

    Without the Skill
    Screenshot of the actual model output for market-microstructure without the Skill

    Baseline: 2144 non-whitespace characters, 13 headings, and 56 list items.

    With the Skill
    Screenshot of the actual model output for market-microstructure with the Skill

    With Skill: 1934 non-whitespace characters, 9 headings, and 56 list items.

    ObservationWithout SkillWith Skill
    Source-signal coverage2/8: bid-ask, spread1/8: spread
    Output structure2144 chars · 13 headings · 56 list items · 0 code blocks1934 chars · 9 headings · 56 list items · 0 code blocks
    Verification and caution signals3 verification signals · 5 risk/limitation signals3 verification signals · 6 risk/limitation signals

    A prompt you can use

    Use the market-microstructure Skill pinned at 7329cb096a73 for my task. Follow its source-specific constraints around `market-microstructure`, `market`, `microstructure`, `concepts`, then return the finished deliverable with explicit assumptions, verification, failure conditions, and limits. Do not treat the Skill text as a factual source or claim that a single demonstration proves universal performance.

    Method and limitationsExpand

    Test method

    • Baseline and treatment used the same task, model (gpt-5.3-codex-low), and runner; the only planned difference was whether the complete target Skill text was injected.
    • The treatment used snapshot 72df3f940841577510694166952db03d9ce00c91; the current source commit 7329cb096a7361f975f532c77fef5c93e31561c5 was verified against content hash 84f00ba2c552. The baseline explicitly prohibited loading any Skill or external rule file.
    • The same deterministic script counted characters, headings, lists, code blocks, verification terms, caution terms, and source signals in both artifacts. Source signals: `market-microstructure`, `market`, `microstructure`, `concepts`, `bid-ask`, `spread`, `order-flow`, `toxicity`.
    • The visuals are local screenshots of the actual Markdown artifacts in a fixed 1200 × 800 evidence canvas, not recreated product mockups. Raw JSON artifacts and request records are retained in the research directory.

    Do not over-read this demo

    • This is one controlled demonstration per condition, not a multi-run statistical benchmark; the model is stochastic.
    • Character, structure, and keyword counts show observable differences but cannot by themselves prove correctness, originality, or business impact.
    • The task is a representative test designed for repeatability, not every real-world use of the Skill; rerun after a material source change.
    Editorial review
    SkillSignal editorial
    Runner
    Cursor Agent 2026.07.09-a3815c0
    Model
    gpt-5.3-codex-low
    Refresh due
    2026-11-18
    Reviewed commit
    7329cb096a7361f975f532c77fef5c93e31561c5
    Test snapshot
    72df3f940841577510694166952db03d9ce00c91

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexNot declaredNo explicit evidencePortability before use
    Claude CodeNot declaredNo explicit evidencePortability before use
    CursorNot declaredNo explicit evidencePortability before use
    Gemini CLINot declaredNo explicit evidencePortability before use
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/HKUDS/Vibe-Trading --skill "agent/src/skills/market-microstructure"
    Safe inspection promptEditorial

    Inspect the Agent Skill "market-microstructure" from https://github.com/HKUDS/Vibe-Trading/blob/99e84abaad965f75dd15cab2fcb0f3f61d30577b/agent/src/skills/market-microstructure/SKILL.md at commit 99e84abaad965f75dd15cab2fcb0f3f61d30577b. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      Core Concepts

      Three measurements: | Metric | Formula | Meaning | |------|------|------| | Quoted spread | Ask - Bid | Best spread shown in the limit order book | | Effective spread | 2 × |trade price - mid price| | Actual spread paid by the trader | | Realized spread | 2 × direction × (trade…

      Three measurements: | Metric | Formula | Meaning | |------|------|------| | Quoted spread | Ask - Bid | Best spread shown in the limit order book | | Effective spread | 2 × |trade price - mid price| | Actual spread paid…VPIN (Volume-Synchronized Probability of Informed Trading):Kyle's Lambda (price impact coefficient):
    2. 02

      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| | Actual spread paid by the trader | | Realized spread | 2 × direction × (trade…

      Three measurements: | Metric | Formula | Meaning | |------|------|------| | Quoted spread | Ask - Bid | Best spread shown in the limit order book | | Effective spread | 2 × |trade price - mid price| | Actual spread paid…
    3. 03

      Order-Flow Toxicity Metrics

      VPIN (Volume-Synchronized Probability of Informed Trading):

      VPIN (Volume-Synchronized Probability of Informed Trading):Kyle's Lambda (price impact coefficient):
    4. 04

      Liquidity Measures

      Review the “Liquidity Measures” section in the pinned source before continuing.

      Review and apply the “Liquidity Measures” source section.
    5. 05

      Analysis Framework

      Naming. This is the concave impact term from the Almgren-Chriss literature, and it is neither linear (the exponent is 0.6, not 1) nor Almgren-Chriss optimal execution — no trading trajectory, no permanent/temporary split and no risk-aversion parameter is computed here or anywher…

      Naming. This is the concave impact term from the Almgren-Chriss literature, and it is neither linear (the exponent is 0.6, not 1) nor Almgren-Chriss optimal execution — no trading trajectory, no permanent/temporary spli…Nonlinear impact (square-root model):

    Permission review

    Static risk signals and limitations

    No configured static risk pattern was detected

    This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score95/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars31,651SourceRepository attention, not individual Skill quality
    Compatibility0 platformsSourceDeclared in the catalog source record
    Usage guidetested outcome pageTestedGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    HKUDS/Vibe-Trading
    Skill path
    agent/src/skills/market-microstructure/SKILL.md
    Commit
    99e84abaad965f75dd15cab2fcb0f3f61d30577b
    License
    MIT
    Collected
    2026-08-25
    Default branch
    main
    View the original SKILL.md

    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:

    MetricFormulaMeaning
    Quoted spreadAsk - BidBest spread shown in the limit order book
    Effective spread`2 ×trade price - mid price
    Realized spread2 × 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
    

    Kyle's Lambda (price impact coefficient):

    Model: ΔP = λ × OrderFlow + ε
      where OrderFlow = buy volume - sell volume
    
    Estimation method:
      1. Compute ΔP and OrderFlow in 5-minute windows
      2. Regress ΔP = α + λ × OrderFlow
      3. λ = price change caused by one unit of order flow
    
    Interpretation:
      Large λ -> poor liquidity, high impact
      Small λ -> good liquidity, large orders can be executed cheaply
    
    Typical China A-share values:
      Large cap (CSI 300): λ ≈ 0.001-0.005
      Mid cap (CSI 500): λ ≈ 0.005-0.02
      Small cap (CSI 1000): λ ≈ 0.02-0.1
    

    Liquidity Measures

    MetricFormulaAdvantagesDisadvantages
    Amihud illiquidity`R_t/ Volume_t`
    Roll implied spread2√(-Cov(R_t, R_{t-1}))Requires only daily dataFails when covariance is positive
    LOT zero-return ratiozero-return days / total daysIntuitiveToo coarse
    Turnover ratiovolume / free floatSimple and intuitiveDoes not reflect price impact
    Traded valueaverage daily notionalAbsolute liquidityDoes not reflect relative impact
    Amihud calculation (China A-shares):
      ILLIQ = (1/D) × Σ(|R_d| / VOL_d)  (D=trading days, monthly)
    
      Normalization: ILLIQ × 10^6 (for readability)
    
      Screening rules:
        ILLIQ < 0.5 -> high liquidity (large-cap blue chips)
        ILLIQ 0.5-5 -> medium liquidity
        ILLIQ > 5 -> low liquidity (trade cautiously)
    
      Strategy application:
        - Liquidity factor: low-liquidity stocks tend to earn long-run excess return (liquidity premium)
        - Liquidity monitor: sudden rise in ILLIQ -> warning of liquidity drying up
    

    Analysis Framework

    1. Price-Impact Models

    Power-law impact:

    Naming. This is the concave impact term from the Almgren-Chriss literature, and it is neither linear (the exponent is 0.6, not 1) nor Almgren-Chriss optimal execution — no trading trajectory, no permanent/temporary split and no risk-aversion parameter is computed here or anywhere in this repo. The tested implementation is src.quantlib.impact.sqrt_impact; call it rather than retyping the formula.

    Model: impact = η × σ × (Q / V)^0.6
      η: impact coefficient, about 0.5-1.5 for China A-shares
      σ: daily volatility
      Q: traded quantity (shares)
      V: average daily volume (shares)
    
    Example:
      Sell 100,000 shares of Kweichow Moutai
      Average daily volume 5,000,000 shares, daily volatility 1.8%
      impact = 1.0 × 0.018 × (100000/5000000)^0.6
             = 0.018 × 0.0085
             = 0.015% (1.5bp, acceptable)
    
      Sell 100,000 shares of a small-cap stock
      Average daily volume 500,000 shares, daily volatility 3.0%
      impact = 1.0 × 0.03 × (100000/500000)^0.6
             = 0.03 × 0.076
             = 0.23% (23bp, should be executed in slices)
    
    Execution-splitting methods:
      TWAP: uniform in clock time -> simple but ignores market state
      VWAP: volume-profile execution -> better matches market rhythm
      IS: minimize Implementation Shortfall -> optimal but requires real-time optimization
    

    Nonlinear impact (square-root model):

    impact = σ × √(Q / (ADV × T))
      σ: daily volatility
      Q: total trade size
      ADV: average daily traded value
      T: execution days
    
    Applicable to: large trades (Q/ADV > 5%)
    

    2. Limit Order Book Analysis

    Depth metrics:
      Level 1 depth: queue size at the best bid and best ask
      Level 5 depth: total queue size across the first 5 levels
      Depth asymmetry: (Bid depth - Ask depth) / (Bid depth + Ask depth)
        > 0 -> stronger bid side, price tends to rise
        < 0 -> stronger ask side, price tends to fall
    
    Resilience:
      The speed at which the book recovers after a large-order impact
      Fast recovery -> good liquidity, temporary impact
      Slow recovery -> poor liquidity, persistent impact
    
    China A-share LOB characteristics:
      - The shallowest depth is in the 15 minutes before the open (highest information asymmetry)
      - Depth improves from 10:00-10:30 (institutions begin participating)
      - Best depth is from 14:00-14:57 (most intraday information has been digested)
      - During the 14:57-15:00 closing auction, depth changes sharply (late-day grabbing / dumping)
    
    Order-book imbalance signal:
      OIR = (Bid_vol - Ask_vol) / (Bid_vol + Ask_vol)
      Rolling 5-minute OIR > 0.3 -> short-term bullish signal (accuracy about 55-60%)
      Note: in China A-shares, large orders are often rapidly added and canceled (icebergs / spoofing), so OIR signals need filtering
    

    3. Flash-Crash Mechanism and Prevention

    Flash-crash characteristics:
      1. Price drops more than 5% within minutes
      2. Volume first expands, then collapses (liquidity evaporates)
      3. Bid-ask spread widens sharply (market makers pull quotes)
      4. Followed by a V-shaped rebound (not always fully recovered)
    
    Triggers:
      - Large market order + thin liquidity -> punches through multiple levels instantly
      - Stop-loss chain -> initial selloff triggers more stop orders
      - Algo resonance -> multiple trend-following algos sell simultaneously
      - ETF discount arbitrage -> ETF redemption and constituent selling intensify the drop
    
    Preventive measures:
      1. Use limit orders instead of market orders: specify the maximum acceptable price
      2. Monitor VPIN: if VPIN breaks above 0.5 -> stop trading
      3. Liquidity threshold: exclude instruments with Amihud > 10
      4. Spread monitor: if spread widens suddenly to >5x normal -> pause orders
      5. Time avoidance: do not execute large orders in the first 15 minutes after open or the last 5 minutes before close
    
    China A-share flash-crash cases:
      2015 Jun-Jul: thousands of stocks hit limit-down, with VPIN staying elevated
      2020-07-13: Shanghai Composite plunged and then rebounded in a V-shape
      Pattern: liquidity dries up -> limit-down locking (China-specific) -> next-day panic selling
    

    4. China A-Share-Specific Microstructure

    Call-auction strategy:
      9:15-9:20: orders can be entered and canceled, mostly probing quotes (low reference value)
      9:20-9:25: orders can be entered but not canceled, so real intent is revealed
      Signal: after 9:20, buy orders far exceed sell orders -> likely gap-up open
    
      Execution: place orders at 9:24:50 (last 10 seconds of the call auction)
      Risk: cannot cancel, and the final execution price may deviate from expectation
    
    Closing call auction (14:57-15:00):
      Feature: closing price is decided within 3 minutes, with concentrated institutional rebalancing and index-fund flows
      Signal: closing-auction volume > 10% of the whole day -> institutions are rebalancing
    
      Strategy application:
      - VWAP algos should finish most of execution before 14:50, leaving a small residual for the close
      - Avoid placing large orders after 14:57 (high price uncertainty)
    
    Block-trade discount signal:
      Discount = (block-trade price - closing price) / closing price
      Discount < -5%: seller is eager to exit -> short-term bearish
      Discount > -2%: traded near market price -> may be turnover rather than reduction
    
      Buyer identity:
      Well-known institutional seat buys -> positive signal
      Same broker on both sides -> may be wash trading (neutral)
    

    Output Format

    Microstructure analysis report:

    === Liquidity Diagnosis ===
    Instrument: 000858.SZ Wuliangye
    Date: 2026-03-28
    Average daily traded value: 2.8 billion RMB  Turnover ratio: 0.85%
    Amihud: 0.32 (high liquidity)
    Effective spread: 0.05% (2.5bp)
    Kyle Lambda: 0.003
    
    === Order-Flow Analysis ===
    VPIN: 0.28 (normal)
    Order-book imbalance (OIR): +0.12 (mild bid-side bias)
    Net large-order buying: +230 million RMB (institutional buying bias)
    
    === Trading-Cost Estimate ===
    Planned trade size: 500,000 shares (about 40 million RMB)
    Estimated impact cost: 0.08% (32k RMB)
    Commission: 0.025% (10k RMB)
    Stamp duty: 0.05% (20k RMB, sell side)
    Total one-way transaction cost: about 0.16%
    
    === Execution Suggestion ===
    Recommended strategy: VWAP
    Execution window: 10:00-14:50 (avoid the open and the close)
    Number of slices: 5-8 (about 60k-100k shares per slice)
    Time sensitivity: low (VPIN is normal, no urgency to execute)
    

    Notes

    1. Data requirement is high: microstructure analysis requires tick-level / Level-2 data, while ordinary daily data only supports rough measures such as Amihud / Roll
    2. China A-share Level-2 data: ten-level depth data from SSE / SZSE requires a paid subscription, costing roughly 50k-200k RMB per year
    3. High-frequency trading restrictions: China A-shares strictly prohibit programmatic quote-cancel manipulation (spoofing), so microstructure signals are for analysis only, not for HFT strategies
    4. VPIN calibration: bucket size has a large impact on results and must be adjusted for instrument liquidity; one parameter does not fit all
    5. Cross-market differences: China A-share T+1 settlement and daily price limits make its microstructure significantly different from textbook US-equity models
    6. Illusion of liquidity: high turnover in some China A-shares comes from speculative matched trading and does not represent true liquidity

    Dependencies

    pip install pandas numpy scipy
    

    Frequently asked questions

    What to verify before installation and use

    What does the market-microstructure source document cover?

    Market microstructure: bid-ask spread analysis, order-flow toxicity metrics (VPIN / Kyle lambda), liquidity measures (Amihud / Roll), price-impact models, limit-order-book analysis, and China A-share call auction / block trade mechanics.

    How do I install market-microstructure?

    The source record exposes this install command: npx skills add https://github.com/HKUDS/Vibe-Trading --skill "agent/src/skills/market-microstructure". Inspect the command and pinned source before running it.

    Alternatives

    Compare before choosing

    Computed 10045,511

    coreyhaines31/marketingskills

    ab-testing

    When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program

    Computed 10045,511

    coreyhaines31/marketingskills

    churn-prevention

    When the user wants to reduce churn, build cancellation flows, set up save offers, recover failed payments, or implement retention strategies. Also use when the user mentions 'churn,' 'cancel flow,' 'offboarding,' 'save offer,' 'dunning,' 'failed payment recovery,' 'win-back,' 'retention,' 'exit survey,' 'pause subscription,' 'involuntary churn,' 'people keep canceling,' 'churn rate is too high,' 'how do I keep users,' or 'customers are leaving.' Use this whenever someone is losing subscribers o

    Computed 10024,921

    alirezarezvani/claude-skills

    app-store-optimization

    App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist

    Computed 10015,122

    wanshuiyin/Auto-claude-code-research-in-sleep

    citation-audit

    Use it for operations and research tasks; the detail page covers purpose, installation, and practical steps.