Novice Navigator

Building a Specialised Agent for Pair Trading

Sep 1, 2025

/

5 Minutes Read

5 Minutes Read

5 Minutes Read

(That does your risk assessment and empowers you with tooling to become more profitable)

1. Why Pair Trading?

Most traders in crypto focus on a single question: “Will this token go up or down?”
Pair trading flips the script. Instead of betting on absolute price, you trade relationships.

There are multiple approaches to pair trading:

  1. Fundamental – e.g. long HYPE / short DYDX

  2. Technical – e.g. based on charts like ETH/BTC

  3. Narrative & Mindshare – e.g. long PUMP / short SOL

A fourth, well-established technique is to take a statistical approach. Here, traders examine variables between two assets such as:

  • their correlation,

  • the current price difference (spread), and

  • how today’s spread compares to its historical average (mean).

The “arbitrage” arises because spreads between related assets tend to mean-revert when they deviate too far. For example, if BTC keeps falling whilst SOL keeps rising, the BTC/SOL spread collapses. A trader applying statistical arbitrage might go long BTC and short SOL, anticipating that the spread will snap back toward its mean.



This method - known as Statistical Arbitrage, is a cornerstone of traditional finance. And because crypto markets are still relatively inefficient, the opportunities to profit from it can be even greater.

To see how this works in practice, it helps to break down the building blocks of statistical arbitrage.



2. Statistical Arbitrage 101

Statistical arbitrage, or stat-arb, is about turning the relationship between two assets into a tradeable signal

Key Concepts
  • Correlation – measures how closely two assets move together. A high correlation suggests a relationship worth monitoring.

  • Beta (β) – shows how much one asset typically moves compared to the other. If SOL tends to move 1.3% when BTC moves 1%, then the hedge ratio is 1.3.

  • Spread – the difference between BTC and SOL after adjusting for beta. This is the trader’s signal:

𝑆𝑝𝑟𝑒𝑎𝑑ₜ = 𝑃ᴮᵀᶜ,ₜ − β · 𝑃ˢᴼᴸ,ₜ

  • Z-score – a way to measure how far today’s spread is from its historical average (mean, denoted as μ). Generally speaking you want to long the pair when Z-Score is <-2 and vice versa.

𝑧ₜ = (𝑆𝑝𝑟𝑒𝑎𝑑ₜ − μ) / σ

Example: BTC vs SOL

Suppose BTC and SOL usually move in sync. If BTC falls sharply while SOL rallies, the BTC/SOL spread shrinks. If the spread is now two standard deviations (σ)  below its mean (Z-score <-2), a stat-arb trader might:

  • Go long BTC and short SOL (beta-weighted),

  • Hold the position until the spread normalises,

  • Exit with profit once mean reversion plays out.

This approach reframes trading: the bet is not on whether BTC will rise or SOL will fall, but on the spread between them returning to equilibrium. Here is the same diagram, with the Z-Score being <-2σ clearly labelled as an entry signal. 


The challenge is not understanding these concepts, but finding opportunities across dozens of assets in real time.



3. Finding Opportunities

So far we have looked at statistical arbitrage in theory. In practice, traders needed tools to surface opportunities, and one of the main options was Crypto Wizards.


Crypto Wizards provided dashboards full of ratios, correlations, and spread charts. On paper this looked powerful, but many traders found it confusing to navigate. The issue was not the math but the usability. Traders did not want another complex dashboard. They wanted simple, tradeable insights: "Here is a pair diverging. Here is when to take the trade."

This is where Agent Pear comes in.

We have rebuilt the full statistical library on our own backend, covering correlation, beta, spreads, and z-scores. The system now updates in real time. Instead of static charts, traders are alerted the moment mean reversion opportunities arise, for example when the z-score compresses.

The result is actionable, trade-ready signals rather than raw analytics. Agent Pear closes the gap between statistical arbitrage theory and real-world execution in fast-moving crypto markets.

This shift from analytics to execution is what Agent Pear is designed to solve.


4. Our approach to rebuilding Crypto Wizards 

When we looked at the original CryptoWizards platform, we saw a lot to admire. It gave traders statistical-arbitrage tools, educational material, and curated backtests - all focused on a limited set of crypto pairs. That was a strong foundation, but we wanted to take things further and build our own library.

Our goal with Agent Pear was to recreate that core experience of pair discovery, statistical insights, and monitoring, and then extend it in three ways:

  1. Execution built-in – not just analysis, but the ability to act directly on signals.

  2. Full-universe coverage – not limited to a subset, but spanning all tradable pairs across supported platforms.

  3. AI-driven context – instead of leaving you to decipher charts, we add narrative explanations that make the opportunities clear.

Database & Time-Series Foundation

A reliable stat-arb agent is only as good as its data. We rebuilt the database from scratch utilising both hourly and daily time series data from the relevant exchanges where our execution/hedging takes place (e.g. Hourly time series data comes directly from HyperCore itself). 

  • Hourly OHLC data: Fine-grained enough to spot intraday divergences, volatility bursts, and short-term reversions.

  • Daily OHLC data: Smooths out noise, perfect for identifying structural shifts, long-term correlations, and regime changes.

  • Each record is indexed with a composite key (time, asset1_id, asset2_id) for efficient retrieval and backtests.


Pair Statistics

For every tracked pair, we calculate and store a full set of metrics at both the 1h and 1d level:

  • Correlation — how closely two assets move together

  • β (hedge ratio) — the relative move of one asset versus the other

  • Spread snapshot — the difference between the beta-adjusted prices

  • Z-score — how far today’s spread is from its long-term mean

  • Cointegration check - confirms a long-term, mean-reverting relationship exists between the two asset prices.

  • Half-life — how quickly the spread tends to revert

  • Sharpe ratio (daily) - to filter for robust strategies

This gives traders a quantifiable, real-time picture of relationships across the market, across 2 different timeframes. 

Importantly, we didn’t just port off-the-shelf quant libraries. Crypto markets behave differently - noisier, more volatile, with structural quirks. So we rebuilt every calculator from scratch. A full breakdown of each calculation is in the Appendix.

Volatility-Aware Signalling

Not all divergences are equal. A spread breaking down during extreme volatility is very different from one in a quiet market. To account for this, we:

  • Compute pair-level volatility in both short (1h) and long (1d) windows

  • Classify regime states (calm vs. volatile) to help you adjust your risk


From Data to Decisions: Signals & Execution

With these building blocks in place, we can surface two levels of actionable insights:

  • Viable signals → opportunities that pass our statistical and backtest filters, showing where pairs are diverging enough to watch.

  • Live trades → when conditions align (e.g. spread < −2σ with strong historical mean reversion), Agent Pear triggers alerts and can be integrated directly with execution on venues like Hyperliquid.

By rebuilding the data layer, extending coverage to the full universe, and adding AI-powered narrative context, we’ve created an agent that doesn’t just crunch numbers - it tells you the story behind the trade and equips you to act.


5. Agent Pear Architecture


Behind the scenes, Agent Pear runs on a production-grade pipeline. Think of it as an orchestra: every component has a role, and the orchestrator makes sure they play in sync.

Orchestration & Configuration
  • Orchestration Service → the conductor. On a fixed schedule (hourly and daily), it lines up each task in the right order:

    1. Fetch fresh data

    2. Store it safely

    3. Run analytics

This sequencing prevents race conditions and ensures data integrity.

  • Configuration Service → the stage manager. It provides credentials, database connections, and settings to all modules, so nothing is hardcoded. That makes the system flexible, secure, and portable across environments.


The Automated Data Pipeline

The pipeline transforms raw market data into actionable intelligence through four layers:

  1. Ingestion Layer

    • Connects directly to exchanges (e.g. Hyperliquid).

    • Pulls in two streams: raw time-series price data + metadata about assets/pairs.


  2. Storage Layer

    • Everything is written into a central database.

    • A unified data-access gateway means every service reads/writes in a consistent, secure way.


  3. Analytical Layer

    • The orchestrator triggers our custom calculators (correlation, cointegration, z-scores, volatility).

    • This is where raw data becomes trade-ready insights.


  4. Results Persistence

    • All outputs are written back into dedicated stats tables for fast retrieval.


API & Interaction Layer

Once signals are generated, traders and systems need to access them.

  • API Layer → the front door. Handles requests from trading interfaces or external agents, pulls data from the database, and returns it cleanly.

  • Security & Signals → every request is validated with API keys. The same interface also exposes the final signal outputs — turning complex analytics into clear, actionable trade signals.

