vike-perp-spread-history
Latest: v1.0.0
First version.
vike-perp-spread-history
One coin, two legs, one series: leg A's price over leg B's, in basis points. 1 request per call. Pass the base asset (BTC, not BTCUSDT); venues are lower case.
Call it
Use the first of these that is available:
- MCP:
perp_spreads_historywithsymbol,exchange_a,exchange_b(all three required) and the optionalmarket_a,market_b,interval,start,end. For the gap now:perp_spreadswithsymbol. - CLI:
bash vike-data md spreads-history BTC --a binance --b okx --interval 4h --json # the last 7 days, 4-hour buckets vike-data md spreads-history ETH --a bybit --market-a spot --b hyperliquid --interval 1d --start 2026-11-01 --json vike-data md spreads-history SOL --a binance --b bybit --interval 1h --start 2026-11-28 --end 2026-11-29 --json vike-data md spreads BTC --json # now: BTC's cheapest and dearest venue, whatever the gap - curl: the credential is
VIKE_API_KEY, elseapi_keyoranon_tokenfrom~/.vike/config.json(Windows%USERPROFILE%\.vike\config.json); with none, get a free anonymous token asvike-coresays.bash curl -s "https://data.vike.io/v1/marketdata/perp/spreads/history?symbol=BTC&exchange_a=binance&exchange_b=okx&interval=4h" -H "X-API-KEY: $TOKEN"
| Flag (API name) | Default | Values |
|---|---|---|
<symbol> | required | base asset: BTC, ETH, SOL |
--a (exchange_a), --b (exchange_b) | required | lower-case venue, e.g. binance, okx, bybit, hyperliquid |
--market-a, --market-b | perp | perp or spot |
--interval | 1h | 1h, 4h, 1d; 4h and 1d buckets start at 00:00 UTC |
--start, --end | the last 7 days | ISO-8601 or unix seconds, UTC; start floored to the interval, end exclusive; from 2026-05-30 |
Reading the answer
The envelope is {symbol, a, b, interval, unit, rows}; a and b name each leg's exchange and market, unit defines the numbers. rows run oldest first, one per bucket:
ts(ISO-8601, the bucket's start);open_bps,close_bps,avg_bps: (A / B - 1) x 10,000, positive when leg A is the dearer. 10 bps = 0.1 %;high_bps_bound,low_bps_bound: they only BOUND the bucket's extremes, because each leg's own extreme can fall on a different minute. Never quote them as a gap that was seen;samples_a,samples_b: minutes the leg was priced (at most 60 an hour, 240 in 4 hours, 1440 a day). Few samples make the average thin;book_bps_a,book_bps_b: the leg's mean quoted bid-ask width in bps, null where the venue has no book.
How to read it:
- Is the gap persistent? Look at the sign and size of
avg_bpsacross the buckets. A gap that keeps its sign for days is structural (fees, funding, a different contract); one that flips around zero is noise. - Is it tradeable? Compare
avg_bpswith both legs'book_bpsplus taker fees on four fills. A 3 bps average gap does not pay 2 x 5 bps of fees. - Spot against perp (
--market-a spot) shows the perp's premium or discount to spot on those venues. - Prices are each venue's book mid, else its last price, so a leg without a book (
book_bpsnull) is priced on trades.
The gap right now: md spreads BTC (or perp spreads --symbol BTC, MCP perp_spreads with symbol) returns BTC's one row whatever its size: buy_exchange (the cheapest venue, perp or spot), sell_exchange (the dearest perp), their prices and spread_pct (in percent, not bps). Without a symbol it lists the ten widest gaps of 0.5 % or more. Measured 2026-12-02: perp spreads --symbol BTC returned kraken vs kucoin at 0.07 %.
Limits
- From 2026-05-30, for the perp symbols listed on at least two major venues (about 300) and their spot pairs.
- At most 10,000 buckets a call: a year of 1h buckets is too many, ask
4hor1d. - A bucket where one leg was not priced has no row. Nothing found returns empty
rowsand anote, never zeros: check the venue spelling and that both venues list the coin. - Two legs per call. For a third venue, run again.
Errors
error: required option '--a <venue>' not specified: the CLI needs both--aand--b.- A 400 names the fix (an
--intervalother than1h,4h,1d; a bad time; too many buckets). The CLI exits 1 with the message. unknown query parameter(curl): useexchange_aandexchange_b, notaandb.- Exit code 3 or HTTP 429: the day's requests are used up; show the server's message and stop.
Anti-patterns
- Don't quote
high_bps_boundas "the gap reached X". - Don't read bps as percent (100 bps = 1 %), or mix the history's bps with
spread_pctin percent. - Don't call a historical gap free money: fees, slippage, funding on each perp leg and moving collateral between venues all cost.
Pairs well with
vike-perp-overviewfor the ten widest gaps right now and the perp snapshotvike-perp-carryfor a pair's net APR after fees, funding includedvike-perp-fundingfor the funding each perp leg pays while the gap is held
