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
394kGoogle Placesを使って、場所を検索し、詳細や口コミを取得し、場所の名前を解決するようエージェントを支援します。スクリプト用にJSON出力もできます。