Takeaway: The architecture ensures reliability, security, and real-time performance - so you can focus on trading, not on infrastructure.



6. Signal Generation Architecture: A Dual-Phase Approach

Once we’ve built the data layer and calculators, the real challenge is turning raw numbers into signals you can actually trade on.

Agent Pear’s signal engine works in two phases:

  1. Batch Discovery → find and rank potential opportunities.

  2. Continuous Monitoring → activate, track, and manage trades in real time.



———————————————————————————————————————————————————————-


Phase 1: Batch Discovery

Think of this as the “scouting phase.” The system scans the entire market and builds a watchlist of high-potential pairs.

  • Sourcing & Filtering

    • Pulls in all pairs with fresh, high-quality stats.

    • Applies quality gates (data sufficiency, stability, no duplicates).


  • Enrichment & Ranking

    • Adds extra context like lead-lag analysis and quick spread backtests.

    • Ranks pairs by strength of mean-reversion signal.


  • Segregation

    • Only a few high-conviction signals are activated immediately.

    • The rest are stored in a watchlist to wait for better entry conditions.


———————————————————————————————————————————————————————-


Phase 2: Continuous Monitoring

This is the always-on engine that watches both the watchlist and live trades.

  • Activating Opportunities

    • Continuously recalculates spreads and z-scores in real time.

    • If a pair crosses a threshold and the market regime looks favorable, it’s promoted to an active trade.

    • The trade is logged in the ledger and a notification goes out instantly.


  • Managing Active Trades
    Once live, each trade is managed with strict rules:


    • Profit-Taking → exit when spread reverts to mean.

    • Dynamic Stop-Loss → exit if spread keeps moving against you.

    • Time Expiry → close if it drags on past its expected half-life.


———————————————————————————————————————————————————————-


Qualitative Enrichment: The AI Narrative Layer

Numbers alone don’t tell the full story. That’s where the AI Narrative Engine comes in.

For every signal, Pear adds a short qualitative remark:

“BTC/SOL diverged unusually far, with strong historical mean-reversion. Expected window: ~8h.”

This bridges the gap between quant output and trader intuition - so instead of staring at a z-score chart, you get a clear story you can act on.



Agent Pear Status

All of the above is now live and Agent Pear will be rolled out in Stages.

Phase 1: For any pair, we now show some key statistics, on demand, for users of Pear Protocol. For example, a user wanting to enter a long LINK / short XRP can see the correlation and real time Z-Score. The extension of this will be to use the beta and volatility calculations to suggest different weightings for the long and short leg respectively.


Phase 2: In this phase we will roll out the signals on a dedicated token-gated page, with holders of staked PEAR (stPEAR) being able to see live trade signals, and importantly with alerts when to enter and close them.



Phase 3: The agent then becomes conversational, so users can speak to it in natural language and get real time thoughts on their pair trades. E.g. one prompt might be:

“What do you think about a long ETH / short SOL pair trade right now?”

Agent Pear would then give a detailed breakdown based not just on statistics, but also live data from various APIs on net funding rates, open interest, liquidation data, upcoming token unlocks and more



Phase 4: The Agent becomes fully autonomous and can enter, monitor and close pair trades. The monetisation for this then becomes Vault architecture, where users deposit their stablecoins like USDC, and the Agent executes trades based on pre-established risk management parameters. Thus, Pear goes from being a full stack pair trading platform to morphing into an AI-powered Asset Management business.




Appendix

Here’s how each component works:

  • Spread Calculator

    • Regress one asset against another to find hedge ratio (β).

    • Dual-beta design:

      • Structural beta (long history) → defines the baseline relationship.

      • Dynamic beta (short window tied to half-life) → adapts to current market conditions.

    • Integrity checks (R², standard error) keep it statistically valid.


  • Correlation Calculator

    • Quick screen using Pearson correlation on log returns.

    • Safeguards for sample size + stability → avoids false positives in volatile coins.


  • Cointegration Calculator

    • ADF test on residuals to check stationarity.

    • Instead of generic tables, we generated our own Monte Carlo thresholds tuned for crypto.

    • Conviction score blends: ADF distance, regression fit (R²), half-life, and Hurst exponent.


  • Half-Life Calculator

    • Fits AR(1) model to the spread.

    • Tells us the expected “action window” for a trade.


  • Z-Score Calculator

    • Two layers:

      • Structural z-score → long-term view.

      • Execution z-score → rolling window for real-time signals.


  • Hurst Exponent Calculator

    • Classifies behaviour:

      • H < 0.5 = mean-reverting.

      • H ≈ 0.5 = random walk.

      • H > 0.5 = trending.

    • Optional DFA path for messy series.


  • Regime Detection

    • Uses z-score + volatility ratios to classify states like Strong Reversion, Peak Divergence, or Idle.

    • Adds “narrative context” for risk gating.


  • Volatility Calculators

    • Daily → Yang-Zhang (handles overnight gaps).

    • Hourly → Parkinson (best for intraday ranges).

    • Spread → close-to-close.


  • Backtester

    • Lightweight mean-reversion sim.

    • Outputs: win rate, Sharpe, max drawdown.

    • Purpose: quickly sanity-check signals, not model full execution.

Novice Navigator

5 min read

Building a Specialised Agent for Pair Trading

(That does your risk assessment and empowers you with tooling to become more profitable)

1. Why Pair Trading?

Most traders in crypto focus on a single question: “Will this token go up or down?”
Pair trading flips the script. Instead of betting on absolute price, you trade relationships.

There are multiple approaches to pair trading:

  1. Fundamental – e.g. long HYPE / short DYDX

  2. Technical – e.g. based on charts like ETH/BTC

  3. Narrative & Mindshare – e.g. long PUMP / short SOL

A fourth, well-established technique is to take a statistical approach. Here, traders examine variables between two assets such as:

  • their correlation,

  • the current price difference (spread), and

  • how today’s spread compares to its historical average (mean).

The “arbitrage” arises because spreads between related assets tend to mean-revert when they deviate too far. For example, if BTC keeps falling whilst SOL keeps rising, the BTC/SOL spread collapses. A trader applying statistical arbitrage might go long BTC and short SOL, anticipating that the spread will snap back toward its mean.



This method - known as Statistical Arbitrage, is a cornerstone of traditional finance. And because crypto markets are still relatively inefficient, the opportunities to profit from it can be even greater.

To see how this works in practice, it helps to break down the building blocks of statistical arbitrage.



2. Statistical Arbitrage 101

Statistical arbitrage, or stat-arb, is about turning the relationship between two assets into a tradeable signal

Key Concepts
  • Correlation – measures how closely two assets move together. A high correlation suggests a relationship worth monitoring.

  • Beta (β) – shows how much one asset typically moves compared to the other. If SOL tends to move 1.3% when BTC moves 1%, then the hedge ratio is 1.3.

  • Spread – the difference between BTC and SOL after adjusting for beta. This is the trader’s signal:

𝑆𝑝𝑟𝑒𝑎𝑑ₜ = 𝑃ᴮᵀᶜ,ₜ − β · 𝑃ˢᴼᴸ,ₜ

  • Z-score – a way to measure how far today’s spread is from its historical average (mean, denoted as μ). Generally speaking you want to long the pair when Z-Score is <-2 and vice versa.

𝑧ₜ = (𝑆𝑝𝑟𝑒𝑎𝑑ₜ − μ) / σ

Example: BTC vs SOL

Suppose BTC and SOL usually move in sync. If BTC falls sharply while SOL rallies, the BTC/SOL spread shrinks. If the spread is now two standard deviations (σ)  below its mean (Z-score <-2), a stat-arb trader might:

  • Go long BTC and short SOL (beta-weighted),

  • Hold the position until the spread normalises,

  • Exit with profit once mean reversion plays out.

This approach reframes trading: the bet is not on whether BTC will rise or SOL will fall, but on the spread between them returning to equilibrium. Here is the same diagram, with the Z-Score being <-2σ clearly labelled as an entry signal. 


The challenge is not understanding these concepts, but finding opportunities across dozens of assets in real time.



3. Finding Opportunities

So far we have looked at statistical arbitrage in theory. In practice, traders needed tools to surface opportunities, and one of the main options was Crypto Wizards.


Crypto Wizards provided dashboards full of ratios, correlations, and spread charts. On paper this looked powerful, but many traders found it confusing to navigate. The issue was not the math but the usability. Traders did not want another complex dashboard. They wanted simple, tradeable insights: "Here is a pair diverging. Here is when to take the trade."

