market-microstructure

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Market 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:
  1. Who is trading? — Whale wallets vs retail, smart money vs bots
  2. How are they trading? — Large single swaps vs DCA-style splits
  3. When are they trading? — Volume clustering around events or time zones
  4. 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 列表)包含丰富的信号:
  1. 谁在交易?——鲸鱼钱包还是散户,聪明钱还是机器人
  2. 如何交易?——单笔大额 swap,还是 DCA 风格的拆分交易
  3. 何时交易?——围绕事件或时区的成交量聚集
  4. 方向如何?——滑动窗口内的净买入与净卖出压力
这些信号可用于把握进出场时机、仓位大小和代币质量评分。

Trade Classification

交易分类

Buy vs Sell Identification

买入与卖出识别

On Solana DEXes, every swap has an input token and output token:
Swap DirectionClassificationMeaning
SOL → TokenBuyTrader spending SOL to acquire token
USDC → TokenBuyTrader spending stables to acquire token
Token → SOLSellTrader converting token back to SOL
Token → USDCSellTrader converting token to stables
Token A → Token BContext-dependentClassify 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
    side
    field:
    "buy"
    or
    "sell"
  • Includes
    from
    (input token) and
    to
    (output token) amounts
DexScreener Pair Trades:
  • Returns
    type
    field indicating swap direction relative to the pair
Helius Parsed Transactions:
  • Parse swap instructions to extract input/output mints and amounts
  • Classify based on which mint matches your target token
See
references/trade_classification.md
for detailed classification logic and size buckets.
Birdeye 交易历史(
/defi/txs/token
):
  • 返回
    side
    字段:
    "buy"
    或
    "sell"
  • 包含
    from
    (输入代币)和
    to
    (输出代币)金额
DexScreener Pair Trades:
  • 返回
    type
    字段,指示相对于交易对的 swap 方向
Helius 解析交易:
  • 解析 swap 指令,提取输入/输出 mint 和金额
  • 根据与目标代币匹配的 mint 进行分类
请参阅
references/trade_classification.md
了解详细的分类逻辑和规模区间。

Volume Profiles

成交量分布

Time-Based Profiles

基于时间的分布

Aggregate trade volume into fixed time buckets to identify patterns:
python
undefined
将交易量汇总到固定时间桶中,以识别模式:
python
undefined

Hourly 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 average
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"]

时间分布中的关键指标:
- **峰值时段**——该代币何时交易最活跃?
- **成交量趋势**——成交量是在增加、减少还是保持稳定?
- **成交量异常**——超过滚动平均值 3 倍的峰值

Size-Based Profiles

基于规模的分布

Classify trades into size buckets to separate whale activity from retail:
BucketSOL RangeTypical Actor
Micro< 0.1 SOLDust / test trades
Small0.1 – 1 SOLRetail traders
Medium1 – 10 SOLActive traders
Large10 – 50 SOLSerious positions
Whale50+ SOLWhales / 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

信号解读

MetricBullishNeutralBearish
Buy Volume %> 60%40–60%< 40%
Net FlowPositive, increasingNear zeroNegative, increasing
Trade Count Ratio> 0.550.45–0.55< 0.45
Large Trade RatioHigh buy-sideBalancedHigh sell-side
See
references/flow_signals.md
for the full signal catalog and composite scoring.
指标看涨中性看跌
买入成交量占比> 60%40–60%< 40%
净流量为正且持续增加接近零为负且持续加剧
交易笔数比率> 0.550.45–0.55< 0.45
大额交易比率买方侧较高均衡卖方侧较高
请参阅
references/flow_signals.md
了解完整的信号目录和综合评分。

