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.
- package/README.en.md +353 -0
- package/README.md +194 -190
- package/dist/account/private-websocket.js +4 -4
- package/dist/account/private-websocket.js.map +1 -1
- package/dist/account/service.d.ts +12 -1
- package/dist/account/service.js +18 -0
- package/dist/account/service.js.map +1 -1
- package/dist/bars/rate-limiter.d.ts +18 -0
- package/dist/bars/rate-limiter.js +84 -0
- package/dist/bars/rate-limiter.js.map +1 -0
- package/dist/bars/schema.d.ts +36 -0
- package/dist/bars/schema.js +134 -0
- package/dist/bars/schema.js.map +1 -0
- package/dist/bars/service.d.ts +60 -0
- package/dist/bars/service.js +120 -0
- package/dist/bars/service.js.map +1 -0
- package/dist/bars/store.d.ts +105 -0
- package/dist/bars/store.js +415 -0
- package/dist/bars/store.js.map +1 -0
- package/dist/bars/timeframe.d.ts +40 -0
- package/dist/bars/timeframe.js +146 -0
- package/dist/bars/timeframe.js.map +1 -0
- package/dist/bars/types.d.ts +68 -0
- package/dist/bars/types.js +13 -0
- package/dist/bars/types.js.map +1 -0
- package/dist/cli/data-render.d.ts +37 -0
- package/dist/cli/data-render.js +143 -0
- package/dist/cli/data-render.js.map +1 -0
- package/dist/cli/doctor.js +7 -3
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/index.js +758 -27
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/live-render.d.ts +24 -0
- package/dist/cli/live-render.js +85 -0
- package/dist/cli/live-render.js.map +1 -0
- package/dist/cli/range.d.ts +28 -0
- package/dist/cli/range.js +63 -0
- package/dist/cli/range.js.map +1 -0
- package/dist/cli/render.js +3 -0
- package/dist/cli/render.js.map +1 -1
- package/dist/cli/strategy-render.d.ts +36 -0
- package/dist/cli/strategy-render.js +391 -0
- package/dist/cli/strategy-render.js.map +1 -0
- package/dist/cli/width.d.ts +18 -0
- package/dist/cli/width.js +71 -0
- package/dist/cli/width.js.map +1 -0
- package/dist/config/loader.js +1 -1
- package/dist/config/schema.d.ts +7 -0
- package/dist/config/schema.js +24 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/core/okx-client.d.ts +9 -1
- package/dist/core/okx-client.js +14 -5
- package/dist/core/okx-client.js.map +1 -1
- package/dist/i18n/locale.d.ts +24 -0
- package/dist/i18n/locale.js +65 -0
- package/dist/i18n/locale.js.map +1 -0
- package/dist/i18n/messages.d.ts +333 -0
- package/dist/i18n/messages.js +660 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/live/account-snapshot.d.ts +30 -0
- package/dist/live/account-snapshot.js +130 -0
- package/dist/live/account-snapshot.js.map +1 -0
- package/dist/live/cutoff-queue.d.ts +42 -0
- package/dist/live/cutoff-queue.js +69 -0
- package/dist/live/cutoff-queue.js.map +1 -0
- package/dist/live/execution-key.d.ts +23 -0
- package/dist/live/execution-key.js +31 -0
- package/dist/live/execution-key.js.map +1 -0
- package/dist/live/failures.d.ts +37 -0
- package/dist/live/failures.js +57 -0
- package/dist/live/failures.js.map +1 -0
- package/dist/live/gates.d.ts +65 -0
- package/dist/live/gates.js +136 -0
- package/dist/live/gates.js.map +1 -0
- package/dist/live/loop.d.ts +56 -0
- package/dist/live/loop.js +197 -0
- package/dist/live/loop.js.map +1 -0
- package/dist/live/preconditions.d.ts +48 -0
- package/dist/live/preconditions.js +69 -0
- package/dist/live/preconditions.js.map +1 -0
- package/dist/live/reconcile.d.ts +46 -0
- package/dist/live/reconcile.js +104 -0
- package/dist/live/reconcile.js.map +1 -0
- package/dist/live/runner.d.ts +57 -0
- package/dist/live/runner.js +160 -0
- package/dist/live/runner.js.map +1 -0
- package/dist/live/schema.d.ts +18 -0
- package/dist/live/schema.js +91 -0
- package/dist/live/schema.js.map +1 -0
- package/dist/live/service.d.ts +144 -0
- package/dist/live/service.js +303 -0
- package/dist/live/service.js.map +1 -0
- package/dist/live/session.d.ts +85 -0
- package/dist/live/session.js +234 -0
- package/dist/live/session.js.map +1 -0
- package/dist/live/sizing.d.ts +62 -0
- package/dist/live/sizing.js +79 -0
- package/dist/live/sizing.js.map +1 -0
- package/dist/live/store.d.ts +123 -0
- package/dist/live/store.js +350 -0
- package/dist/live/store.js.map +1 -0
- package/dist/live/types.d.ts +82 -0
- package/dist/live/types.js +2 -0
- package/dist/live/types.js.map +1 -0
- package/dist/market/websocket.d.ts +16 -1
- package/dist/market/websocket.js +60 -5
- package/dist/market/websocket.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +15 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/network/connectivity.d.ts +9 -1
- package/dist/network/connectivity.js +28 -1
- package/dist/network/connectivity.js.map +1 -1
- package/dist/report/chart-script.d.ts +12 -0
- package/dist/report/chart-script.js +146 -0
- package/dist/report/chart-script.js.map +1 -0
- package/dist/report/compare-html.d.ts +8 -0
- package/dist/report/compare-html.js +254 -0
- package/dist/report/compare-html.js.map +1 -0
- package/dist/report/compare-script.d.ts +12 -0
- package/dist/report/compare-script.js +109 -0
- package/dist/report/compare-script.js.map +1 -0
- package/dist/report/compare.d.ts +61 -0
- package/dist/report/compare.js +205 -0
- package/dist/report/compare.js.map +1 -0
- package/dist/report/fetch.d.ts +20 -0
- package/dist/report/fetch.js +56 -0
- package/dist/report/fetch.js.map +1 -0
- package/dist/report/html.d.ts +54 -0
- package/dist/report/html.js +641 -0
- package/dist/report/html.js.map +1 -0
- package/dist/report/open.d.ts +42 -0
- package/dist/report/open.js +114 -0
- package/dist/report/open.js.map +1 -0
- package/dist/runtime/server.d.ts +16 -1
- package/dist/runtime/server.js +112 -9
- package/dist/runtime/server.js.map +1 -1
- package/dist/setup/installer.d.ts +1 -0
- package/dist/setup/installer.js +8 -0
- package/dist/setup/installer.js.map +1 -1
- package/dist/setup/wizard.d.ts +3 -0
- package/dist/setup/wizard.js +131 -6
- package/dist/setup/wizard.js.map +1 -1
- package/dist/strategy/constants.d.ts +23 -0
- package/dist/strategy/constants.js +24 -0
- package/dist/strategy/constants.js.map +1 -0
- package/dist/strategy/environment.d.ts +52 -0
- package/dist/strategy/environment.js +187 -0
- package/dist/strategy/environment.js.map +1 -0
- package/dist/strategy/instrument.d.ts +29 -0
- package/dist/strategy/instrument.js +39 -0
- package/dist/strategy/instrument.js.map +1 -0
- package/dist/strategy/optimize.d.ts +73 -0
- package/dist/strategy/optimize.js +113 -0
- package/dist/strategy/optimize.js.map +1 -0
- package/dist/strategy/parameter-space.d.ts +59 -0
- package/dist/strategy/parameter-space.js +221 -0
- package/dist/strategy/parameter-space.js.map +1 -0
- package/dist/strategy/python-bridge.d.ts +24 -0
- package/dist/strategy/python-bridge.js +114 -0
- package/dist/strategy/python-bridge.js.map +1 -0
- package/dist/strategy/schema.d.ts +9 -0
- package/dist/strategy/schema.js +91 -0
- package/dist/strategy/schema.js.map +1 -0
- package/dist/strategy/service.d.ts +138 -0
- package/dist/strategy/service.js +745 -0
- package/dist/strategy/service.js.map +1 -0
- package/dist/strategy/settings.d.ts +162 -0
- package/dist/strategy/settings.js +243 -0
- package/dist/strategy/settings.js.map +1 -0
- package/dist/strategy/store.d.ts +96 -0
- package/dist/strategy/store.js +367 -0
- package/dist/strategy/store.js.map +1 -0
- package/dist/strategy/templates.d.ts +11 -0
- package/dist/strategy/templates.js +134 -0
- package/dist/strategy/templates.js.map +1 -0
- package/dist/strategy/types.d.ts +111 -0
- package/dist/strategy/types.js +2 -0
- package/dist/strategy/types.js.map +1 -0
- package/dist/tools/catalog.d.ts +16 -0
- package/dist/tools/catalog.js +118 -17
- package/dist/tools/catalog.js.map +1 -1
- package/dist/trade/service.d.ts +12 -0
- package/dist/trade/service.js +24 -7
- package/dist/trade/service.js.map +1 -1
- package/dist/tui/app.d.ts +23 -0
- package/dist/tui/app.js +322 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/commands.d.ts +70 -0
- package/dist/tui/commands.js +313 -0
- package/dist/tui/commands.js.map +1 -0
- package/dist/tui/entries.d.ts +17 -0
- package/dist/tui/entries.js +24 -0
- package/dist/tui/entries.js.map +1 -0
- package/dist/tui/execute.d.ts +26 -0
- package/dist/tui/execute.js +664 -0
- package/dist/tui/execute.js.map +1 -0
- package/dist/tui/history.d.ts +17 -0
- package/dist/tui/history.js +48 -0
- package/dist/tui/history.js.map +1 -0
- package/dist/tui/index.d.ts +8 -0
- package/dist/tui/index.js +48 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/line-editor.d.ts +44 -0
- package/dist/tui/line-editor.js +98 -0
- package/dist/tui/line-editor.js.map +1 -0
- package/dist/tui/progress.d.ts +23 -0
- package/dist/tui/progress.js +46 -0
- package/dist/tui/progress.js.map +1 -0
- package/dist/tui/settings-editor.d.ts +18 -0
- package/dist/tui/settings-editor.js +115 -0
- package/dist/tui/settings-editor.js.map +1 -0
- package/docs/live-trading.md +455 -0
- package/docs/strategy-research.md +597 -0
- package/package.json +11 -1
- package/python/desic_strategy/__init__.py +34 -0
- package/python/desic_strategy/actions.py +158 -0
- package/python/desic_strategy/context.py +164 -0
- package/python/desic_strategy/engine.py +614 -0
- package/python/desic_strategy/indicators.py +159 -0
- package/python/desic_strategy/live.py +253 -0
- package/python/desic_strategy/policy.py +193 -0
- package/python/desic_strategy/portfolio.py +152 -0
- package/python/desic_strategy/report.py +319 -0
- package/python/desic_strategy/runner.py +574 -0
- package/python/desic_strategy/timeframe.py +150 -0
- package/python/main.py +18 -0
- package/skills/okx-live-trading/SKILL.md +117 -0
- package/skills/okx-live-trading/agents/openai.yaml +9 -0
- package/skills/okx-live-trading/references/lifecycle.md +128 -0
- package/skills/okx-strategy-research/SKILL.md +113 -0
- package/skills/okx-strategy-research/agents/openai.yaml +9 -0
- package/skills/okx-strategy-research/references/execution-semantics.md +107 -0
- package/skills/okx-strategy-research/references/field-traps.md +142 -0
- package/skills/okx-strategy-research/references/python-api.md +121 -0
- package/skills/okx-strategy-research/references/tools-and-data.md +192 -0
- 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.
|