This is where Agent Pear comes in.

We have rebuilt the full statistical library on our own backend, covering correlation, beta, spreads, and z-scores. The system now updates in real time. Instead of static charts, traders are alerted the moment mean reversion opportunities arise, for example when the z-score compresses.

The result is actionable, trade-ready signals rather than raw analytics. Agent Pear closes the gap between statistical arbitrage theory and real-world execution in fast-moving crypto markets.

This shift from analytics to execution is what Agent Pear is designed to solve.


4. Our approach to rebuilding Crypto Wizards 

When we looked at the original CryptoWizards platform, we saw a lot to admire. It gave traders statistical-arbitrage tools, educational material, and curated backtests - all focused on a limited set of crypto pairs. That was a strong foundation, but we wanted to take things further and build our own library.

Our goal with Agent Pear was to recreate that core experience of pair discovery, statistical insights, and monitoring, and then extend it in three ways:

  1. Execution built-in – not just analysis, but the ability to act directly on signals.

  2. Full-universe coverage – not limited to a subset, but spanning all tradable pairs across supported platforms.

  3. AI-driven context – instead of leaving you to decipher charts, we add narrative explanations that make the opportunities clear.

Database & Time-Series Foundation

A reliable stat-arb agent is only as good as its data. We rebuilt the database from scratch utilising both hourly and daily time series data from the relevant exchanges where our execution/hedging takes place (e.g. Hourly time series data comes directly from HyperCore itself). 

  • Hourly OHLC data: Fine-grained enough to spot intraday divergences, volatility bursts, and short-term reversions.

  • Daily OHLC data: Smooths out noise, perfect for identifying structural shifts, long-term correlations, and regime changes.

  • Each record is indexed with a composite key (time, asset1_id, asset2_id) for efficient retrieval and backtests.


Pair Statistics

For every tracked pair, we calculate and store a full set of metrics at both the 1h and 1d level:

  • Correlation — how closely two assets move together

  • β (hedge ratio) — the relative move of one asset versus the other

  • Spread snapshot — the difference between the beta-adjusted prices

  • Z-score — how far today’s spread is from its long-term mean

  • Cointegration check - confirms a long-term, mean-reverting relationship exists between the two asset prices.

  • Half-life — how quickly the spread tends to revert

  • Sharpe ratio (daily) - to filter for robust strategies

This gives traders a quantifiable, real-time picture of relationships across the market, across 2 different timeframes. 

Importantly, we didn’t just port off-the-shelf quant libraries. Crypto markets behave differently - noisier, more volatile, with structural quirks. So we rebuilt every calculator from scratch. A full breakdown of each calculation is in the Appendix.

Volatility-Aware Signalling

Not all divergences are equal. A spread breaking down during extreme volatility is very different from one in a quiet market. To account for this, we:

  • Compute pair-level volatility in both short (1h) and long (1d) windows

  • Classify regime states (calm vs. volatile) to help you adjust your risk


From Data to Decisions: Signals & Execution

With these building blocks in place, we can surface two levels of actionable insights:

  • Viable signals → opportunities that pass our statistical and backtest filters, showing where pairs are diverging enough to watch.

  • Live trades → when conditions align (e.g. spread < −2σ with strong historical mean reversion), Agent Pear triggers alerts and can be integrated directly with execution on venues like Hyperliquid.

By rebuilding the data layer, extending coverage to the full universe, and adding AI-powered narrative context, we’ve created an agent that doesn’t just crunch numbers - it tells you the story behind the trade and equips you to act.


5. Agent Pear Architecture


Behind the scenes, Agent Pear runs on a production-grade pipeline. Think of it as an orchestra: every component has a role, and the orchestrator makes sure they play in sync.

Orchestration & Configuration
  • Orchestration Service → the conductor. On a fixed schedule (hourly and daily), it lines up each task in the right order:

    1. Fetch fresh data

    2. Store it safely

    3. Run analytics

This sequencing prevents race conditions and ensures data integrity.

  • Configuration Service → the stage manager. It provides credentials, database connections, and settings to all modules, so nothing is hardcoded. That makes the system flexible, secure, and portable across environments.


The Automated Data Pipeline

The pipeline transforms raw market data into actionable intelligence through four layers:

  1. Ingestion Layer

    • Connects directly to exchanges (e.g. Hyperliquid).

    • Pulls in two streams: raw time-series price data + metadata about assets/pairs.


  2. Storage Layer

    • Everything is written into a central database.

    • A unified data-access gateway means every service reads/writes in a consistent, secure way.


  3. Analytical Layer

    • The orchestrator triggers our custom calculators (correlation, cointegration, z-scores, volatility).

    • This is where raw data becomes trade-ready insights.


  4. Results Persistence

    • All outputs are written back into dedicated stats tables for fast retrieval.


API & Interaction Layer

Once signals are generated, traders and systems need to access them.

  • API Layer → the front door. Handles requests from trading interfaces or external agents, pulls data from the database, and returns it cleanly.

  • Security & Signals → every request is validated with API keys. The same interface also exposes the final signal outputs — turning complex analytics into clear, actionable trade signals.

Takeaway: The architecture ensures reliability, security, and real-time performance - so you can focus on trading, not on infrastructure.



6. Signal Generation Architecture: A Dual-Phase Approach

Once we’ve built the data layer and calculators, the real challenge is turning raw numbers into signals you can actually trade on.

Agent Pear’s signal engine works in two phases:

  1. Batch Discovery → find and rank potential opportunities.

  2. Continuous Monitoring → activate, track, and manage trades in real time.



———————————————————————————————————————————————————————-


Phase 1: Batch Discovery

Think of this as the “scouting phase.” The system scans the entire market and builds a watchlist of high-potential pairs.

  • Sourcing & Filtering

    • Pulls in all pairs with fresh, high-quality stats.

    • Applies quality gates (data sufficiency, stability, no duplicates).


  • Enrichment & Ranking

    • Adds extra context like lead-lag analysis and quick spread backtests.

    • Ranks pairs by strength of mean-reversion signal.


  • Segregation

    • Only a few high-conviction signals are activated immediately.

    • The rest are stored in a watchlist to wait for better entry conditions.


———————————————————————————————————————————————————————-


Phase 2: Continuous Monitoring

This is the always-on engine that watches both the watchlist and live trades.

  • Activating Opportunities

    • Continuously recalculates spreads and z-scores in real time.

    • If a pair crosses a threshold and the market regime looks favorable, it’s promoted to an active trade.

    • The trade is logged in the ledger and a notification goes out instantly.


  • Managing Active Trades
    Once live, each trade is managed with strict rules:


    • Profit-Taking → exit when spread reverts to mean.

    • Dynamic Stop-Loss → exit if spread keeps moving against you.

    • Time Expiry → close if it drags on past its expected half-life.


———————————————————————————————————————————————————————-


Qualitative Enrichment: The AI Narrative Layer

Numbers alone don’t tell the full story. That’s where the AI Narrative Engine comes in.

For every signal, Pear adds a short qualitative remark:

“BTC/SOL diverged unusually far, with strong historical mean-reversion. Expected window: ~8h.”

This bridges the gap between quant output and trader intuition - so instead of staring at a z-score chart, you get a clear story you can act on.



Agent Pear Status

All of the above is now live and Agent Pear will be rolled out in Stages.

Phase 1: For any pair, we now show some key statistics, on demand, for users of Pear Protocol. For example, a user wanting to enter a long LINK / short XRP can see the correlation and real time Z-Score. The extension of this will be to use the beta and volatility calculations to suggest different weightings for the long and short leg respectively.


Phase 2: In this phase we will roll out the signals on a dedicated token-gated page, with holders of staked PEAR (stPEAR) being able to see live trade signals, and importantly with alerts when to enter and close them.



Phase 3: The agent then becomes conversational, so users can speak to it in natural language and get real time thoughts on their pair trades. E.g. one prompt might be:

“What do you think about a long ETH / short SOL pair trade right now?”

Agent Pear would then give a detailed breakdown based not just on statistics, but also live data from various APIs on net funding rates, open interest, liquidation data, upcoming token unlocks and more



Phase 4: The Agent becomes fully autonomous and can enter, monitor and close pair trades. The monetisation for this then becomes Vault architecture, where users deposit their stablecoins like USDC, and the Agent executes trades based on pre-established risk management parameters. Thus, Pear goes from being a full stack pair trading platform to morphing into an AI-powered Asset Management business.




