Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

19.4 KB
Raw Blame

name: volume-trading-strategies description: Complete mastery guide for volume trading and market making in crypto — understanding order book dynamics, bid-ask spreads, volume profile analysis, VWAP/TWAP execution, market making strategies, liquidity provision, wash trading detection, volume manipulation tactics and defenses, and building automated trading bots. Covers CEX and DEX volume mechanics, on-chain analytics for detecting artificial volume, and legitimate strategies for bootstrapping liquidity in new token launches. license: MIT metadata: category: trading difficulty: advanced author: nich tags: [trading, volume-trading-strategies]

Volume Trading Strategies — From First Principles

This skill teaches you to understand, analyze, and execute volume-based trading strategies. You'll learn why volume is the most important signal in any market, how to read it, and how to use it — both for legitimate market making and for detecting manipulation.

Why Volume Matters

┌─────────────────────────────────────────────────────────┐
│              THE VOLUME TRUTH                            │
├─────────────────────────────────────────────────────────┤
│                                                          │
│   Price tells you WHERE the market is.                   │
│   Volume tells you WHETHER the market MEANS IT.          │
│                                                          │
│   Price up + Volume up   = Strong trend (real buyers)    │
│   Price up + Volume down = Weak trend (fading momentum)  │
│   Price down + Volume up = Capitulation (watch reversal) │
│   Price down + Volume dn = Drift (no conviction either)  │
│                                                          │
│   Volume PRECEDES price. Always.                         │
│                                                          │
└─────────────────────────────────────────────────────────┘

Order Book Fundamentals

Anatomy of an Order Book

        ASKS (Sellers)
        ───────────────
Price   │ Size  │ Total
$1.05   │  500  │  500   ← cheapest seller
$1.06   │ 1200  │ 1700
$1.07   │  800  │ 2500
$1.08   │ 3000  │ 5500   ← thick resistance
$1.10   │  200  │ 5700

═══════════════════════════
        SPREAD: $0.02
═══════════════════════════

$1.03   │ 2000  │ 2000   ← highest buyer
$1.02   │ 1500  │ 3500
$1.01   │  400  │ 3900
$1.00   │ 5000  │ 8900   ← thick support
$0.98   │  300  │ 9200
        ───────────────
        BIDS (Buyers)

Key Metrics

Metric Formula What It Tells You
Spread Best Ask - Best Bid Liquidity cost; tight = liquid
Depth Sum of orders within X% of mid How much size the book can absorb
Imbalance Bid size / (Bid size + Ask size) Directional pressure
VWAP Σ(Price × Volume) / Σ(Volume) Fair price weighted by activity
Slippage Execution price vs mid price Cost of large orders

Volume Profile Analysis

Volume Profile shows WHERE volume was traded, not just when.

Price ←─────────────── Volume ──────────────────→
                                                  
$1.10 │▓▓░░░░░░░░░░░░░░░░░░░░                    Low volume node
$1.08 │▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░           
$1.06 │▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  ← POC (Point of Control)
$1.04 │▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓            Value Area High
$1.02 │▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░             Value Area Low
$1.00 │▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░            
$0.98 │▓▓▓░░░░░░░░░░░░░░░░░░░                    Low volume node

Key Concepts:

  • Point of Control (POC): Price with most volume = "fair value"
  • Value Area: Where 70% of volume traded = "accepted range"
  • Low Volume Nodes: Prices where market moved fast = weak support/resistance
  • High Volume Nodes: Prices where market consolidated = strong S/R
def analyze_volume_profile(trades, bucket_size=0.01):
    """Build volume profile from trade data."""
    profile = defaultdict(float)

    for trade in trades:
        bucket = round(trade.price / bucket_size) * bucket_size
        profile[bucket] += trade.volume

    # Find Point of Control
    poc = max(profile, key=profile.get)

    # Calculate Value Area (70% of total volume)
    total_volume = sum(profile.values())
    target = total_volume * 0.70
    sorted_buckets = sorted(profile.items(), key=lambda x: x[1], reverse=True)

    value_area = []
    accumulated = 0
    for price, vol in sorted_buckets:
        value_area.append(price)
        accumulated += vol
        if accumulated >= target:
            break

    return {
        "poc": poc,
        "value_area_high": max(value_area),
        "value_area_low": min(value_area),
        "profile": dict(profile)
    }

