Use this workflow to compare the same perpetual market across venues. You will
align executable quotes, measure both trading directions, attach funding and
mark-price context, apply explicit costs, and group candidate basis windows.
The example compares the BTC perpetual on Hyperliquid and Pacifica. It resolves
the exact datasets and a shared public interval through Catalog, so it does not
require an API key.
A positive calculated edge is not an executable profit. Quotes can be stale
or too small, orders can move the book, and fees, funding, latency, collateral,
liquidation risk, and transfer constraints can remove the opportunity.
Install the dependencies
Install the Python SDK with DataFrame support and the analysis packages:
Keep venue identity separate from the normalized underlying. Both datasets
represent BTC perpetuals, but their exact source and market values come from
Catalog.
The cost assumptions below are illustrative. Replace them with your fee tier,
order size, expected slippage, funding convention, and holding period before
interpreting the result.
Resolve a shared public interval
Catalog rows define each dataset’s exact bounds and access state. Preview data
is publicly accessible only within the UTC day identified by
public_cutoff_date.
Find active quotes on both venues
Catalog coverage can extend beyond the latest locally available snapshot. Probe
backward until both venues have two-sided quotes that can be aligned without
using future information.
The backward as-of join uses each venue’s latest known quote. Rows with a quote
older than quote_tolerance are excluded.
Calculate executable basis in both directions
An executable basis uses the ask on the venue you buy and the bid on the venue
you sell. Mark-to-mark differences are useful context, but you cannot trade at
a mark price.
This calculation uses top-of-book prices only. Check the displayed quantities
or use Depth metrics before applying the result to a
larger order.
Add mark-price context
Fetch normalized mark prices for the same interval. Mark coverage is not
guaranteed for every source or public window, so preserve missing values and
report coverage instead of substituting a midpoint.
Keep mark_basis_bps as NaN when either venue lacks a mark. Executable BBO
basis remains available independently.
Apply funding and trading costs
Attach each venue’s most recent published funding rate without looking forward.
The example assumes a positive rate means longs pay shorts and scales the rate
by the configured funding period.
Verify each venue’s rate sign and settlement period before using the funding
adjustment. A negative funding cost means the hedge is expected to receive net
funding under the configured assumptions.
Flag candidate windows
Require complete funding inputs and group consecutive qualifying observations
by route. This avoids presenting every aligned quote as a separate opportunity.
Plot gross and net edge to see how much of the apparent basis remains after
carry and trading assumptions:
Interpret the result carefully
- Compare contract multipliers, settlement assets, margin rules, and funding
conventions before treating two markets as interchangeable.
- BBO shows displayed top-of-book liquidity, not your expected average fill.
Recalculate the edge with size-dependent slippage.
- The backward join avoids future quotes but does not remove network, collector,
or venue latency. Tighten
quote_tolerance for latency-sensitive analysis.
- Include capital costs, borrow, liquidation buffers, transfer delays, and the
cost of closing both legs in
cost_assumptions.
- Do not fill missing mark or funding rows with zero. Missing context makes a
net-edge estimate incomplete.
- Candidate windows are research outputs, not trading instructions or evidence
that both legs could have been filled simultaneously.