Appendix

Here’s how each component works:

  • Spread Calculator

    • Regress one asset against another to find hedge ratio (β).

    • Dual-beta design:

      • Structural beta (long history) → defines the baseline relationship.

      • Dynamic beta (short window tied to half-life) → adapts to current market conditions.

    • Integrity checks (R², standard error) keep it statistically valid.


  • Correlation Calculator

    • Quick screen using Pearson correlation on log returns.

    • Safeguards for sample size + stability → avoids false positives in volatile coins.


  • Cointegration Calculator

    • ADF test on residuals to check stationarity.

    • Instead of generic tables, we generated our own Monte Carlo thresholds tuned for crypto.

    • Conviction score blends: ADF distance, regression fit (R²), half-life, and Hurst exponent.


  • Half-Life Calculator

    • Fits AR(1) model to the spread.

    • Tells us the expected “action window” for a trade.


  • Z-Score Calculator

    • Two layers:

      • Structural z-score → long-term view.

      • Execution z-score → rolling window for real-time signals.


  • Hurst Exponent Calculator

    • Classifies behaviour:

      • H < 0.5 = mean-reverting.

      • H ≈ 0.5 = random walk.

      • H > 0.5 = trending.

    • Optional DFA path for messy series.


  • Regime Detection

    • Uses z-score + volatility ratios to classify states like Strong Reversion, Peak Divergence, or Idle.

    • Adds “narrative context” for risk gating.


  • Volatility Calculators

    • Daily → Yang-Zhang (handles overnight gaps).

    • Hourly → Parkinson (best for intraday ranges).

    • Spread → close-to-close.


  • Backtester

    • Lightweight mean-reversion sim.

    • Outputs: win rate, Sharpe, max drawdown.

    • Purpose: quickly sanity-check signals, not model full execution.

Sep 1, 2025

Novice Navigator

5 min read

Building a Specialised Agent for Pair Trading

(That does your risk assessment and empowers you with tooling to become more profitable)

1. Why Pair Trading?

Most traders in crypto focus on a single question: “Will this token go up or down?”
Pair trading flips the script. Instead of betting on absolute price, you trade relationships.

There are multiple approaches to pair trading:

  1. Fundamental – e.g. long HYPE / short DYDX

  2. Technical – e.g. based on charts like ETH/BTC

  3. Narrative & Mindshare – e.g. long PUMP / short SOL

A fourth, well-established technique is to take a statistical approach. Here, traders examine variables between two assets such as:

  • their correlation,

  • the current price difference (spread), and

  • how today’s spread compares to its historical average (mean).

The “arbitrage” arises because spreads between related assets tend to mean-revert when they deviate too far. For example, if BTC keeps falling whilst SOL keeps rising, the BTC/SOL spread collapses. A trader applying statistical arbitrage might go long BTC and short SOL, anticipating that the spread will snap back toward its mean.



This method - known as Statistical Arbitrage, is a cornerstone of traditional finance. And because crypto markets are still relatively inefficient, the opportunities to profit from it can be even greater.

To see how this works in practice, it helps to break down the building blocks of statistical arbitrage.



2. Statistical Arbitrage 101

Statistical arbitrage, or stat-arb, is about turning the relationship between two assets into a tradeable signal

Key Concepts
  • Correlation – measures how closely two assets move together. A high correlation suggests a relationship worth monitoring.

  • Beta (β) – shows how much one asset typically moves compared to the other. If SOL tends to move 1.3% when BTC moves 1%, then the hedge ratio is 1.3.

  • Spread – the difference between BTC and SOL after adjusting for beta. This is the trader’s signal:

𝑆𝑝𝑟𝑒𝑎𝑑ₜ = 𝑃ᴮᵀᶜ,ₜ − β · 𝑃ˢᴼᴸ,ₜ

  • Z-score – a way to measure how far today’s spread is from its historical average (mean, denoted as μ). Generally speaking you want to long the pair when Z-Score is <-2 and vice versa.

𝑧ₜ = (𝑆𝑝𝑟𝑒𝑎𝑑ₜ − μ) / σ

Example: BTC vs SOL

Suppose BTC and SOL usually move in sync. If BTC falls sharply while SOL rallies, the BTC/SOL spread shrinks. If the spread is now two standard deviations (σ)  below its mean (Z-score <-2), a stat-arb trader might:

  • Go long BTC and short SOL (beta-weighted),

  • Hold the position until the spread normalises,

  • Exit with profit once mean reversion plays out.

This approach reframes trading: the bet is not on whether BTC will rise or SOL will fall, but on the spread between them returning to equilibrium. Here is the same diagram, with the Z-Score being <-2σ clearly labelled as an entry signal. 


The challenge is not understanding these concepts, but finding opportunities across dozens of assets in real time.



3. Finding Opportunities

So far we have looked at statistical arbitrage in theory. In practice, traders needed tools to surface opportunities, and one of the main options was Crypto Wizards.


Crypto Wizards provided dashboards full of ratios, correlations, and spread charts. On paper this looked powerful, but many traders found it confusing to navigate. The issue was not the math but the usability. Traders did not want another complex dashboard. They wanted simple, tradeable insights: "Here is a pair diverging. Here is when to take the trade."

This is where Agent Pear comes in.

We have rebuilt the full statistical library on our own backend, covering correlation, beta, spreads, and z-scores. The system now updates in real time. Instead of static charts, traders are alerted the moment mean reversion opportunities arise, for example when the z-score compresses.

The result is actionable, trade-ready signals rather than raw analytics. Agent Pear closes the gap between statistical arbitrage theory and real-world execution in fast-moving crypto markets.

This shift from analytics to execution is what Agent Pear is designed to solve.


4. Our approach to rebuilding Crypto Wizards 

When we looked at the original CryptoWizards platform, we saw a lot to admire. It gave traders statistical-arbitrage tools, educational material, and curated backtests - all focused on a limited set of crypto pairs. That was a strong foundation, but we wanted to take things further and build our own library.

Our goal with Agent Pear was to recreate that core experience of pair discovery, statistical insights, and monitoring, and then extend it in three ways:

  1. Execution built-in – not just analysis, but the ability to act directly on signals.

  2. Full-universe coverage – not limited to a subset, but spanning all tradable pairs across supported platforms.

  3. AI-driven context – instead of leaving you to decipher charts, we add narrative explanations that make the opportunities clear.

Database & Time-Series Foundation

A reliable stat-arb agent is only as good as its data. We rebuilt the database from scratch utilising both hourly and daily time series data from the relevant exchanges where our execution/hedging takes place (e.g. Hourly time series data comes directly from HyperCore itself). 

  • Hourly OHLC data: Fine-grained enough to spot intraday divergences, volatility bursts, and short-term reversions.

  • Daily OHLC data: Smooths out noise, perfect for identifying structural shifts, long-term correlations, and regime changes.

  • Each record is indexed with a composite key (time, asset1_id, asset2_id) for efficient retrieval and backtests.


Pair Statistics

For every tracked pair, we calculate and store a full set of metrics at both the 1h and 1d level:

  • Correlation — how closely two assets move together

  • β (hedge ratio) — the relative move of one asset versus the other

  • Spread snapshot — the difference between the beta-adjusted prices

  • Z-score — how far today’s spread is from its long-term mean

  • Cointegration check - confirms a long-term, mean-reverting relationship exists between the two asset prices.

  • Half-life — how quickly the spread tends to revert

  • Sharpe ratio (daily) - to filter for robust strategies

This gives traders a quantifiable, real-time picture of relationships across the market, across 2 different timeframes. 

Importantly, we didn’t just port off-the-shelf quant libraries. Crypto markets behave differently - noisier, more volatile, with structural quirks. So we rebuilt every calculator from scratch. A full breakdown of each calculation is in the Appendix.

Volatility-Aware Signalling

Not all divergences are equal. A spread breaking down during extreme volatility is very different from one in a quiet market. To account for this, we:

  • Compute pair-level volatility in both short (1h) and long (1d) windows

  • Classify regime states (calm vs. volatile) to help you adjust your risk


From Data to Decisions: Signals & Execution

With these building blocks in place, we can surface two levels of actionable insights:

  • Viable signals → opportunities that pass our statistical and backtest filters, showing where pairs are diverging enough to watch.

  • Live trades → when conditions align (e.g. spread < −2σ with strong historical mean reversion), Agent Pear triggers alerts and can be integrated directly with execution on venues like Hyperliquid.