Execution Algorithms

VWAP — Volume Weighted Average Price

Goal: Execute a large order at the average market price.

class VWAPExecutor:
    """Split large orders across time, following historical volume curve."""

    def __init__(self, total_size, duration_hours=24):
        self.total_size = total_size
        self.remaining = total_size
        self.duration = duration_hours
        self.volume_curve = self.get_historical_volume_curve()

    def get_historical_volume_curve(self):
        """Typical crypto volume follows a pattern by hour."""
        # Normalized volume weight per hour (crypto 24/7)
        return {
            0: 0.03, 1: 0.02, 2: 0.02, 3: 0.02,   # Low (Asia sleep)
            4: 0.03, 5: 0.03, 6: 0.04, 7: 0.04,    # Asia wake
            8: 0.05, 9: 0.06, 10: 0.06, 11: 0.05,  # Asia + EU overlap
            12: 0.05, 13: 0.06, 14: 0.07, 15: 0.07, # EU + US overlap
            16: 0.06, 17: 0.05, 18: 0.05, 19: 0.04, # US afternoon
            20: 0.04, 21: 0.04, 22: 0.03, 23: 0.03  # US evening
        }

    def calculate_slice(self, current_hour):
        """How much to trade this hour."""
        weight = self.volume_curve[current_hour]
        return self.total_size * weight

    def execute_slice(self, target_size, market):
        """Break each hourly slice into smaller random chunks."""
        chunks = random.randint(5, 15)
        for _ in range(chunks):
            chunk_size = target_size / chunks * random.uniform(0.7, 1.3)
            chunk_size = min(chunk_size, self.remaining)
            if chunk_size <= 0:
                break
            market.place_order(size=chunk_size)
            self.remaining -= chunk_size
            time.sleep(random.uniform(10, 300))  # Random delay

TWAP — Time Weighted Average Price

Simpler: trade equal amounts at equal intervals.

class TWAPExecutor:
    """Trade fixed amounts at fixed intervals. Simple and predictable."""

    def __init__(self, total_size, num_slices, interval_seconds):
        self.slice_size = total_size / num_slices
        self.interval = interval_seconds
        self.slices_remaining = num_slices

    async def run(self, market):
        while self.slices_remaining > 0:
            # Add ±20% randomization to prevent detection
            jitter = random.uniform(0.8, 1.2)
            await market.place_order(size=self.slice_size * jitter)
            self.slices_remaining -= 1
            await asyncio.sleep(self.interval * random.uniform(0.8, 1.2))

Iceberg Orders

Show only a small portion of a large order:

class IcebergOrder:
    """Display small 'tip' while hiding total size."""

    def __init__(self, total_size, display_size, price, side):
        self.total_remaining = total_size
        self.display_size = display_size
        self.price = price
        self.side = side

    def on_fill(self, filled_amount):
        self.total_remaining -= filled_amount
        if self.total_remaining > 0:
            # Reload the visible portion
            new_display = min(self.display_size, self.total_remaining)
            # Slightly vary size to look organic
            new_display *= random.uniform(0.85, 1.15)
            return Order(self.side, self.price, new_display)
        return None  # Fully filled

Market Making

The Market Maker's Job

┌─────────────────────────────────────────────────┐
│               MARKET MAKER = LIQUIDITY           │
├─────────────────────────────────────────────────┤
│                                                  │
│   You place BOTH buy and sell orders             │
│   continuously. You EARN the spread.             │
│                                                  │
│   Buy at $0.99 ◄─── Spread $0.02 ───► Sell at $1.01│
│                                                  │
│   Every round-trip = $0.02 profit per unit       │
│   Risk: inventory accumulation if price trends   │
│                                                  │
│   Your enemies:                                  │
│   1. Adverse selection (informed traders)         │
│   2. Inventory risk (stuck holding one side)      │
│   3. Latency (faster MMs pick you off)           │
│                                                  │
└─────────────────────────────────────────────────┘

