paulpas/agent-skill-router/ai-order-flow-analysis

Claude Code and agent skill by paulpas/agent-skill-router

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

'"Provides Analyze order flow to detect market pressure and anticipate

Install

npx vskill@latest install paulpas/agent-skill-router/ai-order-flow-analysis

SKILL.md

The same SKILL.md was published earlier as paulpas/agent-skill-router/ai-order-flow-analysis.

Role: Extract actionable insights from order book dynamics and trade flow data

Philosophy: Order flow reveals hidden liquidity and order imbalances. Prioritize microsecond timing, bid-ask spread analysis, and volume profiling for predictive signals.

Key Principles

  1. Hidden Liquidity Detection: Identify hidden orders through trade size and timing patterns
  2. Order Flow Imbalance: Track buy vs sell pressure at each price level
  3. Liquidity Profiling: Map liquidity across price levels and time
  4. Trade Size Analysis: Detect large institutional orders via size anomalies
  5. Time and Sales Processing: Analyze tick-by-tick data for microstructure signals

Implementation Guidelines

Structure
  • Core logic: orderflow/parser.py - Order flow data parsing
  • Analyzer: orderflow/analyzers.py - Order flow analysis
  • Detector: orderflow/detectors.py - Order flow pattern detection
  • Config: config/orderflow_config.yaml - Order flow parameters
Patterns to Follow
  • Process order book snapshots and trade streams separately
  • Calculate cumulative delta over multiple time scales
  • Track order flow imbalance with volume-weighted pricing
  • Detect order flow divergence from price action

Adherence Checklist

Before completing your task, verify:

  • [ ] Order book imbalance (bid-ask pressure) calculated
  • [ ] Cumulative delta tracked over time
  • [ ] Hidden liquidity detected via trade size patterns
  • [ ] Volume profile constructed at key levels
  • [ ] Order flow divergence from price identified

Code Examples

