market-microstructure
하는 일
이 스킬은 호가창에서 가격이 어떻게 형성되는지 설명합니다. 스프레드, 주문 흐름, 유동성을 다룹니다. 거래 비용을 줄이거나 대량 주문의 시기를 잘 잡으려는 트레이더를 위한 스킬입니다.
사용하는 경우
- ✓고정 수수료가 아니라 실제 거래 비용을 현실적으로 추정하고 싶을 때.
- ✓큰 포지션을 사거나 팔 계획이며 가격 영향을 줄이고 싶을 때.
- ✓전략에 맞을 만큼 종목의 유동성이 충분한지 확인하고 싶은 경우.
스킬 링크
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/market-microstructure/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 주식을 가격을 움직이지 않고 5만 주 사려면 실제로 비용이 얼마나 드나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 매수가와 매도가 사이의 차이, 그리고 체결이 가격을 어떻게 밀어내는지 측정합니다. 또한 유동성 지표와 호가창 데이터를 사용해 주문의 규모와 시점을 정합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
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
| Metric | Formula | Advantages | Disadvantages |
|---|---|---|---|
| Amihud illiquidity | ` | R_t | / Volume_t` |
| Roll implied spread | 2√(-Cov(R_t, R_{t-1})) |
Requires only daily data | Fails when covariance is positive |
| LOT zero-return ratio | zero-return days / total days | Intuitive | Too coarse |
| Turnover ratio | volume / free float | Simple and intuitive | Does not reflect price impact |
| Traded value | average daily notional | Absolute liquidity | Does 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
자주 묻는 질문
매수와 매도 호가 차이란 무엇인가요?
매수자가 제시하는 가장 높은 가격과 매도자가 요구하는 가장 낮은 가격 사이의 차이입니다.
중국 A주도 다루나요?
네. 중국 A주의 동시호가, 마감 동시호가, 블록 거래를 포함합니다.
VPIN은 무엇인가요?
주문 흐름의 독성을 측정하는 지표로, 거래의 얼마나 많은 부분이 정보를 가진 트레이더에게서 나올 수 있는지 보여 줍니다.
상세 정보
작성자의 원본 설명
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.
repo: HKUDS/Vibe-Trading
인기도
- GitHub 스타
- 37k
- 순위
- #7531
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
vibe-trading
37k에이전트에게 백테스트, 팩터 분석, 옵션 가격 결정, 여러 시장의 시장 데이터를 포함하는 완전한 금융 연구 도구 모음을 제공합니다.
adr-hshare
37k에이전트에게 미국 ADR과 홍콩 주식처럼 여러 시장에 상장된 중국 기업의 가격을 비교하는 방법을 보여 줍니다.
akshare
37k에이전트가 API 키 없이 중국과 해외 주식, 선물, 외환, 경제 지표의 무료 시장 데이터를 가져오도록 돕습니다.
alpha-zoo
37k에이전트가 만들어진 주식 팩터 라이브러리를 둘러보고, 선택한 시장에서 팩터 묶음이 수익률을 얼마나 잘 예측하는지 시험하도록 돕습니다.
비슷한 스킬
gitcrawl
394k에이전트가 저장된 GitHub 이슈와 풀 리퀘스트 보관본을 검색하고, 중복 항목을 묶고, GitHub에서 현재 상태를 확인하도록 돕습니다.
slacrawl
394k에이전트가 로컬 Slack 보관본에서 메시지를 검색하고 개수를 세며, 보관본이 얼마나 최신인지 확인하고 필요할 때 새로 고치도록 돕습니다.
goplaces
394k에이전트가 Google Places로 장소를 검색하고, 세부 정보와 리뷰를 가져오고, 장소 이름을 확인하며, 스크립트용 JSON을 출력하도록 돕습니다.