Basic Market Making Bot

class MarketMaker:
    """Continuously quote bid/ask around mid price."""

    def __init__(self, config):
        self.base_spread = config.spread       # e.g., 0.002 (0.2%)
        self.order_size = config.size           # e.g., 100 USDC
        self.num_levels = config.levels         # e.g., 5 levels each side
        self.inventory = 0                       # Net position
        self.max_inventory = config.max_inv     # Risk limit

    def calculate_quotes(self, mid_price, volatility):
        """Generate bid/ask grid with inventory skew."""
        # Widen spread when volatility is high
        spread = self.base_spread * (1 + volatility * 10)

        # Skew quotes to reduce inventory risk
        # If long: lower bids (buy less), raise asks (sell more aggressively)
        skew = self.inventory / self.max_inventory * spread * 0.5

        quotes = []
        for level in range(self.num_levels):
            offset = spread * (level + 1) / 2
            bid_price = mid_price * (1 - offset + skew)
            ask_price = mid_price * (1 + offset + skew)

            # Reduce size at wider levels
            level_size = self.order_size * (0.8 ** level)

            quotes.append(Order("buy", bid_price, level_size))
            quotes.append(Order("sell", ask_price, level_size))

        return quotes

    def on_fill(self, order):
        """Update inventory on fill."""
        if order.side == "buy":
            self.inventory += order.filled_size
        else:
            self.inventory -= order.filled_size

        # Emergency: flatten if inventory exceeds limits
        if abs(self.inventory) > self.max_inventory:
            self.emergency_flatten()

DEX Volume Mechanics

AMM Volume vs Order Book Volume

Aspect CEX (Order Book) DEX (AMM)
Volume source Matched orders Swap transactions
Spread Bid-ask gap Determined by pool depth
Slippage Depends on depth Formula: x * y = k
Fees Maker/taker fee tiers Flat % to LPs
Transparency Opaque (exchange data) Fully on-chain
Manipulation Wash trading (hard to prove) Detectable on-chain

Concentrated Liquidity (Uniswap V3)

def calculate_v3_slippage(pool, swap_amount):
    """
    In V3, liquidity is concentrated in price ranges.
    Slippage depends on where liquidity is positioned.
    """
    current_tick = pool.current_tick
    liquidity_in_range = pool.get_liquidity_at_tick(current_tick)

    # Step through ticks consumed by the swap
    remaining = swap_amount
    total_output = 0
    tick = current_tick

    while remaining > 0:
        tick_liquidity = pool.get_liquidity_at_tick(tick)
        if tick_liquidity == 0:
            tick += 1  # Skip empty ticks (gap = high slippage)
            continue

        consumable = tick_liquidity_to_amount(tick_liquidity)
        consumed = min(remaining, consumable)
        output = consumed * tick_to_price(tick)
        total_output += output
        remaining -= consumed
        tick += 1

    effective_price = swap_amount / total_output
    slippage = (effective_price - pool.current_price) / pool.current_price
    return slippage

Detecting Fake Volume

Red Flags for Wash Trading

