desic-okx-agent 0.2.1 → 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 +90 -10
- package/README.md +76 -10
- 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 +757 -26
- 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.js +19 -22
- 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 +10 -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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage for queued and completed strategy runs.
|
|
3
|
+
*
|
|
4
|
+
* The equity curve is stored as fixed-width little-endian float64 blocks rather
|
|
5
|
+
* than JSON rows. A 500k-bar curve is tens of megabytes as JSON objects and
|
|
6
|
+
* under a megabyte here, and every value round-trips bit-for-bit — decimal JSON
|
|
7
|
+
* text does not guarantee that.
|
|
8
|
+
*/
|
|
9
|
+
export const STRATEGY_SCHEMA_SQL = `
|
|
10
|
+
CREATE TABLE IF NOT EXISTS strategy_runs (
|
|
11
|
+
id TEXT PRIMARY KEY,
|
|
12
|
+
kind TEXT NOT NULL,
|
|
13
|
+
status TEXT NOT NULL,
|
|
14
|
+
strategy_name TEXT NOT NULL,
|
|
15
|
+
strategy_hash TEXT NOT NULL,
|
|
16
|
+
strategy_source TEXT NOT NULL,
|
|
17
|
+
inst_id TEXT NOT NULL,
|
|
18
|
+
request_json TEXT NOT NULL,
|
|
19
|
+
data_snapshot_id TEXT,
|
|
20
|
+
bar_count INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
preload_bars INTEGER NOT NULL DEFAULT 0,
|
|
22
|
+
progress_pct REAL NOT NULL DEFAULT 0,
|
|
23
|
+
eta_ms INTEGER,
|
|
24
|
+
metrics_json TEXT,
|
|
25
|
+
-- The assumptions the run actually used. Stored per run because settings can
|
|
26
|
+
-- change between runs, and a report that cannot say what it assumed is not
|
|
27
|
+
-- comparable to any other report.
|
|
28
|
+
assumptions_json TEXT,
|
|
29
|
+
error TEXT,
|
|
30
|
+
created_at INTEGER NOT NULL,
|
|
31
|
+
started_at INTEGER,
|
|
32
|
+
finished_at INTEGER
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE INDEX IF NOT EXISTS idx_strategy_runs_created
|
|
36
|
+
ON strategy_runs(created_at DESC);
|
|
37
|
+
CREATE INDEX IF NOT EXISTS idx_strategy_runs_status
|
|
38
|
+
ON strategy_runs(status, created_at DESC);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE IF NOT EXISTS strategy_run_series (
|
|
41
|
+
run_id TEXT NOT NULL,
|
|
42
|
+
chunk_index INTEGER NOT NULL,
|
|
43
|
+
from_point INTEGER NOT NULL,
|
|
44
|
+
to_point INTEGER NOT NULL,
|
|
45
|
+
start_ms INTEGER NOT NULL,
|
|
46
|
+
step_ms INTEGER NOT NULL,
|
|
47
|
+
payload BLOB NOT NULL,
|
|
48
|
+
PRIMARY KEY(run_id, chunk_index)
|
|
49
|
+
) WITHOUT ROWID;
|
|
50
|
+
|
|
51
|
+
CREATE TABLE IF NOT EXISTS strategy_run_trades (
|
|
52
|
+
run_id TEXT NOT NULL,
|
|
53
|
+
seq INTEGER NOT NULL,
|
|
54
|
+
trade_json TEXT NOT NULL,
|
|
55
|
+
PRIMARY KEY(run_id, seq)
|
|
56
|
+
) WITHOUT ROWID;
|
|
57
|
+
|
|
58
|
+
CREATE TABLE IF NOT EXISTS strategy_run_actions (
|
|
59
|
+
run_id TEXT NOT NULL,
|
|
60
|
+
seq INTEGER NOT NULL,
|
|
61
|
+
action_json TEXT NOT NULL,
|
|
62
|
+
PRIMARY KEY(run_id, seq)
|
|
63
|
+
) WITHOUT ROWID;
|
|
64
|
+
|
|
65
|
+
-- One row per evaluated parameter combination of an optimize run.
|
|
66
|
+
--
|
|
67
|
+
-- Training and validation metrics are stored separately rather than merged into
|
|
68
|
+
-- one figure. The gap between them is the finding: a candidate that earned its
|
|
69
|
+
-- ranking and one that memorized the training segment are indistinguishable from
|
|
70
|
+
-- a single number.
|
|
71
|
+
CREATE TABLE IF NOT EXISTS strategy_optimization_candidates (
|
|
72
|
+
run_id TEXT NOT NULL,
|
|
73
|
+
candidate_index INTEGER NOT NULL,
|
|
74
|
+
params_json TEXT NOT NULL,
|
|
75
|
+
status TEXT NOT NULL,
|
|
76
|
+
train_metrics_json TEXT,
|
|
77
|
+
validation_metrics_json TEXT,
|
|
78
|
+
-- Validation-segment score. Null while queued, and for a candidate that failed.
|
|
79
|
+
rank_score REAL,
|
|
80
|
+
-- Which formula produced rank_score, because it is not always Calmar.
|
|
81
|
+
rank_basis TEXT,
|
|
82
|
+
verdict TEXT,
|
|
83
|
+
error TEXT,
|
|
84
|
+
PRIMARY KEY(run_id, candidate_index)
|
|
85
|
+
) WITHOUT ROWID;
|
|
86
|
+
|
|
87
|
+
-- Ranking reads this in score order, so it is indexed rather than sorted per read.
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_optimization_rank
|
|
89
|
+
ON strategy_optimization_candidates(run_id, rank_score DESC);
|
|
90
|
+
`;
|
|
91
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/strategy/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFlC,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type ToolResult } from "../core/types.js";
|
|
2
|
+
import type { BarService } from "../bars/service.js";
|
|
3
|
+
import type { MarketService } from "../market/service.js";
|
|
4
|
+
import { type PythonStatus } from "./environment.js";
|
|
5
|
+
import { type BacktestSettings } from "./settings.js";
|
|
6
|
+
import { StrategyStore } from "./store.js";
|
|
7
|
+
import { type ComparisonReport } from "../report/compare.js";
|
|
8
|
+
import type { BacktestRequest, EquityPoint, OptimizationReport, OptimizeRequest, Page, RunStatus, RunSummary, ValidationResult } from "./types.js";
|
|
9
|
+
export declare class StrategyService {
|
|
10
|
+
readonly store: StrategyStore;
|
|
11
|
+
private readonly bars;
|
|
12
|
+
/**
|
|
13
|
+
* Source of contract specifications. Optional so a test can construct the
|
|
14
|
+
* service without a market runtime; a run then fails with a clear message
|
|
15
|
+
* rather than falling back to a guessed contract size.
|
|
16
|
+
*/
|
|
17
|
+
private readonly market?;
|
|
18
|
+
private readonly maxWorkers;
|
|
19
|
+
private readonly now;
|
|
20
|
+
/** Test seam: bypasses the settings file so a run is reproducible. */
|
|
21
|
+
private readonly injectedSettings?;
|
|
22
|
+
private readonly active;
|
|
23
|
+
private queue;
|
|
24
|
+
private running;
|
|
25
|
+
constructor(store: StrategyStore, bars: BarService,
|
|
26
|
+
/**
|
|
27
|
+
* Source of contract specifications. Optional so a test can construct the
|
|
28
|
+
* service without a market runtime; a run then fails with a clear message
|
|
29
|
+
* rather than falling back to a guessed contract size.
|
|
30
|
+
*/
|
|
31
|
+
market?: MarketService | undefined, maxWorkers?: number, now?: () => number,
|
|
32
|
+
/** Test seam: bypasses the settings file so a run is reproducible. */
|
|
33
|
+
injectedSettings?: BacktestSettings | undefined);
|
|
34
|
+
/** Reports interpreter availability without changing anything. */
|
|
35
|
+
environment(): Promise<ToolResult<PythonStatus>>;
|
|
36
|
+
setupEnvironment(onLog?: (line: string) => void): Promise<ToolResult<Record<string, unknown>>>;
|
|
37
|
+
/** Saved settings, or the injected ones when a caller supplied them. */
|
|
38
|
+
settings(): BacktestSettings;
|
|
39
|
+
readSettings(): ToolResult<BacktestSettings>;
|
|
40
|
+
/**
|
|
41
|
+
* Applies saved settings. Unknown keys and out-of-range values are rejected
|
|
42
|
+
* rather than ignored: a silently dropped change means the next run uses
|
|
43
|
+
* assumptions the caller believes it changed.
|
|
44
|
+
*/
|
|
45
|
+
updateSettings(values: Record<string, unknown>, reset?: boolean): ToolResult<BacktestSettings>;
|
|
46
|
+
/** Static policy check. Fast enough to run on every edit. */
|
|
47
|
+
validate(source: string): Promise<ToolResult<ValidationResult>>;
|
|
48
|
+
/**
|
|
49
|
+
* Queues a backtest and returns immediately.
|
|
50
|
+
*
|
|
51
|
+
* A run can take minutes, so the caller polls `getRun` rather than holding a
|
|
52
|
+
* request open and risking a client-side timeout.
|
|
53
|
+
*/
|
|
54
|
+
startBacktest(request: BacktestRequest): Promise<ToolResult<{
|
|
55
|
+
runId: string;
|
|
56
|
+
status: RunStatus;
|
|
57
|
+
}>>;
|
|
58
|
+
/**
|
|
59
|
+
* Queues a parameter search and returns immediately.
|
|
60
|
+
*
|
|
61
|
+
* The space is validated against the strategy's own declared parameters before
|
|
62
|
+
* anything is queued, so a range naming a parameter the strategy never reads
|
|
63
|
+
* fails at the prompt rather than after every candidate has run identically.
|
|
64
|
+
*/
|
|
65
|
+
startOptimize(request: OptimizeRequest): Promise<ToolResult<{
|
|
66
|
+
runId: string;
|
|
67
|
+
status: RunStatus;
|
|
68
|
+
}>>;
|
|
69
|
+
/**
|
|
70
|
+
* Ranked candidates for one optimize run.
|
|
71
|
+
*
|
|
72
|
+
* Ranking is by the held-back segment, never the searched one. The winner's
|
|
73
|
+
* ranking basis is reported alongside, because Calmar is unavailable on short
|
|
74
|
+
* windows and a column that silently changes meaning is worse than a labelled
|
|
75
|
+
* one.
|
|
76
|
+
*/
|
|
77
|
+
optimization(id: string, top?: number): ToolResult<OptimizationReport>;
|
|
78
|
+
/**
|
|
79
|
+
* Compares completed runs.
|
|
80
|
+
*
|
|
81
|
+
* The equity curves are read whole here rather than paged: a comparison is
|
|
82
|
+
* summary-level, and the curves are downsampled before they leave. The response
|
|
83
|
+
* carries metrics, the assumptions that differ, and the warnings — not the
|
|
84
|
+
* curves, which would bury an agent's context for no benefit.
|
|
85
|
+
*/
|
|
86
|
+
compareRuns(runIds: string[]): ToolResult<Omit<ComparisonReport, "series">>;
|
|
87
|
+
getRun(id: string): ToolResult<RunSummary>;
|
|
88
|
+
listRuns(options?: {
|
|
89
|
+
limit?: number;
|
|
90
|
+
status?: RunStatus;
|
|
91
|
+
instId?: string;
|
|
92
|
+
}): ToolResult<RunSummary[]>;
|
|
93
|
+
equity(id: string, offset?: number, limit?: number): ToolResult<Page<EquityPoint>>;
|
|
94
|
+
trades(id: string, offset?: number, limit?: number): ToolResult<Page<unknown>>;
|
|
95
|
+
actions(id: string, offset?: number, limit?: number): ToolResult<Page<unknown>>;
|
|
96
|
+
cancel(id: string): ToolResult<{
|
|
97
|
+
cancelled: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
deleteRun(id: string): ToolResult<{
|
|
100
|
+
deleted: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Resolves the exact bar window a request describes.
|
|
104
|
+
*
|
|
105
|
+
* Preloaded history is context only: it warms up indicators and supplies the
|
|
106
|
+
* first decision point, and is excluded from every reported statistic.
|
|
107
|
+
*/
|
|
108
|
+
resolveWindow(request: BacktestRequest): {
|
|
109
|
+
evaluationStart: number;
|
|
110
|
+
evaluationEnd: number;
|
|
111
|
+
preloadStart: number;
|
|
112
|
+
preloadBars: number;
|
|
113
|
+
totalBars: number;
|
|
114
|
+
};
|
|
115
|
+
private execute;
|
|
116
|
+
/**
|
|
117
|
+
* Runs one parameter search.
|
|
118
|
+
*
|
|
119
|
+
* The bars are loaded once and every candidate is measured against that single
|
|
120
|
+
* array. Batches go out one per worker rather than one per candidate: the
|
|
121
|
+
* payload is a small share of a candidate's cost, so nothing is gained by
|
|
122
|
+
* splitting further, while a process per candidate would hold the same
|
|
123
|
+
* multi-megabyte array once per candidate.
|
|
124
|
+
*/
|
|
125
|
+
private executeOptimize;
|
|
126
|
+
/** Stores one batch's results, keyed by the candidate index the host assigned. */
|
|
127
|
+
private recordBatch;
|
|
128
|
+
/**
|
|
129
|
+
* Reads the instrument's contract specification.
|
|
130
|
+
*
|
|
131
|
+
* Refuses rather than defaulting: a backtest sized off a guessed contract value
|
|
132
|
+
* reports confident numbers for positions that could never have been taken.
|
|
133
|
+
*/
|
|
134
|
+
private contractSpec;
|
|
135
|
+
private requireInterpreter;
|
|
136
|
+
private enqueue;
|
|
137
|
+
private drain;
|
|
138
|
+
}
|