desic-okx-agent 0.2.0 → 0.3.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.
Files changed (237) hide show
  1. package/README.en.md +353 -0
  2. package/README.md +194 -190
  3. package/dist/account/private-websocket.js +4 -4
  4. package/dist/account/private-websocket.js.map +1 -1
  5. package/dist/account/service.d.ts +12 -1
  6. package/dist/account/service.js +18 -0
  7. package/dist/account/service.js.map +1 -1
  8. package/dist/bars/rate-limiter.d.ts +18 -0
  9. package/dist/bars/rate-limiter.js +84 -0
  10. package/dist/bars/rate-limiter.js.map +1 -0
  11. package/dist/bars/schema.d.ts +36 -0
  12. package/dist/bars/schema.js +134 -0
  13. package/dist/bars/schema.js.map +1 -0
  14. package/dist/bars/service.d.ts +60 -0
  15. package/dist/bars/service.js +120 -0
  16. package/dist/bars/service.js.map +1 -0
  17. package/dist/bars/store.d.ts +105 -0
  18. package/dist/bars/store.js +415 -0
  19. package/dist/bars/store.js.map +1 -0
  20. package/dist/bars/timeframe.d.ts +40 -0
  21. package/dist/bars/timeframe.js +146 -0
  22. package/dist/bars/timeframe.js.map +1 -0
  23. package/dist/bars/types.d.ts +68 -0
  24. package/dist/bars/types.js +13 -0
  25. package/dist/bars/types.js.map +1 -0
  26. package/dist/cli/data-render.d.ts +37 -0
  27. package/dist/cli/data-render.js +143 -0
  28. package/dist/cli/data-render.js.map +1 -0
  29. package/dist/cli/doctor.js +7 -3
  30. package/dist/cli/doctor.js.map +1 -1
  31. package/dist/cli/index.js +758 -27
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/cli/live-render.d.ts +24 -0
  34. package/dist/cli/live-render.js +85 -0
  35. package/dist/cli/live-render.js.map +1 -0
  36. package/dist/cli/range.d.ts +28 -0
  37. package/dist/cli/range.js +63 -0
  38. package/dist/cli/range.js.map +1 -0
  39. package/dist/cli/render.js +3 -0
  40. package/dist/cli/render.js.map +1 -1
  41. package/dist/cli/strategy-render.d.ts +36 -0
  42. package/dist/cli/strategy-render.js +391 -0
  43. package/dist/cli/strategy-render.js.map +1 -0
  44. package/dist/cli/width.d.ts +18 -0
  45. package/dist/cli/width.js +71 -0
  46. package/dist/cli/width.js.map +1 -0
  47. package/dist/config/loader.js +1 -1
  48. package/dist/config/schema.d.ts +7 -0
  49. package/dist/config/schema.js +24 -0
  50. package/dist/config/schema.js.map +1 -1
  51. package/dist/core/okx-client.d.ts +9 -1
  52. package/dist/core/okx-client.js +14 -5
  53. package/dist/core/okx-client.js.map +1 -1
  54. package/dist/i18n/locale.d.ts +24 -0
  55. package/dist/i18n/locale.js +65 -0
  56. package/dist/i18n/locale.js.map +1 -0
  57. package/dist/i18n/messages.d.ts +333 -0
  58. package/dist/i18n/messages.js +660 -0
  59. package/dist/i18n/messages.js.map +1 -0
  60. package/dist/live/account-snapshot.d.ts +30 -0
  61. package/dist/live/account-snapshot.js +130 -0
  62. package/dist/live/account-snapshot.js.map +1 -0
  63. package/dist/live/cutoff-queue.d.ts +42 -0
  64. package/dist/live/cutoff-queue.js +69 -0
  65. package/dist/live/cutoff-queue.js.map +1 -0
  66. package/dist/live/execution-key.d.ts +23 -0
  67. package/dist/live/execution-key.js +31 -0
  68. package/dist/live/execution-key.js.map +1 -0
  69. package/dist/live/failures.d.ts +37 -0
  70. package/dist/live/failures.js +57 -0
  71. package/dist/live/failures.js.map +1 -0
  72. package/dist/live/gates.d.ts +65 -0
  73. package/dist/live/gates.js +136 -0
  74. package/dist/live/gates.js.map +1 -0
  75. package/dist/live/loop.d.ts +56 -0
  76. package/dist/live/loop.js +197 -0
  77. package/dist/live/loop.js.map +1 -0
  78. package/dist/live/preconditions.d.ts +48 -0
  79. package/dist/live/preconditions.js +69 -0
  80. package/dist/live/preconditions.js.map +1 -0
  81. package/dist/live/reconcile.d.ts +46 -0
  82. package/dist/live/reconcile.js +104 -0
  83. package/dist/live/reconcile.js.map +1 -0
  84. package/dist/live/runner.d.ts +57 -0
  85. package/dist/live/runner.js +160 -0
  86. package/dist/live/runner.js.map +1 -0
  87. package/dist/live/schema.d.ts +18 -0
  88. package/dist/live/schema.js +91 -0
  89. package/dist/live/schema.js.map +1 -0
  90. package/dist/live/service.d.ts +144 -0
  91. package/dist/live/service.js +303 -0
  92. package/dist/live/service.js.map +1 -0
  93. package/dist/live/session.d.ts +85 -0
  94. package/dist/live/session.js +234 -0
  95. package/dist/live/session.js.map +1 -0
  96. package/dist/live/sizing.d.ts +62 -0
  97. package/dist/live/sizing.js +79 -0
  98. package/dist/live/sizing.js.map +1 -0
  99. package/dist/live/store.d.ts +123 -0
  100. package/dist/live/store.js +350 -0
  101. package/dist/live/store.js.map +1 -0
  102. package/dist/live/types.d.ts +82 -0
  103. package/dist/live/types.js +2 -0
  104. package/dist/live/types.js.map +1 -0
  105. package/dist/market/websocket.d.ts +16 -1
  106. package/dist/market/websocket.js +60 -5
  107. package/dist/market/websocket.js.map +1 -1
  108. package/dist/mcp/server.d.ts +1 -0
  109. package/dist/mcp/server.js +15 -1
  110. package/dist/mcp/server.js.map +1 -1
  111. package/dist/network/connectivity.d.ts +9 -1
  112. package/dist/network/connectivity.js +28 -1
  113. package/dist/network/connectivity.js.map +1 -1
  114. package/dist/report/chart-script.d.ts +12 -0
  115. package/dist/report/chart-script.js +146 -0
  116. package/dist/report/chart-script.js.map +1 -0
  117. package/dist/report/compare-html.d.ts +8 -0
  118. package/dist/report/compare-html.js +254 -0
  119. package/dist/report/compare-html.js.map +1 -0
  120. package/dist/report/compare-script.d.ts +12 -0
  121. package/dist/report/compare-script.js +109 -0
  122. package/dist/report/compare-script.js.map +1 -0
  123. package/dist/report/compare.d.ts +61 -0
  124. package/dist/report/compare.js +205 -0
  125. package/dist/report/compare.js.map +1 -0
  126. package/dist/report/fetch.d.ts +20 -0
  127. package/dist/report/fetch.js +56 -0
  128. package/dist/report/fetch.js.map +1 -0
  129. package/dist/report/html.d.ts +54 -0
  130. package/dist/report/html.js +641 -0
  131. package/dist/report/html.js.map +1 -0
  132. package/dist/report/open.d.ts +42 -0
  133. package/dist/report/open.js +114 -0
  134. package/dist/report/open.js.map +1 -0
  135. package/dist/runtime/server.d.ts +16 -1
  136. package/dist/runtime/server.js +112 -9
  137. package/dist/runtime/server.js.map +1 -1
  138. package/dist/setup/installer.d.ts +1 -0
  139. package/dist/setup/installer.js +8 -0
  140. package/dist/setup/installer.js.map +1 -1
  141. package/dist/setup/wizard.d.ts +3 -0
  142. package/dist/setup/wizard.js +131 -6
  143. package/dist/setup/wizard.js.map +1 -1
  144. package/dist/strategy/constants.d.ts +23 -0
  145. package/dist/strategy/constants.js +24 -0
  146. package/dist/strategy/constants.js.map +1 -0
  147. package/dist/strategy/environment.d.ts +52 -0
  148. package/dist/strategy/environment.js +187 -0
  149. package/dist/strategy/environment.js.map +1 -0
  150. package/dist/strategy/instrument.d.ts +29 -0
  151. package/dist/strategy/instrument.js +39 -0
  152. package/dist/strategy/instrument.js.map +1 -0
  153. package/dist/strategy/optimize.d.ts +73 -0
  154. package/dist/strategy/optimize.js +113 -0
  155. package/dist/strategy/optimize.js.map +1 -0
  156. package/dist/strategy/parameter-space.d.ts +59 -0
  157. package/dist/strategy/parameter-space.js +221 -0
  158. package/dist/strategy/parameter-space.js.map +1 -0
  159. package/dist/strategy/python-bridge.d.ts +24 -0
  160. package/dist/strategy/python-bridge.js +114 -0
  161. package/dist/strategy/python-bridge.js.map +1 -0
  162. package/dist/strategy/schema.d.ts +9 -0
  163. package/dist/strategy/schema.js +91 -0
  164. package/dist/strategy/schema.js.map +1 -0
  165. package/dist/strategy/service.d.ts +138 -0
  166. package/dist/strategy/service.js +745 -0
  167. package/dist/strategy/service.js.map +1 -0
  168. package/dist/strategy/settings.d.ts +162 -0
  169. package/dist/strategy/settings.js +243 -0
  170. package/dist/strategy/settings.js.map +1 -0
  171. package/dist/strategy/store.d.ts +96 -0
  172. package/dist/strategy/store.js +367 -0
  173. package/dist/strategy/store.js.map +1 -0
  174. package/dist/strategy/templates.d.ts +11 -0
  175. package/dist/strategy/templates.js +134 -0
  176. package/dist/strategy/templates.js.map +1 -0
  177. package/dist/strategy/types.d.ts +111 -0
  178. package/dist/strategy/types.js +2 -0
  179. package/dist/strategy/types.js.map +1 -0
  180. package/dist/tools/catalog.d.ts +16 -0
  181. package/dist/tools/catalog.js +118 -17
  182. package/dist/tools/catalog.js.map +1 -1
  183. package/dist/trade/service.d.ts +12 -0
  184. package/dist/trade/service.js +24 -7
  185. package/dist/trade/service.js.map +1 -1
  186. package/dist/tui/app.d.ts +23 -0
  187. package/dist/tui/app.js +322 -0
  188. package/dist/tui/app.js.map +1 -0
  189. package/dist/tui/commands.d.ts +70 -0
  190. package/dist/tui/commands.js +313 -0
  191. package/dist/tui/commands.js.map +1 -0
  192. package/dist/tui/entries.d.ts +17 -0
  193. package/dist/tui/entries.js +24 -0
  194. package/dist/tui/entries.js.map +1 -0
  195. package/dist/tui/execute.d.ts +26 -0
  196. package/dist/tui/execute.js +664 -0
  197. package/dist/tui/execute.js.map +1 -0
  198. package/dist/tui/history.d.ts +17 -0
  199. package/dist/tui/history.js +48 -0
  200. package/dist/tui/history.js.map +1 -0
  201. package/dist/tui/index.d.ts +8 -0
  202. package/dist/tui/index.js +48 -0
  203. package/dist/tui/index.js.map +1 -0
  204. package/dist/tui/line-editor.d.ts +44 -0
  205. package/dist/tui/line-editor.js +98 -0
  206. package/dist/tui/line-editor.js.map +1 -0
  207. package/dist/tui/progress.d.ts +23 -0
  208. package/dist/tui/progress.js +46 -0
  209. package/dist/tui/progress.js.map +1 -0
  210. package/dist/tui/settings-editor.d.ts +18 -0
  211. package/dist/tui/settings-editor.js +115 -0
  212. package/dist/tui/settings-editor.js.map +1 -0
  213. package/docs/live-trading.md +455 -0
  214. package/docs/strategy-research.md +597 -0
  215. package/package.json +11 -1
  216. package/python/desic_strategy/__init__.py +34 -0
  217. package/python/desic_strategy/actions.py +158 -0
  218. package/python/desic_strategy/context.py +164 -0
  219. package/python/desic_strategy/engine.py +614 -0
  220. package/python/desic_strategy/indicators.py +159 -0
  221. package/python/desic_strategy/live.py +253 -0
  222. package/python/desic_strategy/policy.py +193 -0
  223. package/python/desic_strategy/portfolio.py +152 -0
  224. package/python/desic_strategy/report.py +319 -0
  225. package/python/desic_strategy/runner.py +574 -0
  226. package/python/desic_strategy/timeframe.py +150 -0
  227. package/python/main.py +18 -0
  228. package/skills/okx-live-trading/SKILL.md +117 -0
  229. package/skills/okx-live-trading/agents/openai.yaml +9 -0
  230. package/skills/okx-live-trading/references/lifecycle.md +128 -0
  231. package/skills/okx-strategy-research/SKILL.md +113 -0
  232. package/skills/okx-strategy-research/agents/openai.yaml +9 -0
  233. package/skills/okx-strategy-research/references/execution-semantics.md +107 -0
  234. package/skills/okx-strategy-research/references/field-traps.md +142 -0
  235. package/skills/okx-strategy-research/references/python-api.md +121 -0
  236. package/skills/okx-strategy-research/references/tools-and-data.md +192 -0
  237. package/skills/okx-trading/SKILL.md +11 -10