Order Book Imbalance Calculator
python
import numpy as np
import pandas as pd
from typing import Dict, List, Tuple
from dataclasses import dataclass
@dataclass
class OrderBook:
"""Order book state at a point in time."""
timestamp: int
bids: List[Tuple[float, float]] # (price, size)
asks: List[Tuple[float, float]] # (price, size)
class OrderBookImbalance:
"""Calculate order book imbalance metrics."""
def __init__(self, depth: int = 5):
self.depth = depth
def calculate_imbalance(self, order_book: OrderBook) -> Dict:
"""Calculate order book imbalance metrics."""
bids = order_book.bids[:self.depth]
asks = order_book.asks[:self.depth]
if not bids or not asks:
return {
'imbalance': 0.5,
'bid_volume': 0,
'ask_volume': 0,
'imbalance_signed': 0,
'price_weighted_imbalance': 0
}
# Calculate volumes
bid_volume = sum(size for _, size in bids)
ask_volume = sum(size for _, size in asks)
total_volume = bid_volume + ask_volume
# Basic imbalance (0 = all bids, 1 = all asks)
imbalance = ask_volume / total_volume if total_volume > 0 else 0.5
# Signed imbalance (-1 = all bids, +1 = all asks)
imbalance_signed = (ask_volume - bid_volume) / total_volume if total_volume > 0 else 0
# Price-weighted imbalance (better pressure indicator)
bid_weighted = sum(price * size for price, size in bids)
ask_weighted = sum(price * size for price, size in asks)
price_weighted_imbalance = (ask_weighted - bid_weighted) / (bid_weighted + ask_weighted) if (bid_weighted + ask_weighted) > 0 else 0
return {
'imbalance': imbalance,
'imbalance_signed': imbalance_signed,
'bid_volume': bid_volume,
'ask_volume': ask_volume,
'total_volume': total_volume,
'price_weighted_imbalance': price_weighted_imbalance,
'bid_ask_ratio': bid_volume / ask_volume if ask_volume > 0 else float('inf')
}
def calculate_imbalance_change(self, imbalance_series: np.ndarray,
window: int = 10) -> np.ndarray:
"""Calculate change in order book imbalance."""
if len(imbalance_series) < window:
return np.zeros_like(imbalance_series)
current = np.array(imbalance_series)
previous = np.roll(current, window)
previous[:window] = current[:window]
return current - previous
def calculate_cumulative_delta(self, prices: np.ndarray,
volumes: np.ndarray,
buy_signals: np.ndarray) -> np.ndarray:
"""Calculate cumulative delta (net buying volume)."""
delta = np.where(buy_signals, volumes, -volumes)
return np.cumsum(delta)
Trade Flow Analyzer
python
import numpy as np
import pandas as pd
from typing import List, Dict, Tuple
from dataclasses import dataclass
@dataclass
class Trade:
"""Single trade record."""
timestamp: int
price: float
size: float
side: str # 'buy' or 'sell'
class TradeFlowAnalyzer:
"""Analyze trade flow patterns for market signals."""
def __init__(self, high_frequency_threshold: float = 1000):
"""High frequency = trades faster than this threshold (ms)."""
self.high_freq_threshold = high_frequency_threshold
def detect_large_liquidity_orders(self, trades: List[Trade],
volume_threshold: float = 3.0) -> List[Dict]:
"""Detect large hidden liquidity orders."""
if not trades:
return []
volumes = [t.size for t in trades]
avg_volume = np.mean(volumes)
std_volume = np.std(volumes)
large_orders = []
for trade in trades:
z_score = (trade.size - avg_volume) / (std_volume + 1e-6)
if z_score > volume_threshold:
large_orders.append({
'timestamp': trade.timestamp,
'price': trade.price,
'size': trade.size,
'z_score': z_score,
'side': trade.side,
'type': 'large_liquidity'
})
return large_orders
def detect_aggressive_trades(self, trades: List[Trade],
spread: float = 0.01) -> List[Dict]:
"""Detect aggressive trades that hit posted orders."""
if not trades or len(trades) < 2:
return []
aggressive = []
for i in range(1, len(trades)):
prev_trade = trades[i-1]
curr_trade = trades[i]
# Check if trade crossed spread aggressively
if curr_trade.side == 'buy' and curr_trade.price >= prev_trade.price + spread:
aggressive.append({
'timestamp': curr_trade.timestamp,
'price': curr_trade.price,
'size': curr_trade.size,
'side': 'buy',
'type': 'aggressive_buy'
})
elif curr_trade.side == 'sell' and curr_trade.price <= prev_trade.price - spread:
aggressive.append({
'timestamp': curr_trade.timestamp,
'price': curr_trade.price,
'size': curr_trade.size,
'side': 'sell',
'type': 'aggressive_sell'
})
return aggressive
def calculate_volume_profile(self, trades: List[Trade],
price_bins: int = 100) -> Dict:
"""Calculate volume profile across price levels."""
if not trades:
return {}
prices = [t.price for t in trades]
volumes = [t.size for t in trades]
min_price = min(prices)
max_price = max(prices)
bin_size = (max_price - min_price) / price_bins
volume_profile = np.zeros(price_bins)
for price, volume in zip(prices, volumes):
bin_idx = int((price - min_price) / bin_size)
bin_idx = min(bin_idx, price_bins - 1)
volume_profile[bin_idx] += volume
return {
'min_price': min_price,
'max_price': max_price,
'bin_size': bin_size,
'volume_profile': volume_profile,
'price_levels': np.linspace(min_price, max_price, price_bins),
'total_volume': sum(volumes)
}
def detect_volume_spike(self, volumes: np.ndarray,
window: int = 60,
threshold: float = 2.0) -> List[Dict]:
"""Detect volume spikes relative to recent average."""
if len(volumes) < window:
return []
# Rolling statistics
rolling_mean = pd.Series(volumes).rolling(window).mean().fillna(np.mean(volumes))
rolling_std = pd.Series(volumes).rolling(window).std().fillna(np.std(volumes))
spikes = []
for i in range(len(volumes)):
if rolling_std[i] > 0:
z_score = (volumes[i] - rolling_mean[i]) / rolling_std[i]
if z_score > threshold:
spikes.append({
'timestamp': i,
'volume': volumes[i],
'z_score': z_score,
'rolling_mean': rolling_mean[i],
'rolling_std': rolling_std[i]
})
return spikes
Hidden Liquidity Detector
python
import numpy as np
import pandas as pd
from typing import List, Dict
from dataclasses import dataclass
@dataclass
class Trade:
timestamp: int
price: float
size: float
side: str

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
4
7-day trend score
8

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/paulpas/agent-skill-router/ai-order-flow-analysis/badge)](https://verified-skill.com/skills/paulpas/agent-skill-router/ai-order-flow-analysis)

Something wrong with this skill or its page? Tell us.