By rebuilding the data layer, extending coverage to the full universe, and adding AI-powered narrative context, we’ve created an agent that doesn’t just crunch numbers - it tells you the story behind the trade and equips you to act.


5. Agent Pear Architecture


Behind the scenes, Agent Pear runs on a production-grade pipeline. Think of it as an orchestra: every component has a role, and the orchestrator makes sure they play in sync.

Orchestration & Configuration
  • Orchestration Service → the conductor. On a fixed schedule (hourly and daily), it lines up each task in the right order:

    1. Fetch fresh data

    2. Store it safely

    3. Run analytics

This sequencing prevents race conditions and ensures data integrity.

  • Configuration Service → the stage manager. It provides credentials, database connections, and settings to all modules, so nothing is hardcoded. That makes the system flexible, secure, and portable across environments.


The Automated Data Pipeline

The pipeline transforms raw market data into actionable intelligence through four layers:

  1. Ingestion Layer

    • Connects directly to exchanges (e.g. Hyperliquid).

    • Pulls in two streams: raw time-series price data + metadata about assets/pairs.


  2. Storage Layer

    • Everything is written into a central database.

    • A unified data-access gateway means every service reads/writes in a consistent, secure way.


  3. Analytical Layer

    • The orchestrator triggers our custom calculators (correlation, cointegration, z-scores, volatility).

    • This is where raw data becomes trade-ready insights.


  4. Results Persistence

    • All outputs are written back into dedicated stats tables for fast retrieval.


API & Interaction Layer

Once signals are generated, traders and systems need to access them.

  • API Layer → the front door. Handles requests from trading interfaces or external agents, pulls data from the database, and returns it cleanly.

  • Security & Signals → every request is validated with API keys. The same interface also exposes the final signal outputs — turning complex analytics into clear, actionable trade signals.

Takeaway: The architecture ensures reliability, security, and real-time performance - so you can focus on trading, not on infrastructure.



6. Signal Generation Architecture: A Dual-Phase Approach

Once we’ve built the data layer and calculators, the real challenge is turning raw numbers into signals you can actually trade on.

Agent Pear’s signal engine works in two phases:

  1. Batch Discovery → find and rank potential opportunities.

  2. Continuous Monitoring → activate, track, and manage trades in real time.



———————————————————————————————————————————————————————-


Phase 1: Batch Discovery

Think of this as the “scouting phase.” The system scans the entire market and builds a watchlist of high-potential pairs.

  • Sourcing & Filtering

    • Pulls in all pairs with fresh, high-quality stats.

    • Applies quality gates (data sufficiency, stability, no duplicates).


  • Enrichment & Ranking

    • Adds extra context like lead-lag analysis and quick spread backtests.

    • Ranks pairs by strength of mean-reversion signal.


  • Segregation

    • Only a few high-conviction signals are activated immediately.

    • The rest are stored in a watchlist to wait for better entry conditions.


———————————————————————————————————————————————————————-


Phase 2: Continuous Monitoring

This is the always-on engine that watches both the watchlist and live trades.

  • Activating Opportunities

    • Continuously recalculates spreads and z-scores in real time.

    • If a pair crosses a threshold and the market regime looks favorable, it’s promoted to an active trade.

    • The trade is logged in the ledger and a notification goes out instantly.


  • Managing Active Trades
    Once live, each trade is managed with strict rules:


    • Profit-Taking → exit when spread reverts to mean.

    • Dynamic Stop-Loss → exit if spread keeps moving against you.

    • Time Expiry → close if it drags on past its expected half-life.


———————————————————————————————————————————————————————-


Qualitative Enrichment: The AI Narrative Layer

Numbers alone don’t tell the full story. That’s where the AI Narrative Engine comes in.

For every signal, Pear adds a short qualitative remark:

“BTC/SOL diverged unusually far, with strong historical mean-reversion. Expected window: ~8h.”

This bridges the gap between quant output and trader intuition - so instead of staring at a z-score chart, you get a clear story you can act on.



Agent Pear Status

All of the above is now live and Agent Pear will be rolled out in Stages.

Phase 1: For any pair, we now show some key statistics, on demand, for users of Pear Protocol. For example, a user wanting to enter a long LINK / short XRP can see the correlation and real time Z-Score. The extension of this will be to use the beta and volatility calculations to suggest different weightings for the long and short leg respectively.


Phase 2: In this phase we will roll out the signals on a dedicated token-gated page, with holders of staked PEAR (stPEAR) being able to see live trade signals, and importantly with alerts when to enter and close them.



Phase 3: The agent then becomes conversational, so users can speak to it in natural language and get real time thoughts on their pair trades. E.g. one prompt might be:

“What do you think about a long ETH / short SOL pair trade right now?”

Agent Pear would then give a detailed breakdown based not just on statistics, but also live data from various APIs on net funding rates, open interest, liquidation data, upcoming token unlocks and more



Phase 4: The Agent becomes fully autonomous and can enter, monitor and close pair trades. The monetisation for this then becomes Vault architecture, where users deposit their stablecoins like USDC, and the Agent executes trades based on pre-established risk management parameters. Thus, Pear goes from being a full stack pair trading platform to morphing into an AI-powered Asset Management business.




Appendix

Here’s how each component works:

  • Spread Calculator

    • Regress one asset against another to find hedge ratio (β).

    • Dual-beta design:

      • Structural beta (long history) → defines the baseline relationship.

      • Dynamic beta (short window tied to half-life) → adapts to current market conditions.

    • Integrity checks (R², standard error) keep it statistically valid.


  • Correlation Calculator

    • Quick screen using Pearson correlation on log returns.

    • Safeguards for sample size + stability → avoids false positives in volatile coins.


  • Cointegration Calculator

    • ADF test on residuals to check stationarity.

    • Instead of generic tables, we generated our own Monte Carlo thresholds tuned for crypto.

    • Conviction score blends: ADF distance, regression fit (R²), half-life, and Hurst exponent.


  • Half-Life Calculator

    • Fits AR(1) model to the spread.

    • Tells us the expected “action window” for a trade.


  • Z-Score Calculator

    • Two layers:

      • Structural z-score → long-term view.

      • Execution z-score → rolling window for real-time signals.


  • Hurst Exponent Calculator

    • Classifies behaviour:

      • H < 0.5 = mean-reverting.

      • H ≈ 0.5 = random walk.

      • H > 0.5 = trending.

    • Optional DFA path for messy series.


  • Regime Detection

    • Uses z-score + volatility ratios to classify states like Strong Reversion, Peak Divergence, or Idle.

    • Adds “narrative context” for risk gating.


  • Volatility Calculators

    • Daily → Yang-Zhang (handles overnight gaps).

    • Hourly → Parkinson (best for intraday ranges).

    • Spread → close-to-close.


  • Backtester

    • Lightweight mean-reversion sim.

    • Outputs: win rate, Sharpe, max drawdown.

    • Purpose: quickly sanity-check signals, not model full execution.

Sep 1, 2025

Novice Navigator

2 min read

How Pear Protocol Enhances Pair Trading on Hyperliquid

If you're actively trading on Hyperliquid, you're already ahead of the curve. But if you're managing each leg of a pair trade manually—long HYPE, short SOL, for example—you're leaving alpha (and points) on the table. Here's why using Pear Protocol x Hyperliquid is the smarter, faster, and more profitable way to pair trade.


1. 🎯 Take-Profit / Stop-Loss on the Ratio

In manual pair trading, managing TP/SL for each leg is a headache. You’re subject to the path dependence of both assets—HYPE could moon while SOL crabwalks, and you’re left guessing. On Pear, TP/SL logic is applied directly on the ratio, not the individual legs. This gives you:

  • Precise risk management

  • Simpler setups

  • Cleaner exits

2. 💸 Superior Execution with Limit & TWAP Orders

Forget micromanaging leg fills. Pear lets you:

  • Set limit orders on the ratio

  • Execute TWAP orders over time to reduce slippage

  • Avoid the drift that happens when leg execution is misaligned

This leads to tighter entries, cleaner fills, and better performance.

3. 📈 Earn More with Season 3 Points

If Hyperliquid launches a Season 3 campaign, volume traded through Pear still counts toward your Season 3 leaderboard. So you’re not just trading smarter—you’re earning more.

4. ⚖️ Custom Weighting Strategies (Coming Soon)

Manual leg sizing often ignores volatility or beta. In addition to Custom Weightings (available), Pear Protocol is rolling out:

  • Beta-weighted pair construction

  • Volatility-weighted allocations

