koinju
Use this skill for any query mentioning Koinju (koinju.io, api.koinju.io, docs.koinju.io, mcp koinju) — getting credentials, connecting, querying, integrating, or optimizing the Koinju API. Also use when the user wants crypto market data without naming Koinju: historical OHLCV/candles, tick trades, funding rates, option chains, implied volatility, vol smile, IV surface, DVOL — across 13 exchanges, among them Binance, Bybit, OKX, Deribit, Coinbase and Kraken. Covers backtesting strategies on crypto price history, quant research, and enriching existing ClickHouse/Postgres/Redis stores with crypto data. Do NOT use for stock/equity markets or for general ClickHouse architecture questions unrelated to Koinju.
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-15
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- koinju
- metadata
- { "author": "Dmitry Prokofyev", "version": "0.9.4", "homepage": "https://docs.koinju.io" }
- description
- Use this skill for any query mentioning Koinju (koinju.io, api.koinju.io, docs.koinju.io, mcp koinju) — getting credentials, connecting, querying, integrating, or optimizing the Koinju API. Also use when the user wants crypto market data without naming Koinju: historical OHLCV/candles, tick trades, funding rates, option chains, implied volatility, vol smile, IV surface, DVOL — across 13 exchanges, among them Binance, Bybit, OKX, Deribit, Coinbase and Kraken. Covers backtesting strategies on crypto price history, quant research, and enriching existing ClickHouse/Postgres/Redis stores with crypto data. Do NOT use for stock/equity markets or for general ClickHouse architecture questions unrelated to Koinju.
02 资源文件 31
- 参考文档README.md2.4 KB
- 参考文档references/auth.md6.7 KB
- 参考文档references/backtesting.md4.9 KB
- 参考文档references/bootstrap.md9.6 KB
- 参考文档references/data-tables.md18.2 KB
- 参考文档references/integrations.md5.7 KB
- 参考文档references/koinju.env.example1.2 KB
- 参考文档references/optimization.md5.3 KB
- 参考文档references/option_iv_greeks.md6.6 KB
- 参考文档references/plotting.md5.5 KB
- 参考文档references/recipes/bollinger_bands.md6.2 KB
- 参考文档references/recipes/correlation.md5.7 KB
- 参考文档references/recipes/cross_exchange_arbitrage.md6.2 KB
- 参考文档references/recipes/dca_vs_lump_sum.md7.3 KB
- 参考文档references/recipes/deribit_perpetual_funding.md8.4 KB
- 参考文档references/recipes/historical_volatility.md6.4 KB
- 参考文档references/recipes/max_drawdown_calmar.md5.9 KB
- 参考文档references/recipes/mean_reversion_zscore.md5.9 KB
- 参考文档references/recipes/ohlcv_streaming.md6.6 KB
- 参考文档references/recipes/README.md796 B
- 参考文档references/recipes/sortino_ratio.md5.6 KB
- 参考文档references/recipes/spot_futures_perp_spreads.md8.0 KB
- 参考文档references/rest.md12.2 KB
- 脚本scripts/backtest_buy_and_hold.py5.4 KB
- 脚本scripts/plot_option_smile.py5.5 KB
- 脚本scripts/probe-env.sh2.2 KB
- 脚本scripts/probe-schema.sh3.5 KB
- 脚本scripts/setup.sh2.9 KB
- 脚本scripts/welcome_btc_usdt.py4.3 KB
- 参考文档SOURCE.md314 B
- 参考文档TRUST.auto.yaml2.3 KB
03 SKILL.md 正文
Koinju API Skill
Help users discover, query, and integrate Koinju's multi-exchange crypto market data into research, backtesting, or production pipelines.
Quick start (fast-path)
Most "test the API" sessions need only this. Read the Workflow below for nuance.
- Set up a project:
bash ~/.claude/skills/koinju/scripts/setup.sh [target-dir]— auto-detects cwd-empty / uv / venv, scaffolds + installs deps + seedsmain.pyand.koinju.env, idempotent. Without[target-dir]: cwd if empty (ignoring.git), else./koinju-demo/. - Probe state:
bash ~/.claude/skills/koinju/scripts/probe-env.sh— one line likeuv:ok pyproject:found venv:active deps:ok creds:ok project_env:found home_env:found suggest_save_global:no. Use this before deciding to bootstrap, instead of running 4 separatecommand -v/python -c import/[ -n $VAR ]probes. If the trailing token issuggest_save_global:yes(project.koinju.envpopulated, but no~/.koinju.env), propose copying — see Workflow step 5. - Verify schema:
bash ~/.claude/skills/koinju/scripts/probe-schema.sh [table]— dumps liveapi.*tables and columns. Run before writing SQL against any table you haven't used this session. Note:DESCRIBE(what it uses) returns empty for parameterized views likeapi.ohlcv— that's "parameterized view", not "missing"; the script falls back toSHOW CREATEand prints the{param:Type}signature. - Get credentials: https://koinju.io/pricing → sign up → check email for the dataroom link. The credential template lives at
references/koinju.env.example(the bootstrap copies it). - No credentials: the free demo database holds one validated UTC day, 18 October 2026 (
2026-10-18), and needs none (hostsn7u7x3woz.eu-central-1.aws.clickhouse.cloud, port 8443, userdemo, empty password, databaseapi). Seereferences/auth.md; docs: https://docs.koinju.io/free-demo-database - Public REST (no auth — market / product / instrument discovery):
curl -s 'https://api.koinju.io/market/spot' | jq '[.[] | select(.base == "BTC")]'. Seereferences/rest.md. - MCP server :
claude mcp add --transport http koinju https://mcp.koinju.io/mcp, then/mcpto sign in with the Koinju account (no API key in the config), gives nine read-only tools. Seven sit over the REST endpoints —get_ohlcv,get_trades,get_funding_rate,get_volatility_index,get_option_chain,get_option_smile,get_option_matrix— spending the account's own API key and REST quota.find_marketsreads the public market lists with no key, so it spends no quota: call it first, it returns the exactexchangeandmarket_symbolthe data tools want.run_sqlruns one ClickHouse statement with the account's own SQL login, so the same tables, time limit and daily quota as direct SQL; an answer over 100,000 characters is refused, not cut. Bulk history belongs in SQL. Docs: https://docs.koinju.io/mcp-server - Migration: legacy
KOINJU_HOST/KOINJU_USER/KOINJU_PASSWORD→ currentKOINJU_DB_HOST/KOINJU_DB_USER/KOINJU_DB_PASSWORD(andKOINJU_API_KEYis new). See Migration below for the one-liner.
Workflow
-
Capture intent. Identify the data class the user needs:
- candles / OHLCV / historical price →
api.ohlcv(parameterized),api.ohlcv_1m,api.ohlcv_1h(no_1dview) - tick trades →
api.trade - funding rates (perpetual) →
api.funding_rate(time column istimestamp, notfunding_timestamp) - option chain / Greeks / IV / smile / DVOL → all via
api.option_chains(plural; there's noapi.option_smileorapi.volatility_index) - exchange or market coverage →
api.market_spot/_future/_option(or REST/market/*)
Before writing any SQL against a table you haven't queried this session, run
bash ~/.claude/skills/koinju/scripts/probe-schema.sh [table]to verify columns. The bundled refs drift; the live schema is the source of truth — but mind the lens:probe-schema.shusesDESCRIBE, which returns empty for parameterized views likeapi.ohlcv. An empty or error probe means "parameterized view", not "table is gone." Confirm withSHOW CREATE TABLE api.ohlcv, aDESCRIBE (SELECT * FROM api.ohlcv(candle_duration_in_minutes = 1440) LIMIT 0), or just run the SELECT. (The bundledprobe-schema.shalready does theSHOW CREATEfallback and prints the{param:Type}signature for you.) - candles / OHLCV / historical price →
-
Choose interface.
- Public REST
/market/*— always use this for any market / product / instrument discovery question ("what BTC pairs / futures / options exist?", "which exchanges list X?", "list all spot pairs"). No auth, no Python deps, justcurl+jq. Don't fall back to SQL for plain listings. Seereferences/rest.md. - Authenticated REST (
/ohlcv,/trade,/funding-rate,/volatility-index,/stats) — small data pulls, simple HTTP, supports free tier; needsx-api-key. - ClickHouse SQL via
clickhouse-connect(Python),clickhouse-rs(Rust),clickhouse-go(Go), or BI tools — heavy analytics, joins, custom aggregations, parameterized candle durations; needs host + username + password.
- Public REST
-
Auth check. The bundled scripts and
load_koinju_credentials()auto-source.koinju.env(project-local, in cwd) then~/.koinju.env(global) — project-local wins per-var; existing env vars still win over both. A user running scripts from insidekoinju-demo/(with a populated project.koinju.env) gets their credentials picked up automatically. When writing ad-hoc Python, copy the_autosource_koinju_env()helper fromreferences/auth.md. From a shell, source both explicitly:[ -f .koinju.env ] && source .koinju.env [ -f ~/.koinju.env ] && source ~/.koinju.env : "${KOINJU_API_KEY:?}" "${KOINJU_DB_HOST:?}" "${KOINJU_DB_USER:?}" "${KOINJU_DB_PASSWORD:?}"KOINJU_DB_PORT(default8443) andKOINJU_DB_DATABASE(defaultapi) are optional.If any required var is missing: the cleanest response is to propose the Project setup & dependency bootstrap flow below — it scaffolds the project, creates a
.koinju.env(project-local, auto-loaded by the scripts), and walks through getting credentials in one motion (and bundles dep install too, in caseclickhouse_connectis also missing). No credentials, and a task that one day of data answers? Use the free demo database: seereferences/auth.md. For the credential-acquisition steps alone: Don't yet have them? Pick a plan at https://koinju.io/pricing — after sign-up Koinju emails you a link to https://dataroom.koinju.io/ where the REST key and ClickHouse host / user / password live. Already signed up but no email / can't access the dataroom? Fall back to support@koinju.io. Then have themexportthe variables in their shell profile (or a sourced~/.koinju.envwithchmod 600). Seereferences/auth.mdfor full details. -
Write the query. Reach for the right reference:
- Market / product / instrument discovery ("what BTC pairs exist?", "which options are listed?") → public
/market/*endpoints inreferences/rest.md. No auth, no SQL. Never reach forapi.spot_markets/api.future_markets/api.option_marketsfor a plain listing. references/data-tables.md— table schemas, latest-value patterns (analytics, not discovery)references/optimization.md— query perf for trade / year-long ohlcvreferences/backtesting.md— strategy vs buy-and-hold workflowreferences/plotting.md— option smile, vol surface, candlestick, DVOL, equity curvereferences/option_iv_greeks.md— recompute Deribit option IV + Greeks (Black-76 on the forward) from premiums; verified againstmark_iv/ chain Greeks; deep history via thederibit-option/deribit-futuretrade tapesreferences/integrations.md— Postgres / ClickHouse / Redis plug-in patternsreferences/rest.md— REST endpoints (discovery + authed quick lookups). Autogenerated endpoint catalog at the bottom is the canonical reference for paths / params / return shapes.references/recipes/— 11 CI-validated cookbook recipes (Bollinger, Sortino, max drawdown, mean-reversion z-score, historical volatility, DCA vs lump-sum, perp funding, spot/perp spreads, cross-exchange arbitrage, OHLCV streaming, correlation). Reach here before reinventing a metric — each pairs the Python implementation with the SQL equivalent and a parity test.
- Market / product / instrument discovery ("what BTC pairs exist?", "which options are listed?") → public
-
Execute & verify. Run the query, validate the result shape, return to user.
Default rendering: markdown tables. When the result fits on screen (roughly ≤ 50 rows × ≤ 8 columns, no cell wider than ~40 chars), render it as a markdown table in your response — Claude Code renders these natively and they're the most scannable format. For DataFrames:
print(df.to_markdown(index=False))(needstabulate— bundled in the project-setup deps). For REST /jqoutput: wrap in pandas first, or align text columns withcolumn -t -s$'\t'. For single scalars ("current BTC volatility → 47.3%"), state the value in prose with context, not a 1×1 table.Too large for a table: don't dump. Show head/tail with a
... (N more rows)indicator, summarize with counts/aggregations, or save the full result to a file (df.to_csv("out.csv"),df.to_parquet("out.parquet")) and tell the user the path.After the first successful run in a project, run
bash ~/.claude/skills/koinju/scripts/probe-env.shand check the trailing token. If it ends insuggest_save_global:yes(project.koinju.envpopulated and working, no~/.koinju.env), propose:"Your project
.koinju.envworks. Want me to copy it to~/.koinju.envso future Claude sessions in other projects pick up the same credentials automatically?"On yes:
cp .koinju.env ~/.koinju.env && chmod 600 ~/.koinju.env. On no: drop it; don't ask again in the same session. The bundled helpers auto-source both files (project wins per-var), so the global copy doesn't conflict with future per-project overrides.
Project setup & dependency bootstrap
Default: run bash ~/.claude/skills/koinju/scripts/setup.sh [target-dir]. It probes cwd (empty → in-place, else ./koinju-demo/), probes uv, runs uv init (or python3 -m venv fallback), installs clickhouse-connect pandas plotly tabulate, seeds main.py from the welcome script, creates .koinju.env from the bundled template (chmod 600), appends to .gitignore, prints the credential URL and run command. Idempotent.
Two triggers, same script:
-
Proactive — user asks "set up a python project for koinju", "scaffold a koinju starter", "create a project to call the API", etc. Just run
setup.sh; this IS the proposal. -
Reactive — a SQL task fails with
ModuleNotFoundErrorand/orKOINJU_*env vars are unset. Stop. Do NOTpip installin the current shell. Do NOT hunt for an alternative Python (/usr/bin/python3,python3.10, ...) — that "works" by accident and confuses the user about which env runs their code. Don't fix one blocker and leave the other.- Probe with
bash ~/.claude/skills/koinju/scripts/probe-env.sh— one line tells you uv / venv / deps / creds / env-file state. - Propose: "[Deps / credentials / both] aren't set up — I can scaffold a clean uv project at
./koinju-demo/that handles it: installs deps, creates a.koinju.env(auto-loaded by the scripts), points you at koinju.io/pricing for credentials. OK?" - If accepted →
setup.sh. If declined → print the code you would have run as a fenced block plus akoinju.io/pricingpointer if creds were the missing piece.
- Probe with
For manual bootstrap (no script access, custom requirements, debugging), see references/bootstrap.md — full templates, variations (existing project, plotting starter), and the don'ts.
Migration: legacy env-var names
A project using KOINJU_HOST / KOINJU_USER / KOINJU_PASSWORD (and no KOINJU_API_KEY) is on the old naming. Current names:
| Legacy | Current |
|---|---|
KOINJU_HOST |
KOINJU_DB_HOST |
KOINJU_USER |
KOINJU_DB_USER |
KOINJU_PASSWORD |
KOINJU_DB_PASSWORD |
| (none) | KOINJU_API_KEY (new — required by REST endpoints and the unified load_koinju_credentials() helper) |
Also: rename the file from .env / .env.example to .koinju.env (project-local) or ~/.koinju.env (global), then chmod 600. The bundled scripts and _autosource_koinju_env() only look at .koinju.env — they don't auto-source .env.
One-liner to migrate an existing .env:
sed \
-e 's/^export KOINJU_HOST=/export KOINJU_DB_HOST=/' \
-e 's/^export KOINJU_USER=/export KOINJU_DB_USER=/' \
-e 's/^export KOINJU_PASSWORD=/export KOINJU_DB_PASSWORD=/' \
.env > .koinju.env \
&& rm .env \
&& chmod 600 .koinju.env \
&& { grep -qxF '.koinju.env' .gitignore 2>/dev/null || echo '.koinju.env' >> .gitignore; }
(Stream-rewrite form rather than sed -i — portable across GNU and BSD sed without the -i '' macOS quirk.)
Then have the user add export KOINJU_API_KEY=... to .koinju.env (grab the REST key from dataroom.koinju.io).
Format reminder for KOINJU_DB_HOST: bare hostname only (e.g. abc123.koinju.io). Strip any https:// scheme, trailing :8443 port, or trailing / if the user copy/pasted the full dataroom URL — clickhouse-connect adds the scheme and port itself, and port is set via KOINJU_DB_PORT (default 8443).
Bundled resources
references/auth.md— credential setup (KOINJU_*env vars, dataroom URL, support email, Python helper)references/data-tables.md— gotchas (Decimal, snapshot cadence,mark_ivin percent), per-table notes (api.ohlcv,api.trade,api.funding_rate,api.option_chains,api.market_*), and an autogenerated full-schema reference appendix regenerated from liveDESCRIBEreferences/optimization.md— query optimization rules for koinju tables + a worked LINK-USDT examplereferences/backtesting.md— strategy vs buy-and-hold workflow, metrics, common pitfallsreferences/plotting.md— Plotly recipes for option smile, vol surface, candlestick, DVOL, equity curvesreferences/option_iv_greeks.md— recompute Deribit option IV + Greeks with Black-76 on the forward (underlying_price, not spot); one-query SQL solver (erf+arrayFold) verified against the chain; deep history from thederibit-option/deribit-futuretrade tapesreferences/integrations.md— Postgres / ClickHouse (remoteSecure(), ETL) / Redis caching patternsreferences/rest.md— discovery rule, BTC-productjqcookbook, per-tier rate limits, Python example, REST-vs-SQL decision — and an autogenerated endpoint catalog regenerated fromapi/market-data.yamlreferences/recipes/— 11 CI-validated cookbook articles (Bollinger, Sortino, max drawdown, mean-reversion z-score, historical vol, DCA vs lump-sum, perp funding, spot/perp spreads, cross-exchange arbitrage, OHLCV streaming, correlation), each with a Python implementation, SQL equivalent, and parity test. Synced fromapi/python_vs_sql/.references/bootstrap.md— fallback whenclickhouse_connectis missing: propose a uv project (or print the code if declined); explicit "don't pip install / don't hunt alternative Pythons" guidancereferences/koinju.env.example— credential template (the bootstrapcps this to.koinju.envand chmod 600s it)scripts/setup.sh— one-shot bootstrap: cwd-probe, uv-or-venv, install deps, seedmain.py+.koinju.env+.gitignore. Pass target dir as$1. Idempotent.scripts/probe-env.sh— one-line state probe (uv:ok pyproject:found venv:active deps:ok creds:ok ...). Single tool call instead of multiplecommand -v/python -c import/[ -n $VAR ]invocations.scripts/probe-schema.sh— dumps liveapi.*tables + columns over the ClickHouse HTTPS interface. Run before writing SQL against an unfamiliar table; live schema is the source of truth, not the bundled refs.scripts/welcome_btc_usdt.py— runnable demo: 7d of BTC-USDT 1h candles via ClickHouse, Plotly candlestick (used as the seedmain.pybysetup.sh)scripts/plot_option_smile.py— runnable: BTC option smile across two exchanges at the nearest expirationscripts/backtest_buy_and_hold.py— runnable: SMA(20/50) vs buy-and-hold on any market, reports total return / Sharpe / max drawdown
Deeper SQL recipes ship inside the skill at references/recipes/. The corresponding GitBook pages live at https://docs.koinju.io/sql-cookbook/.
Source of truth: https://docs.koinju.io. Always prefer the live docs if there's a conflict with bundled references.
04 同仓库更多 Skills
troves
Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.
trade
Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".
staking
Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.
send
Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".
portfolio
View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".
multi-swap
Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.