┌─────────────────────────────────────────────────────┐
│           WASH TRADING DETECTION CHECKLIST            │
├─────────────────────────────────────────────────────┤
│                                                      │
│ On-Chain (DEX):                                      │
│ □ Same address on both sides of trades               │
│ □ Circular flows: A→B→C→A within short timeframe     │
│ □ Perfect round numbers (exactly 1000 USDC swaps)    │
│ □ Regular intervals (trade every exactly 60 seconds) │
│ □ Volume spikes with no price movement               │
│ □ Gas paid > trading profits (uneconomic behavior)   │
│                                                      │
│ Off-Chain (CEX):                                     │
│ □ Volume/market-cap ratio > 100% daily               │
│ □ OHLC candles with zero spread repeatedly           │
│ □ Volume drops 90%+ during exchange maintenance      │
│ □ Self-trade ratio high (matched by same entity)     │
│                                                      │
└─────────────────────────────────────────────────────┘
def detect_wash_trading(trades, window_hours=24):
    """Score a token's trading activity for wash trading signals."""
    signals = {}

    # Signal 1: Circular address flows
    address_pairs = Counter()
    for trade in trades:
        pair = frozenset([trade.from_addr, trade.to_addr])
        address_pairs[pair] += 1
    signals["repeat_pair_ratio"] = (
        sum(1 for c in address_pairs.values() if c > 3) / len(address_pairs)
    )

    # Signal 2: Volume with no price impact
    hourly_volume = group_by_hour(trades)
    hourly_price_change = calculate_hourly_returns(trades)
    signals["volume_no_impact"] = correlation(
        list(hourly_volume.values()),
        [abs(r) for r in hourly_price_change.values()]
    )  # Low correlation = suspicious

    # Signal 3: Regularity (bots trade at fixed intervals)
    intervals = [trades[i+1].time - trades[i].time for i in range(len(trades)-1)]
    signals["interval_regularity"] = 1 - (np.std(intervals) / np.mean(intervals))
    # High regularity = suspicious

    # Signal 4: Round numbers
    amounts = [t.amount for t in trades]
    round_count = sum(1 for a in amounts if a == round(a, 0))
    signals["round_number_ratio"] = round_count / len(amounts)

    # Composite score
    wash_score = (
        signals["repeat_pair_ratio"] * 0.3 +
        (1 - signals["volume_no_impact"]) * 0.3 +
        signals["interval_regularity"] * 0.2 +
        signals["round_number_ratio"] * 0.2
    )
    return {"score": wash_score, "signals": signals}

Legitimate Volume Bootstrapping

For new token launches (like SPA on a new chain), you need real volume to attract organic traders:

Strategy Cost Risk Effectiveness
Liquidity mining Token emissions Mercenary capital ★★★★
Market maker partnerships Fee sharing Dependency ★★★★★
Trading competitions Prize pool Short-lived spikes ★★★
Integration with aggregators Dev time None ★★★★
Concentrated LP incentives Token emissions IL for LPs ★★★★★
USDs auto-yield appeal None (built-in) None ★★★★

Sperax Ecosystem Volume Considerations

  • USDs pairs naturally attract volume because LPs earn both trading fees AND auto-yield from USDs
  • SPA/USDs pool incentivized via Sperax Farms — creates sustained volume from yield seekers
  • Arbitrum L2 enables high-frequency market making with negligible gas costs ($0.001-0.01 per swap)
  • ERC-8004 registered trading agents can advertise their strategies on-chain, building verifiable track records

Risk Management

Position Sizing

def kelly_criterion(win_rate, win_loss_ratio):
    """Optimal bet size to maximize long-term growth."""
    # f* = (bp - q) / b
    # b = win/loss ratio, p = win probability, q = loss probability
    b = win_loss_ratio
    p = win_rate
    q = 1 - p
    kelly = (b * p - q) / b
    # Use fractional Kelly (25-50%) for safety
    return max(0, kelly * 0.25)

# Example: 55% win rate, 1.5:1 reward/risk
optimal_size = kelly_criterion(0.55, 1.5)
# → ~6.4% of bankroll per trade (quarter Kelly)

Maximum Drawdown Limits

class RiskManager:
    def __init__(self, max_drawdown=0.10, max_daily_loss=0.03):
        self.peak_equity = 0
        self.max_drawdown = max_drawdown
        self.max_daily_loss = max_daily_loss
        self.daily_pnl = 0

    def check(self, current_equity):
        self.peak_equity = max(self.peak_equity, current_equity)
        drawdown = (self.peak_equity - current_equity) / self.peak_equity

        if drawdown > self.max_drawdown:
            return "HALT: Max drawdown exceeded"
        if self.daily_pnl < -self.max_daily_loss * self.peak_equity:
            return "HALT: Daily loss limit hit"
        return "OK"

Tools of the Trade

Tool Purpose Free?
TradingView Volume profile, VWAP overlay Freemium
Dune Analytics On-chain volume analysis Free
DEXTools Real-time DEX volume Free
CoinGecko Exchange volume rankings Free
Kaiko Institutional-grade market data Paid
Arkham Intelligence Wallet-level trade tracking Freemium
Boosty (by nirholas) Automated volume strategies Open source