@senpi/runtime 3.0.233 → 3.0.234
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/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +7 -0
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/deploy/job.d.ts +2 -0
- package/dist/deploy/job.d.ts.map +1 -1
- package/dist/deploy/job.js +2 -2
- package/dist/deploy/job.js.map +1 -1
- package/dist/deploy/orchestrator.d.ts +6 -0
- package/dist/deploy/orchestrator.d.ts.map +1 -1
- package/dist/deploy/orchestrator.js +21 -7
- package/dist/deploy/orchestrator.js.map +1 -1
- package/dist/deploy/register.d.ts.map +1 -1
- package/dist/deploy/register.js +30 -1
- package/dist/deploy/register.js.map +1 -1
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +8 -0
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/types.d.ts +7 -0
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/strategy/settings.d.ts +25 -0
- package/dist/strategy/settings.d.ts.map +1 -0
- package/dist/strategy/settings.js +127 -0
- package/dist/strategy/settings.js.map +1 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RuntimeConfig } from "../runtime/runtime-schema.js";
|
|
2
|
+
import type { StrategyFacts } from "./facts.js";
|
|
3
|
+
export type StrategySettingValue = number | string | boolean;
|
|
4
|
+
export type StrategySettings = Record<string, StrategySettingValue>;
|
|
5
|
+
export declare const MAX_STRATEGY_SETTINGS = 200;
|
|
6
|
+
export declare const MAX_GROUP_DESCRIPTION = 2000;
|
|
7
|
+
export declare const MAX_SETTING_STRING = 500;
|
|
8
|
+
/**
|
|
9
|
+
* The flat, dotted settings of one runtime.yaml: what the backend stores as a strategy's settings
|
|
10
|
+
* and shows as chips. Pure and total. Keys follow `strategy-manager` `src/identity/settings-registry.ts`:
|
|
11
|
+
* the registry's keys come first, every other key after them in key order, at most
|
|
12
|
+
* {@link MAX_STRATEGY_SETTINGS} in all.
|
|
13
|
+
*/
|
|
14
|
+
export declare function strategySettings(config: RuntimeConfig): StrategySettings;
|
|
15
|
+
export interface SimulationGroup {
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
assets?: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The group a simulation is created under: the runtime.yaml's top-level `group`, with its
|
|
22
|
+
* `description` and the coins the strategy names explicitly. Null when the file has no group.
|
|
23
|
+
*/
|
|
24
|
+
export declare function simulationGroup(config: RuntimeConfig, facts?: Pick<StrategyFacts, "assets">): SimulationGroup | null;
|
|
25
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/strategy/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7D,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAEpE,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AA6EtC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CA2BxE;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GAAG,eAAe,GAAG,IAAI,CAUpH"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export const MAX_STRATEGY_SETTINGS = 200;
|
|
2
|
+
export const MAX_GROUP_DESCRIPTION = 2000;
|
|
3
|
+
export const MAX_SETTING_STRING = 500;
|
|
4
|
+
const REGISTRY_KEYS = [
|
|
5
|
+
"strategy.slots",
|
|
6
|
+
"strategy.margin_pct",
|
|
7
|
+
"strategy.default_leverage",
|
|
8
|
+
"strategy.trading_risk",
|
|
9
|
+
"scanner.interval_seconds",
|
|
10
|
+
"scanner.default_signal_validity_seconds",
|
|
11
|
+
"scanner.timeout_seconds",
|
|
12
|
+
"entry.order_type",
|
|
13
|
+
"entry.execution_timeout_seconds",
|
|
14
|
+
"exit.interval_seconds",
|
|
15
|
+
"exit.order_type",
|
|
16
|
+
"exit.dsl_preset.phase1.max_loss_pct",
|
|
17
|
+
"exit.dsl_preset.phase1.enabled",
|
|
18
|
+
"exit.dsl_preset.phase1.retrace_threshold",
|
|
19
|
+
"exit.dsl_preset.phase1.consecutive_breaches_required",
|
|
20
|
+
"exit.dsl_preset.hard_timeout.enabled",
|
|
21
|
+
"exit.dsl_preset.hard_timeout.interval_in_minutes",
|
|
22
|
+
"exit.dsl_preset.weak_peak_cut.enabled",
|
|
23
|
+
"exit.dsl_preset.weak_peak_cut.interval_in_minutes",
|
|
24
|
+
"exit.dsl_preset.weak_peak_cut.min_value",
|
|
25
|
+
"exit.dsl_preset.dead_weight_cut.enabled",
|
|
26
|
+
"exit.dsl_preset.dead_weight_cut.interval_in_minutes",
|
|
27
|
+
"risk.guard_rails.max_entries_per_day",
|
|
28
|
+
"risk.guard_rails.daily_loss_limit_pct",
|
|
29
|
+
"risk.guard_rails.drawdown_halt_pct",
|
|
30
|
+
"risk.guard_rails.max_consecutive_losses",
|
|
31
|
+
"risk.guard_rails.cooldown_seconds",
|
|
32
|
+
"risk.guard_rails.per_asset_cooldown_seconds",
|
|
33
|
+
];
|
|
34
|
+
function isRec(value) {
|
|
35
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
36
|
+
}
|
|
37
|
+
function scalar(value) {
|
|
38
|
+
return (typeof value === "boolean" ||
|
|
39
|
+
(typeof value === "string" && value.length <= MAX_SETTING_STRING) ||
|
|
40
|
+
(typeof value === "number" && Number.isFinite(value)));
|
|
41
|
+
}
|
|
42
|
+
function scalarsOf(node, prefix, skip, out) {
|
|
43
|
+
if (!isRec(node))
|
|
44
|
+
return;
|
|
45
|
+
for (const [key, value] of Object.entries(node)) {
|
|
46
|
+
if (skip.has(key))
|
|
47
|
+
continue;
|
|
48
|
+
if (scalar(value))
|
|
49
|
+
out[`${prefix}.${key}`] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function leavesOf(node, path, out, skipTop = new Set()) {
|
|
53
|
+
if (!isRec(node))
|
|
54
|
+
return;
|
|
55
|
+
for (const [key, value] of Object.entries(node)) {
|
|
56
|
+
if (skipTop.has(key))
|
|
57
|
+
continue;
|
|
58
|
+
const next = `${path}.${key}`;
|
|
59
|
+
if (scalar(value))
|
|
60
|
+
out[next] = value;
|
|
61
|
+
else
|
|
62
|
+
leavesOf(value, next, out);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function signalScanner(config) {
|
|
66
|
+
const open = config.actions?.find((a) => a.action_type === "OPEN_POSITION");
|
|
67
|
+
const name = open?.scanners?.[0];
|
|
68
|
+
if (typeof name !== "string")
|
|
69
|
+
return undefined;
|
|
70
|
+
const found = config.scanners?.find((s) => s.name === name);
|
|
71
|
+
return isRec(found) ? found : undefined;
|
|
72
|
+
}
|
|
73
|
+
const NONE = new Set();
|
|
74
|
+
const STRATEGY_SKIP = new Set(["wallet", "enabled"]);
|
|
75
|
+
const SCANNER_SKIP = new Set(["name", "type", "path", "entrypoint"]);
|
|
76
|
+
/**
|
|
77
|
+
* The flat, dotted settings of one runtime.yaml: what the backend stores as a strategy's settings
|
|
78
|
+
* and shows as chips. Pure and total. Keys follow `strategy-manager` `src/identity/settings-registry.ts`:
|
|
79
|
+
* the registry's keys come first, every other key after them in key order, at most
|
|
80
|
+
* {@link MAX_STRATEGY_SETTINGS} in all.
|
|
81
|
+
*/
|
|
82
|
+
export function strategySettings(config) {
|
|
83
|
+
const all = {};
|
|
84
|
+
scalarsOf(config.strategy, "strategy", STRATEGY_SKIP, all);
|
|
85
|
+
const scanner = signalScanner(config);
|
|
86
|
+
if (scanner) {
|
|
87
|
+
scalarsOf(scanner, "scanner", SCANNER_SKIP, all);
|
|
88
|
+
scalarsOf(scanner.inputs, "scanner.inputs", NONE, all);
|
|
89
|
+
}
|
|
90
|
+
const open = config.actions?.find((a) => a.action_type === "OPEN_POSITION");
|
|
91
|
+
const params = open?.params;
|
|
92
|
+
if (isRec(params)) {
|
|
93
|
+
scalarsOf(params, "entry", NONE, all);
|
|
94
|
+
const timeout = isRec(params.fee_optimized_limit_options)
|
|
95
|
+
? params.fee_optimized_limit_options.execution_timeout_seconds
|
|
96
|
+
: undefined;
|
|
97
|
+
if (scalar(timeout))
|
|
98
|
+
all["entry.execution_timeout_seconds"] = timeout;
|
|
99
|
+
}
|
|
100
|
+
leavesOf(config.exit, "exit", all, new Set(["engine"]));
|
|
101
|
+
leavesOf(config.risk, "risk", all);
|
|
102
|
+
const ordered = {};
|
|
103
|
+
for (const key of REGISTRY_KEYS)
|
|
104
|
+
if (key in all)
|
|
105
|
+
ordered[key] = all[key];
|
|
106
|
+
for (const key of Object.keys(all).sort())
|
|
107
|
+
if (!(key in ordered))
|
|
108
|
+
ordered[key] = all[key];
|
|
109
|
+
return Object.fromEntries(Object.entries(ordered).slice(0, MAX_STRATEGY_SETTINGS));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The group a simulation is created under: the runtime.yaml's top-level `group`, with its
|
|
113
|
+
* `description` and the coins the strategy names explicitly. Null when the file has no group.
|
|
114
|
+
*/
|
|
115
|
+
export function simulationGroup(config, facts) {
|
|
116
|
+
const name = typeof config.group === "string" ? config.group.trim() : "";
|
|
117
|
+
if (!name)
|
|
118
|
+
return null;
|
|
119
|
+
const description = typeof config.description === "string" ? config.description.trim().slice(0, MAX_GROUP_DESCRIPTION) : "";
|
|
120
|
+
const assets = facts?.assets;
|
|
121
|
+
return {
|
|
122
|
+
name,
|
|
123
|
+
...(description ? { description } : {}),
|
|
124
|
+
...(assets && assets.length > 0 ? { assets } : {}),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/strategy/settings.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,MAAM,aAAa,GAAsB;IACvC,gBAAgB;IAChB,qBAAqB;IACrB,2BAA2B;IAC3B,uBAAuB;IACvB,0BAA0B;IAC1B,yCAAyC;IACzC,yBAAyB;IACzB,kBAAkB;IAClB,iCAAiC;IACjC,uBAAuB;IACvB,iBAAiB;IACjB,qCAAqC;IACrC,gCAAgC;IAChC,0CAA0C;IAC1C,sDAAsD;IACtD,sCAAsC;IACtC,kDAAkD;IAClD,uCAAuC;IACvC,mDAAmD;IACnD,yCAAyC;IACzC,yCAAyC;IACzC,qDAAqD;IACrD,sCAAsC;IACtC,uCAAuC;IACvC,oCAAoC;IACpC,yCAAyC;IACzC,mCAAmC;IACnC,6CAA6C;CAC9C,CAAC;AAIF,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,C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C;AACrF,CAAC;AAQD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAqB,EAAE,KAAqC;IAC1F,MAAM,IAAI,GAAG,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5H,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,CAAC;IAC7B,OAAO;QACL,IAAI;QACJ,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC"}
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "runtime",
|
|
3
3
|
"name": "Senpi Runtime",
|
|
4
4
|
"description": "Senpi runtime plugin for OpenClaw. Orchestrates scanners, LLM-based trade decisions, and a DSL trailing stop-loss exit engine.",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.234",
|
|
6
6
|
"commandAliases": [
|
|
7
7
|
{
|
|
8
8
|
"name": "senpi"
|