Trade 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
skew_indicator
(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.
分析交易规模分布有助于揭示市场结构:
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_indicator
(均值/中位数)表明 其呈肥尾分布——少数大额交易占据主导。这对于受到鲸鱼关注的代币很常见, 但也可能预示操纵行为。

Momentum 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_ratio
Positive
buy_momentum
with increasing volume is a strong accumulation signal.
追踪买方比率随时间的变化:
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_ratio
buy_momentum
为正且成交量增长,是强烈的吸筹信号。

Token Velocity

代币周转率

Token velocity measures how frequently tokens change hands:
python
velocity = daily_volume / circulating_supply
VelocityInterpretation
< 0.01Low activity, illiquid, or strong holders
0.01–0.05Normal trading activity
0.05–0.20Active trading, possible speculation
> 0.20Very 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:
  1. Low unique trader ratio —
    unique_wallets / trade_count < 0.3
  2. Volume/TVL anomaly —
    daily_volume / tvl > 10
    (volume vastly exceeds liquidity)
  3. Uniform trade sizes — low entropy in trade size distribution
  4. Self-trading — same wallet on both sides within short windows
  5. Funded-together clusters — multiple wallets funded from the same source
See
references/wash_trading.md
for detailed detection methods and scoring.
洗售交易会虚增成交量,使代币看起来比实际更活跃。 主要检测信号:
  1. 唯一交易者比率偏低——
    unique_wallets / trade_count < 0.3
  2. 成交量/TVL 异常——
    daily_volume / tvl > 10
    (成交量远超流动性)
  3. 交易规模高度一致——交易规模分布熵值低
  4. 自成交——同一钱包在短时间内同时处于买卖双方
  5. 同源资助的钱包集群——多个钱包由同一资金来源资助
请参阅
references/wash_trading.md
了解详细的检测方法和评分。

Data Sources

数据源

Birdeye API

Birdeye API

Primary source for trade history on Solana tokens:
  • GET /defi/txs/token
    — recent trades for a token
  • GET /defi/ohlcv
    — candle data with volume
  • GET /defi/price/volume
    — aggregated volume data
Requires API key. See the
birdeye-api
skill for endpoint details.
Solana 代币交易历史的主要数据源:
  • GET /defi/txs/token
    ——代币的近期交易
  • GET /defi/ohlcv
    ——包含成交量的蜡烛图数据
  • GET /defi/price/volume
    ——汇总成交量数据
需要 API key。请参阅
birdeye-api
skill 了解端点详情。

DexScreener API

DexScreener API

Free, no-auth alternative for pair-level data:
  • GET /latest/dex/tokens/{address}
    — token pairs with volume
  • GET /latest/dex/pairs/solana/{pairAddress}
    — pair details
无需认证的免费替代方案,可获取交易对级别数据:
  • 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
    helius-api
    skill for transaction parsing.
用于钱包级交易分析和解析交易:
  • 解析 swap 交易以提取交易详情
  • 将交易归因到特定钱包
  • 有关交易解析,请参阅
    helius-api
    skill。

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 RangeInterpretation
+60 to +100Strong accumulation — heavy buy pressure
+20 to +60Moderate buying — cautious accumulation
-20 to +20Neutral / balanced flow
-60 to -20Moderate selling — distribution underway
-100 to -60Strong 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 的集成

SkillHow It Connects
birdeye-api
Primary data source for trade history and volume
helius-api
Wallet-attributed trade data from parsed transactions
liquidity-analysis
Volume/TVL ratios, liquidity context for flow signals
whale-tracking
Identify whale wallets for large trade attribution
token-holder-analysis
Supply distribution context for velocity metrics
position-sizing
Use flow signals to adjust entry sizing
regime-detection
Combine flow momentum with regime classification
Skill集成方式
birdeye-api
交易历史和成交量的主要数据源
helius-api
从解析交易中获取可归因到钱包的交易数据
liquidity-analysis
为资金流信号提供成交量/TVL 比率和流动性背景
whale-tracking
识别鲸鱼钱包,用于大额交易归因
token-holder-analysis
为周转率指标提供供应分布背景
position-sizing
使用资金流信号调整入场仓位
regime-detection
将资金流动量与市场状态分类相结合

Files

文件

References

参考资料

  • references/trade_classification.md
    — Buy/sell classification logic, size buckets, aggregation
  • references/flow_signals.md
    — Complete signal catalog with formulas and interpretation
  • references/wash_trading.md
    — Detection methods, metrics, and risk scoring
  • references/trade_classification.md
    ——买卖分类逻辑、规模区间和聚合
  • references/flow_signals.md
    ——包含公式与解读的完整信号目录
  • references/wash_trading.md
    ——检测方法、指标和风险评分

Scripts

脚本

  • scripts/trade_flow_analysis.py
    — Fetch trades, classify, compute flow signals and momentum
  • scripts/volume_profile.py
    — Hourly volume profiles, trend detection, anomaly identification
  • scripts/trade_flow_analysis.py
    ——获取交易、进行分类并计算资金流信号和动量
  • scripts/volume_profile.py
    ——小时成交量分布、趋势检测和异常识别