Soon, you’ll be able to build institutional-grade pair strategies in one click.

5. ⚡ One-Click Entry & Exit

No more leg-by-leg execution. One click enters or exits the full position. That means:

  • Less room for error

  • Faster trade deployment

  • Easier mobile execution

6. 📊 Direct Charting of Ratios

Want to chart HYPE/SOL directly? Good luck doing that manually. Pear gives you:

  • Custom pair ratio charts

  • Historical data overlays

  • Visual clarity for trade setups

7. 💰 Analyse Net Funding Across Pairs

The Markets page shows you:

  • Net funding differentials

  • Cost of holding positions

  • Alpha opportunities in funding arbitrage

No spreadsheet hacks required.

8. ⭐ Favourite Your Pairs

Track your favourite pairs and monitor:

  • Daily PnL

  • 24h performance

  • Spread changes

Perfect for power users managing a basket of trades.


9. 🎁 Earn Hypear Points

Trading on Pear earns Hypear Points, based on:

  • Volume

  • PnL

These convert directly into claimable $HYPE. So your trades aren’t just profitable—they’re rewarded.

🔟 [Redacted] 🤫

Stay tuned.


Pear x Hyperliquid is not just a better interface—it's a complete edge amplifier for pair traders.



Jul 10, 2025

Novice Navigator

2 min read

How Pear Protocol Enhances Pair Trading on Hyperliquid

If you're actively trading on Hyperliquid, you're already ahead of the curve. But if you're managing each leg of a pair trade manually—long HYPE, short SOL, for example—you're leaving alpha (and points) on the table. Here's why using Pear Protocol x Hyperliquid is the smarter, faster, and more profitable way to pair trade.


1. 🎯 Take-Profit / Stop-Loss on the Ratio

In manual pair trading, managing TP/SL for each leg is a headache. You’re subject to the path dependence of both assets—HYPE could moon while SOL crabwalks, and you’re left guessing. On Pear, TP/SL logic is applied directly on the ratio, not the individual legs. This gives you:

  • Precise risk management

  • Simpler setups

  • Cleaner exits

2. 💸 Superior Execution with Limit & TWAP Orders

Forget micromanaging leg fills. Pear lets you:

  • Set limit orders on the ratio

  • Execute TWAP orders over time to reduce slippage

  • Avoid the drift that happens when leg execution is misaligned

This leads to tighter entries, cleaner fills, and better performance.

3. 📈 Earn More with Season 3 Points

If Hyperliquid launches a Season 3 campaign, volume traded through Pear still counts toward your Season 3 leaderboard. So you’re not just trading smarter—you’re earning more.

4. ⚖️ Custom Weighting Strategies (Coming Soon)

Manual leg sizing often ignores volatility or beta. In addition to Custom Weightings (available), Pear Protocol is rolling out:

  • Beta-weighted pair construction

  • Volatility-weighted allocations

Soon, you’ll be able to build institutional-grade pair strategies in one click.

5. ⚡ One-Click Entry & Exit

No more leg-by-leg execution. One click enters or exits the full position. That means:

  • Less room for error

  • Faster trade deployment

  • Easier mobile execution

6. 📊 Direct Charting of Ratios

Want to chart HYPE/SOL directly? Good luck doing that manually. Pear gives you:

  • Custom pair ratio charts

  • Historical data overlays

  • Visual clarity for trade setups

7. 💰 Analyse Net Funding Across Pairs

The Markets page shows you:

  • Net funding differentials

  • Cost of holding positions

  • Alpha opportunities in funding arbitrage

No spreadsheet hacks required.

8. ⭐ Favourite Your Pairs

Track your favourite pairs and monitor:

  • Daily PnL

  • 24h performance

  • Spread changes

Perfect for power users managing a basket of trades.


9. 🎁 Earn Hypear Points

Trading on Pear earns Hypear Points, based on:

  • Volume

  • PnL

These convert directly into claimable $HYPE. So your trades aren’t just profitable—they’re rewarded.

🔟 [Redacted] 🤫

Stay tuned.


Pear x Hyperliquid is not just a better interface—it's a complete edge amplifier for pair traders.



Jul 10, 2025

Trading Bitcoin Dominance

Novice Navigator

2 min read

What is Bitcoin Dominance and How to Trade it on Pear Protocol

Bitcoin Dominance (BTC.d or BTCDOM) is Bitcoin's market share relative to the whole crypto market share. It’s calculated by dividing Bitcoin's market capitalization by the total market capitalization of all crypto currencies and multiplying it by 100.

For example: If Bitcoin's market capitalization is 2 Trillion and the market capitalization of all crypto currencies is 3.4 Trillion, BTC dominance would be: (2 / 3.4) * 100 = 58.8

In other words, Bitcoin makes up 58.8% of all crypto currencies.

Why is this interesting?

Bitcoin dominance gives you an idea where we could be in the market cycle.

If it rises it could either mean that Bitcoin price is going up and altcoins are staying flat or even declining.

If it goes down that either means Bitcoin price is going down or altcoins are growing in value.

Changes in the BTC.d could either mean that money is flowing from BTC to alts or vice versa or that new money is coming in for one of these sectors.

Historically, at the start of a bull market cycle, money flows into Bitcoin and Bitcoin dominance rises. At some point it tops and through a wealth effect it flows into alt coins, which leads to a further decline in BTC.d


Trading BTC.d index

What if there was a way to put money on BTC.d going up or down? This index is traded on Binance and Bitfinex and is also available as a long or short leg on the INTENT engine on Pear Protocol:

https://intent.pear.garden/trade/BTCDOM-USDC

How to use it for trading?

A) Long BTCDOM

Longing BTCDOM vs. USDC results in a straight long position


B) Short BTCDOM

Shorting BTCDOM vs. USDC results in a short position and is betting on altcoins to rise


C) As a short leg: Betting on the beginning of an altcoin season AND ethereum profiting

For example: Long ETH / Short BTCDOM 


D) As a long leg: Betting on the decline of altcoins and BTCs growth.

For example: When Bitcoin is showing strength and a small correction in Bitcoin lets altcoins correct 20-30%, Long BTCDOM / Short Meme coins


Recent BTCDOM trades and ideas

  • BTC / BTCDOM

  • SOL / BTCDOM

  • BTCDOM / USDC

  • USDC / BTCDOM

  • DOGE / BTCDOM

  • ETH / BTCDOM

  • BTCDOM / XLM

Nov 25, 2024

Trading Bitcoin Dominance

Novice Navigator

2 min read

What is Bitcoin Dominance and How to Trade it on Pear Protocol

Bitcoin Dominance (BTC.d or BTCDOM) is Bitcoin's market share relative to the whole crypto market share. It’s calculated by dividing Bitcoin's market capitalization by the total market capitalization of all crypto currencies and multiplying it by 100.

For example: If Bitcoin's market capitalization is 2 Trillion and the market capitalization of all crypto currencies is 3.4 Trillion, BTC dominance would be: (2 / 3.4) * 100 = 58.8

In other words, Bitcoin makes up 58.8% of all crypto currencies.

Why is this interesting?

Bitcoin dominance gives you an idea where we could be in the market cycle.

If it rises it could either mean that Bitcoin price is going up and altcoins are staying flat or even declining.

If it goes down that either means Bitcoin price is going down or altcoins are growing in value.

Changes in the BTC.d could either mean that money is flowing from BTC to alts or vice versa or that new money is coming in for one of these sectors.

Historically, at the start of a bull market cycle, money flows into Bitcoin and Bitcoin dominance rises. At some point it tops and through a wealth effect it flows into alt coins, which leads to a further decline in BTC.d


Trading BTC.d index

What if there was a way to put money on BTC.d going up or down? This index is traded on Binance and Bitfinex and is also available as a long or short leg on the INTENT engine on Pear Protocol:

https://intent.pear.garden/trade/BTCDOM-USDC

How to use it for trading?

A) Long BTCDOM

Longing BTCDOM vs. USDC results in a straight long position


B) Short BTCDOM

Shorting BTCDOM vs. USDC results in a short position and is betting on altcoins to rise


C) As a short leg: Betting on the beginning of an altcoin season AND ethereum profiting

For example: Long ETH / Short BTCDOM 


D) As a long leg: Betting on the decline of altcoins and BTCs growth.

For example: When Bitcoin is showing strength and a small correction in Bitcoin lets altcoins correct 20-30%, Long BTCDOM / Short Meme coins