package/README.en.md ADDED
@@ -0,0 +1,353 @@
1
+ # Desic OKX Agent
2
+
3
+ [简体中文](README.md) | [English](README.en.md)
4
+
5
+ An independent local OKX Runtime, MCP server, CLI, and reusable agent Skills for Codex, Claude Code, and other MCP clients.
6
+
7
+ > [!IMPORTANT]
8
+ > Desic OKX Agent is an independent community project. It is not affiliated with, endorsed by, or an official product of OKX.
9
+
10
+ > [!NOTE]
11
+ > All trading tools in this project support OKX perpetual swaps only (`instId` must end in `-SWAP`). Spot, dated futures, options, and all other instrument types are not supported for trading. Public market data and account inspection are unaffected.
12
+
13
+ ## Installation
14
+
15
+ Requires Node.js 22.12 or newer and network access to OKX, either directly or through an HTTP/HTTPS proxy.
16
+
17
+ First-time installation uses two commands:
18
+
19
+ ```bash
20
+ npm install --global desic-okx-agent
21
+ desic-okx setup
22
+ ```
23
+
24
+ The commands serve different purposes:
25
+
26
+ 1. `npm install` installs the `desic-okx` program.
27
+ 2. `desic-okx setup` connects AI clients, installs Skills, checks the network, and offers to configure an OKX API account.
28
+
29
+ Run `setup` once after the initial installation. Normal upgrades do not require it again. Run it again only to add an AI client, repair configuration, or change proxy settings.
30
+
31
+ Restart the selected AI clients after setup, then verify the installation:
32
+
33
+ ```bash
34
+ desic-okx doctor
35
+ ```
36
+
37
+ ## What setup does
38
+
39
+ The interactive guide:
40
+
41
+ 1. Lets you select Codex, Claude Code, Cursor, VS Code / GitHub Copilot, Cline, or all clients.
42
+ 2. Registers the `desic-okx` MCP server without replacing existing MCP entries.
43
+ 3. Installs all nine bundled Skills for Codex and Claude Code.
44
+ 4. Checks OKX REST and WebSocket connectivity and guides you through testing and saving an HTTP proxy when needed.
45
+ 5. Explains which features require an API key and lets you configure one now or skip it.
46
+ 6. Masks credential input, automatically detects Live or Demo Trading, and saves the account only after successful verification.
47
+
48
+ An API account is optional. Public market and derivatives tools remain available when you skip this step. Configure an account later with:
49
+
50
+ ```bash
51
+ desic-okx account add
52
+ ```
53
+
54
+ For automation, select clients without opening the interactive guide. Non-interactive setup never requests or saves API credentials:
55
+
56
+ ```bash
57
+ desic-okx setup --targets codex --yes
58
+ desic-okx setup --targets codex,claude-code --yes
59
+ desic-okx setup --all --yes
60
+ desic-okx setup --targets codex --yes --skip-network-check
61
+ ```
62
+
63
+ ## Configure an OKX API account
64
+
65
+ Create an API key in the official OKX website or app. Live and Demo Trading accounts use keys for their respective environments. Desic OKX Agent detects the environment through read-only verification, so the user does not select it.
66
+
67
+ Grant only the permissions needed for your use case:
68
+
69
+ | Capability | API key required | Requirement |
70
+ | --- | --- | --- |
71
+ | Public market data, candles, books, derivatives analysis | No | None |
72
+ | Balances, positions, orders, fills, and risk summaries | Yes | Read permission |
73
+ | Remote News and Smart Money | Yes | A `live` account; read permission is sufficient |
74
+ | Perpetual swap place, amend, cancel, close, and leverage operations | Yes | Trade permission on the OKX API key; `*-SWAP` only |
75
+
76
+ This project has no withdrawal, deposit, transfer, asset-movement, or API-key-management tools. Those permissions are not needed. Test trading workflows with an OKX Demo account first, and configure an IP allowlist in OKX according to your security policy.
77
+
78
+ Add an account interactively:
79
+
80
+ ```bash
81
+ desic-okx account add --name demo
82
+ desic-okx account add --name main
83
+ ```
84
+
85
+ API Key, Secret Key, and Passphrase input is hidden. `account add` verifies the credentials with OKX before writing them; failed verification saves nothing. Credentials are stored in `config.json` under the system configuration directory, with Unix permissions set to `0600`:
86
+
87
+ ```bash
88
+ desic-okx config-path
89
+ ```
90
+
91
+ Environment variables can override an account with the same name:
92
+
93
+ ```text
94
+ OKX_ACCOUNT
95
+ OKX_API_KEY
96
+ OKX_API_SECRET
97
+ OKX_API_PASSPHRASE
98
+ ```
99
+
100
+ All three credential variables must be provided together. The Runtime detects the account environment automatically. Trading availability is determined entirely by the permissions assigned to the API key in OKX.
101
+
102
+ ## Ask an AI to install it
103
+
104
+ Paste this prompt into Codex, Claude Code, Cursor, VS Code / GitHub Copilot, or Cline. Replace `codex` with `claude-code`, `cursor`, `vscode`, `cline`, or `all` as appropriate.
105
+
106
+ ```text
107
+ Install Desic OKX Agent for me:
108
+ 1. Confirm Node.js is version 22.12 or newer.
109
+ 2. Run npm install --global desic-okx-agent.
110
+ 3. Run desic-okx setup --targets codex --yes.
111
+ 4. Run desic-okx doctor to verify MCP, Skills, and OKX connectivity.
112
+ 5. Never ask me to send an API Key, Secret, or Passphrase in chat.
113
+ 6. Confirm that public tools are ready. If I need account, News, Smart Money, or trading features, guide me to run desic-okx account add in my own terminal and enter credentials into its hidden prompts.
114
+ ```
115
+
116
+ ## Quick start
117
+
118
+ Public market data does not require an account:
119
+
120
+ ```bash
121
+ desic-okx call market_get_ticker --json '{"instId":"BTC-USDT-SWAP"}'
122
+ desic-okx call market_get_decision_snapshot --json '{"instId":"BTC-USDT-SWAP","bar":"1m"}'
123
+ ```
124
+
125
+ The Runtime starts automatically on the first MCP or CLI call. Running `desic-okx start` manually is normally unnecessary.
126
+
127
+ Useful commands:
128
+
129
+ ```bash
130
+ desic-okx status
131
+ desic-okx doctor
132
+ desic-okx tools
133
+ desic-okx tool market_get_decision_snapshot
134
+ desic-okx account list
135
+ desic-okx update --check
136
+ ```
137
+
138
+ `status` reports Runtime version, uptime, proxy route, WebSocket state, subscriptions and data ages, accounts, and database state. `doctor` actively checks installation, network, SQLite, market data, accounts, MCP clients, and Skills. Both support `--json`.
139
+
140
+ ## Main capabilities
141
+
142
+ - A shared singleton Runtime reused by multiple MCP and CLI clients
143
+ - In-memory ticker, order book, trades, candles, funding, mark price, and open-interest data
144
+ - Time-aligned decision snapshots with freshness, exchange timestamps, and consistency metadata
145
+ - Public market data, indicators, scanning, and public derivatives analysis
146
+ - Account balances, positions, orders, fills, bills, and risk summaries
147
+ - Perpetual-swap-only ordinary orders, algo orders, leverage, amend, cancel, and close-position operations
148
+ - Experimental News and Smart Money capabilities with SQLite history fallback
149
+ - SQLite WAL persistence for closed candles, intelligence history, derived events, and execution records
150
+ - Python strategy research: one-minute history, backtests, parameter tuning, and run comparison
151
+ - Live execution: bind a backtested strategy to an account and act on every closed minute, behind eight risk gates
152
+
153
+ ## One chain, not two products
154
+
155
+ The capabilities above are not a flat list — they are segments of one chain. **Working by hand and
156
+ delegating to an AI follow the same chain:**
157
+
158
+ ```text
159
+ analyze ──→ write a strategy ──→ backtest ──→ tune ──→ create a profile ──→ verify on demo ──→ go live
160
+ market/derivatives Python 70/30 split rank on creating never real orders real
161
+ news/smart money source file validation starts trading money
162
+ (you approve)
163
+ ```
164
+
165
+ The only difference between the two is who presses the keys:
166
+
167
+ | | By hand | Delegated to an AI |
168
+ | --- | --- | --- |
169
+ | Find an idea | `market_*` / `news_*` tools, or the TUI | `okx-market-analysis` and related Skills |
170
+ | Write a strategy | `strategy new`, then edit it | the agent writes the file, `strategy_validate_source` checks it |
171
+ | Backtest and tune | `strategy backtest` / `optimize` / `compare` | the same MCP tools, plus the `okx-strategy-research` Skill |
172
+ | Create a profile | `live create` | `live_create_profile` (requires `agent-access`) |
173
+ | Enable live | `live start` | `live_start`, and the Skill requires **asking you first, with numbers** |
174
+
175
+ By default an agent can only read and stop; creating and enabling are absent from its tool list. To
176
+ let an AI run the whole chain:
177
+
178
+ ```bash
179
+ desic-okx live agent-access on # restart the MCP client to apply
180
+ desic-okx live agent-access # show the current setting
181
+ ```
182
+
183
+ Even then the Skill requires the agent to stop and ask before enabling a live profile — that
184
+ constraint lives in the Skill, not in a system gate. The system can verify whether a profile *can*
185
+ run; it cannot verify whether real money *should* be committed to it.
186
+
187
+ ## Strategy research
188
+
189
+ Write strategies in Python and backtest, tune, and compare them against local
190
+ one-minute history:
191
+
192
+ ```bash
193
+ desic-okx strategy env --setup
194
+ desic-okx data download --inst BTC-USDT-SWAP --days 90
195
+ desic-okx strategy new --out ema.py --template ema-trend
196
+ desic-okx strategy backtest --file ema.py --inst BTC-USDT-SWAP --days 30 --follow
197
+ ```
198
+
199
+ Tuning splits the window 70/30 and ranks candidates on the part they never saw, so
200
+ overfitting is visible rather than buried. Comparison warns when two runs used
201
+ different data, instruments, windows, or costs.
202
+
203
+ Full guide: **[docs/strategy-research.md](docs/strategy-research.md)** (Chinese).
204
+
205
+ ## Live execution
206
+
207
+ Run a validated strategy against a real account, acting on every closed minute:
208
+
209
+ ```bash
210
+ desic-okx live create --file ema.py --inst BTC-USDT-SWAP --account demo \
211
+ --environment demo --entry-budget 100 --side-budget 200 --daily-loss 500
212
+ desic-okx live readiness --id lp_xxxx
213
+ desic-okx live start --id lp_xxxx
214
+ desic-okx live signals --id lp_xxxx
215
+ ```
216
+
217
+ Enabling requires a completed backtest of that exact source on that exact instrument, matched by
218
+ source hash rather than filename, and writes the profile's leverage to the exchange — the entry
219
+ budget is sized against that figure, so a mismatch makes the budget mean something else. Eight risk
220
+ gates refuse rather than adjust, and every refusal is kept — those rows are the evidence risk
221
+ control ran. After a crash, unresolved signals are reconciled against the exchange and never
222
+ resubmitted.
223
+
224
+ **This places real orders.** Full guide: **[docs/live-trading.md](docs/live-trading.md)**
225
+ (Chinese).
226
+
227
+ ## Skills
228
+
229
+ `desic-okx setup` automatically installs these for Codex and Claude Code:
230
+
231
+ - `okx-market-analysis`
232
+ - `okx-derivatives-analysis`
233
+ - `okx-news-intelligence`
234
+ - `okx-smart-money-analysis`
235
+ - `okx-account-analysis`
236
+ - `okx-trading`
237
+ - `okx-strategy-research`
238
+ - `okx-live-trading`
239
+ - `trading-philosophy`
240
+
241
+ Skills are synchronized after upgrades. You can also inspect or synchronize them manually; modified copies are backed up first:
242
+
243
+ ```bash
244
+ desic-okx skills status
245
+ desic-okx skills sync
246
+ desic-okx skills sync --targets codex --dry-run
247
+ ```
248
+
249
+ ## Account management
250
+
251
+ ```bash
252
+ desic-okx account list
253
+ desic-okx account verify --name main
254
+ desic-okx account verify --all
255
+ desic-okx account set-default main
256
+ desic-okx account rename main primary
257
+ desic-okx account edit primary
258
+ desic-okx account remove primary
259
+ ```
260
+
261
+ `account add` and `account edit` verify credentials before writing the configuration. Tool parameters accept account aliases only, never API Key, Secret, or Passphrase values.
262
+
263
+ ## Tool help
264
+
265
+ ```bash
266
+ desic-okx tools
267
+ desic-okx tool news_search
268
+ desic-okx tool trade_place_order
269
+ desic-okx tool trade_place_order --json
270
+ ```
271
+
272
+ Help includes purpose, account requirements, input schema, and a runnable call example. Remote News and Smart Money interfaces are experimental. Upstream compatibility failures return `CAPABILITY_UNAVAILABLE` without disabling market, account, or trading modules.
273
+
274
+ ## Proxy
275
+
276
+ REST and public, business, and private WebSocket connections use the same proxy resolution order:
277
+
278
+ 1. `proxy.url` in `config.json`
279
+ 2. `HTTPS_PROXY`, `HTTP_PROXY`, or `ALL_PROXY`, with `NO_PROXY` support
280
+ 3. The enabled Windows or macOS HTTP/HTTPS system proxy
281
+ 4. Direct connection
282
+
283
+ Only HTTP and HTTPS proxy URLs are supported. PAC-only and SOCKS-only environments need an HTTP proxy endpoint. Example:
284
+
285
+ ```json
286
+ {
287
+ "proxy": {
288
+ "url": "http://127.0.0.1:7890"
289
+ }
290
+ }
291
+ ```
292
+
293
+ Stop the Runtime after changing configuration:
294
+
295
+ ```bash
296
+ desic-okx stop
297
+ ```
298
+
299
+ ## Update
300
+
301
+ ```bash
302
+ desic-okx update --check
303
+ desic-okx update
304
+ desic-okx update --yes
305
+ ```
306
+
307
+ The updater checks the official npm registry, stops the Runtime, waits for Windows to release the native SQLite module, installs the global update, synchronizes installed Skills, and runs Doctor. A newer CLI or MCP adapter also replaces an older running Runtime automatically.
308
+
309
+ ## Manual client setup
310
+
311
+ `desic-okx setup` is recommended. To register only the MCP server:
312
+
313
+ ```bash
314
+ codex mcp add desic-okx -- desic-okx mcp
315
+ claude mcp add --transport stdio --scope user desic-okx -- desic-okx mcp
316
+ ```
317
+
318
+ Manual Codex configuration:
319
+
320
+ ```toml
321
+ [mcp_servers.desic-okx]
322
+ command = "desic-okx"
323
+ args = ["mcp"]
324
+ ```
325
+
326
+ ## Development from source
327
+
328
+ ```bash
329
+ git clone https://github.com/xiazhi88/desic-okx-agent.git
330
+ cd desic-okx-agent
331
+ npm ci
332
+ npm run check
333
+ npm link
334
+ ```
335
+
336
+ The check pipeline includes TypeScript type checking, unit tests, Skill validation, sensitive-information scanning, a production build, and an MCP transport smoke test. Normal tests never submit orders; real trading end-to-end tests are restricted to OKX Demo.
337
+
338
+ ## Runtime behavior
339
+
340
+ - The Runtime binds a random `127.0.0.1` port and stores its PID, port, and access token in private state files.
341
+ - It prewarms `BTC-USDT-SWAP` and `ETH-USDT-SWAP`; other instruments are subscribed on demand and released after 15 idle minutes.
342
+ - Hot data is returned from memory. Cold or stale data is backfilled by REST.
343
+ - WebSockets reconnect automatically; the order book is rebuilt after sequence or checksum failures.
344
+ - `market_get_decision_snapshot` aligns components and reports their maximum time skew. Trading prechecks reject inconsistent snapshots.
345
+ - Trading writes use a stable `executionKey`. Ambiguous or timed-out writes query remote state before any retry.
346
+
347
+ Trading software can cause financial loss. This project provides no investment advice and makes no guarantee of execution results.
348
+
349
+ ## Status and license
350
+
351
+ This is pre-release software at version `0.3.0`. OKX Demo trading should be validated in the target network environment before a `1.0.0` release. Strategy research and live execution have been verified end to end on the OKX demo venue; **live execution has not yet run against real money over any length of time**.
352
+
353
+ MIT License. See `LICENSE`. OKX and related marks belong to their respective owners.