PearPear
API IntegrationImportant Terms

Price Ratio

How one long and one short collapse into a single line, which formula the API actually uses, and how to trade the ratio with a trigger.

When you hold one long asset and one short asset, the Price Ratio is one of the cleanest ways to visualize their relationship. It is defined simply as:

Price Ratio=PriceLONGPriceSHORT\text{Price Ratio} = \frac{\text{Price}_{\text{LONG}}}{\text{Price}_{\text{SHORT}}}

Despite being simple, this ratio does several powerful things at once:

Captures Relative Strength

Instead of tracking two separate price charts, the ratio collapses the performance of both assets into a single line.

  • If the ratio trends upward, your long asset is outperforming your short.
  • If it trends downward, your short asset is outperforming your long.

This is particularly useful when the two assets are highly correlated (e.g., competitors, L1 vs L2 tokens, two DeFi governance tokens, etc.).

Encodes Correlation and Divergences

When two assets normally move together, deviations in the ratio often indicate:

  • A temporary mispricing
  • A divergence that may revert
  • A possible trading opportunity

For example, if Asset A and Asset B are historically correlated but suddenly one rallies without the other, the ratio will spike, often a sign the spread might snap back.

Creates a Natural Mean-Reversion Indicator

Because many asset pairs have long-term equilibrium relationships (due to fundamentals or shared market conditions), the price ratio often behaves like an oscillator:

  • Overstretched highs → long is unusually strong → potential short-the-ratio setup
  • Overstretched lows → short is unusually strong → potential long-the-ratio setup

This behavior is the foundation of pair trading, stat arb, and market-neutral strategies.

Reading it from the API

Pear computes a ratio for you on every basket market. GET /markets/baskets returns price and weightRatio on each basket, with priceChange24h and weightRatioChange24h alongside. For the raw inputs, GET /prices returns mid and mark prices per instrument.

Four things to know before you display those numbers:

  • price and weightRatio hold the same value. So do priceChange24h and weightRatioChange24h. The endpoint computes one ratio and reports it under both names.
  • The ratio is a mean over a mean. It is the average price of the long legs divided by the average price of the short legs, not a product of prices.
  • It is unweighted. Every leg counts equally. A basket on this endpoint carries no weights at all: a leg is { id, symbol, side }.
  • A one-long/one-short pair is the special case. Each mean is then a single price, so the value equals Price_LONG / Price_SHORT exactly. Only a multi-leg basket differs.
price=mean(Price of each LONG leg)mean(Price of each SHORT leg)\text{price} = \frac{\operatorname{mean}\left(\text{Price of each LONG leg}\right)}{\operatorname{mean}\left(\text{Price of each SHORT leg}\right)}

The endpoint returns materialized multi-leg baskets first, then generated one-long/one-short pairs, so both cases arrive in one response.

Which formula runs where

Three parts of Pear collapse a basket into one number, and they do not agree. Match the formula to the surface you are on.

WhereRatioNet fundingWeight unit
GET /markets/basketsMean of long prices ÷ mean of short prices.Mean of long rates − mean of short rates. Positive means you pay.None. Every leg counts equally.
weighted_ratio conditions on triggers and ladders∏ Priceᵢ ^ (signᵢ × weightᵢ)Not computed.Fractions. The legs sum to 1.
@pear-protocol/market-sdk charts∏ Priceᵢ ^ (signᵢ × weightᵢ)Σ (short rate × weight) − Σ (long rate × weight). Positive means you earn.Percents. The legs sum to 100.

signᵢ is +1 for a BUY leg and −1 for a SELL leg.

The two net-funding columns carry opposite signs. Read Net Funding before you colour a number red. The product formula is on Weighted Price Ratio.

Trading it

The ratio is a first-class trigger condition, so you can act on it without polling:

{
  "condition": {
    "type": "ratio",
    "data": {
      "priceSource": "mid",
      "symbol_a": "0",
      "symbol_b": "1",
      "track": "TROUGH",
      "threshold": 24
    }
  }
}
FieldRule
priceSourceRequired. mid or mark.
symbol_aThe numerator, as an instrument ID.
symbol_bThe denominator. It must differ from symbol_a, or the call is rejected.
trackPEAK fires when the ratio reaches or passes the threshold. TROUGH fires only when the ratio falls strictly below it.
thresholdRequired on an open condition, and greater than 0.

The same condition takes a different shape on each endpoint:

  • POST /triggers/open takes all five fields above.
  • POST /triggers/close takes no track. A close condition is priceSource, symbol_a, symbol_b, and threshold.
  • POST /ladders takes no threshold. A ladder takes track, and its range comes from config.thresholdStart and config.thresholdEnd.

On this page