Recent BTCDOM trades and ideas

  • BTC / BTCDOM

  • SOL / BTCDOM

  • BTCDOM / USDC

  • USDC / BTCDOM

  • DOGE / BTCDOM

  • ETH / BTCDOM

  • BTCDOM / XLM

Nov 25, 2024

Novice Navigator

5 min read

Building a Specialised Agent for Pair Trading

(That does your risk assessment and empowers you with tooling to become more profitable)

1. Why Pair Trading?

Most traders in crypto focus on a single question: “Will this token go up or down?”
Pair trading flips the script. Instead of betting on absolute price, you trade relationships.

There are multiple approaches to pair trading:

  1. Fundamental – e.g. long HYPE / short DYDX

  2. Technical – e.g. based on charts like ETH/BTC

  3. Narrative & Mindshare – e.g. long PUMP / short SOL

A fourth, well-established technique is to take a statistical approach. Here, traders examine variables between two assets such as:

  • their correlation,

  • the current price difference (spread), and

  • how today’s spread compares to its historical average (mean).

The “arbitrage” arises because spreads between related assets tend to mean-revert when they deviate too far. For example, if BTC keeps falling whilst SOL keeps rising, the BTC/SOL spread collapses. A trader applying statistical arbitrage might go long BTC and short SOL, anticipating that the spread will snap back toward its mean.



This method - known as Statistical Arbitrage, is a cornerstone of traditional finance. And because crypto markets are still relatively inefficient, the opportunities to profit from it can be even greater.

To see how this works in practice, it helps to break down the building blocks of statistical arbitrage.



2. Statistical Arbitrage 101

Statistical arbitrage, or stat-arb, is about turning the relationship between two assets into a tradeable signal

Key Concepts
  • Correlation – measures how closely two assets move together. A high correlation suggests a relationship worth monitoring.

  • Beta (β) – shows how much one asset typically moves compared to the other. If SOL tends to move 1.3% when BTC moves 1%, then the hedge ratio is 1.3.

  • Spread – the difference between BTC and SOL after adjusting for beta. This is the trader’s signal:

𝑆𝑝𝑟𝑒𝑎𝑑ₜ = 𝑃ᴮᵀᶜ,ₜ − β · 𝑃ˢᴼᴸ,ₜ

  • Z-score – a way to measure how far today’s spread is from its historical average (mean, denoted as μ). Generally speaking you want to long the pair when Z-Score is <-2 and vice versa.

𝑧ₜ = (𝑆𝑝𝑟𝑒𝑎𝑑ₜ − μ) / σ

Example: BTC vs SOL

Suppose BTC and SOL usually move in sync. If BTC falls sharply while SOL rallies, the BTC/SOL spread shrinks. If the spread is now two standard deviations (σ)  below its mean (Z-score <-2), a stat-arb trader might:

  • Go long BTC and short SOL (beta-weighted),

  • Hold the position until the spread normalises,

  • Exit with profit once mean reversion plays out.

This approach reframes trading: the bet is not on whether BTC will rise or SOL will fall, but on the spread between them returning to equilibrium. Here is the same diagram, with the Z-Score being <-2σ clearly labelled as an entry signal. 


The challenge is not understanding these concepts, but finding opportunities across dozens of assets in real time.



3. Finding Opportunities

So far we have looked at statistical arbitrage in theory. In practice, traders needed tools to surface opportunities, and one of the main options was Crypto Wizards.


Crypto Wizards provided dashboards full of ratios, correlations, and spread charts. On paper this looked powerful, but many traders found it confusing to navigate. The issue was not the math but the usability. Traders did not want another complex dashboard. They wanted simple, tradeable insights: "Here is a pair diverging. Here is when to take the trade."

This is where Agent Pear comes in.

We have rebuilt the full statistical library on our own backend, covering correlation, beta, spreads, and z-scores. The system now updates in real time. Instead of static charts, traders are alerted the moment mean reversion opportunities arise, for example when the z-score compresses.

The result is actionable, trade-ready signals rather than raw analytics. Agent Pear closes the gap between statistical arbitrage theory and real-world execution in fast-moving crypto markets.

This shift from analytics to execution is what Agent Pear is designed to solve.


4. Our approach to rebuilding Crypto Wizards 

When we looked at the original CryptoWizards platform, we saw a lot to admire. It gave traders statistical-arbitrage tools, educational material, and curated backtests - all focused on a limited set of crypto pairs. That was a strong foundation, but we wanted to take things further and build our own library.

Our goal with Agent Pear was to recreate that core experience of pair discovery, statistical insights, and monitoring, and then extend it in three ways:

  1. Execution built-in – not just analysis, but the ability to act directly on signals.

  2. Full-universe coverage – not limited to a subset, but spanning all tradable pairs across supported platforms.

  3. AI-driven context – instead of leaving you to decipher charts, we add narrative explanations that make the opportunities clear.

Database & Time-Series Foundation

A reliable stat-arb agent is only as good as its data. We rebuilt the database from scratch utilising both hourly and daily time series data from the relevant exchanges where our execution/hedging takes place (e.g. Hourly time series data comes directly from HyperCore itself). 

  • Hourly OHLC data: Fine-grained enough to spot intraday divergences, volatility bursts, and short-term reversions.

  • Daily OHLC data: Smooths out noise, perfect for identifying structural shifts, long-term correlations, and regime changes.

  • Each record is indexed with a composite key (time, asset1_id, asset2_id) for efficient retrieval and backtests.


Pair Statistics

For every tracked pair, we calculate and store a full set of metrics at both the 1h and 1d level:

  • Correlation — how closely two assets move together

  • β (hedge ratio) — the relative move of one asset versus the other

  • Spread snapshot — the difference between the beta-adjusted prices

  • Z-score — how far today’s spread is from its long-term mean

  • Cointegration check - confirms a long-term, mean-reverting relationship exists between the two asset prices.

  • Half-life — how quickly the spread tends to revert

  • Sharpe ratio (daily) - to filter for robust strategies

This gives traders a quantifiable, real-time picture of relationships across the market, across 2 different timeframes. 

Importantly, we didn’t just port off-the-shelf quant libraries. Crypto markets behave differently - noisier, more volatile, with structural quirks. So we rebuilt every calculator from scratch. A full breakdown of each calculation is in the Appendix.

Volatility-Aware Signalling

Not all divergences are equal. A spread breaking down during extreme volatility is very different from one in a quiet market. To account for this, we:

  • Compute pair-level volatility in both short (1h) and long (1d) windows

  • Classify regime states (calm vs. volatile) to help you adjust your risk


From Data to Decisions: Signals & Execution

With these building blocks in place, we can surface two levels of actionable insights:

  • Viable signals → opportunities that pass our statistical and backtest filters, showing where pairs are diverging enough to watch.

  • Live trades → when conditions align (e.g. spread < −2σ with strong historical mean reversion), Agent Pear triggers alerts and can be integrated directly with execution on venues like Hyperliquid.

By rebuilding the data layer, extending coverage to the full universe, and adding AI-powered narrative context, we’ve created an agent that doesn’t just crunch numbers - it tells you the story behind the trade and equips you to act.


5. Agent Pear Architecture


Behind the scenes, Agent Pear runs on a production-grade pipeline. Think of it as an orchestra: every component has a role, and the orchestrator makes sure they play in sync.

Orchestration & Configuration
  • Orchestration Service → the conductor. On a fixed schedule (hourly and daily), it lines up each task in the right order:

    1. Fetch fresh data

    2. Store it safely

    3. Run analytics

This sequencing prevents race conditions and ensures data integrity.

  • Configuration Service → the stage manager. It provides credentials, database connections, and settings to all modules, so nothing is hardcoded. That makes the system flexible, secure, and portable across environments.


The Automated Data Pipeline

The pipeline transforms raw market data into actionable intelligence through four layers:

  1. Ingestion Layer

    • Connects directly to exchanges (e.g. Hyperliquid).

    • Pulls in two streams: raw time-series price data + metadata about assets/pairs.


  2. Storage Layer

    • Everything is written into a central database.

    • A unified data-access gateway means every service reads/writes in a consistent, secure way.


  3. Analytical Layer

    • The orchestrator triggers our custom calculators (correlation, cointegration, z-scores, volatility).

    • This is where raw data becomes trade-ready insights.


  4. Results Persistence

    • All outputs are written back into dedicated stats tables for fast retrieval.


API & Interaction Layer

