desic-okx-agent 0.1.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/LICENSE +21 -0
- package/README.md +242 -0
- package/dist/account/private-websocket.d.ts +13 -0
- package/dist/account/private-websocket.js +102 -0
- package/dist/account/private-websocket.js.map +1 -0
- package/dist/account/service.d.ts +22 -0
- package/dist/account/service.js +118 -0
- package/dist/account/service.js.map +1 -0
- package/dist/account/store.d.ts +12 -0
- package/dist/account/store.js +48 -0
- package/dist/account/store.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +122 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/prompts.d.ts +2 -0
- package/dist/cli/prompts.js +52 -0
- package/dist/cli/prompts.js.map +1 -0
- package/dist/config/loader.d.ts +9 -0
- package/dist/config/loader.js +87 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/paths.d.ts +7 -0
- package/dist/config/paths.js +11 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/schema.d.ts +42 -0
- package/dist/config/schema.js +30 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/attribution.d.ts +2 -0
- package/dist/core/attribution.js +29 -0
- package/dist/core/attribution.js.map +1 -0
- package/dist/core/errors.d.ts +9 -0
- package/dist/core/errors.js +33 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/okx-client.d.ts +13 -0
- package/dist/core/okx-client.js +102 -0
- package/dist/core/okx-client.js.map +1 -0
- package/dist/core/sanitize.d.ts +2 -0
- package/dist/core/sanitize.js +19 -0
- package/dist/core/sanitize.js.map +1 -0
- package/dist/core/types.d.ts +38 -0
- package/dist/core/types.js +18 -0
- package/dist/core/types.js.map +1 -0
- package/dist/derivatives/service.d.ts +28 -0
- package/dist/derivatives/service.js +144 -0
- package/dist/derivatives/service.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/intelligence/service.d.ts +38 -0
- package/dist/intelligence/service.js +324 -0
- package/dist/intelligence/service.js.map +1 -0
- package/dist/market/indicators.d.ts +2 -0
- package/dist/market/indicators.js +74 -0
- package/dist/market/indicators.js.map +1 -0
- package/dist/market/service.d.ts +28 -0
- package/dist/market/service.js +232 -0
- package/dist/market/service.js.map +1 -0
- package/dist/market/store.d.ts +46 -0
- package/dist/market/store.js +158 -0
- package/dist/market/store.js.map +1 -0
- package/dist/market/websocket.d.ts +33 -0
- package/dist/market/websocket.js +213 -0
- package/dist/market/websocket.js.map +1 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +28 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/runtime/client.d.ts +15 -0
- package/dist/runtime/client.js +106 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/server.d.ts +28 -0
- package/dist/runtime/server.js +140 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/runtime/state.d.ts +14 -0
- package/dist/runtime/state.js +98 -0
- package/dist/runtime/state.js.map +1 -0
- package/dist/storage/database.d.ts +23 -0
- package/dist/storage/database.js +106 -0
- package/dist/storage/database.js.map +1 -0
- package/dist/tools/catalog.d.ts +21 -0
- package/dist/tools/catalog.js +236 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/trade/service.d.ts +128 -0
- package/dist/trade/service.js +470 -0
- package/dist/trade/service.js.map +1 -0
- package/examples/claude-code/mcp.json +8 -0
- package/examples/codex/config.toml +3 -0
- package/examples/config.example.json +18 -0
- package/package.json +71 -0
- package/skills/okx-account-analysis/SKILL.md +14 -0
- package/skills/okx-account-analysis/agents/openai.yaml +9 -0
- package/skills/okx-derivatives-analysis/SKILL.md +14 -0
- package/skills/okx-derivatives-analysis/agents/openai.yaml +9 -0
- package/skills/okx-market-analysis/SKILL.md +14 -0
- package/skills/okx-market-analysis/agents/openai.yaml +9 -0
- package/skills/okx-news-intelligence/SKILL.md +14 -0
- package/skills/okx-news-intelligence/agents/openai.yaml +9 -0
- package/skills/okx-smart-money-analysis/SKILL.md +15 -0
- package/skills/okx-smart-money-analysis/agents/openai.yaml +9 -0
- package/skills/okx-trading/SKILL.md +16 -0
- package/skills/okx-trading/agents/openai.yaml +9 -0
- package/skills/trading-philosophy/SKILL.md +14 -0
- package/skills/trading-philosophy/agents/openai.yaml +4 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"accounts": {},
|
|
3
|
+
"market": {
|
|
4
|
+
"prewarm": ["BTC-USDT-SWAP", "ETH-USDT-SWAP"],
|
|
5
|
+
"bars": ["1m", "5m", "15m", "1H", "4H", "1D"],
|
|
6
|
+
"idleSubscriptionMs": 900000,
|
|
7
|
+
"maxSnapshotSkewMs": 1000,
|
|
8
|
+
"orderBookDepth": 50,
|
|
9
|
+
"recentTradeLimit": 1000
|
|
10
|
+
},
|
|
11
|
+
"proxy": {},
|
|
12
|
+
"intelligence": {
|
|
13
|
+
"newsPollSeconds": 120,
|
|
14
|
+
"sentimentPollMinutes": 15,
|
|
15
|
+
"smartMoneyPollMinutes": 15,
|
|
16
|
+
"retentionDays": 30
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "desic-okx-agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Independent Desic runtime, MCP server, CLI, and agent skills for OKX",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/xiazhi88/desic-okx-agent.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/xiazhi88/desic-okx-agent#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/xiazhi88/desic-okx-agent/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"okx",
|
|
17
|
+
"mcp",
|
|
18
|
+
"codex",
|
|
19
|
+
"claude-code",
|
|
20
|
+
"trading",
|
|
21
|
+
"market-data"
|
|
22
|
+
],
|
|
23
|
+
"bin": {
|
|
24
|
+
"desic-okx": "dist/cli/index.js"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"skills",
|
|
32
|
+
"examples",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=22.12.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.build.json",
|
|
41
|
+
"dev": "tsx src/cli/index.ts",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:demo": "node scripts/run-demo-e2e.mjs",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"validate:skills": "node scripts/validate-skills.mjs",
|
|
47
|
+
"scan:sensitive": "node scripts/scan-sensitive.mjs",
|
|
48
|
+
"test:mcp": "node scripts/mcp-smoke.mjs",
|
|
49
|
+
"check": "npm run typecheck && npm run test && npm run validate:skills && npm run scan:sensitive && npm run build && npm run test:mcp",
|
|
50
|
+
"prepack": "npm run check"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
54
|
+
"better-sqlite3": "^13.0.2",
|
|
55
|
+
"commander": "^15.0.0",
|
|
56
|
+
"crc-32": "^1.2.2",
|
|
57
|
+
"env-paths": "^4.0.0",
|
|
58
|
+
"https-proxy-agent": "^7.0.6",
|
|
59
|
+
"undici": "^7.16.0",
|
|
60
|
+
"ws": "^8.21.1",
|
|
61
|
+
"zod": "^4.4.3"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
65
|
+
"@types/node": "^22.19.15",
|
|
66
|
+
"@types/ws": "^8.18.1",
|
|
67
|
+
"tsx": "^4.21.0",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"vitest": "^3.2.4"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: okx-account-analysis
|
|
3
|
+
description: Inspect configured OKX account balances, positions, pending orders, order history, fills, bills, account settings, and generic risk. Use for account-state, exposure, reconciliation, or risk-summary questions without changing exchange state.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OKX Account Analysis
|
|
7
|
+
|
|
8
|
+
1. Select the requested account alias; use the configured default only when no account was specified.
|
|
9
|
+
2. Start with `account_get_snapshot` for current state, then use history, fills, or bills for reconciliation.
|
|
10
|
+
3. Report environment and account alias with every conclusion.
|
|
11
|
+
4. Distinguish equity, available balance, margin, notional exposure, realized results, and pending orders.
|
|
12
|
+
5. Treat empty data as an observed empty result only when no warning or upstream error is present.
|
|
13
|
+
6. Never request, print, infer, or return API credentials.
|
|
14
|
+
7. Do not call any `trade_*` tool while using this read-only analysis workflow.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "OKX Account Analysis"
|
|
3
|
+
short_description: "Inspect balances, positions, orders, fills, and account risk."
|
|
4
|
+
default_prompt: "Use $okx-account-analysis to summarize the selected OKX account safely."
|
|
5
|
+
dependencies:
|
|
6
|
+
tools:
|
|
7
|
+
- type: "mcp"
|
|
8
|
+
value: "desic-okx"
|
|
9
|
+
description: "Desic OKX Agent MCP server"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: okx-derivatives-analysis
|
|
3
|
+
description: Analyze OKX open interest, taker flow, funding and basis, liquidations, crowding, position changes, consensus, and system stress. Use for perpetual-market positioning and derivatives-risk questions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OKX Derivatives Analysis
|
|
7
|
+
|
|
8
|
+
1. Start with `derivatives_get_decision_snapshot` for a broad view, then call focused tools for evidence that needs more history.
|
|
9
|
+
2. State instrument, period, sample size, timestamps, and data limitations.
|
|
10
|
+
3. Distinguish account long-short ratio, top-trader account ratio, and top-trader position ratio; they measure different populations and quantities.
|
|
11
|
+
4. Interpret open-interest changes together with price and taker flow. Do not assign direction from open interest alone.
|
|
12
|
+
5. Interpret funding as positioning cost, not a standalone reversal signal.
|
|
13
|
+
6. Treat liquidation samples and system-stress data as incomplete observations unless coverage is explicit.
|
|
14
|
+
7. Present supporting evidence, contradictory evidence, likely interpretation, and invalidation conditions.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "OKX Derivatives Analysis"
|
|
3
|
+
short_description: "Analyze positioning, funding, flow, and crowding evidence."
|
|
4
|
+
default_prompt: "Use $okx-derivatives-analysis to assess derivatives positioning for BTC-USDT-SWAP."
|
|
5
|
+
dependencies:
|
|
6
|
+
tools:
|
|
7
|
+
- type: "mcp"
|
|
8
|
+
value: "desic-okx"
|
|
9
|
+
description: "Desic OKX Agent MCP server"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: okx-market-analysis
|
|
3
|
+
description: Analyze live OKX ticker, order book, trades, candles, funding, open interest, indicators, and time-aligned decision snapshots. Use for current market structure, liquidity, momentum, volatility, or watchlist analysis on OKX.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OKX Market Analysis
|
|
7
|
+
|
|
8
|
+
1. Call `market_get_decision_snapshot` before combining multiple live market facts.
|
|
9
|
+
2. Check `consistent`, `maxTimeSkewMs`, component timestamps, and warnings. State that the snapshot is stale or inconsistent when applicable.
|
|
10
|
+
3. Use `market_get_instrument` before interpreting size, tick, lot, or contract value.
|
|
11
|
+
4. Use focused tools only when additional depth is needed: candles and indicators for trend, order book for current liquidity, recent trades for aggressive flow.
|
|
12
|
+
5. Separate closed candles from the active candle. Do not describe an active candle as final.
|
|
13
|
+
6. Report observed facts first, then interpretations, invalidation evidence, and limitations.
|
|
14
|
+
7. Never treat one indicator, one order-book snapshot, or one large trade as a sufficient trading signal.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "OKX Market Analysis"
|
|
3
|
+
short_description: "Analyze live OKX market structure and aligned snapshots."
|
|
4
|
+
default_prompt: "Use $okx-market-analysis to analyze BTC-USDT-SWAP market structure."
|
|
5
|
+
dependencies:
|
|
6
|
+
tools:
|
|
7
|
+
- type: "mcp"
|
|
8
|
+
value: "desic-okx"
|
|
9
|
+
description: "Desic OKX Agent MCP server"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: okx-news-intelligence
|
|
3
|
+
description: Research OKX news, sources, coin sentiment, economic events, clustered events, market reactions, anomalies, and daily briefings. Use for time-sensitive crypto news or event-impact analysis with a configured live read-only OKX account.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OKX News Intelligence
|
|
7
|
+
|
|
8
|
+
1. Use `news_search` for a targeted question and `news_list` for current coverage.
|
|
9
|
+
2. Read details when a headline is material; record source, publication time, language, and freshness.
|
|
10
|
+
3. Use sentiment trends and rankings as aggregated observations, not as factual confirmation of an event.
|
|
11
|
+
4. Use clustered events to consolidate repeated coverage. Preserve whether evidence comes from one or several independent sources.
|
|
12
|
+
5. Use `news_read_market_reaction` only to describe observed movement around an event; do not claim causality without stronger evidence.
|
|
13
|
+
6. Surface `CAPABILITY_UNAVAILABLE`, local-history fallbacks, and other warnings because the upstream intelligence interfaces are experimental.
|
|
14
|
+
7. Never convert a headline directly into a trade. Require market and derivatives confirmation plus explicit risk and invalidation.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "OKX News Intelligence"
|
|
3
|
+
short_description: "Research OKX news, sentiment, events, and market reactions."
|
|
4
|
+
default_prompt: "Use $okx-news-intelligence to build an evidence-based crypto news briefing."
|
|
5
|
+
dependencies:
|
|
6
|
+
tools:
|
|
7
|
+
- type: "mcp"
|
|
8
|
+
value: "desic-okx"
|
|
9
|
+
description: "Desic OKX Agent MCP server"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: okx-smart-money-analysis
|
|
3
|
+
description: Analyze OKX public trader rankings, performance, positions, histories, and Smart Money signal trends. Use to compare trader cohorts or investigate positioning with a configured live read-only OKX account.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OKX Smart Money Analysis
|
|
7
|
+
|
|
8
|
+
1. Define the period, sort field, filters, and sample size before comparing traders.
|
|
9
|
+
2. Use performance to shortlist; inspect current positions and history before interpreting behavior.
|
|
10
|
+
3. Separate current positions, closed-position history, public order history, signal overview, and signal trend.
|
|
11
|
+
4. Check whether results were refreshed remotely or returned from local history, and report limitations.
|
|
12
|
+
5. Surface `CAPABILITY_UNAVAILABLE` and compatibility warnings because the upstream interfaces are experimental.
|
|
13
|
+
6. Compare several traders or a defined cohort. Do not generalize from one account.
|
|
14
|
+
7. Look for disagreement between performance, current exposure, derivatives flow, and price action.
|
|
15
|
+
8. Do not blindly copy positions or imply that past ranking predicts future returns.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "OKX Smart Money Analysis"
|
|
3
|
+
short_description: "Analyze public trader performance, positions, and signal trends."
|
|
4
|
+
default_prompt: "Use $okx-smart-money-analysis to compare Smart Money signals without blindly following them."
|
|
5
|
+
dependencies:
|
|
6
|
+
tools:
|
|
7
|
+
- type: "mcp"
|
|
8
|
+
value: "desic-okx"
|
|
9
|
+
description: "Desic OKX Agent MCP server"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: okx-trading
|
|
3
|
+
description: Precheck and execute direct OKX leverage, ordinary-order, algo-order, amend, cancel, and position-close operations. Use when the user explicitly requests an OKX trading action and has configured an API key with the required official permission.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OKX Trading
|
|
7
|
+
|
|
8
|
+
1. Identify the account alias, environment, instrument, side, margin mode, position side, order type, price, and size from the user's request. Do not invent missing trading intent.
|
|
9
|
+
2. Call `market_get_instrument`; treat `size` as contracts for derivatives and respect `lotSz`, `minSz`, and `tickSz`.
|
|
10
|
+
3. Call `market_get_decision_snapshot`. Do not proceed when `consistent` is false.
|
|
11
|
+
4. Call `trade_evaluate_plan`, then `trade_precheck_order` for ordinary orders or `trade_precheck_algo_order` for strategy orders. Resolve every blocker before submitting.
|
|
12
|
+
5. Create a stable, unique `executionKey` for each intended mutation. Reuse it only when retrying the exact same intent.
|
|
13
|
+
6. Call the narrowest write tool that matches the request. Do not substitute batch cancellation or full position closure for a narrower action.
|
|
14
|
+
7. If a result is `AMBIGUOUS_WRITE`, inspect remote order state. Never retry with a new execution key until the original outcome is resolved.
|
|
15
|
+
8. Report the exchange environment, returned order identifiers, status, reconciliation state, and any warnings.
|
|
16
|
+
9. Never use or propose withdrawal, transfer, deposit, or API-key-management operations.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "OKX Trading"
|
|
3
|
+
short_description: "Precheck and execute direct OKX orders with explicit parameters."
|
|
4
|
+
default_prompt: "Use $okx-trading to precheck and submit the requested OKX order."
|
|
5
|
+
dependencies:
|
|
6
|
+
tools:
|
|
7
|
+
- type: "mcp"
|
|
8
|
+
value: "desic-okx"
|
|
9
|
+
description: "Desic OKX Agent MCP server"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trading-philosophy
|
|
3
|
+
description: Apply evidence-first, probabilistic, risk-aware reasoning to trading theses and post-trade reviews. Use when forming, challenging, explaining, or reviewing a market view, setup, decision, or outcome.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Trading Philosophy
|
|
7
|
+
|
|
8
|
+
1. Separate observed facts, interpretations, assumptions, and unknowns.
|
|
9
|
+
2. Express a thesis as a conditional scenario rather than certainty.
|
|
10
|
+
3. State invalidation conditions before discussing entry or expected return.
|
|
11
|
+
4. Seek contradictory evidence and plausible alternative explanations.
|
|
12
|
+
5. Evaluate liquidity, sizing, loss at invalidation, execution risk, and data freshness.
|
|
13
|
+
6. Do not promote a single indicator, headline, trader, funding rate, or order-book imbalance into a complete thesis.
|
|
14
|
+
7. After an outcome, evaluate decision quality, execution quality, and randomness separately.
|