Liquidity Analysis - Reading the Order Book
Learning Objectives
Analyze bid-ask spreads and understand what they indicate about market quality
Assess order book depth and calculate whether your trade size is appropriate
Estimate market impact and slippage before executing trades
Identify warning signs of illiquid or manipulated markets
Use XRPL tools to gather real-time liquidity data
The spread is the gap between the best buy price (bid) and best sell price (ask).
BID-ASK SPREAD EXPLAINED
Order Book Snapshot:
ASKS (Sellers)
$0.52 [====] 5,000 XRP ← Sellers willing to sell at $0.52
$0.51 [==] 3,000 XRP ← Best ask: lowest sell price
─────────────────────────
$0.49 [===] 4,000 XRP ← Best bid: highest buy price
$0.48 [=====] 6,000 XRP ← Buyers willing to buy at $0.48
BIDS (Buyers)
Spread Calculation:
Best Ask: $0.51 (cheapest available to buy)
Best Bid: $0.49 (best price to sell)
Spread: $0.51 - $0.49 = $0.02
Percentage Spread:
Midpoint: ($0.51 + $0.49) / 2 = $0.50
Spread %: $0.02 / $0.50 = 4%
- Buying costs $0.51 (2% above midpoint)
- Selling yields $0.49 (2% below midpoint)
- Round-trip cost: 4% (buy then sell)
SPREAD INTERPRETATION GUIDE
- Highly liquid market
- Active market makers
- Efficient price discovery
- Good for trading
- Example: XRP/USD on major CEX
- Reasonably liquid
- Some market making activity
- Acceptable for most trades
- Watch execution quality
- Example: Popular XRPL pairs
- Limited liquidity
- Few market makers
- Higher trading costs
- Use limit orders only
- Example: Minor XRPL pairs
- Illiquid market
- Avoid market orders
- Significant execution risk
- Consider if trade is worth it
- Example: Exotic XRPL pairs
Spreads aren't static—they change based on conditions:
WHAT MOVES SPREADS
- Volatility increases (risk to market makers)
- Volume drops (less competition)
- Major news pending (uncertainty)
- Market makers pull quotes (risk off)
- One side heavily depleted
- Volatility decreases (safer for MMs)
- Volume increases (competition)
- Price stabilizes (confidence)
- More market makers enter
- Balanced buying/selling
- Spreads often wider at night (fewer traders)
- Tighter during high-activity periods
- May widen during CEX maintenance (less arbitrage)
- Event-driven widening (announcements)
PRACTICAL IMPLICATION:
Check spread before trading. If unusually wide,
ask why. Might be better to wait.
Depth measures how much volume is available at various price levels.
DEPTH ANALYSIS
Order Book:
Price Volume Cumulative
─────────────────────────────
ASKS (Selling pressure above market)
$0.55 8,000 30,000
$0.54 7,000 22,000
$0.53 5,000 15,000
$0.52 4,000 10,000
$0.51 6,000 6,000 ← Best ask
─────────────────────────────
$0.49 5,000 5,000 ← Best bid
$0.48 7,000 12,000
$0.47 6,000 18,000
$0.46 5,000 23,000
$0.45 10,000 33,000
BIDS (Buying support below market)
- 6,000 XRP available to buy at $0.51
- 10,000 XRP within 2% of best ask
- 30,000 XRP within 8% of best ask
- 5,000 XRP available to sell at $0.49
- 12,000 XRP within 2% of best bid
Key metrics to assess order book health:
DEPTH METRICS
1. Top-of-Book Volume
1. Depth at X%
1. Depth Ratio
1. Order Count
READING DEPTH CHARTS
ASCII Depth Chart:
Price Bid Volume Ask Volume
$0.55 ████████████ 15,000
$0.54 ██████████ 12,000
$0.53 ████████ 10,000
$0.52 █████ 6,000
$0.51 ███ 4,000 (best ask)
─────────── SPREAD ───────────
$0.49 ████ 5,000 (best bid)
$0.48 ██████ 7,000
$0.47 █████████ 11,000
$0.46 ███████████ 14,000
$0.45 ██████████████ 18,000
- More depth on bid side (buyers)
- Ask side has resistance at $0.55
- Large bid support at $0.45
- Current spread: $0.49-$0.51 (4%)
Slippage is the difference between expected price and actual execution price.
SLIPPAGE DEFINED
Expected: You expect to buy at $0.50
Actual: You execute at $0.515
Slippage: $0.015 / $0.50 = 3%
- Eating through order book depth
- Price moving while order processes
- Insufficient liquidity at target price
- Large orders relative to market depth
- Buying: Slippage means paying MORE
- Selling: Slippage means receiving LESS
- Always moves against you
Before trading, calculate your expected slippage:
SLIPPAGE CALCULATION WALKTHROUGH
Goal: Buy 10,000 XRP
Order Book (Asks):
Price Volume Cumulative
$0.51 3,000 3,000
$0.52 4,000 7,000
$0.53 5,000 12,000
$0.54 6,000 18,000
Execution Simulation:
Layer 1: 3,000 XRP @ $0.51 = $1,530
Layer 2: 4,000 XRP @ $0.52 = $2,080
Layer 3: 3,000 XRP @ $0.53 = $1,590
─────────────────────────────────
Total: 10,000 XRP for $5,200
Average Price: $5,200 / 10,000 = $0.52
Slippage Calculation:
Best ask: $0.51
Avg execution: $0.52
Slippage: ($0.52 - $0.51) / $0.51 = 1.96%
Cost of Slippage:
If you could buy all at $0.51: $5,100
Actual cost: $5,200
Slippage cost: $100
SLIPPAGE ESTIMATION
Quick Estimate:
Slippage ≈ (Order Size / Depth at 1%) × 1%
Example:
Order: 5,000 XRP
Depth within 1%: 10,000 XRP
Slippage ≈ (5,000 / 10,000) × 1% = 0.5%
- Get full order book
- Simulate execution layer by layer
- Calculate volume-weighted average price
- Compare to best available price
- Order < 10% of depth at 1%: Minimal slippage (<0.5%)
- Order = 25-50% of depth at 1%: Moderate slippage (0.5-2%)
- Order > 100% of depth at 1%: Significant slippage (2%+)
MINIMIZING SLIPPAGE
- Use Limit Orders
- Split Large Orders
- Time Your Trades
- Use Auto-Bridging
- Accept Partial Fills
Market impact is the lasting price change caused by your trade.
SLIPPAGE VS MARKET IMPACT
- Immediate execution cost
- You pay more than best price
- One-time cost for your trade
- Price change after your trade
- Affects subsequent trades
- May be permanent or temporary
Example:
Before your 50,000 XRP buy:
Best ask: $0.50
After your 50,000 XRP buy:
You paid average: $0.52 (slippage = 4%)
New best ask: $0.53 (market impact = 6%)
If you need to buy more:
Starting point is now $0.53, not $0.50
Your first trade made future trades more expensive
```
MARKET IMPACT ESTIMATION
Simple Model:
Market Impact ≈ k × √(Order Size / Daily Volume)
Where k = market-specific constant (typically 0.1-0.5)
Example:
Daily volume: 100,000 XRP
Your order: 10,000 XRP
k = 0.3
Impact ≈ 0.3 × √(10,000/100,000)
≈ 0.3 × √0.1
≈ 0.3 × 0.316
≈ 9.5%
- Order book shape
- Current market conditions
- Time of execution
- Other participants
XRPL Reality:
Daily DEX volume often low ($10-50M total)
Single large trade can significantly move prices
Impact is real concern for $10K+ trades
```
IMPACT REDUCTION STRATEGIES
- TWAP (Time-Weighted Average Price)
Example: Buy 50,000 XRP
- 10 orders of 5,000 XRP each
- One every 10 minutes
- Reduces concentrated impact
- Iceberg Approach
- Multiple Venues
- Patience
WARNING: THIN MARKET INDICATORS
- Market makers absent
- Expensive round-trip
- Avoid market orders
- No orders between levels
- Flash crash risk
- Single order moves price far
- Few participants
- Single party can dominate
- Withdrawal risk
- Orders haven't updated
- Market makers gone
- Potentially manipulated
- 90%+ volume on one side
- Potential for sharp move
- Trapped liquidity
POTENTIAL MANIPULATION SIGNS
- Large orders appear and disappear
- Not intended to execute
- Creates false impression of depth
- XRPL: All orders are real (can't spoof)
- But can cancel quickly
- Same party buying and selling
- Creates false volume
- XRPL: Offers can't cross self
- But can use multiple accounts
- Multiple orders at different levels
- Creates illusion of support/resistance
- Cancelled before execution
- Sudden price spike on low volume
- Often with social media promotion
- Followed by crash
- All orders are real (cost reserve)
- Can't trade with yourself (directly)
- Transparent order book
- But manipulation still possible via multiple accounts
BEFORE TRADING A PAIR - CHECK:
□ Spread reasonable for trade size?
□ Depth sufficient for your order?
□ Both sides of book populated?
□ Orders at multiple price levels?
□ Recent trading activity visible?
□ Price consistent with other venues?
□ Issuer reputable (for IOUs)?
□ Volume history looks normal?
□ No suspicious patterns?
□ Willing to accept execution quality?
The primary tool for order book analysis:
// QUERYING ORDER BOOK
const xrpl = require('xrpl');
async function getOrderBook(client, base, quote) {
// Get asks (offers to sell base for quote)
const asks = await client.request({
command: 'book_offers',
taker_gets: base, // What taker gets (base)
taker_pays: quote, // What taker pays (quote)
limit: 50
});
// Get bids (offers to buy base with quote)
const bids = await client.request({
command: 'book_offers',
taker_gets: quote, // What taker gets (quote)
taker_pays: base, // What taker pays (base)
limit: 50
});
return { asks: asks.result.offers, bids: bids.result.offers };
}
// Example: XRP/USD.Bitstamp
const base = { currency: 'XRP' }; // Native XRP
const quote = {
currency: 'USD',
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
};
// Parse results
function parseOffers(offers, isAsk) {
return offers.map(offer => {
const gets = typeof offer.TakerGets === 'string'
? parseInt(offer.TakerGets) / 1000000 // XRP in drops
: parseFloat(offer.TakerGets.value);
const pays = typeof offer.TakerPays === 'string'
? parseInt(offer.TakerPays) / 1000000
: parseFloat(offer.TakerPays.value);
return {
price: isAsk ? pays / gets : gets / pays,
volume: isAsk ? gets : pays
};
});
}
// DEPTH ANALYSIS FUNCTION
function analyzeDepth(orderBook, tradeSize) {
const { asks, bids } = orderBook;
// Calculate spread
const bestAsk = asks[0]?.price || 0;
const bestBid = bids[0]?.price || 0;
const midpoint = (bestAsk + bestBid) / 2;
const spreadPercent = (bestAsk - bestBid) / midpoint * 100;
// Calculate depth at levels
function depthWithin(orders, percent) {
const threshold = midpoint * (1 + percent/100);
return orders
.filter(o => o.price <= threshold)
.reduce((sum, o) => sum + o.volume, 0);
}
// Simulate execution
function simulateExecution(orders, size) {
let remaining = size;
let totalCost = 0;
for (const order of orders) {
if (remaining <= 0) break;
const fillSize = Math.min(remaining, order.volume);
totalCost += fillSize * order.price;
remaining -= fillSize;
}
if (remaining > 0) {
return { filled: size - remaining, avgPrice: null, slippage: null };
}
const avgPrice = totalCost / size;
const slippage = (avgPrice - bestAsk) / bestAsk * 100;
return { filled: size, avgPrice, slippage };
}
return {
spread: spreadPercent,
bestBid,
bestAsk,
depthAt1Percent: depthWithin(asks, 1),
depthAt2Percent: depthWithin(asks, 2),
depthAt5Percent: depthWithin(asks, 5),
execution: simulateExecution(asks, tradeSize)
};
}
```
// WEBSOCKET SUBSCRIPTION FOR LIVE DATA
async function subscribeToOrderBook(client, base, quote) {
// Subscribe to order book updates
await client.request({
command: 'subscribe',
books: [{
taker_gets: base,
taker_pays: quote,
both: true
}]
});
// Handle updates
client.on('transaction', (tx) => {
if (tx.transaction.TransactionType === 'OfferCreate' ||
tx.transaction.TransactionType === 'OfferCancel') {
// Order book changed - refresh analysis
console.log('Order book updated');
// Re-fetch and analyze
}
});
}
// Useful for:
// - Real-time spread monitoring
// - Alert when liquidity changes
// - Detecting large orders
// - Timing trade execution
```
XRPL LIQUIDITY TOOLS
- book_offers: Order book data
- account_offers: Your open orders
- subscribe: Real-time updates
- path_find: Best execution path
- XRPL.org Explorer: Basic order books
- Sologenic: Trading interface with charts
- XRP Toolkit: Order book visualization
- First Ledger: DEX aggregator view
- XRPScan: Transaction/volume analytics
- Bithomp: Account and trading data
- Various community tools
- No built-in depth charts (must build)
- Limited historical depth data
- No native volume indicators
- Basic compared to CEX tools
LIQUIDITY ASSESSMENT CHECKLIST
Before Every Trade:
Check Current Spread
Measure Depth for Your Size
Calculate Expected Execution
Check Timing
Compare Options
TRADE SIZE DECISION FRAMEWORK
Your Order Size vs Available Liquidity:
Excellent liquidity for your size
Market order acceptable
Minimal slippage expected
Execute with confidence
Good liquidity
Limit order recommended
Small slippage expected
Execute normally
Moderate liquidity
Limit orders only
Noticeable slippage
Consider splitting
Limited liquidity for size
Must use limits, accept partial
Significant slippage
Strong split recommendation
Insufficient liquidity
Will move market significantly
Split required, patience needed
Consider alternative venues
LIQUIDITY ANALYSIS CASE STUDY
Scenario: Buy 25,000 XRP on XRPL DEX
Step 1: Get Order Book
Asks:
$0.500 - 5,000 XRP
$0.505 - 8,000 XRP
$0.510 - 6,000 XRP
$0.520 - 12,000 XRP
$0.530 - 15,000 XRP
Bids:
$0.495 - 4,000 XRP
$0.490 - 7,000 XRP
$0.485 - 5,000 XRP
Step 2: Calculate Metrics
Spread: ($0.500 - $0.495) / $0.4975 = 1.0%
Depth at 1% ($0.505): 5,000 + 8,000 = 13,000 XRP
Depth at 2% ($0.510): 13,000 + 6,000 = 19,000 XRP
Depth at 4% ($0.520): 19,000 + 12,000 = 31,000 XRP
Step 3: Simulate 25,000 XRP Buy
5,000 @ $0.500 = $2,500
8,000 @ $0.505 = $4,040
6,000 @ $0.510 = $3,060
6,000 @ $0.520 = $3,120
─────────────────────────
25,000 XRP for $12,720
Average: $0.5088
Best ask: $0.500
Slippage: 1.76%
Step 4: Decision
- 1.76% slippage is moderate
- 25,000 XRP is ~130% of 2% depth
- Market impact will be noticeable
- New best ask will be $0.520+
- Split into 5 orders of 5,000 XRP
- Space over 30 minutes
- Use limit orders at $0.51 or better
- Expect 0.5-1% improvement over market order
✅ Spread indicates market quality - Tight spreads correlate with better execution
✅ Depth determines slippage - Calculable relationship between size and slippage
✅ XRPL provides necessary data - book_offers gives full order book access
✅ Pre-trade analysis improves execution - Simulating trades prevents surprises
⚠️ Optimal timing - Best times to trade vary and aren't consistent
⚠️ Book stability - Order book can change between analysis and execution
⚠️ Hidden liquidity - Some traders may wait to show their orders
⚠️ Cross-venue dynamics - XRPL DEX vs CEX arbitrage affects liquidity
🔴 Ignoring liquidity - Market orders on thin books cause severe slippage
🔴 Trusting displayed depth - Orders can be pulled; analyze but verify
🔴 Large orders without splitting - Market impact makes future trades expensive
🔴 Trading illiquid pairs - Wide spreads and gaps create adverse execution
XRPL DEX liquidity is real but thin compared to major centralized exchanges. For small trades (<$1,000) in major pairs, liquidity is usually adequate. For larger trades or minor pairs, careful analysis is essential. The good news: XRPL provides complete transparency into order books, allowing precise pre-trade analysis. Use that transparency—never trade blind on a DEX.
Assignment: Conduct a comprehensive liquidity analysis of 5 XRPL trading pairs.
Requirements:
Part 1: Pair Selection
- 1 highly liquid pair (e.g., XRP/USD major gateway)
- 2 moderately liquid pairs
- 1 less liquid pair
- 1 exotic/thin pair
Document why you selected each.
Part 2: Metrics Collection
- Best bid and ask prices
- Spread (absolute and percentage)
- Volume at top of book (both sides)
- Depth within 1%, 2%, and 5% of midpoint
- Number of orders within 5% (both sides)
- Depth ratio (bid volume / ask volume)
Part 3: Analysis Table
Create a comparison table:
| Metric | Pair 1 | Pair 2 | Pair 3 | Pair 4 | Pair 5 |
|---|---|---|---|---|---|
| Spread % | |||||
| Depth at 1% | |||||
| Depth at 2% | |||||
| Order count | |||||
| Depth ratio | |||||
| Quality rating |
Part 4: Slippage Simulation
- Small: $500
- Medium: $5,000
- Large: $25,000
Calculate expected slippage for each size on each pair.
Part 5: Trading Recommendations
- What maximum order size would you recommend for <1% slippage?
- Should traders use this pair or look elsewhere?
- What order type strategy would you use?
- Any red flags or concerns?
Part 6: Overall Insights
How XRPL DEX liquidity compares across pairs
What patterns you observed
How this affects your trading approach
Data accuracy and completeness: 30%
Analysis quality: 25%
Slippage calculations: 20%
Recommendations and insights: 25%
Time investment: 2.5-3 hours
Knowledge Check
Question 1 of 1You need to buy 50,000 XRP on a pair with 10,000 XRP depth at 1% slippage. What is the optimal execution approach?
- book_offers Method: https://xrpl.org/book_offers.html
- Order Book Structure: https://xrpl.org/offers.html
- Subscribe Method: https://xrpl.org/subscribe.html
- Market Microstructure Theory
- Slippage and Market Impact Models
- Order Book Dynamics
- XRPL.js Library: https://js.xrpl.org/
- XRPL Order Book Explorers
- Trading Interface Documentation
For Next Lesson:
Lesson 6 covers fees, costs, and execution economics—building a complete picture of what every trade actually costs on the XRPL DEX.
End of Lesson 5
Total words: ~5,100
Estimated completion time: 60 minutes reading + 2.5-3 hours for deliverable
Key Takeaways
Spread measures market quality
: <0.5% is excellent, 0.5-2% is acceptable, >2% requires caution, >5% is a warning sign.
Depth determines your capacity
: Compare your order size to available depth at 1-2% to estimate slippage.
Always simulate before executing
: Calculate your expected average price by walking through the order book.
Size your orders to liquidity
: If your order is >25% of nearby depth, consider splitting.
Market impact lasts beyond your trade
: Large orders move the market for subsequent trades—factor this in.
Use XRPL's transparency
: book_offers gives complete order book data—use it every time.
Warning signs matter
: Wide spreads, thin books, and imbalanced depth are red flags. Don't ignore them. ---