Once signals are generated, traders and systems need to access them.

  • API Layer → the front door. Handles requests from trading interfaces or external agents, pulls data from the database, and returns it cleanly.

  • Security & Signals → every request is validated with API keys. The same interface also exposes the final signal outputs — turning complex analytics into clear, actionable trade signals.

Takeaway: The architecture ensures reliability, security, and real-time performance - so you can focus on trading, not on infrastructure.



6. Signal Generation Architecture: A Dual-Phase Approach

Once we’ve built the data layer and calculators, the real challenge is turning raw numbers into signals you can actually trade on.

Agent Pear’s signal engine works in two phases:

  1. Batch Discovery → find and rank potential opportunities.

  2. Continuous Monitoring → activate, track, and manage trades in real time.



———————————————————————————————————————————————————————-


Phase 1: Batch Discovery

Think of this as the “scouting phase.” The system scans the entire market and builds a watchlist of high-potential pairs.

  • Sourcing & Filtering

    • Pulls in all pairs with fresh, high-quality stats.

    • Applies quality gates (data sufficiency, stability, no duplicates).


  • Enrichment & Ranking

    • Adds extra context like lead-lag analysis and quick spread backtests.

    • Ranks pairs by strength of mean-reversion signal.


  • Segregation

    • Only a few high-conviction signals are activated immediately.

    • The rest are stored in a watchlist to wait for better entry conditions.


———————————————————————————————————————————————————————-


Phase 2: Continuous Monitoring

This is the always-on engine that watches both the watchlist and live trades.

  • Activating Opportunities

    • Continuously recalculates spreads and z-scores in real time.

    • If a pair crosses a threshold and the market regime looks favorable, it’s promoted to an active trade.

    • The trade is logged in the ledger and a notification goes out instantly.


  • Managing Active Trades
    Once live, each trade is managed with strict rules:


    • Profit-Taking → exit when spread reverts to mean.

    • Dynamic Stop-Loss → exit if spread keeps moving against you.

    • Time Expiry → close if it drags on past its expected half-life.


———————————————————————————————————————————————————————-


Qualitative Enrichment: The AI Narrative Layer

Numbers alone don’t tell the full story. That’s where the AI Narrative Engine comes in.

For every signal, Pear adds a short qualitative remark:

“BTC/SOL diverged unusually far, with strong historical mean-reversion. Expected window: ~8h.”

This bridges the gap between quant output and trader intuition - so instead of staring at a z-score chart, you get a clear story you can act on.



Agent Pear Status

All of the above is now live and Agent Pear will be rolled out in Stages.

Phase 1: For any pair, we now show some key statistics, on demand, for users of Pear Protocol. For example, a user wanting to enter a long LINK / short XRP can see the correlation and real time Z-Score. The extension of this will be to use the beta and volatility calculations to suggest different weightings for the long and short leg respectively.


Phase 2: In this phase we will roll out the signals on a dedicated token-gated page, with holders of staked PEAR (stPEAR) being able to see live trade signals, and importantly with alerts when to enter and close them.



Phase 3: The agent then becomes conversational, so users can speak to it in natural language and get real time thoughts on their pair trades. E.g. one prompt might be:

“What do you think about a long ETH / short SOL pair trade right now?”

Agent Pear would then give a detailed breakdown based not just on statistics, but also live data from various APIs on net funding rates, open interest, liquidation data, upcoming token unlocks and more



Phase 4: The Agent becomes fully autonomous and can enter, monitor and close pair trades. The monetisation for this then becomes Vault architecture, where users deposit their stablecoins like USDC, and the Agent executes trades based on pre-established risk management parameters. Thus, Pear goes from being a full stack pair trading platform to morphing into an AI-powered Asset Management business.




Appendix

Here’s how each component works:

  • Spread Calculator

    • Regress one asset against another to find hedge ratio (β).

    • Dual-beta design:

      • Structural beta (long history) → defines the baseline relationship.

      • Dynamic beta (short window tied to half-life) → adapts to current market conditions.

    • Integrity checks (R², standard error) keep it statistically valid.


  • Correlation Calculator

    • Quick screen using Pearson correlation on log returns.

    • Safeguards for sample size + stability → avoids false positives in volatile coins.


  • Cointegration Calculator

    • ADF test on residuals to check stationarity.

    • Instead of generic tables, we generated our own Monte Carlo thresholds tuned for crypto.

    • Conviction score blends: ADF distance, regression fit (R²), half-life, and Hurst exponent.


  • Half-Life Calculator

    • Fits AR(1) model to the spread.

    • Tells us the expected “action window” for a trade.


  • Z-Score Calculator

    • Two layers:

      • Structural z-score → long-term view.

      • Execution z-score → rolling window for real-time signals.


  • Hurst Exponent Calculator

    • Classifies behaviour:

      • H < 0.5 = mean-reverting.

      • H ≈ 0.5 = random walk.

      • H > 0.5 = trending.

    • Optional DFA path for messy series.


  • Regime Detection

    • Uses z-score + volatility ratios to classify states like Strong Reversion, Peak Divergence, or Idle.

    • Adds “narrative context” for risk gating.


  • Volatility Calculators

    • Daily → Yang-Zhang (handles overnight gaps).

    • Hourly → Parkinson (best for intraday ranges).

    • Spread → close-to-close.


  • Backtester

    • Lightweight mean-reversion sim.

    • Outputs: win rate, Sharpe, max drawdown.

    • Purpose: quickly sanity-check signals, not model full execution.

Sep 1, 2025

Novice Navigator

2 min read

How Pear Protocol Enhances Pair Trading on Hyperliquid

If you're actively trading on Hyperliquid, you're already ahead of the curve. But if you're managing each leg of a pair trade manually—long HYPE, short SOL, for example—you're leaving alpha (and points) on the table. Here's why using Pear Protocol x Hyperliquid is the smarter, faster, and more profitable way to pair trade.


1. 🎯 Take-Profit / Stop-Loss on the Ratio

In manual pair trading, managing TP/SL for each leg is a headache. You’re subject to the path dependence of both assets—HYPE could moon while SOL crabwalks, and you’re left guessing. On Pear, TP/SL logic is applied directly on the ratio, not the individual legs. This gives you:

  • Precise risk management

  • Simpler setups

  • Cleaner exits

2. 💸 Superior Execution with Limit & TWAP Orders

Forget micromanaging leg fills. Pear lets you:

  • Set limit orders on the ratio

  • Execute TWAP orders over time to reduce slippage

  • Avoid the drift that happens when leg execution is misaligned

This leads to tighter entries, cleaner fills, and better performance.

3. 📈 Earn More with Season 3 Points

If Hyperliquid launches a Season 3 campaign, volume traded through Pear still counts toward your Season 3 leaderboard. So you’re not just trading smarter—you’re earning more.

4. ⚖️ Custom Weighting Strategies (Coming Soon)

Manual leg sizing often ignores volatility or beta. In addition to Custom Weightings (available), Pear Protocol is rolling out:

  • Beta-weighted pair construction

  • Volatility-weighted allocations

Soon, you’ll be able to build institutional-grade pair strategies in one click.

5. ⚡ One-Click Entry & Exit

No more leg-by-leg execution. One click enters or exits the full position. That means:

  • Less room for error

  • Faster trade deployment

  • Easier mobile execution

6. 📊 Direct Charting of Ratios

Want to chart HYPE/SOL directly? Good luck doing that manually. Pear gives you:

  • Custom pair ratio charts

  • Historical data overlays

  • Visual clarity for trade setups

7. 💰 Analyse Net Funding Across Pairs

The Markets page shows you:

  • Net funding differentials

  • Cost of holding positions

  • Alpha opportunities in funding arbitrage

No spreadsheet hacks required.

8. ⭐ Favourite Your Pairs

Track your favourite pairs and monitor:

  • Daily PnL

  • 24h performance

  • Spread changes

Perfect for power users managing a basket of trades.


9. 🎁 Earn Hypear Points

Trading on Pear earns Hypear Points, based on:

  • Volume

  • PnL

These convert directly into claimable $HYPE. So your trades aren’t just profitable—they’re rewarded.

🔟 [Redacted] 🤫

Stay tuned.


Pear x Hyperliquid is not just a better interface—it's a complete edge amplifier for pair traders.



Jul 10, 2025

All systems operational

© 2025 Pear Protocol. All rights reserved.

All systems operational

© 2025 Pear Protocol. All rights reserved.

All systems operational

© 2025 Pear Protocol. All rights reserved.