market-microstructure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarket Microstructure — DEX Orderflow Analysis
市场微结构——DEX 订单流分析
Overview
概述
Market microstructure on Solana DEXes differs fundamentally from traditional finance.
There are no orderbooks on AMMs — every trade is a swap against a liquidity pool. Yet
trade flow analysis remains powerful: the sequence, size, and direction of swaps reveal
accumulation, distribution, whale activity, and wash trading patterns.
This skill covers:
- Trade classification — identifying buys vs sells from swap direction
- Volume profiles — time-based and size-based breakdowns
- Buyer/seller pressure — ratio metrics, net flow, trade count asymmetry
- Trade size distribution — whale detection, retail vs institutional flow
- Flow momentum signals — acceleration, volume spikes, composite scores
- Token velocity — turnover rate as a sentiment proxy
- Wash trading detection — spotting fake volume and bot patterns
Solana DEX 上的市场微结构与传统金融存在根本差异。
AMM 没有订单簿——每笔交易都是与流动性池进行的一次 swap。然而,
交易流分析依然十分强大:swap 的顺序、规模和方向能够揭示
吸筹、派发、鲸鱼活动以及洗售交易模式。
本 skill 涵盖:
- 交易分类——通过 swap 方向识别买入与卖出
- 成交量分布——按时间和规模拆分
- 买方/卖方压力——比率指标、净流量、交易笔数不对称
- 交易规模分布——鲸鱼检测、散户与机构资金流
- 资金流动量信号——加速、成交量骤增、综合评分
- 代币周转率——作为情绪代理指标
- 洗售交易检测——识别虚假成交量和机器人模式
Why Microstructure Matters on DEXes
微结构在 DEX 中的重要性
On CEXes, microstructure means orderbook depth, bid-ask spread, and queue position.
On AMMs, liquidity sits in pool curves — there is no spread or queue. But the trade
tape (the chronological list of swaps) contains rich signal:
- Who is trading? — Whale wallets vs retail, smart money vs bots
- How are they trading? — Large single swaps vs DCA-style splits
- When are they trading? — Volume clustering around events or time zones
- What direction? — Net buy vs sell pressure over sliding windows
These signals feed into entry/exit timing, position sizing, and token quality scoring.
在 CEX 上,微结构意味着订单簿深度、买卖价差和队列位置。
在 AMM 上,流动性位于池曲线中——没有价差或队列。但 交易记录(trade tape)(按时间顺序排列的 swap 列表)包含丰富的信号:
- 谁在交易?——鲸鱼钱包还是散户,聪明钱还是机器人
- 如何交易?——单笔大额 swap,还是 DCA 风格的拆分交易
- 何时交易?——围绕事件或时区的成交量聚集
- 方向如何?——滑动窗口内的净买入与净卖出压力
这些信号可用于把握进出场时机、仓位大小和代币质量评分。
Trade Classification
交易分类
Buy vs Sell Identification
买入与卖出识别
On Solana DEXes, every swap has an input token and output token:
| Swap Direction | Classification | Meaning |
|---|---|---|
| SOL → Token | Buy | Trader spending SOL to acquire token |
| USDC → Token | Buy | Trader spending stables to acquire token |
| Token → SOL | Sell | Trader converting token back to SOL |
| Token → USDC | Sell | Trader converting token to stables |
| Token A → Token B | Context-dependent | Classify based on which token you're analyzing |
在 Solana DEX 上,每笔 swap 都有一个输入代币和一个输出代币:
| Swap 方向 | 分类 | 含义 |
|---|---|---|
| SOL → Token | 买入 | 交易者花费 SOL 购入代币 |
| USDC → Token | 买入 | 交易者花费稳定币购入代币 |
| Token → SOL | 卖出 | 交易者将代币兑换回 SOL |
| Token → USDC | 卖出 | 交易者将代币兑换为稳定币 |
| Token A → Token B | 取决于上下文 | 根据正在分析的代币进行分类 |
From API Data Sources
来自 API 数据源
Birdeye Trade History ():
/defi/txs/token- Returns field:
sideor"buy""sell" - Includes (input token) and
from(output token) amountsto
DexScreener Pair Trades:
- Returns field indicating swap direction relative to the pair
type
Helius Parsed Transactions:
- Parse swap instructions to extract input/output mints and amounts
- Classify based on which mint matches your target token
See for detailed classification logic and size buckets.
references/trade_classification.mdBirdeye 交易历史():
/defi/txs/token- 返回 字段:
side或"buy""sell" - 包含 (输入代币)和
from(输出代币)金额to
DexScreener Pair Trades:
- 返回 字段,指示相对于交易对的 swap 方向
type
Helius 解析交易:
- 解析 swap 指令,提取输入/输出 mint 和金额
- 根据与目标代币匹配的 mint 进行分类
请参阅 了解详细的分类逻辑和规模区间。
references/trade_classification.mdVolume Profiles
成交量分布
Time-Based Profiles
基于时间的分布
Aggregate trade volume into fixed time buckets to identify patterns:
python
undefined将交易量汇总到固定时间桶中,以识别模式:
python
undefinedHourly volume profile
Hourly volume profile
hourly_volume = {}
for trade in trades:
hour = trade["timestamp"] // 3600 * 3600
hourly_volume.setdefault(hour, {"buy_vol": 0, "sell_vol": 0})
if trade["side"] == "buy":
hourly_volume[hour]["buy_vol"] += trade["volume_usd"]
else:
hourly_volume[hour]["sell_vol"] += trade["volume_usd"]
Key metrics from time profiles:
- **Peak hours** — when is the token most actively traded?
- **Volume trend** — is volume increasing, decreasing, or stable?
- **Volume anomalies** — spikes exceeding 3x the rolling averagehourly_volume = {}
for trade in trades:
hour = trade["timestamp"] // 3600 * 3600
hourly_volume.setdefault(hour, {"buy_vol": 0, "sell_vol": 0})
if trade["side"] == "buy":
hourly_volume[hour]["buy_vol"] += trade["volume_usd"]
else:
hourly_volume[hour]["sell_vol"] += trade["volume_usd"]
时间分布中的关键指标:
- **峰值时段**——该代币何时交易最活跃?
- **成交量趋势**——成交量是在增加、减少还是保持稳定?
- **成交量异常**——超过滚动平均值 3 倍的峰值Size-Based Profiles
基于规模的分布
Classify trades into size buckets to separate whale activity from retail:
| Bucket | SOL Range | Typical Actor |
|---|---|---|
| Micro | < 0.1 SOL | Dust / test trades |
| Small | 0.1 – 1 SOL | Retail traders |
| Medium | 1 – 10 SOL | Active traders |
| Large | 10 – 50 SOL | Serious positions |
| Whale | 50+ SOL | Whales / institutions |
将交易划分到不同规模区间,以区分鲸鱼活动与散户活动:
| 区间 | SOL 范围 | 典型参与者 |
|---|---|---|
| 微型 | < 0.1 SOL | 尘量/测试交易 |
| 小型 | 0.1–1 SOL | 散户交易者 |
| 中型 | 1–10 SOL | 活跃交易者 |
| 大型 | 10–50 SOL | 大额持仓 |
| 鲸鱼 | 50+ SOL | 鲸鱼/机构 |
Buyer/Seller Pressure Metrics
买方/卖方压力指标
Core Ratios
核心比率
python
def compute_pressure(trades: list[dict], period_seconds: int = 3600) -> dict:
"""Compute buy/sell pressure metrics over a time period."""
buy_vol = sum(t["volume_usd"] for t in trades if t["side"] == "buy")
sell_vol = sum(t["volume_usd"] for t in trades if t["side"] == "sell")
total_vol = buy_vol + sell_vol
buy_trades = sum(1 for t in trades if t["side"] == "buy")
sell_trades = sum(1 for t in trades if t["side"] == "sell")
total_trades = buy_trades + sell_trades
return {
"buy_sell_ratio": buy_vol / sell_vol if sell_vol > 0 else float("inf"),
"buy_volume_pct": buy_vol / total_vol if total_vol > 0 else 0.5,
"net_flow_usd": buy_vol - sell_vol,
"trade_count_ratio": buy_trades / total_trades if total_trades > 0 else 0.5,
}python
def compute_pressure(trades: list[dict], period_seconds: int = 3600) -> dict:
"""Compute buy/sell pressure metrics over a time period."""
buy_vol = sum(t["volume_usd"] for t in trades if t["side"] == "buy")
sell_vol = sum(t["volume_usd"] for t in trades if t["side"] == "sell")
total_vol = buy_vol + sell_vol
buy_trades = sum(1 for t in trades if t["side"] == "buy")
sell_trades = sum(1 for t in trades if t["side"] == "sell")
total_trades = buy_trades + sell_trades
return {
"buy_sell_ratio": buy_vol / sell_vol if sell_vol > 0 else float("inf"),
"buy_volume_pct": buy_vol / total_vol if total_vol > 0 else 0.5,
"net_flow_usd": buy_vol - sell_vol,
"trade_count_ratio": buy_trades / total_trades if total_trades > 0 else 0.5,
}Signal Interpretation
信号解读
| Metric | Bullish | Neutral | Bearish |
|---|---|---|---|
| Buy Volume % | > 60% | 40–60% | < 40% |
| Net Flow | Positive, increasing | Near zero | Negative, increasing |
| Trade Count Ratio | > 0.55 | 0.45–0.55 | < 0.45 |
| Large Trade Ratio | High buy-side | Balanced | High sell-side |
See for the full signal catalog and composite scoring.
references/flow_signals.md| 指标 | 看涨 | 中性 | 看跌 |
|---|---|---|---|
| 买入成交量占比 | > 60% | 40–60% | < 40% |
| 净流量 | 为正且持续增加 | 接近零 | 为负且持续加剧 |
| 交易笔数比率 | > 0.55 | 0.45–0.55 | < 0.45 |
| 大额交易比率 | 买方侧较高 | 均衡 | 卖方侧较高 |
请参阅 了解完整的信号目录和综合评分。
references/flow_signals.mdTrade Size Distribution
交易规模分布
Analyzing the distribution of trade sizes reveals market structure:
python
import statistics
def analyze_trade_sizes(trades: list[dict]) -> dict:
"""Analyze trade size distribution."""
sizes = [t["volume_usd"] for t in trades]
if not sizes:
return {}
return {
"mean": statistics.mean(sizes),
"median": statistics.median(sizes),
"stdev": statistics.stdev(sizes) if len(sizes) > 1 else 0,
"skew_indicator": statistics.mean(sizes) / statistics.median(sizes),
"max_trade": max(sizes),
"whale_pct": sum(s for s in sizes if s > 5000) / sum(sizes),
}Interpreting skew: A (mean/median) well above 1.0 indicates a
fat-tailed distribution — a few large trades dominate. This is normal for tokens with
whale interest but can also signal manipulation.
skew_indicator分析交易规模分布有助于揭示市场结构:
python
import statistics
def analyze_trade_sizes(trades: list[dict]) -> dict:
"""Analyze trade size distribution."""
sizes = [t["volume_usd"] for t in trades]
if not sizes:
return {}
return {
"mean": statistics.mean(sizes),
"median": statistics.median(sizes),
"stdev": statistics.stdev(sizes) if len(sizes) > 1 else 0,
"skew_indicator": statistics.mean(sizes) / statistics.median(sizes),
"max_trade": max(sizes),
"whale_pct": sum(s for s in sizes if s > 5000) / sum(sizes),
}**偏度解读:**显著高于 1.0 的 (均值/中位数)表明
其呈肥尾分布——少数大额交易占据主导。这对于受到鲸鱼关注的代币很常见,
但也可能预示操纵行为。
skew_indicatorMomentum Signals from Trade Flow
交易流中的动量信号
Volume Acceleration
成交量加速
Compare current period volume to the previous period:
python
acceleration = current_volume / previous_volume if previous_volume > 0 else 0- acceleration > 2.0 — volume surge, potential breakout or dump
- acceleration 0.8–1.2 — stable activity
- acceleration < 0.5 — dying interest
将当前周期成交量与上一周期进行比较:
python
acceleration = current_volume / previous_volume if previous_volume > 0 else 0- acceleration > 2.0——成交量激增,可能向上突破或抛售
- acceleration 0.8–1.2——活动保持稳定
- acceleration < 0.5——市场热度快速消退
Buy Pressure Acceleration
买方压力加速
Track how the buy ratio changes over time:
python
current_buy_ratio = current_buy_vol / current_total_vol
previous_buy_ratio = prev_buy_vol / prev_total_vol
buy_momentum = current_buy_ratio - previous_buy_ratioPositive with increasing volume is a strong accumulation signal.
buy_momentum追踪买方比率随时间的变化:
python
current_buy_ratio = current_buy_vol / current_total_vol
previous_buy_ratio = prev_buy_vol / prev_total_vol
buy_momentum = current_buy_ratio - previous_buy_ratiobuy_momentumToken Velocity
代币周转率
Token velocity measures how frequently tokens change hands:
python
velocity = daily_volume / circulating_supply| Velocity | Interpretation |
|---|---|
| < 0.01 | Low activity, illiquid, or strong holders |
| 0.01–0.05 | Normal trading activity |
| 0.05–0.20 | Active trading, possible speculation |
| > 0.20 | Very high turnover, potential wash trading |
High velocity combined with low unique trader count is a wash trading red flag.
代币周转率衡量代币易手的频率:
python
velocity = daily_volume / circulating_supply| 周转率 | 解读 |
|---|---|
| < 0.01 | 活跃度低、流动性不足,或筹码集中于少数大户 |
| 0.01–0.05 | 正常交易活动 |
| 0.05–0.20 | 交易活跃,可能存在投机 |
| > 0.20 | 周转率极高,可能存在洗售交易 |
高周转率与较低的唯一交易者数量结合,是洗售交易的危险信号。
Wash Trading Detection
洗售交易检测
Wash trading inflates volume to make a token appear more active than it truly is.
Key detection signals:
- Low unique trader ratio —
unique_wallets / trade_count < 0.3 - Volume/TVL anomaly — (volume vastly exceeds liquidity)
daily_volume / tvl > 10 - Uniform trade sizes — low entropy in trade size distribution
- Self-trading — same wallet on both sides within short windows
- Funded-together clusters — multiple wallets funded from the same source
See for detailed detection methods and scoring.
references/wash_trading.md洗售交易会虚增成交量,使代币看起来比实际更活跃。
主要检测信号:
- 唯一交易者比率偏低——
unique_wallets / trade_count < 0.3 - 成交量/TVL 异常——(成交量远超流动性)
daily_volume / tvl > 10 - 交易规模高度一致——交易规模分布熵值低
- 自成交——同一钱包在短时间内同时处于买卖双方
- 同源资助的钱包集群——多个钱包由同一资金来源资助
请参阅 了解详细的检测方法和评分。
references/wash_trading.mdData Sources
数据源
Birdeye API
Birdeye API
Primary source for trade history on Solana tokens:
- — recent trades for a token
GET /defi/txs/token - — candle data with volume
GET /defi/ohlcv - — aggregated volume data
GET /defi/price/volume
Requires API key. See the skill for endpoint details.
birdeye-apiSolana 代币交易历史的主要数据源:
- ——代币的近期交易
GET /defi/txs/token - ——包含成交量的蜡烛图数据
GET /defi/ohlcv - ——汇总成交量数据
GET /defi/price/volume
需要 API key。请参阅 skill 了解端点详情。
birdeye-apiDexScreener API
DexScreener API
Free, no-auth alternative for pair-level data:
- — token pairs with volume
GET /latest/dex/tokens/{address} - — pair details
GET /latest/dex/pairs/solana/{pairAddress}
无需认证的免费替代方案,可获取交易对级别数据:
- ——包含成交量的代币交易对
GET /latest/dex/tokens/{address} - ——交易对详情
GET /latest/dex/pairs/solana/{pairAddress}
Helius API
Helius API
For wallet-level trade analysis and parsed transactions:
- Parse swap transactions to extract trade details
- Attribute trades to specific wallets
- See the skill for transaction parsing.
helius-api
用于钱包级交易分析和解析交易:
- 解析 swap 交易以提取交易详情
- 将交易归因到特定钱包
- 有关交易解析,请参阅 skill。
helius-api
Composite Momentum Score
综合动量评分
Combine multiple flow signals into a single score (range: -100 to +100):
python
def compute_momentum_score(
buy_ratio: float,
volume_accel: float,
whale_buy_pct: float,
unique_trader_trend: float,
) -> float:
"""Compute composite momentum score from flow signals.
Args:
buy_ratio: Buy volume / total volume (0 to 1).
volume_accel: Current vol / previous vol.
whale_buy_pct: Whale buy volume / total whale volume (0 to 1).
unique_trader_trend: Change in unique traders vs previous period.
Returns:
Score from -100 (strong sell pressure) to +100 (strong buy pressure).
"""
# Buy ratio component: 0.5 = neutral, maps to [-40, +40]
buy_component = (buy_ratio - 0.5) * 80
# Volume acceleration: >1 = growing, maps to [-20, +20]
vol_component = min(max((volume_accel - 1.0) * 20, -20), 20)
# Whale direction: 0.5 = neutral, maps to [-25, +25]
whale_component = (whale_buy_pct - 0.5) * 50
# Unique trader growth: positive = healthy, maps to [-15, +15]
trader_component = min(max(unique_trader_trend * 15, -15), 15)
score = buy_component + vol_component + whale_component + trader_component
return max(-100, min(100, score))| Score Range | Interpretation |
|---|---|
| +60 to +100 | Strong accumulation — heavy buy pressure |
| +20 to +60 | Moderate buying — cautious accumulation |
| -20 to +20 | Neutral / balanced flow |
| -60 to -20 | Moderate selling — distribution underway |
| -100 to -60 | Strong distribution — heavy sell pressure |
将多个资金流信号合并为单一评分(范围:-100 至 +100):
python
def compute_momentum_score(
buy_ratio: float,
volume_accel: float,
whale_buy_pct: float,
unique_trader_trend: float,
) -> float:
"""Compute composite momentum score from flow signals.
Args:
buy_ratio: Buy volume / total volume (0 to 1).
volume_accel: Current vol / previous vol.
whale_buy_pct: Whale buy volume / total whale volume (0 to 1).
unique_trader_trend: Change in unique traders vs previous period.
Returns:
Score from -100 (strong sell pressure) to +100 (strong buy pressure).
"""
# Buy ratio component: 0.5 = neutral, maps to [-40, +40]
buy_component = (buy_ratio - 0.5) * 80
# Volume acceleration: >1 = growing, maps to [-20, +20]
vol_component = min(max((volume_accel - 1.0) * 20, -20), 20)
# Whale direction: 0.5 = neutral, maps to [-25, +25]
whale_component = (whale_buy_pct - 0.5) * 50
# Unique trader growth: positive = healthy, maps to [-15, +15]
trader_component = min(max(unique_trader_trend * 15, -15), 15)
score = buy_component + vol_component + whale_component + trader_component
return max(-100, min(100, score))| 评分范围 | 解读 |
|---|---|
| +60 至 +100 | 强烈吸筹——沉重的买方压力 |
| +20 至 +60 | 适度买入——谨慎吸筹 |
| -20 至 +20 | 中性/均衡资金流 |
| -60 至 -20 | 适度卖出——派发进行中 |
| -100 至 -60 | 强烈派发——沉重的卖方压力 |
Integration with Other Skills
与其他 Skill 的集成
| Skill | How It Connects |
|---|---|
| Primary data source for trade history and volume |
| Wallet-attributed trade data from parsed transactions |
| Volume/TVL ratios, liquidity context for flow signals |
| Identify whale wallets for large trade attribution |
| Supply distribution context for velocity metrics |
| Use flow signals to adjust entry sizing |
| Combine flow momentum with regime classification |
| Skill | 集成方式 |
|---|---|
| 交易历史和成交量的主要数据源 |
| 从解析交易中获取可归因到钱包的交易数据 |
| 为资金流信号提供成交量/TVL 比率和流动性背景 |
| 识别鲸鱼钱包,用于大额交易归因 |
| 为周转率指标提供供应分布背景 |
| 使用资金流信号调整入场仓位 |
| 将资金流动量与市场状态分类相结合 |
Files
文件
References
参考资料
- — Buy/sell classification logic, size buckets, aggregation
references/trade_classification.md - — Complete signal catalog with formulas and interpretation
references/flow_signals.md - — Detection methods, metrics, and risk scoring
references/wash_trading.md
- ——买卖分类逻辑、规模区间和聚合
references/trade_classification.md - ——包含公式与解读的完整信号目录
references/flow_signals.md - ——检测方法、指标和风险评分
references/wash_trading.md
Scripts
脚本
- — Fetch trades, classify, compute flow signals and momentum
scripts/trade_flow_analysis.py - — Hourly volume profiles, trend detection, anomaly identification
scripts/volume_profile.py
- ——获取交易、进行分类并计算资金流信号和动量
scripts/trade_flow_analysis.py - ——小时成交量分布、趋势检测和异常识别
scripts/volume_profile.py