desic-okx-agent 0.3.1 → 0.3.3
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 +1 -1
- package/README.md +1 -1
- package/dist/i18n/messages.d.ts +27 -0
- package/dist/i18n/messages.js +55 -1
- package/dist/i18n/messages.js.map +1 -1
- package/dist/report/brand-font.d.ts +1 -0
- package/dist/report/brand-font.js +4 -0
- package/dist/report/brand-font.js.map +1 -0
- package/dist/report/chart-script.d.ts +3 -8
- package/dist/report/chart-script.js +735 -115
- package/dist/report/chart-script.js.map +1 -1
- package/dist/report/compare-html.d.ts +1 -6
- package/dist/report/compare-html.js +177 -122
- package/dist/report/compare-html.js.map +1 -1
- package/dist/report/compare-script.d.ts +1 -11
- package/dist/report/compare-script.js +310 -64
- package/dist/report/compare-script.js.map +1 -1
- package/dist/report/fetch.d.ts +32 -0
- package/dist/report/fetch.js +42 -0
- package/dist/report/fetch.js.map +1 -1
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +846 -268
- package/dist/report/html.js.map +1 -1
- package/dist/strategy/service.js +4 -1
- package/dist/strategy/service.js.map +1 -1
- package/dist/strategy/store.d.ts +12 -1
- package/dist/strategy/store.js +32 -1
- package/dist/strategy/store.js.map +1 -1
- package/dist/tools/catalog.js +20 -1
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tui/app.js +106 -35
- package/dist/tui/app.js.map +1 -1
- package/dist/tui/commands.d.ts +33 -0
- package/dist/tui/commands.js +59 -14
- package/dist/tui/commands.js.map +1 -1
- package/dist/tui/file-completion.d.ts +13 -0
- package/dist/tui/file-completion.js +57 -0
- package/dist/tui/file-completion.js.map +1 -0
- package/docs/strategy-research.md +16 -3
- package/package.json +1 -1
- package/python/desic_strategy/context.py +23 -5
- package/python/desic_strategy/engine.py +4 -1
- package/python/desic_strategy/live.py +1 -1
- package/python/desic_strategy/policy.py +51 -0
- package/python/desic_strategy/runner.py +36 -9
- package/python/desic_strategy/timeframe.py +17 -0
- package/skills/okx-strategy-research/SKILL.md +55 -1
- package/skills/okx-strategy-research/agents/openai.yaml +1 -1
- package/skills/okx-strategy-research/references/python-api.md +7 -0
- package/skills/okx-strategy-research/references/tools-and-data.md +20 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: okx-strategy-research
|
|
3
|
-
description: Write, validate, and backtest Python trading strategies against local OKX one-minute history. Use for strategy authoring, backtest execution, reading
|
|
3
|
+
description: Write, validate, and backtest Python trading strategies against local OKX one-minute history. Use for strategy authoring, backtest execution, reading results, generating or opening detailed standalone HTML reports, visually comparing runs, and diagnosing local data coverage or gaps.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# OKX Strategy Research
|
|
@@ -40,6 +40,11 @@ names directly; do not probe for spellings.
|
|
|
40
40
|
quoting two reports in sequence. Read its `warnings` first and repeat them: two
|
|
41
41
|
runs over different data, instruments, windows, or costs are not two answers to
|
|
42
42
|
one question, and that is invisible in the metrics alone.
|
|
43
|
+
9. When the user asks for a detailed report, visual report, HTML report, charts,
|
|
44
|
+
or to open/view a report (including Chinese requests such as "详细报告",
|
|
45
|
+
"HTML 报告", "打开报告", or "查看图表"), generate it immediately with
|
|
46
|
+
`strategy_open_report` or `strategy_open_comparison`. Do not replace that action
|
|
47
|
+
with paged data reads or merely tell the user which CLI command they could run.
|
|
43
48
|
|
|
44
49
|
## Where this leads
|
|
45
50
|
|
|
@@ -77,6 +82,55 @@ describe a backtest result as expected future return.
|
|
|
77
82
|
When `marginExhausted` is true, say the run hit its simulated collateral limit
|
|
78
83
|
and that this is a research risk boundary, not an OKX liquidation estimate.
|
|
79
84
|
|
|
85
|
+
### Generate and open the detailed HTML report
|
|
86
|
+
|
|
87
|
+
A completed backtest's detailed view is the standalone HTML report, not a dump of
|
|
88
|
+
`strategy_get_run_equity` or `strategy_get_run_trades`. It contains the interactive
|
|
89
|
+
equity and drawdown curves, execution orbit, return spectrum, monthly performance,
|
|
90
|
+
trade distribution, assumptions, and full trade ledger. All assets are inline, so
|
|
91
|
+
the file remains private and works offline.
|
|
92
|
+
|
|
93
|
+
When a completed run is available, or whenever the user asks to open or view its
|
|
94
|
+
detailed/visual/HTML report, call the tool instead of only describing it:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
strategy_open_report { "runId": "bt_abc123" }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Omit `open` (or pass `"open": true`) to launch the operator's default browser.
|
|
101
|
+
Use `"open": false` only when the user explicitly asks to generate the file
|
|
102
|
+
without opening it. The result carries `data.file` and `data.opened`:
|
|
103
|
+
|
|
104
|
+
- When `opened` is `true`, say the report was opened and still provide `file` so it
|
|
105
|
+
can be reopened or archived.
|
|
106
|
+
- When `opened` is `false`, say the HTML was generated but the browser did not
|
|
107
|
+
launch, then provide the exact `file` path for the user to open locally. Do not
|
|
108
|
+
claim it opened.
|
|
109
|
+
|
|
110
|
+
For two to six runs, generate the comparison observatory rather than opening
|
|
111
|
+
several single-run files:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
strategy_open_comparison { "runIds": ["bt_abc123", "bt_def456"] }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
It opens one normalized multi-curve report with the metrics matrix and assumption
|
|
118
|
+
differences. Read `data.warnings` and repeat every warning in your own reply rather
|
|
119
|
+
than leaving it only in the document. Different data, instruments, windows, or
|
|
120
|
+
costs are not two answers to one question.
|
|
121
|
+
|
|
122
|
+
If the MCP open tools are unavailable but the Desic CLI is available, the direct
|
|
123
|
+
operator equivalents are:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
desic-okx strategy report --run bt_abc123 --open
|
|
127
|
+
desic-okx strategy compare --runs bt_abc123,bt_def456 --open
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Do not open a report for a queued, running, failed, or cancelled run. Poll a queued
|
|
131
|
+
or running backtest to a terminal status first; report failures and cancellations
|
|
132
|
+
instead of producing a document without the result it exists to show.
|
|
133
|
+
|
|
80
134
|
## Judging a result
|
|
81
135
|
|
|
82
136
|
A high trade count with a profit factor near or below 1 usually means fees
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface:
|
|
2
2
|
display_name: "OKX Strategy Research"
|
|
3
|
-
short_description: "
|
|
3
|
+
short_description: "Backtest OKX strategies and open detailed visual HTML reports."
|
|
4
4
|
default_prompt: "Use $okx-strategy-research to backtest an EMA trend strategy on BTC-USDT-SWAP."
|
|
5
5
|
dependencies:
|
|
6
6
|
tools:
|
|
@@ -41,6 +41,13 @@ Always pass `lookback` when only a tail is needed. It costs the size of the wind
|
|
|
41
41
|
asked for, whereas omitting it copies every bar seen so far on every call — on a
|
|
42
42
|
long run that is the difference between a few seconds and a few minutes.
|
|
43
43
|
|
|
44
|
+
A higher timeframe does not have to be declared on the request. The engine reads the
|
|
45
|
+
source and aggregates whatever interval a `bars` call names, so writing
|
|
46
|
+
`ctx.market.bars(id, "15m")` is enough. The run's `assumptions.intervals` reports what
|
|
47
|
+
was actually aggregated, which is what to quote. An interval built at runtime —
|
|
48
|
+
`bars(id, ctx.params["tf"])` — cannot be read from the source, so that case still needs
|
|
49
|
+
`intervals` on the request.
|
|
50
|
+
|
|
44
51
|
`Bar` fields: `openTimeMs`, `closeTimeMs`, `open`, `high`, `low`, `close`,
|
|
45
52
|
`volume`, `confirmed`.
|
|
46
53
|
|
|
@@ -30,9 +30,29 @@ There is no `bar` parameter on any data tool.
|
|
|
30
30
|
| `strategy_get_run_trades` | Paged closed trades. |
|
|
31
31
|
| `strategy_get_run_actions` | Paged decisions the strategy emitted. |
|
|
32
32
|
| `strategy_compare_runs` | Two or more runs side by side, with the assumptions that differ and comparability warnings. |
|
|
33
|
+
| `strategy_open_report` | Write a standalone HTML report for one run and open it in the operator's browser. |
|
|
34
|
+
| `strategy_open_comparison` | The same for two or more runs, overlaying their equity curves. |
|
|
33
35
|
| `strategy_cancel_run` | Cancel a queued or running run. |
|
|
34
36
|
| `strategy_delete_run` | Delete a run and its stored series. Confirm with the user first. |
|
|
35
37
|
|
|
38
|
+
Both open tools return their result under `data`: `data.file` is the absolute HTML
|
|
39
|
+
path and `data.opened` says whether the default browser launched. Omit `open` to
|
|
40
|
+
open by default; pass `open: false` only when the user asks to generate without
|
|
41
|
+
opening. Always give the path. When `data.opened` is false, say the document was
|
|
42
|
+
written but do not claim it opened. `strategy_open_comparison` also returns
|
|
43
|
+
`data.warnings`, which belong in your reply and not only in the document.
|
|
44
|
+
|
|
45
|
+
Use these calls for requests such as “detailed report”, “HTML report”, “open the
|
|
46
|
+
report”, “详细报告”, “打开报告”, or “查看图表”:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
strategy_open_report { "runId": "bt_abc123" }
|
|
50
|
+
strategy_open_comparison { "runIds": ["bt_abc123", "bt_def456"] }
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The report tools collect all required pages internally. Do not page the full equity
|
|
54
|
+
curve or trade ledger into the conversation before calling them.
|
|
55
|
+
|
|
36
56
|
## Check coverage before backtesting
|
|
37
57
|
|
|
38
58
|
```
|