@vike-io/cli 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +25 -10
- package/package.json +1 -1
- package/skills/vike/SKILL.md +18 -5
- package/skills/vike-daily-brief/SKILL.md +2 -2
- package/skills/vike-hl-asset-briefing/SKILL.md +1 -1
- package/skills/vike-perp-carry/SKILL.md +94 -0
- package/skills/vike-perp-crowding/SKILL.md +4 -4
- package/skills/vike-perp-funding/SKILL.md +39 -0
- package/skills/vike-perp-overview/SKILL.md +14 -7
- package/skills.sh.json +3 -2
- package/src/commands/md.js +156 -0
- package/src/commands/tool-command.js +15 -11
- package/src/format.js +10 -6
- package/src/index.js +2 -0
- package/src/mcp-client.js +49 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f375e7a: New `md` commands and fields for the `/v1/marketdata` routes added since 0.24.0:
|
|
8
|
+
|
|
9
|
+
- `md spreads-history <symbol> --a <venue> --b <venue>`: one pair's price spread over time from `GET /v1/marketdata/perp/spreads/history`, leg A's price over leg B's in basis points per bucket (`(A / B - 1) x 10,000`), any two venues, perp or spot (`--market-a`, `--market-b`), since 2026-05-30. `--interval 1h|4h|1d`, `--start`, `--end` (default: the last 7 days); `--a` and `--b` are required. Rows: `ts`, `open_bps`, `close_bps`, `avg_bps`, `high_bps_bound` / `low_bps_bound` (bounds, not observed values), `samples_a` / `samples_b`, `book_bps_a` / `book_bps_b`.
|
|
10
|
+
- `md basis [symbol]`: every live dated future (quarterly, monthly, weekly) on binance, bybit, okx, deribit, gate and kraken from `GET /v1/marketdata/futures/basis`, with `basis` against `--ref index|spot|perp` (default `index`) and `apr`, the cash-and-carry yield to expiry before fees. `--exchange`, `--sort apr|expiry`, `--limit`.
|
|
11
|
+
- `md funding-oi [symbol]`: each coin's current funding averaged across venues by open interest from `GET /v1/marketdata/perp/funding/oi-weighted` (`rate_8h`, `apr`, `oi_usd`, `venues`), largest open interest first. `--limit` up to 500.
|
|
12
|
+
- `md funding-now`: the table shows the new fields. Per venue: `avg_apr_7d` / `avg_apr_30d`, `cum_1d` / `cum_7d` / `cum_30d` and `oi_usd`. On arbitrage pairs: `opportunity_age_h`, `stability_7d`, `spread_avg_7d_daily_pct` / `spread_avg_30d_daily_pct` and each leg's `next_daily_pct`.
|
|
13
|
+
- In the table view of `md funding-now`, `md carry` and `md spreads`, a venue that is delisting or reduce-only is marked after its name, e.g. `binance (delisting 2026-12-08)` or `bybit (reduce_only)`. `--json` keeps the raw `market_status` and `delist_ts`.
|
|
14
|
+
|
|
15
|
+
- Table output (every command, never `--json` or piped output) prints numbers below a thousand at up to 6 significant digits, with the float noise gone: `0.10950000000000001` prints as `0.1095`, and `0.0000259` stays `0.0000259`.
|
|
16
|
+
|
|
17
|
+
The `vike`, `vike-perp-funding`, `vike-perp-overview` and `vike-perp-carry` skills name them.
|
|
18
|
+
|
|
19
|
+
## 0.24.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- 8a211f4: `marketdata` (alias `md`): CEX perp market data from the REST API `/v1/marketdata`, one GET each with the same key (not an MCP tool; `--json` prints the route's body). `md funding <symbol>` (funding history, newest first: `--exchange`, `--start`, `--end`, `--limit` up to 5000), `md funding-now [symbol]` (each venue now; no symbol: the top 5 funding-arbitrage pairs), `md spreads [symbol]`, `md oi <symbol>` and `md long-short <symbol>` (`--exchange`, `--hours` 1-168), `md liquidations [symbol]` (forced liquidations on binance, bybit, okx, deribit and aster: `--exchange`, `--side long|short`, `--start`, `--end`, `--interval 1m|5m|15m|1h|4h|1d` for long/short totals per bucket, `--limit`), `md carry` (the carry screener: `--legs all|perp_perp|perp_spot`, `--direction funding|convergence`, `--costs none|fees|fees_slippage`, `--fee-bps`, `--slippage-bps`, `--horizon <hours>` sent as `horizon_h`, `--min-spread-pct` (default 0), `--sort net|gross`, `--limit` up to 500). In the table view of `md carry` and `md funding-now`, a rate at its venue's cap or floor prints as `<rate> capped`, and the funding interval as published (`8h assumed` where the venue publishes none); `--json` keeps the raw fields. `perp funding` and `perp spreads` are unchanged (MCP). New skill `vike-perp-carry`; the `vike`, `vike-perp-funding`, `vike-perp-overview`, `vike-perp-crowding`, `vike-daily-brief` and `vike-hl-asset-briefing` skills use `md oi` / `md long-short` where they used `vike-data call perp_open_interest` / `perp_long_short`.
|
|
24
|
+
|
|
3
25
|
## 0.23.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ for the wallet and token tools. The same data is served three ways: an **MCP ser
|
|
|
18
18
|
this CLI calls), a **REST API** at `https://data.vike.io/v1/`, and the **Parquet archive** at
|
|
19
19
|
`https://data.vike.io/archive/`. A key allows 20,000 requests an hour, and an account can hold up
|
|
20
20
|
to 5 keys; archive downloads are not counted. The archive manifest and a sample market need no key
|
|
21
|
-
at all.
|
|
21
|
+
at all. Derivatives market data from centralised exchanges (perp funding, cross-venue spreads, open
|
|
22
|
+
interest, long/short, liquidations, a carry screener, dated-futures basis) is served at
|
|
23
|
+
`https://data.vike.io/v1/marketdata/` (`vike-data md`).
|
|
22
24
|
|
|
23
25
|
## Install
|
|
24
26
|
|
|
@@ -135,8 +137,10 @@ not only the HTTP status. A rate-limited call gets HTTP 429 with `Retry-After: 6
|
|
|
135
137
|
|
|
136
138
|
## CLI commands
|
|
137
139
|
|
|
138
|
-
Every data command is one `tools/call` to the MCP server
|
|
139
|
-
`
|
|
140
|
+
Every data command is one `tools/call` to the MCP server, except `vike-data md`: one GET of the REST
|
|
141
|
+
API `/v1/marketdata` with the same key, whose `--json` output is the route's body as served.
|
|
142
|
+
`vike-data <group> --help` lists the flags; `vike-data schema --pretty` prints every tool the server
|
|
143
|
+
exposes, with its parameters.
|
|
140
144
|
|
|
141
145
|
| Command | Subcommands | MCP tool |
|
|
142
146
|
|---|---|---|
|
|
@@ -148,6 +152,7 @@ Every data command is one `tools/call` to the MCP server. `vike-data <group> --h
|
|
|
148
152
|
| `vike-data candles` | `hl <symbol>` (Hyperliquid perp or spot, from executed fills; `--view export`, or `--view latest` for the newest bar of every symbol), `polymarket <token_id>` (one outcome token); live bars: `stream hl --channel hl.candles` | `hl_ohlcv`, `polymarket_ohlcv` |
|
|
149
153
|
| `vike-data polymarket` (`pm`) | `markets`, `market <condition_id>`, `wallet <address>`, `smart-money`, `leaderboard`, `market-trades <condition_id>`, `tape`, `orderbook <token_id>`, `market-stats <token_id>`, `settlement <condition_id>`, `settlements`, `chainlink-prices <symbol>` (the Chainlink prices the crypto up/down markets resolve on), `archive` | `polymarket_markets`, `polymarket_market_detail`, `polymarket_wallet`, `polymarket_smart_money`, `polymarket_leaderboard`, `polymarket_market_trades`, `polymarket_tape`, `polymarket_orderbook`, `polymarket_market_stats`, `polymarket_settlement`, `polymarket_settlements_bulk`, `polymarket_chainlink_prices`, `polymarket_archive` |
|
|
150
154
|
| `vike-data predictfun` (`pf`) | `overview`, `markets`, `market <market_id>`, `orderbook <market_id>`, `market-trades <market_id>`, `wallet <address>` (positions and P&L), `wallet-trades <address>`, `wallet-flows <address>` (USDT deposits and withdrawals), `leaderboard` | `predictfun_overview`, `predictfun_markets`, `predictfun_market_detail`, `predictfun_market_book`, `predictfun_market_trades`, `predictfun_wallet_positions`, `predictfun_wallet_trades`, `predictfun_leaderboard` |
|
|
155
|
+
| `vike-data marketdata` (`md`) | CEX derivatives: `funding <symbol>` (history, newest first: `--exchange`, `--start`, `--end`, `--limit` up to 5000), `funding-now [symbol]` (each venue now, with `avg_apr_7d`/`_30d`, `cum_1d`/`_7d`/`_30d` and `oi_usd`; no symbol: the top 5 funding-arbitrage pairs, with `opportunity_age_h`, `stability_7d`, `spread_avg_7d`/`_30d_daily_pct` and each leg's `next_daily_pct`), `funding-oi [symbol]` (each coin's funding averaged across venues by open interest: `rate_8h`, `apr`, `oi_usd`, `venues`; `--limit` up to 500), `spreads [symbol]` (the 10 widest cross-venue price gaps), `spreads-history <symbol> --a <venue> --b <venue>` (leg A's price over leg B's per bucket in bps since 2026-05-30, perp or spot legs: `--market-a`, `--market-b`, `--interval 1h\|4h\|1d`, `--start`, `--end`; rows carry `open_bps`, `close_bps`, `avg_bps`, `high_bps_bound`/`low_bps_bound`, `samples_a`/`_b`, `book_bps_a`/`_b`), `oi <symbol>` and `long-short <symbol>` (`--exchange`, `--hours` 1-168 for an hourly series), `liquidations [symbol]` (forced liquidations on binance, bybit, okx, deribit and aster, newest first: `--exchange`, `--side long\|short`, `--start`, `--end`, `--interval 1m\|5m\|15m\|1h\|4h\|1d` for long/short totals per bucket, `--limit`; `coverage` says which venues undercount), `carry` (the carry screener, by default the list on vike.io/perp/carry: `--legs all\|perp_perp\|perp_spot`, `--direction funding\|convergence`, `--costs none\|fees\|fees_slippage`, `--fee-bps`, `--slippage-bps`, `--horizon <hours>`, `--min-spread-pct` (default 0), `--sort net\|gross`, `--limit` up to 500; rows carry `gross_apr` and `net_apr` as fractions, `fees_usd` and `net_usd` per $1,000 a leg, `breakeven_h`), `basis [symbol]` (every live dated future on binance, bybit, okx, deribit, gate and kraken: `basis` against `--ref index\|spot\|perp` and `apr`, the cash-and-carry yield to expiry before fees; `--exchange`, `--sort apr\|expiry`, `--limit`). In the table view of `funding-now`, `carry` and `spreads`, a rate at its venue's cap or floor prints as `<rate> capped`, the funding interval as published (`8h assumed` where the venue publishes none), and a venue that is delisting or reduce-only as `binance (delisting 2026-12-08)` / `bybit (reduce_only)`; `--json` keeps the raw `capped`, `interval_src`, `market_status` and `delist_ts`. An undeclared parameter is a 400. | REST, not MCP: `GET /v1/marketdata/perp/funding`, `/funding/current`, `/funding/oi-weighted`, `/spreads`, `/spreads/history`, `/oi`, `/long-short`, `/liquidations`, `/carry`; `/v1/marketdata/futures/basis` |
|
|
151
156
|
| `vike-data alerts` | `list`, `channels`, `create`, `edit`, `delete`, `events`, `resend`, `register-webhook`, `test-webhook`, `rotate-secret`: transfer alerts (a token or one wallet, on eth, bsc, base, hyperevm) Hyperliquid alerts (`--type hl_wallet`, `hl_cohort_fill`, `hl_liquidation`, `hl_cohort_bias`, `hl_liq_proximity`, `hl_wallet_orders`: one wallet's orders placed or gone, `--side`, `--events placed gone`) and Polymarket alerts (`--type pm_wallet_trade`, `pm_market_trade`, `pm_price_move`, `pm_resolution`), by email or an HTTPS webhook, HMAC-signed; at most 200 active alerts per account; `events` pages by `--cursor` while `has_more` is true (a page ends at about 2 MB) | `alerts_*` |
|
|
152
157
|
| `vike-data stream <path>` | live events from `wss://stream.vike.io/v1/stream/<path>` (`hl`, `hl-cohorts`, `onchain`, `polymarket`) as NDJSON: `--channel` (one or more), `--filter key=value`, `--cursor` | WebSocket, not MCP |
|
|
153
158
|
| `vike-data stream` | `info`, `check <channel>` (the server's validator), `events <channel>` (stored events, 3 days), `connections` (yours) | `stream_info`, `stream_check_filter`, `stream_events`, `stream_connections` |
|
|
@@ -155,8 +160,15 @@ Every data command is one `tools/call` to the MCP server. `vike-data <group> --h
|
|
|
155
160
|
| `vike-data call <tool>` | any MCP tool by name: `--args '{json}'` or `--args-file`, `--timeout`; prints the raw result | any |
|
|
156
161
|
| setup | `init`, `login`, `logout`, `whoami`, `doctor`, `schema`, `install` | — |
|
|
157
162
|
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
The `md` series (CEX perp market data, [vike.io/data/marketdata](https://vike.io/data/marketdata)): These series may
|
|
164
|
+
be published (charts, tables, screenshots, aggregated results and up to 100 rows per publication) with the credit
|
|
165
|
+
“© Vike (vike.io)”, under the same rules as the other sources: [Licensing](https://vike.io/data/licensing). Bulk
|
|
166
|
+
data and full datasets may not, and commercial use needs a written agreement. Plans and limits:
|
|
167
|
+
[Pricing](https://vike.io/pricing); an API key: [API](https://vike.io/data/api).
|
|
168
|
+
|
|
169
|
+
Output is a table on a terminal and JSON with `--json` or whenever stdout is piped. The table rounds numbers
|
|
170
|
+
below a thousand to 6 significant digits and shortens larger ones to K/M/B; JSON carries every value exactly as
|
|
171
|
+
served. A tool that refuses its input exits 1 in every mode:
|
|
160
172
|
|
|
161
173
|
```bash
|
|
162
174
|
vike-data token search BTC --json | jq '.'
|
|
@@ -193,7 +205,7 @@ Downloads go to `./vike-archive/`.
|
|
|
193
205
|
|
|
194
206
|
## For AI agents
|
|
195
207
|
|
|
196
|
-
This package ships **
|
|
208
|
+
This package ships **52 skill playbooks** under [`skills/`](skills/): markdown files an AI coding
|
|
197
209
|
agent loads so it knows when and how to call each command. [`skills.sh.json`](skills.sh.json) groups
|
|
198
210
|
them by domain (Quick start, Tokens, Wallets, CEX perps, Hyperliquid perps, Candles, Polymarket, Predict.fun, Alerts, Live streams). The
|
|
199
211
|
entry point is the umbrella skill `vike`, which routes a question to the specialised skill. Per-tool
|
|
@@ -222,7 +234,7 @@ block in files it does not own.
|
|
|
222
234
|
| Variable | Default | Purpose |
|
|
223
235
|
|---|---|---|
|
|
224
236
|
| `VIKE_API_KEY` | — | API key; wins over the saved config |
|
|
225
|
-
| `VIKE_MCP_URL` | `https://data.vike.io/mcp` | MCP endpoint override |
|
|
237
|
+
| `VIKE_MCP_URL` | `https://data.vike.io/mcp` | MCP endpoint override; `md` sends its REST calls to the same origin |
|
|
226
238
|
| `VIKE_NO_TELEMETRY=1` or `DO_NOT_TRACK=1` | telemetry on | Turns off anonymous usage telemetry |
|
|
227
239
|
| `VIKE_NO_UPDATE_CHECK=1` or `NO_UPDATE_NOTIFIER=1` | check on | Turns off the background npm update check |
|
|
228
240
|
|
|
@@ -238,9 +250,12 @@ The CLI is MIT, see [LICENSE](LICENSE). Everything you get from Vike through it
|
|
|
238
250
|
server, the CLI and the Parquet files) is covered by the [Terms of Service](https://vike.io/terms), section 7:
|
|
239
251
|
|
|
240
252
|
- you can research and trade your own capital, keep the data on your own machine, run private backtests,
|
|
241
|
-
and publish charts, tables, screenshots, backtest and research results and up to 100 rows per publication
|
|
242
|
-
from on-chain, Hyperliquid, Polymarket and Predict.fun data
|
|
243
|
-
|
|
253
|
+
and publish charts, tables, screenshots, backtest and research results, and up to 100 rows per publication,
|
|
254
|
+
from our on-chain, Hyperliquid, Polymarket and Predict.fun data and our CEX derivatives market data (funding
|
|
255
|
+
rates, price spreads, open interest, long/short ratios and the carry screener, from the exchanges listed on
|
|
256
|
+
[vike.io/data/marketdata](https://vike.io/data/marketdata)), credited "© Vike (vike.io)";
|
|
257
|
+
- you cannot publish bulk data or full datasets, or publish candles, trades, ticks or order books of exchanges
|
|
258
|
+
shown on the Service;
|
|
244
259
|
- commercial use (signals or a service for others, use on behalf of a company, fund or prop firm, resale)
|
|
245
260
|
needs a written agreement: info@vike.io.
|
|
246
261
|
Details: [vike.io/data/licensing](https://vike.io/data/licensing).
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.25.0",
|
|
7
7
|
"description": "CLI, agent skills and MCP client for the free Vike Data API: a Polymarket full-L2 order-book archive in Parquet, Hyperliquid positions, fills and cohorts, and labelled Ethereum/BNB wallets",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "src/index.js",
|
package/skills/vike/SKILL.md
CHANGED
|
@@ -97,8 +97,9 @@ Pick by the question, then read the named skill for the recipe and the traps. If
|
|
|
97
97
|
| Label many addresses (up to 100) | `vike-data wallet batch` / `wallet_batch_labels` | `vike-wallet-batch` |
|
|
98
98
|
| Why is this wallet labelled X (sources) | `vike-data labels <address>` / `wallet_label_provenance` | `vike-wallet-label-provenance` |
|
|
99
99
|
| Funding rates, funding arb, one symbol across venues | `vike-data perp funding` / `perp_funding` | `vike-perp-funding` |
|
|
100
|
-
| Cross-venue price
|
|
101
|
-
|
|
|
100
|
+
| Cross-venue carry after fees and slippage (price gap plus funding, net APR, break-even); funding history of one symbol | `vike-data md carry`, `md funding <symbol>` (REST `/v1/marketdata`) | `vike-perp-carry` |
|
|
101
|
+
| Cross-venue price spread, "perp market overview"; CEX open interest or long/short of one symbol | `vike-data perp spreads` + `perp funding` + `perp top-traders`; `md oi`, `md long-short` | `vike-perp-overview` |
|
|
102
|
+
| Is X crowded: funding, open interest net of price, long/short per venue | `perp funding` + `md oi` + `md long-short` + `candles hl` | `vike-perp-crowding` |
|
|
102
103
|
| Top Hyperliquid traders; the full leaderboard | `vike-data perp top-traders` / `hl_perp_top_traders`; `vike-data hl leaderboard` | `vike-hl-top-traders` |
|
|
103
104
|
| HL share card → which wallet holds it | `vike-data perp find-position` / `hl_position_match` | `vike-hl-position-match` |
|
|
104
105
|
| One HL wallet: equity, positions, cohorts, risk, closed trades, funding, ledger, orders, liquidations | `vike-data hl wallet`, `hl wallet-trades`, `hl wallet-activity` | `vike-hl-trader-profile` |
|
|
@@ -206,10 +207,22 @@ Chains: every token and wallet tool takes `chain` = `ethereum` | `bsc` | `base`
|
|
|
206
207
|
|---|---|
|
|
207
208
|
| `perp_funding` | with `symbol`: raw per-venue `funding_rate` + `interval_h` (daily % = rate × 24 / interval_h × 100); without: up to 5 pre-ranked arb rows (`long_exchange`, `short_exchange`, `spread_daily_pct`) |
|
|
208
209
|
| `perp_spreads` | up to 10 cross-venue price-gap rows (≥ 0.5%); `symbol` only filters that global top 10, so it is often empty |
|
|
209
|
-
| `perp_open_interest` (`
|
|
210
|
-
| `perp_long_short` (`
|
|
210
|
+
| `perp_open_interest` (`md oi`) | `oi_usd` per venue (USD notional, moves with price), newest print or an hourly series (`hours` 1-168); `stale_venues` are never in a total |
|
|
211
|
+
| `perp_long_short` (`md long-short`) | `long_share`, `short_share` (fractions), `long_short_ratio` per venue, each with its `basis` (what the venue counts); about 40 major symbols |
|
|
211
212
|
|
|
212
|
-
|
|
213
|
+
Open interest and long/short: `vike-data md oi BTC --hours 24`, `md long-short BTC` (`--exchange`, `--hours` 1-168). None returns bid/ask per venue. "Spread" here is perp vs perp across venues, not spot vs perp.
|
|
214
|
+
|
|
215
|
+
`vike-data md` is the REST API `/v1/marketdata`, one GET each (`--json` is the route's body). `md funding-now [symbol]`, `md spreads [symbol]`, `md oi` and `md long-short` give the same answer as the four tools above. `md spreads-history <symbol> --a <venue> --b <venue>` is one pair's price gap over time: leg A over leg B in bps per `--interval 1h|4h|1d` bucket, perp or spot legs, since 2026-05-30 (`high_bps_bound`/`low_bps_bound` are bounds, not observed values). `md liquidations [symbol]` lists forced liquidations on binance, bybit, okx, deribit and aster, newest first. `side` is the LIQUIDATED position, `notional_usd` = price x qty. `--interval 1h` (or 1m to 1d) gives long and short totals per bucket. Read `coverage`: binance and aster publish at most one per symbol per second, so their totals undercount, and nothing exists before recording started. Two more have no tool row here: `md funding <symbol>` is the funding history, newest first (`--exchange`, `--start`, `--end`, `--limit` up to 5000), each row with `rate`, `interval_h`, `rate_8h` and `apr` (a fraction: 0.11 = 11 % a year). `md carry` is the carry screener. By default it pairs perp-perp and spot-perp legs (`--legs`), longs the lower funding rate and shorts the higher (`--direction funding`; `convergence` longs the cheaper price instead), and applies no minimum gap. Rows carry `gross_apr` and `net_apr` (fractions), `fees_usd` and `net_usd` for $1,000 a leg, and `breakeven_h`. Each leg carries `market`, `interval_src` and `capped` (the rate is at the venue's cap or floor). See `vike-perp-carry`.
|
|
216
|
+
|
|
217
|
+
Further `md` commands:
|
|
218
|
+
- `md funding-oi [symbol]`: each coin's funding averaged across venues by open interest (`rate_8h`, `apr`, `oi_usd`, `venues`).
|
|
219
|
+
- `md basis [symbol]`: dated futures on binance, bybit, okx, deribit, gate and kraken, with `basis` against `--ref index|spot|perp` and `apr`, the cash-and-carry yield to expiry before fees (`null` under 2 days).
|
|
220
|
+
|
|
221
|
+
`md funding-now` rows also carry:
|
|
222
|
+
- per venue: `avg_apr_7d`/`_30d`, `cum_1d`/`_7d`/`_30d` (settled funding) and `oi_usd`;
|
|
223
|
+
- on arbitrage pairs: `opportunity_age_h`, `stability_7d` and `spread_avg_7d`/`_30d_daily_pct`.
|
|
224
|
+
|
|
225
|
+
Funding, spread and carry rows carry `market_status` (`delisting`, `reduce_only`, or `null`) and `delist_ts`. Never present a leg on a delisting or reduce-only venue as a trade.
|
|
213
226
|
|
|
214
227
|
### Hyperliquid
|
|
215
228
|
| Tool | Returns |
|
|
@@ -12,8 +12,8 @@ About 15 credits for all four sections; run only the ones the user wants and say
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
vike-data perp funding --json & # top cross-venue funding arbs (daily %, spread >= 0.3%)
|
|
15
|
-
vike-data
|
|
16
|
-
vike-data
|
|
15
|
+
vike-data md oi BTC --json & # repeat for ETH; oi_usd is USD notional
|
|
16
|
+
vike-data md long-short BTC --json & # repeat for ETH; read each venue's `basis`
|
|
17
17
|
wait
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -15,7 +15,7 @@ S=ETH
|
|
|
15
15
|
vike-data candles hl $S --interval 1h --limit 24 --json # price: 24 hourly bars
|
|
16
16
|
vike-data hl market --view hourly --symbols $S --days 7 --json # Hyperliquid close, open interest, funding rate, premium per hour
|
|
17
17
|
vike-data perp funding --symbol $S --json # funding on every venue now (normalise it yourself)
|
|
18
|
-
vike-data
|
|
18
|
+
vike-data md oi ETH --json # open interest per venue, USD notional
|
|
19
19
|
vike-data hl cohort-metrics $S --axis size --hours 1 --json # whales' long/short
|
|
20
20
|
vike-data hl cohort-metrics $S --axis pnl --hours 1 --json # profitable vs losing wallets
|
|
21
21
|
vike-data hl liquidations --view heatmap --symbol $S --bins 20 --json # where liquidations would cluster
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vike-perp-carry
|
|
3
|
+
description: Cross-venue perp carry after costs. Long one leg on one venue and short the other on another (two perps, or spot bought against a perp shorted); each pair is scored by the funding it earns plus the price gap it captures, as gross and net APR, with fees, net dollars and break-even hours. Also the funding history that shows whether a funding gap lasts. Use when the user asks "is this funding arb worth it after fees" / "best carry trade right now" / "net APR of a cross-exchange perp trade" / "spot-perp carry" / "how long until it breaks even" / "has BTC funding on Binance been positive all week".
|
|
4
|
+
allowed-tools: Bash(vike-data:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# vike-perp-carry
|
|
8
|
+
|
|
9
|
+
`vike-data md` reads the REST API `/v1/marketdata` (CEX perps, 1 credit a call). `md carry` is the carry screener, and its defaults return the list on vike.io/perp/carry. `md funding` is one symbol's funding history, for checking that a funding gap is more than one print. Pass the base asset (`BTC`, not `BTCUSDT`); venues are lower case.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
vike-data md carry --json # defaults: --legs all --direction funding --costs fees_slippage --horizon 48 --min-spread-pct 0 --sort net --limit 50
|
|
15
|
+
vike-data md carry --legs perp_spot --json # spot bought, perp shorted: earns the perp's funding
|
|
16
|
+
vike-data md carry --direction convergence --min-spread-pct 0.5 --json # long the cheaper price, short the dearer
|
|
17
|
+
vike-data md carry --costs fees --fee-bps 5 --horizon 24 --json
|
|
18
|
+
vike-data md funding BTC --exchange binance --start 2026-11-23 --json # one venue's settled funding since a date, newest first
|
|
19
|
+
vike-data md funding-now BTC --json # every venue's funding now
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- `--legs`: `all` (the default), `perp_perp` (a perpetual on each of two venues) or `perp_spot` (spot bought and a perpetual shorted; spot is never shorted).
|
|
23
|
+
- `--direction`: `funding` (the default: long the lower funding rate, short the higher) or `convergence` (long the cheaper price, short the dearer).
|
|
24
|
+
- `--costs`: `none` (net equals gross), `fees` (taker fees, entry and exit on both legs) or `fees_slippage` (fees plus slippage on all four fills, the default).
|
|
25
|
+
- `--fee-bps` (0-100) replaces every venue's own taker fee. It is refused with `--costs none`.
|
|
26
|
+
- `--slippage-bps` (0-100, default 2) is accepted only with `--costs fees_slippage`.
|
|
27
|
+
- `--horizon` is the holding period in hours (1-720, sent as `horizon_h`): funding accrues over it, and both APRs are annualised from it.
|
|
28
|
+
- `--min-spread-pct` (0-25, default 0) is the smallest PRICE gap between the two legs, in percent, of either sign. It is not a funding spread.
|
|
29
|
+
- Any flag the route does not take is a 400. A refusal exits 1 with the server's message.
|
|
30
|
+
|
|
31
|
+
## Reading the answer
|
|
32
|
+
|
|
33
|
+
The envelope has `as_of` (unix seconds of the prices), the inputs as applied (`legs` and `direction` among them), `notional_usd` (1000) and `rows`. Each row has:
|
|
34
|
+
|
|
35
|
+
- `symbol`, and for `long_` and `short_`:
|
|
36
|
+
- `venue` and `market` (`perp` or `spot`), `price` (mid);
|
|
37
|
+
- `funding_rate` (one settlement), `interval_h` and `interval_src`, `rate_8h`, `apr`, `capped`, `next_funding_ts`. Every funding field is `null` on a spot leg.
|
|
38
|
+
- `spread_pct`: the short leg's price over the long leg's, in percent. It is negative when the long leg is the dearer, which is common with `--direction funding`.
|
|
39
|
+
- `funding_spread_24h_pct`: what the pair's funding earns in 24 hours.
|
|
40
|
+
- `spread_capture_usd` (the gap, captured when prices meet; negative when it costs), `net_funding_usd` (over the horizon), `fees_usd` (the costs) and `net_usd`. All are for $1,000 on EACH leg.
|
|
41
|
+
- `gross_apr` and `net_apr`, both **fractions of the capital on both legs** (0.25 = 25 % a year; 3.19 = 319 %).
|
|
42
|
+
- `breakeven_h`: hours of funding needed to pay the costs the gap does not. 0 means the gap alone pays them; `null` means funding never does.
|
|
43
|
+
- `min_leg_vol_usd`: only legs with $1M+ of 24-hour volume are listed. A pair whose perp leg has no current funding rate is left out.
|
|
44
|
+
|
|
45
|
+
What the funding-leg fields mean:
|
|
46
|
+
|
|
47
|
+
- **`capped: true`** means that leg's rate sits at its venue's published cap or floor. The real pressure may be larger, and the rate can stay pinned there. `null` means the venue publishes no cap.
|
|
48
|
+
- **`interval_src`** says where `interval_h` comes from: `venue` (the venue publishes it for the symbol), `fixed` (the venue settles hourly for every market) or `default` (nothing published, 8 h assumed). Treat a `default` leg's `rate_8h` and `apr` as an estimate.
|
|
49
|
+
- **`market_status`** on a perp leg is `delisting` (the venue has set a date, `delist_ts` in unix seconds) or `reduce_only` (it takes only orders that close or reduce a position). It is `null` while the market trades normally and on a spot leg. Never present a row with such a leg as a trade: the position can be force-closed or cannot be opened.
|
|
50
|
+
- In the table view (no `--json`):
|
|
51
|
+
- a capped rate prints as `0.002 capped`;
|
|
52
|
+
- the interval prints as published, e.g. `4h`, or `8h assumed` for `default`;
|
|
53
|
+
- a leg's venue with a status prints as `binance (delisting 2026-12-08)` or `bybit (reduce_only)`.
|
|
54
|
+
|
|
55
|
+
`--json` keeps the raw `capped`, `interval_src`, `market_status` and `delist_ts` fields.
|
|
56
|
+
|
|
57
|
+
## Dated futures: the cash-and-carry basis
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
vike-data md basis BTC --json # every live dated BTC future, highest apr first; basis against the index
|
|
61
|
+
vike-data md basis ETH --ref spot --sort expiry --json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Each row in `futures` describes one contract:
|
|
65
|
+
- `exchange`, `instrument`, `expiry` (unix seconds), `days_to_expiry`, `type` (`linear` or `inverse`) with `contract_size`;
|
|
66
|
+
- `price` and `price_src` (book mid, else mark, else last);
|
|
67
|
+
- `index_price`, `spot_price`, `perp_price` and `ref_price` (the one `--ref` picks);
|
|
68
|
+
- `basis` = (price - ref_price) / ref_price, a fraction;
|
|
69
|
+
- `apr` = basis x 365 / days_to_expiry, the yield of buying the underlying and selling the future to expiry, before fees. It is `null` under 2 days;
|
|
70
|
+
- `vol_24h_usd` and `oi_usd`.
|
|
71
|
+
|
|
72
|
+
Covers binance (USDT-M), bybit, okx, deribit, gate and kraken; not Binance COIN-M. Unlike a funding carry, this yield is locked in at entry if held to expiry. A short horizon still inflates the APR, so quote `basis` next to it.
|
|
73
|
+
|
|
74
|
+
How to read it:
|
|
75
|
+
|
|
76
|
+
- **Lead with `net_usd` for the horizon and `net_apr`, not `gross_apr`.** Say which `--legs`, `--direction`, `--costs` and `--horizon` you used.
|
|
77
|
+
- A large APR on a short horizon is mostly a one-off gap capture annualised: a 2.6 % gap over 48 hours reads as hundreds of percent a year. It is not repeatable. Quote `net_usd` per $1,000 a leg next to it.
|
|
78
|
+
- `spread_capture_usd` assumes the two prices meet within the horizon. If they do not, only `net_funding_usd` is earned, and the exit pays the costs.
|
|
79
|
+
- Funding is the rate now, not a forecast. Run `md funding <SYM> --exchange <venue>` for each perp leg and check that the sign held over recent days. In those rows `apr` is also a fraction, and `rate_8h` puts 1h, 4h and 8h venues on one scale.
|
|
80
|
+
|
|
81
|
+
## Anti-patterns
|
|
82
|
+
|
|
83
|
+
- Don't present `gross_apr` as the return, and don't read an APR fraction as percent (0.25 is 25 %, not 0.25 %).
|
|
84
|
+
- Don't compare rows fetched with different `--legs`, `--direction`, `--costs` or `--horizon`.
|
|
85
|
+
- Don't extrapolate a `capped` leg's rate, or a leg with `interval_src: default`, without saying so.
|
|
86
|
+
- Don't call a wide gap free money. Gaps above 25 % are dropped as ticker collisions, and a 2-25 % gap on a thin pair can be a different contract or a stale venue. Check `min_leg_vol_usd` and both prices.
|
|
87
|
+
- Don't treat a row as risk-free: the two legs sit on two venues, each with its own margin, liquidation and transfer risk.
|
|
88
|
+
- Don't extrapolate one funding print to a year without the history check above.
|
|
89
|
+
|
|
90
|
+
## Pairs well with
|
|
91
|
+
|
|
92
|
+
- `vike-perp-funding` for each venue's funding of one symbol and the pre-ranked funding-arbitrage list
|
|
93
|
+
- `vike-perp-overview` for the widest price gaps, open interest and long/short
|
|
94
|
+
- `vike-perp-crowding` to see whether the side you would short is crowded
|
|
@@ -6,7 +6,7 @@ allowed-tools: Bash(vike-data:*)
|
|
|
6
6
|
|
|
7
7
|
# vike-perp-crowding
|
|
8
8
|
|
|
9
|
-
Three lenses on one symbol, about 6 credits. No lens has a validated threshold: judge each against the symbol's OWN last week and report what agrees, never a score. Base asset only (`BTC`, not `BTCUSDT`). Open interest and long/short
|
|
9
|
+
Three lenses on one symbol, about 6 credits. No lens has a validated threshold: judge each against the symbol's OWN last week and report what agrees, never a score. Base asset only (`BTC`, not `BTCUSDT`). Open interest and long/short are `vike-data md oi` and `md long-short` (REST `/v1/marketdata`, the same answer as the MCP tools `perp_open_interest` and `perp_long_short`).
|
|
10
10
|
|
|
11
11
|
## Chain
|
|
12
12
|
|
|
@@ -14,13 +14,13 @@ Three lenses on one symbol, about 6 credits. No lens has a validated threshold:
|
|
|
14
14
|
S=BTC
|
|
15
15
|
vike-data perp funding --symbol $S --json # funding on every venue now
|
|
16
16
|
vike-data hl market --view hourly --symbols $S --days 7 --json # Hyperliquid funding, open interest and close per hour
|
|
17
|
-
vike-data
|
|
18
|
-
vike-data
|
|
17
|
+
vike-data md oi $S --hours 168 --json # hourly oi_usd per venue
|
|
18
|
+
vike-data md long-short $S --hours 168 --json # hourly long_short_ratio per venue, with `basis`
|
|
19
19
|
vike-data candles hl $S --interval 1h --limit 169 --json # price over the same hours, to net it out of OI
|
|
20
20
|
vike-data hl cohort-metrics $S --axis size --hours 1 --json # optional: whales on Hyperliquid
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Without
|
|
23
|
+
Without `--hours` both return the newest print per venue; `--exchange binance` narrows to one venue.
|
|
24
24
|
|
|
25
25
|
## Lens 1: funding
|
|
26
26
|
|
|
@@ -41,6 +41,44 @@ annualised_pct = daily_pct × 365
|
|
|
41
41
|
|
|
42
42
|
`vol_24h_usd` is the venue's 24h perp notional: use it as the liquidity check.
|
|
43
43
|
|
|
44
|
+
### C. History, and the arb after costs
|
|
45
|
+
|
|
46
|
+
Both modes above are a snapshot. The REST API `/v1/marketdata` (`vike-data md`, one GET each) adds the history and the costs. `md funding-now` gives the same answer as `perp funding`.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
vike-data md funding BTC --exchange bybit --start 2026-11-23 --json # settled funding since a date, newest first, one venue or all
|
|
50
|
+
vike-data md funding-now BTC --json # every venue now (no symbol: the top-5 arb list)
|
|
51
|
+
vike-data md carry --costs fees_slippage --horizon 48 --json # cross-venue pairs: gross_apr vs net_apr, breakeven_h
|
|
52
|
+
vike-data md funding-oi --limit 20 --json # each coin's funding averaged across venues by open interest
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`md funding` rows carry `rate` (one settlement), `interval_h`, `rate_8h` (the rate scaled to 8 hours, so 1h and 8h venues compare) and `apr` (a fraction: 0.11 = 11 % a year). `md funding-now BTC` rows carry `rate_8h` and `apr` too. Arbitrage rows (no symbol) carry `long_`/`short_` versions of the last two fields below. Two more fields on each venue's rate:
|
|
56
|
+
- `capped: true`: the rate sits at the venue's published cap or floor, so the real pressure may be larger. `null` means the venue publishes no cap.
|
|
57
|
+
- `interval_src`: `venue` (published for the symbol), `fixed` (the venue settles hourly for every market) or `default` (nothing published, 8 h assumed, so `rate_8h` and `apr` are an estimate).
|
|
58
|
+
|
|
59
|
+
The settled history behind the snapshot is in the same answer. All of it covers funding settled up to the start of the current UTC hour, and is `null` when nothing settled in the window.
|
|
60
|
+
- Per venue (`md funding-now BTC`):
|
|
61
|
+
- `avg_apr_7d` and `avg_apr_30d`: the average settled rate, a year, as a fraction.
|
|
62
|
+
- `cum_1d`, `cum_7d` and `cum_30d`: the sum of settled rates, what a long paid per unit of notional; negative means it was paid.
|
|
63
|
+
- `oi_usd`: open interest in USD.
|
|
64
|
+
- On arbitrage pairs (no symbol):
|
|
65
|
+
- `opportunity_age_h`: how many hours in a row the gap held at 0.3 %/day or more; 720 means all 30 days.
|
|
66
|
+
- `stability_7d`: the share of the last 7 days' hours in which it held, 0 to 1.
|
|
67
|
+
- `spread_avg_7d_daily_pct` and `spread_avg_30d_daily_pct`: the average gap.
|
|
68
|
+
- each leg's `next_daily_pct`: the rate quoted for its next settlement.
|
|
69
|
+
- **Prefer a pair with a long `opportunity_age_h` and a high `stability_7d`.** A pair at age 0 or with a low stability is one hour's print.
|
|
70
|
+
|
|
71
|
+
`md funding-oi` gives one funding number per coin: its venues' rates weighted by open interest. Positive means longs pay. Venues without dollar open interest (deribit, bingx, gate, lighter, mexc, weex) carry no weight.
|
|
72
|
+
|
|
73
|
+
`market_status` (`delisting`, `reduce_only` or `null`) and `delist_ts` on each venue or leg come from the venue's own API (binance, bybit, okx, bitget, gate, kucoin, aster). A funding gap on a delisting or reduce-only venue is not a trade.
|
|
74
|
+
|
|
75
|
+
The table view prints:
|
|
76
|
+
- a capped rate as `0.0075 capped`;
|
|
77
|
+
- the interval as `4h`, or `8h assumed`;
|
|
78
|
+
- a venue with a status as `binance (delisting 2026-12-08)` or `bybit (reduce_only)`.
|
|
79
|
+
|
|
80
|
+
Whether a pair pays after fees: `vike-perp-carry`.
|
|
81
|
+
|
|
44
82
|
## Venue comparison (one symbol)
|
|
45
83
|
|
|
46
84
|
Run B, normalise, then report:
|
|
@@ -81,5 +119,6 @@ A funding arb at 0.4–1% daily is real. Anything much higher on a liquid pair i
|
|
|
81
119
|
## Pairs well with
|
|
82
120
|
|
|
83
121
|
- `vike-perp-overview` for cross-venue price gaps, open interest, long/short and the market snapshot
|
|
122
|
+
- `vike-perp-carry` for a cross-venue pair's net APR after fees and slippage, and the funding history of each leg
|
|
84
123
|
- `vike-perp-crowding` to put a funding number next to open interest and positioning; `vike-hl-asset-briefing` for one Hyperliquid symbol
|
|
85
124
|
- `vike-hl-top-traders` to see how Hyperliquid's best traders are doing
|
|
@@ -10,16 +10,16 @@ One-shot market overview for perpetuals, plus the cross-venue price-gap, open-in
|
|
|
10
10
|
|
|
11
11
|
## Open interest and long/short (one symbol, per venue)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`vike-data md` reads them from the REST API `/v1/marketdata` (1 credit each; the same answer as the MCP tools `perp_open_interest` and `perp_long_short`):
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
vike-data
|
|
17
|
-
vike-data
|
|
18
|
-
vike-data
|
|
19
|
-
vike-data
|
|
16
|
+
vike-data md oi BTC --json # newest print per venue
|
|
17
|
+
vike-data md oi BTC --exchange binance --hours 48 --json # hourly series, 1-168
|
|
18
|
+
vike-data md long-short ETH --json
|
|
19
|
+
vike-data md long-short ETH --exchange okx --hours 24 --json
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Pass the base asset (`BTC`, not `BTCUSDT`);
|
|
22
|
+
Pass the base asset (`BTC`, not `BTCUSDT`); `--exchange` is lower case.
|
|
23
23
|
|
|
24
24
|
- **`oi_usd` is USD notional** (open contracts x mark price when polled): not a contract count, so venues add up, and it moves with price even when no position opens or closes. Venues: aster, binance, bitget, bybit, hyperliquid, kucoin, okx. A venue silent for over an hour is under `stale_venues` and NOT in `venues`: never add it into a total.
|
|
25
25
|
- **`long_share` / `short_share` are fractions of 1**; `long_short_ratio` = long / short, above 1 = long-heavy. **Each venue counts something different, named in the row's `basis`**: binance top traders by positions; okx and gate top traders by accounts; bybit all accounts. Never average across venues; compare a venue with its own history.
|
|
@@ -31,9 +31,16 @@ Pass the base asset (`BTC`, not `BTCUSDT`); `exchange` is lower case.
|
|
|
31
31
|
```bash
|
|
32
32
|
vike-data perp spreads --json # up to 10 symbols with a cross-venue price gap >= 0.5%
|
|
33
33
|
vike-data perp spreads --symbol BTC --json # the same list, filtered to one symbol
|
|
34
|
+
vike-data md spreads --json # the same answer from the REST API /v1/marketdata
|
|
35
|
+
vike-data md spreads-history BTC --a binance --b okx --interval 4h --json # one pair's gap over time, in bps
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
`md spreads-history` is leg A's price over leg B's per bucket, in basis points: `(A / B - 1) x 10,000`, positive when A is the dearer. It covers any two venues, perp or spot (`--market-a`, `--market-b`), since 2026-05-30, over the last 7 days unless `--start`/`--end` say otherwise.
|
|
39
|
+
- `high_bps_bound` and `low_bps_bound` only BOUND the bucket's extremes, because each leg's extreme can fall on a different minute. Don't quote them as observed spreads.
|
|
40
|
+
- `book_bps_a` and `book_bps_b` are each leg's mean bid-ask width.
|
|
41
|
+
- A bucket where one leg was unpriced has no row.
|
|
42
|
+
|
|
43
|
+
Rows: `symbol`, `buy_exchange`, `buy_price`, `sell_exchange`, `sell_price`, `spread_pct`, and for `buy_` and `sell_` the venue's `market_status` (`delisting`, `reduce_only`, or `null`) and `delist_ts`. Pre-ranked: cite the rows directly, except a row with a delisting or reduce-only leg: its gap is often the delisting itself, not a trade. The `md spreads` table prints such a venue as `binance (delisting 2026-12-08)`.
|
|
37
44
|
|
|
38
45
|
- **"Spread" is perp vs perp across venues, not spot vs perp.** `buy_exchange` is the cheapest venue and `sell_exchange` the dearest for that symbol.
|
|
39
46
|
- **`--symbol` only filters the global top 10.** An empty answer means the symbol is not among today's widest gaps, not that its venues agree. Don't answer "where's X cheapest" from an empty result; say the tool only lists the 10 widest gaps.
|
package/skills.sh.json
CHANGED
|
@@ -48,11 +48,12 @@
|
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"title": "CEX perps",
|
|
51
|
-
"description": "Funding-rate arb and per-symbol venue comparison, cross-venue perp price gaps, open interest and long/short lean per venue,
|
|
51
|
+
"description": "Funding-rate arb and per-symbol venue comparison, cross-venue perp price gaps, open interest and long/short lean per venue, a crowding read that nets open interest against price, and funding carry after costs with the funding history.",
|
|
52
52
|
"skills": [
|
|
53
53
|
"vike-perp-funding",
|
|
54
54
|
"vike-perp-overview",
|
|
55
|
-
"vike-perp-crowding"
|
|
55
|
+
"vike-perp-crowding",
|
|
56
|
+
"vike-perp-carry"
|
|
56
57
|
]
|
|
57
58
|
},
|
|
58
59
|
{
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { addTool } from './tool-command.js';
|
|
2
|
+
import { fmtNum } from '../format.js';
|
|
3
|
+
|
|
4
|
+
// Each subcommand is one GET of the REST namespace /v1/marketdata (not an MCP tool): the flags are
|
|
5
|
+
// exactly its query parameters (the server refuses any other with a 400), and --json prints the
|
|
6
|
+
// route's body as served.
|
|
7
|
+
export function registerMarketdata(program) {
|
|
8
|
+
const cmd = program
|
|
9
|
+
.command('marketdata')
|
|
10
|
+
.alias('md')
|
|
11
|
+
.description('CEX derivatives market data from the REST API /v1/marketdata: funding history, now and OI-weighted, spreads and their history, open interest, long/short, liquidations, carry screener, dated-futures basis');
|
|
12
|
+
|
|
13
|
+
const P = '/v1/marketdata/perp';
|
|
14
|
+
const EXCHANGE = ['--exchange <venue>', 'Only this venue, lower case (e.g. binance); omit for every venue'];
|
|
15
|
+
const HOURS = ['--hours <n>', '1-168: an hourly series, the last print in each UTC hour; omit for the newest print per venue'];
|
|
16
|
+
|
|
17
|
+
addTool(cmd, 'funding <symbol>', {
|
|
18
|
+
path: `${P}/funding`,
|
|
19
|
+
args: ['symbol'],
|
|
20
|
+
desc: 'Funding-rate history of one perp symbol (e.g. BTC), newest first, every venue or one: rate, interval_h, rate_8h, apr, mark_price',
|
|
21
|
+
options: [
|
|
22
|
+
EXCHANGE,
|
|
23
|
+
['--start <time>', 'From this time, inclusive: ISO-8601 (2026-11-01, 2026-11-01T08:00:00Z) or unix seconds'],
|
|
24
|
+
['--end <time>', 'Before this time, exclusive; same forms as --start'],
|
|
25
|
+
['--limit <n>', 'Rows, 1-5000 (default 500)'],
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
addTool(cmd, 'funding-now [symbol]', {
|
|
30
|
+
path: `${P}/funding/current`,
|
|
31
|
+
args: ['symbol'],
|
|
32
|
+
desc: 'Current funding of one symbol on each venue (with 7/30-day average APR, 1/7/30-day sums, oi_usd); without a symbol, the top 5 cross-venue funding-arbitrage pairs (with age, 7-day stability, 7/30-day average spread). Marks a capped rate and a delisting or reduce-only venue',
|
|
33
|
+
human: (r) => (Array.isArray(r) ? r.map(markLegs) : r),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
addTool(cmd, 'funding-oi [symbol]', {
|
|
37
|
+
path: `${P}/funding/oi-weighted`,
|
|
38
|
+
args: ['symbol'],
|
|
39
|
+
desc: 'Each coin\'s current funding averaged across venues by open interest (rate_8h, apr, oi_usd, venues), largest open interest first; a symbol for one coin',
|
|
40
|
+
options: [['--limit <n>', 'Coins, 1-500 (default 50)']],
|
|
41
|
+
human: rowsOr('rows'),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
addTool(cmd, 'spreads [symbol]', {
|
|
45
|
+
path: `${P}/spreads`,
|
|
46
|
+
args: ['symbol'],
|
|
47
|
+
desc: 'The 10 widest cross-venue price gaps (>= 0.5%): buy on one venue, sell the dearer perp; a symbol filters those 10. Marks a delisting or reduce-only venue',
|
|
48
|
+
human: (r) => (Array.isArray(r) ? r.map(markLegs) : r),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
addTool(cmd, 'spreads-history <symbol>', {
|
|
52
|
+
path: `${P}/spreads/history`,
|
|
53
|
+
args: ['symbol'],
|
|
54
|
+
desc: 'Price of leg A over leg B per bucket, in bps ((A / B - 1) x 10,000), since 2026-05-30: open, close, avg, high/low bounds, samples, bid-ask width',
|
|
55
|
+
options: [
|
|
56
|
+
['--a <venue>', 'Leg A\'s venue, lower case (e.g. binance)', true],
|
|
57
|
+
['--b <venue>', 'Leg B\'s venue, lower case (e.g. okx)', true],
|
|
58
|
+
['--market-a <m>', 'perp (default) | spot'],
|
|
59
|
+
['--market-b <m>', 'perp (default) | spot'],
|
|
60
|
+
['--interval <i>', '1h (default) | 4h | 1d; 4h and 1d buckets start at 00:00 UTC'],
|
|
61
|
+
['--start <time>', 'From this time, inclusive: ISO-8601 or unix seconds, floored to the interval (default: 7 days before --end)'],
|
|
62
|
+
['--end <time>', 'Before this time, exclusive; same forms (default: now)'],
|
|
63
|
+
],
|
|
64
|
+
names: { a: 'exchange_a', b: 'exchange_b' },
|
|
65
|
+
human: rowsOr('rows'),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
addTool(cmd, 'oi <symbol>', {
|
|
69
|
+
path: `${P}/oi`,
|
|
70
|
+
args: ['symbol'],
|
|
71
|
+
desc: 'Open interest of one perp symbol on each venue, USD notional (stale_venues are never summed in)',
|
|
72
|
+
options: [EXCHANGE, HOURS],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
addTool(cmd, 'long-short <symbol>', {
|
|
76
|
+
path: `${P}/long-short`,
|
|
77
|
+
args: ['symbol'],
|
|
78
|
+
desc: 'Long/short split of one perp symbol on each venue; each venue counts something different (basis): compare a venue with itself',
|
|
79
|
+
options: [EXCHANGE, HOURS],
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
addTool(cmd, 'liquidations [symbol]', {
|
|
83
|
+
path: `${P}/liquidations`,
|
|
84
|
+
args: ['symbol'],
|
|
85
|
+
desc: 'Forced liquidations on CEX perps, newest first, one row each (side = the liquidated position) or long/short totals per --interval bucket; binance and aster undercount (see coverage)',
|
|
86
|
+
options: [
|
|
87
|
+
['--exchange <venue>', 'Only this venue: binance, bybit, okx, deribit or aster; omit for every venue'],
|
|
88
|
+
['--side <s>', 'long | short: only liquidations of this position side'],
|
|
89
|
+
['--start <time>', 'From this time, inclusive: ISO-8601 or unix seconds'],
|
|
90
|
+
['--end <time>', 'Before this time, exclusive; same forms as --start'],
|
|
91
|
+
['--interval <i>', '1m | 5m | 15m | 1h | 4h | 1d: long and short totals per UTC bucket instead of one row each'],
|
|
92
|
+
['--limit <n>', 'Rows or buckets, 1-5000 (default 500)'],
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
addTool(cmd, 'carry', {
|
|
97
|
+
path: `${P}/carry`,
|
|
98
|
+
desc: 'Carry screener: long one leg, short the other on another venue; price gap plus funding over the horizon as gross_apr and net_apr (fractions), fees_usd, breakeven_h. Marks a capped rate and a delisting or reduce-only venue',
|
|
99
|
+
options: [
|
|
100
|
+
['--legs <l>', 'all (default) | perp_perp (a perp on each venue) | perp_spot (spot bought, a perp shorted)'],
|
|
101
|
+
['--direction <d>', 'funding (default: long the lower funding rate, short the higher) | convergence (long the cheaper price, short the dearer)'],
|
|
102
|
+
['--costs <c>', 'What net_apr subtracts: none | fees | fees_slippage (default)'],
|
|
103
|
+
['--fee-bps <bps>', 'Taker fee per fill for every venue, 0-100 (default: each venue\'s own); refused with --costs none'],
|
|
104
|
+
['--slippage-bps <bps>', 'Slippage per fill, 0-100 (default 2); only with --costs fees_slippage'],
|
|
105
|
+
['--horizon <hours>', 'Hours the pair is held, 1-720 (default 48); sent as horizon_h'],
|
|
106
|
+
['--min-spread-pct <p>', 'Smallest price gap between the two legs, percent, either sign, 0-25 (default 0)'],
|
|
107
|
+
['--sort <s>', 'net (default) | gross'],
|
|
108
|
+
['--limit <n>', 'Rows, 1-500 (default 50)'],
|
|
109
|
+
],
|
|
110
|
+
names: { horizon: 'horizon_h' },
|
|
111
|
+
human: (r) => (Array.isArray(r?.rows) ? r.rows.map(markLegs) : r),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
addTool(cmd, 'basis [symbol]', {
|
|
115
|
+
path: '/v1/marketdata/futures/basis',
|
|
116
|
+
args: ['symbol'],
|
|
117
|
+
desc: 'Dated futures (quarterly, monthly, weekly) on binance, bybit, okx, deribit, gate and kraken: basis against --ref and apr, the cash-and-carry yield to expiry before fees',
|
|
118
|
+
options: [
|
|
119
|
+
['--exchange <venue>', 'Only this venue: binance, bybit, okx, deribit, gate or kraken; omit for every venue'],
|
|
120
|
+
['--ref <r>', 'What the basis is measured against: index (default, the index the contract settles on) | spot | perp (the same venue\'s)'],
|
|
121
|
+
['--sort <s>', 'apr (default, highest first) | expiry (soonest first)'],
|
|
122
|
+
['--limit <n>', 'Rows, 1-5000 (default 500)'],
|
|
123
|
+
],
|
|
124
|
+
human: rowsOr('futures'),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Table view of the rows under `key`; with none, the whole answer, so its `note` shows.
|
|
129
|
+
const rowsOr = (key) => (r) => (r?.[key]?.length ? r[key] : r);
|
|
130
|
+
|
|
131
|
+
// Table view of a leg: "capped" after a rate at the venue's published cap or floor, the interval as
|
|
132
|
+
// published ("8h assumed" when the venue publishes none), and the venue's market status after its name
|
|
133
|
+
// ("binance (delisting 2026-12-05)", "bybit (reduce_only)"). --json keeps the raw fields.
|
|
134
|
+
export function markLegs(row) {
|
|
135
|
+
const out = { ...row };
|
|
136
|
+
for (const p of ['', 'long_', 'short_', 'buy_', 'sell_']) {
|
|
137
|
+
const rate = [`${p}funding_rate`, `${p}daily_pct`].find((k) => k in out);
|
|
138
|
+
if (out[`${p}capped`] === true && rate) out[rate] = `${typeof out[rate] === 'number' ? fmtNum(out[rate]) : out[rate]} capped`;
|
|
139
|
+
delete out[`${p}capped`];
|
|
140
|
+
if (`${p}interval_src` in out) {
|
|
141
|
+
const h = out[`${p}interval_h`];
|
|
142
|
+
out[`${p}interval_h`] = h == null ? null : `${h}h${out[`${p}interval_src`] === 'default' ? ' assumed' : ''}`;
|
|
143
|
+
delete out[`${p}interval_src`];
|
|
144
|
+
}
|
|
145
|
+
const venue = [`${p}exchange`, `${p}venue`].find((k) => k in out);
|
|
146
|
+
if (venue && (`${p}market_status` in out || `${p}delist_ts` in out)) {
|
|
147
|
+
const status = out[`${p}market_status`];
|
|
148
|
+
const ts = out[`${p}delist_ts`];
|
|
149
|
+
const date = ts ? new Date(ts * 1000).toISOString().slice(0, 10) : null;
|
|
150
|
+
if (status || date) out[venue] = `${out[venue]} (${[status ?? 'delisting', date].filter(Boolean).join(' ')})`;
|
|
151
|
+
delete out[`${p}market_status`];
|
|
152
|
+
delete out[`${p}delist_ts`];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { callTool } from '../mcp-client.js';
|
|
2
|
-
import { emit, emitError } from '../format.js';
|
|
1
|
+
import { callTool, getRest } from '../mcp-client.js';
|
|
2
|
+
import { emit, emitError, isJsonMode } from '../format.js';
|
|
3
3
|
|
|
4
|
-
// Register `<group> <spec>` as one call to one MCP tool
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
4
|
+
// Register `<group> <spec>` as one call to one MCP tool, or with `path` one GET of that REST route
|
|
5
|
+
// (the parameters go as its query string). `args` names the tool parameters the positional
|
|
6
|
+
// arguments of `spec` fill, in order. Each flag is forwarded under its snake_case parameter name
|
|
7
|
+
// (--from-ms -> from_ms), or the name `names` gives it, and an unset flag is not sent: a view-based
|
|
8
|
+
// tool refuses a parameter its view does not take, and the server's defaults stay the defaults.
|
|
9
|
+
// Values go as typed; the server casts them and names the fix when one is wrong. `human` reshapes the
|
|
10
|
+
// answer for the table only; --json and a pipe get it as served. An option whose third element is true
|
|
11
|
+
// is required (commander refuses the call without it).
|
|
12
|
+
export function addTool(group, spec, { tool, path, desc, args = [], options = [], names = {}, human }) {
|
|
10
13
|
const cmd = group.command(spec).description(desc);
|
|
11
|
-
for (const [flags, text] of options) cmd
|
|
14
|
+
for (const [flags, text, required] of options) cmd[required ? 'requiredOption' : 'option'](flags, text);
|
|
12
15
|
cmd.option('--json', 'Emit JSON');
|
|
13
16
|
cmd.action(async (...received) => {
|
|
14
17
|
received.pop(); // the Command
|
|
@@ -17,10 +20,11 @@ export function addTool(group, spec, { tool, desc, args = [], options = [] }) {
|
|
|
17
20
|
args.forEach((name, i) => { payload[name] = received[i]; });
|
|
18
21
|
for (const [key, value] of Object.entries(opts)) {
|
|
19
22
|
if (value === undefined || key === 'json') continue;
|
|
20
|
-
payload[key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`)] = value;
|
|
23
|
+
payload[names[key] ?? key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`)] = value;
|
|
21
24
|
}
|
|
22
25
|
try {
|
|
23
|
-
|
|
26
|
+
const result = await (path ? getRest(path, payload) : callTool(tool, payload));
|
|
27
|
+
emit(human && !isJsonMode(opts) ? human(result) : result, opts);
|
|
24
28
|
} catch (err) { emitError(err, opts); }
|
|
25
29
|
});
|
|
26
30
|
return cmd;
|
package/src/format.js
CHANGED
|
@@ -59,14 +59,18 @@ function printTable(rows) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// A number in a table cell (never JSON): K/M/B from a thousand up, else at most 6 significant digits with the
|
|
63
|
+
// float noise gone (0.10950000000000001 -> 0.1095; 0.0000259 stays 0.0000259, an integer stays whole).
|
|
64
|
+
export function fmtNum(v) {
|
|
65
|
+
if (Math.abs(v) >= 1e9) return (v / 1e9).toFixed(2) + 'B';
|
|
66
|
+
if (Math.abs(v) >= 1e6) return (v / 1e6).toFixed(2) + 'M';
|
|
67
|
+
if (Math.abs(v) >= 1e3) return (v / 1e3).toFixed(2) + 'K';
|
|
68
|
+
return Number.isInteger(v) ? String(v) : String(Number(v.toPrecision(6)));
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
function fmt(v) {
|
|
63
72
|
if (v === null || v === undefined) return '';
|
|
64
|
-
if (typeof v === 'number')
|
|
65
|
-
if (Math.abs(v) >= 1e9) return (v / 1e9).toFixed(2) + 'B';
|
|
66
|
-
if (Math.abs(v) >= 1e6) return (v / 1e6).toFixed(2) + 'M';
|
|
67
|
-
if (Math.abs(v) >= 1e3) return (v / 1e3).toFixed(2) + 'K';
|
|
68
|
-
return String(v);
|
|
69
|
-
}
|
|
73
|
+
if (typeof v === 'number') return fmtNum(v);
|
|
70
74
|
if (typeof v === 'object') return JSON.stringify(v);
|
|
71
75
|
const s = String(v);
|
|
72
76
|
return s.length > 80 ? s.slice(0, 77) + '...' : s;
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { registerPerp } from './commands/perp.js';
|
|
|
6
6
|
import { registerAlerts } from './commands/alerts.js';
|
|
7
7
|
import { registerPolymarket } from './commands/polymarket.js';
|
|
8
8
|
import { registerPredictfun } from './commands/predictfun.js';
|
|
9
|
+
import { registerMarketdata } from './commands/md.js';
|
|
9
10
|
import { registerLabels } from './commands/labels.js';
|
|
10
11
|
import { registerCandles } from './commands/candles.js';
|
|
11
12
|
// New wallet subcommands (counterparties, pnl-history, balances, ens) are
|
|
@@ -69,6 +70,7 @@ registerPerp(program);
|
|
|
69
70
|
registerAlerts(program);
|
|
70
71
|
registerPolymarket(program);
|
|
71
72
|
registerPredictfun(program);
|
|
73
|
+
registerMarketdata(program);
|
|
72
74
|
registerLabels(program);
|
|
73
75
|
registerCandles(program);
|
|
74
76
|
registerHl(program);
|
package/src/mcp-client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { URL } from 'node:url';
|
|
1
2
|
import { requireApiKey, getEndpoint } from './auth.js';
|
|
2
3
|
import { readPackageVersion } from './util.js';
|
|
3
4
|
|
|
@@ -21,31 +22,12 @@ async function post(endpoint, apiKey, init) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const endpoint = opts.endpoint ?? getEndpoint();
|
|
27
|
-
const timeoutMs = opts.timeoutMs ?? 60_000;
|
|
28
|
-
|
|
29
|
-
// argsText: the caller's own JSON object text, sent byte for byte (a 77-digit number is not rounded).
|
|
30
|
-
const envelope = JSON.stringify({ jsonrpc: '2.0', id: nextId(), method: 'tools/call' });
|
|
31
|
-
const body = `${envelope.slice(0, -1)},"params":{"name":${JSON.stringify(toolName)},`
|
|
32
|
-
+ `"arguments":${opts.argsText ?? JSON.stringify(args)}}}`;
|
|
33
|
-
|
|
25
|
+
// post() with a deadline on the response headers; a failure says which, timeout or network.
|
|
26
|
+
async function send(endpoint, apiKey, init, timeoutMs) {
|
|
34
27
|
const ctrl = new AbortController();
|
|
35
28
|
const t = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
36
|
-
|
|
37
|
-
let resp;
|
|
38
29
|
try {
|
|
39
|
-
|
|
40
|
-
method: 'POST',
|
|
41
|
-
headers: {
|
|
42
|
-
'Content-Type': 'application/json',
|
|
43
|
-
'X-API-KEY': apiKey,
|
|
44
|
-
'User-Agent': USER_AGENT,
|
|
45
|
-
},
|
|
46
|
-
body,
|
|
47
|
-
signal: ctrl.signal,
|
|
48
|
-
});
|
|
30
|
+
return await post(endpoint, apiKey, { ...init, signal: ctrl.signal });
|
|
49
31
|
} catch (err) {
|
|
50
32
|
if (err.name === 'AbortError') {
|
|
51
33
|
throw new Error(`Request timed out after ${timeoutMs}ms`);
|
|
@@ -54,6 +36,27 @@ export async function callTool(toolName, args = {}, opts = {}) {
|
|
|
54
36
|
} finally {
|
|
55
37
|
clearTimeout(t);
|
|
56
38
|
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function callTool(toolName, args = {}, opts = {}) {
|
|
42
|
+
const apiKey = opts.apiKey ?? requireApiKey();
|
|
43
|
+
const endpoint = opts.endpoint ?? getEndpoint();
|
|
44
|
+
const timeoutMs = opts.timeoutMs ?? 60_000;
|
|
45
|
+
|
|
46
|
+
// argsText: the caller's own JSON object text, sent byte for byte (a 77-digit number is not rounded).
|
|
47
|
+
const envelope = JSON.stringify({ jsonrpc: '2.0', id: nextId(), method: 'tools/call' });
|
|
48
|
+
const body = `${envelope.slice(0, -1)},"params":{"name":${JSON.stringify(toolName)},`
|
|
49
|
+
+ `"arguments":${opts.argsText ?? JSON.stringify(args)}}}`;
|
|
50
|
+
|
|
51
|
+
const resp = await send(endpoint, apiKey, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
'X-API-KEY': apiKey,
|
|
56
|
+
'User-Agent': USER_AGENT,
|
|
57
|
+
},
|
|
58
|
+
body,
|
|
59
|
+
}, timeoutMs);
|
|
57
60
|
|
|
58
61
|
const text = await resp.text();
|
|
59
62
|
let json;
|
|
@@ -79,6 +82,30 @@ export async function callTool(toolName, args = {}, opts = {}) {
|
|
|
79
82
|
return opts.raw ? content : parsed;
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
// GET one REST route (`/v1/...`) on the MCP endpoint's origin with the same key; an unset param is not sent.
|
|
86
|
+
export async function getRest(path, params = {}, opts = {}) {
|
|
87
|
+
const apiKey = opts.apiKey ?? requireApiKey();
|
|
88
|
+
const url = new URL(path, opts.endpoint ?? getEndpoint());
|
|
89
|
+
for (const [k, v] of Object.entries(params)) {
|
|
90
|
+
if (v !== undefined) url.searchParams.set(k, v);
|
|
91
|
+
}
|
|
92
|
+
const resp = await send(url.href, apiKey, {
|
|
93
|
+
headers: { 'X-API-KEY': apiKey, 'User-Agent': USER_AGENT },
|
|
94
|
+
}, opts.timeoutMs ?? 60_000);
|
|
95
|
+
|
|
96
|
+
const text = await resp.text();
|
|
97
|
+
let json;
|
|
98
|
+
try { json = JSON.parse(text); } catch {
|
|
99
|
+
throw new Error(`Bad response (HTTP ${resp.status}): ${text.slice(0, 200)}`);
|
|
100
|
+
}
|
|
101
|
+
if (!resp.ok) {
|
|
102
|
+
// 429 {"error": {"message"}}, 422 {"error": "<readable>"}, any other refusal {"detail": ...}
|
|
103
|
+
const e = json?.error?.message ?? json?.error ?? json?.detail ?? text.slice(0, 200);
|
|
104
|
+
throw new Error(`HTTP ${resp.status}: ${typeof e === 'string' ? e : JSON.stringify(e)}`);
|
|
105
|
+
}
|
|
106
|
+
return json;
|
|
107
|
+
}
|
|
108
|
+
|
|
82
109
|
export async function listTools(opts = {}) {
|
|
83
110
|
const apiKey = opts.apiKey ?? requireApiKey();
|
|
84
111
|
const endpoint = opts.endpoint ?? getEndpoint();
|