@senpi-ai/runtime 3.0.3 → 3.0.5
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/actions/decision-engine.js +1 -1
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +21 -12
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/open-position/resolve-margin.d.ts +18 -3
- package/dist/actions/open-position/resolve-margin.d.ts.map +1 -1
- package/dist/actions/open-position/resolve-margin.js +22 -9
- package/dist/actions/open-position/resolve-margin.js.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +21 -3
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +10 -1
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/runtime-api/intake/types.d.ts +5 -6
- package/dist/runtime-api/intake/types.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.js +3 -2
- package/dist/runtime-api/routes/signals.js.map +1 -1
- package/dist/runtime-api/routes/signals.schema.d.ts +1 -2
- package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.schema.js +5 -3
- package/dist/runtime-api/routes/signals.schema.js.map +1 -1
- package/dist/scanners/external/scaffold/delivery.py +19 -0
- package/dist/scanners/external/scaffold/senpi_mcp.py +34 -16
- package/dist/scanners/external/scaffold/signal_envelope.py +57 -19
- package/dist/scanners/external-scanner-receiver.d.ts +9 -3
- package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
- package/dist/scanners/external-scanner-receiver.js +13 -5
- package/dist/scanners/external-scanner-receiver.js.map +1 -1
- package/dist/scanners/providers/factory.d.ts.map +1 -1
- package/dist/scanners/providers/factory.js +17 -19
- package/dist/scanners/providers/factory.js.map +1 -1
- package/dist/strategy/strategy-state.d.ts.map +1 -1
- package/dist/strategy/strategy-state.js +16 -19
- package/dist/strategy/strategy-state.js.map +1 -1
- package/dist/types/scanner.d.ts +12 -3
- package/dist/types/scanner.d.ts.map +1 -1
- package/dist/utils/clearing-house-aggregate.d.ts +32 -0
- package/dist/utils/clearing-house-aggregate.d.ts.map +1 -0
- package/dist/utils/clearing-house-aggregate.js +41 -0
- package/dist/utils/clearing-house-aggregate.js.map +1 -0
- package/examples/strategies/iguana/README.md +4 -4
- package/examples/strategies/iguana/recipe.yaml +1 -1
- package/examples/strategies/iguana/scanners/scan.py +4 -5
- package/examples/strategies/raptor/README.md +2 -2
- package/examples/strategies/raptor/recipe.yaml +1 -1
- package/examples/strategies/raptor/scanners/scan.py +5 -6
- package/examples/strategies/spider/README.md +3 -3
- package/examples/strategies/spider/scalp/recipe.yaml +1 -1
- package/examples/strategies/spider/scalp/scanners/scan.py +1 -1
- package/examples/strategies/spider/swing/recipe.yaml +1 -1
- package/examples/strategies/spider/swing/scanners/scan.py +3 -3
- package/examples/strategies/turbine/README.md +12 -9
- package/examples/strategies/turbine/recipe-runners.yaml +2 -2
- package/examples/strategies/turbine/recipe-volume.yaml +2 -2
- package/examples/strategies/turbine/scanners/scan.py +10 -6
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { asNumber } from "./response.js";
|
|
2
|
+
export function emptyDexSummaryTotals() {
|
|
3
|
+
return {
|
|
4
|
+
accountValue: 0,
|
|
5
|
+
withdrawable: 0,
|
|
6
|
+
totalMarginUsed: 0,
|
|
7
|
+
totalUnrealizedPnl: 0,
|
|
8
|
+
totalNtlPos: 0,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Folds one dex section's account scalars into the running totals.
|
|
13
|
+
*
|
|
14
|
+
* A Hyperliquid strategy wallet is a single unified cross-margin account that
|
|
15
|
+
* the API mirrors as one view per perp DEX (`{ main, xyz, … }`), all sharing
|
|
16
|
+
* ONE USDC collateral pool. The per-field aggregation rule follows from that:
|
|
17
|
+
*
|
|
18
|
+
* - `accountValue` / `withdrawable` describe the WHOLE account. The dex holding
|
|
19
|
+
* a position reports full equity; every other view reports only free
|
|
20
|
+
* collateral; and `withdrawable` is identical in every view. So take the
|
|
21
|
+
* `max()`, NEVER the sum — summing double-counts the shared pool and sizes
|
|
22
|
+
* `margin_pct` positions ~2× too large.
|
|
23
|
+
* - `totalMarginUsed` / `totalUnrealizedPnl` / `totalNtlPos` are genuine
|
|
24
|
+
* per-dex usage of the shared pool → sum.
|
|
25
|
+
*
|
|
26
|
+
* Single-collateral-token assumption: this is correct while every dex shares
|
|
27
|
+
* one collateral (today all USDC). A dex on a different collateral (e.g. USDT
|
|
28
|
+
* CASH perps) would need grouping by collateral token — neither max nor sum is
|
|
29
|
+
* exact across collaterals. Equity/withdrawable are non-negative, so the `0`
|
|
30
|
+
* seed is a safe `max()` identity.
|
|
31
|
+
*/
|
|
32
|
+
export function foldDexSummary(totals, summary, withdrawable) {
|
|
33
|
+
if (summary) {
|
|
34
|
+
totals.accountValue = Math.max(totals.accountValue, asNumber(summary.accountValue) ?? 0);
|
|
35
|
+
totals.totalMarginUsed += asNumber(summary.totalMarginUsed) ?? 0;
|
|
36
|
+
totals.totalUnrealizedPnl += asNumber(summary.totalUnrealizedPnl) ?? 0;
|
|
37
|
+
totals.totalNtlPos += asNumber(summary.totalNtlPos) ?? 0;
|
|
38
|
+
}
|
|
39
|
+
totals.withdrawable = Math.max(totals.withdrawable, asNumber(withdrawable) ?? 0);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=clearing-house-aggregate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clearing-house-aggregate.js","sourceRoot":"","sources":["../../src/utils/clearing-house-aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAWzC,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,eAAe,EAAE,CAAC;QAClB,kBAAkB,EAAE,CAAC;QACrB,WAAW,EAAE,CAAC;KACf,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAwB,EACxB,OAA4C,EAC5C,YAAqB;IAErB,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACzF,MAAM,CAAC,eAAe,IAAI,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACjE,MAAM,CAAC,kBAAkB,IAAI,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -34,9 +34,9 @@ in the source repo and are ported **verbatim** into `scoring.py`.
|
|
|
34
34
|
Sizing rides on each signal's `data{}` so the `OPEN_POSITION` rule action sizes
|
|
35
35
|
identically to the source:
|
|
36
36
|
|
|
37
|
-
- **
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
- **marginPct** = percent of withdrawable (0–100): **20.0**. Dual-DEX equity is
|
|
38
|
+
collapsed via **`max()` not `sum()`** — one cross-margined wallet, two sub-DEX
|
|
39
|
+
views (summing double-counts the shared free balance → 2x sizing).
|
|
40
40
|
- **leverage** = `min(config leverage 3, MAX_LEVERAGE 5)`.
|
|
41
41
|
|
|
42
42
|
MCP tools used (all **read-only**): `market_get_asset_data` (4h candles),
|
|
@@ -109,7 +109,7 @@ map for the next tick.
|
|
|
109
109
|
### Action gate: `decision_mode: llm` → `rule`
|
|
110
110
|
|
|
111
111
|
The source `OPEN_POSITION` action used `decision_mode: llm` with a pass-through
|
|
112
|
-
prompt that copied the signal's `asset`/`direction`/`leverage`/`
|
|
112
|
+
prompt that copied the signal's `asset`/`direction`/`leverage`/`marginPct`
|
|
113
113
|
verbatim and pinned confidence — a rule wearing an LLM costume. This recipe uses
|
|
114
114
|
`decision_mode: rule` directly.
|
|
115
115
|
|
|
@@ -25,7 +25,7 @@ description: >
|
|
|
25
25
|
strategy:
|
|
26
26
|
wallet: "${IGUANA_WALLET}"
|
|
27
27
|
slots: 1 # source slots 1 (iguana emits <=1 signal/tick — two assets, one decision)
|
|
28
|
-
margin_pct: 20 # source margin_pct 20 (% of account per slot; scan.py carries the exact
|
|
28
|
+
margin_pct: 20 # source margin_pct 20 (% of account per slot; scan.py carries the exact marginPct)
|
|
29
29
|
default_leverage: 3 # source leverage 3 (capped at MAX_LEVERAGE 5 in scan.py)
|
|
30
30
|
trading_risk: conservative # source trading_risk conservative
|
|
31
31
|
enabled: true
|
|
@@ -29,9 +29,9 @@ ceiling on purpose.
|
|
|
29
29
|
|
|
30
30
|
Sizing — carried on each signal's data{} so the OPEN_POSITION rule action sizes
|
|
31
31
|
identically to the source:
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
- marginPct = percent of withdrawable (0–100), 20.0. Dual-DEX equity is
|
|
33
|
+
collapsed via max() (NOT sum()) — one cross-margined wallet, two sub-DEX
|
|
34
|
+
views; summing double-counts free balance -> 2x sizing.
|
|
35
35
|
- leverage = min(config leverage 3, MAX_LEVERAGE 5).
|
|
36
36
|
|
|
37
37
|
FLAGS — behaviors that changed under the v2 contract (NOT silent drops):
|
|
@@ -206,13 +206,12 @@ def scan(inputs, ctx):
|
|
|
206
206
|
if thesis is not None and thesis["score"] >= min_score:
|
|
207
207
|
coin = thesis["coin"]
|
|
208
208
|
if coin.upper() not in held_set:
|
|
209
|
-
margin_usd = round(account_value * margin_pct, 2)
|
|
210
209
|
# Stamp the 240s recent-signal dedup so we don't re-emit.
|
|
211
210
|
recent[coin.upper()] = now
|
|
212
211
|
out.append({
|
|
213
212
|
"asset": coin,
|
|
214
213
|
"direction": thesis["direction"],
|
|
215
|
-
"
|
|
214
|
+
"marginPct": round(margin_pct * 100, 2),
|
|
216
215
|
"leverage": float(leverage),
|
|
217
216
|
"data": {
|
|
218
217
|
"score": thesis["score"],
|
|
@@ -41,8 +41,8 @@ Quality-first copy-follow pipeline, run once per tick:
|
|
|
41
41
|
Sizing rides on each signal's `data{}` so the `OPEN_POSITION` rule action sizes
|
|
42
42
|
identically to the source:
|
|
43
43
|
|
|
44
|
-
- **
|
|
45
|
-
|
|
44
|
+
- **marginPct** = percent of withdrawable (0–100): **25.0** (**35.0** if
|
|
45
|
+
`score ≥ 10`). Dual-DEX equity is collapsed via **`max()` not `sum()`** —
|
|
46
46
|
one cross-margined wallet, two sub-DEX views.
|
|
47
47
|
- **leverage** = conviction tier (**≥10 → 10x, ≥8 → 8x, ≥6 → 7x**), clamped to
|
|
48
48
|
the per-asset Hyperliquid venue max via `strategy_get_asset_trading_limits`.
|
|
@@ -30,7 +30,7 @@ description: >
|
|
|
30
30
|
strategy:
|
|
31
31
|
wallet: "${RAPTOR_WALLET}"
|
|
32
32
|
slots: 2 # source slots 2 (raptor still emits <=1 signal/tick — see scan.py)
|
|
33
|
-
margin_pct: 25 # source margin_pct 25 (% of account per slot; scan.py carries the exact
|
|
33
|
+
margin_pct: 25 # source margin_pct 25 (% of account per slot; scan.py carries the exact marginPct)
|
|
34
34
|
default_leverage: 7 # source leverage.default 7 (conviction-tier 7/8/10x in scan.py, clamped per-asset)
|
|
35
35
|
trading_risk: moderate # source trading_risk moderate
|
|
36
36
|
enabled: true
|
|
@@ -36,9 +36,9 @@ emission ceiling on purpose.
|
|
|
36
36
|
|
|
37
37
|
Sizing — carried on each signal's data{} so the OPEN_POSITION rule action sizes
|
|
38
38
|
identically to the source:
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
- marginPct = percent of withdrawable (0–100), 25.0 (35.0 if score >= 10).
|
|
40
|
+
Dual-DEX equity is collapsed via max() (NOT sum()) — one cross-margined
|
|
41
|
+
wallet, two sub-DEX views; summing double-counts free balance.
|
|
42
42
|
- leverage = conviction tier (>=10 -> 10x, >=8 -> 8x, >=6 -> 7x), clamped to
|
|
43
43
|
the per-asset Hyperliquid venue max via strategy_get_asset_trading_limits.
|
|
44
44
|
|
|
@@ -297,9 +297,8 @@ def scan(inputs, ctx):
|
|
|
297
297
|
candidates.sort(key=lambda c: c["score"], reverse=True)
|
|
298
298
|
best = candidates[0]
|
|
299
299
|
if best["score"] >= min_score:
|
|
300
|
-
# Conviction-tier sizing.
|
|
300
|
+
# Conviction-tier sizing: emit percent of withdrawable (0–100).
|
|
301
301
|
margin_pct = margin_pct_high if best["score"] >= 10 else margin_pct_base
|
|
302
|
-
margin_usd = round(account_value * margin_pct, 2)
|
|
303
302
|
requested = scoring.get_leverage_for_score(
|
|
304
303
|
best["score"], scoring.LEVERAGE_TIERS, default_leverage)
|
|
305
304
|
leverage = _get_safe_leverage(ctx, best["asset"], requested)
|
|
@@ -310,7 +309,7 @@ def scan(inputs, ctx):
|
|
|
310
309
|
out.append({
|
|
311
310
|
"asset": best["asset"],
|
|
312
311
|
"direction": best["direction"],
|
|
313
|
-
"
|
|
312
|
+
"marginPct": round(margin_pct * 100, 2),
|
|
314
313
|
"leverage": float(leverage),
|
|
315
314
|
"data": {
|
|
316
315
|
"score": best["score"],
|
|
@@ -78,9 +78,9 @@ emitted at most `min(open_slots, affordable)` signals per tick, where
|
|
|
78
78
|
`affordable` was derived from free margin. In v2 the runtime owns slot count and
|
|
79
79
|
affordability (`strategy.slots` + the `risk.guard_rails`), so `scan()` emits
|
|
80
80
|
**every** candidate that clears `minScore` (after filtering held + recently
|
|
81
|
-
signaled assets) and carries
|
|
82
|
-
on each signal's
|
|
83
|
-
per-tick emission cap moved to the runtime.
|
|
81
|
+
signaled assets) and carries `marginPct` (percent of withdrawable, 0–100) +
|
|
82
|
+
venue-clamped `leverage` on each signal's top level. The signal-gating
|
|
83
|
+
thresholds are unchanged; only the per-tick emission cap moved to the runtime.
|
|
84
84
|
|
|
85
85
|
## Action gate
|
|
86
86
|
|
|
@@ -19,7 +19,7 @@ description: >
|
|
|
19
19
|
strategy:
|
|
20
20
|
wallet: "${SPIDER_SCALP_WALLET}"
|
|
21
21
|
slots: 4 # source maxSlots 4
|
|
22
|
-
margin_pct: 15 # source marginPct 0.15 →
|
|
22
|
+
margin_pct: 15 # source marginPct 0.15 → scan.py emits marginPct 15.0 (% of withdrawable)
|
|
23
23
|
default_leverage: 5 # source scalpMaxLeverage cap (clamped per-asset to HL venue max in scan.py)
|
|
24
24
|
trading_risk: moderate
|
|
25
25
|
enabled: true
|
|
@@ -19,7 +19,7 @@ description: >
|
|
|
19
19
|
strategy:
|
|
20
20
|
wallet: "${SPIDER_SWING_WALLET}"
|
|
21
21
|
slots: 3 # source maxSlots 3
|
|
22
|
-
margin_pct: 28 # source marginPct 0.28 →
|
|
22
|
+
margin_pct: 28 # source marginPct 0.28 → scan.py emits marginPct 28.0 (% of withdrawable)
|
|
23
23
|
default_leverage: 10 # source swingMaxLeverage cap (clamped per-asset to HL venue max in scan.py)
|
|
24
24
|
trading_risk: moderate
|
|
25
25
|
enabled: true
|
|
@@ -24,8 +24,8 @@ What was simplified vs the source (FLAGGED):
|
|
|
24
24
|
qualifying candidates above minScore (held + recently-signaled filtered).
|
|
25
25
|
The signal-GATING thresholds (minScore, held-set, recent-dedup, venue min
|
|
26
26
|
notional) are preserved exactly; only the per-tick emission CAP moves to the
|
|
27
|
-
runtime.
|
|
28
|
-
|
|
27
|
+
runtime. marginPct (percent of withdrawable, 0–100) is carried on each signal
|
|
28
|
+
so the action sizes identically to the source.
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
import sys
|
|
@@ -301,7 +301,7 @@ def scan(inputs, ctx):
|
|
|
301
301
|
out.append({
|
|
302
302
|
"asset": th["coin"],
|
|
303
303
|
"direction": th["direction"],
|
|
304
|
-
"
|
|
304
|
+
"marginPct": round(margin_pct * 100, 2),
|
|
305
305
|
"leverage": leverage,
|
|
306
306
|
"data": {
|
|
307
307
|
"score": th["score"],
|
|
@@ -13,8 +13,8 @@ recipe's `interval_seconds`.
|
|
|
13
13
|
|
|
14
14
|
| Leg | Thesis (identical signal) | Slots | Margin/slot | Lev | DSL exit |
|
|
15
15
|
|-----------|---------------------------|-------|-------------|-----|----------|
|
|
16
|
-
| `volume` | Funding-fade rotation | 7 |
|
|
17
|
-
| `runners` | Funding-fade rotation | 2 |
|
|
16
|
+
| `volume` | Funding-fade rotation | 7 | 20% withdrawable | 5x | force-close: 10-min hard timeout, phase1 max_loss 50 / retrace 30, **no phase2**, maker exit |
|
|
17
|
+
| `runners` | Funding-fade rotation | 2 | 20% withdrawable | 5x | patient: 4h hard timeout, weak_peak 90m@3 + dead_weight 120m, phase1 max_loss 30 / retrace 8, 5-tier phase2 (5/0·10/35·20/55·35/75·50/85), taker exit |
|
|
18
18
|
|
|
19
19
|
Both legs run the **identical** rotation alpha (same universe, same direction
|
|
20
20
|
logic, same gates). The wallet boundary selects DSL behavior: `volume` prints
|
|
@@ -59,7 +59,7 @@ turbine/
|
|
|
59
59
|
└── scoring.py # pure rotation/direction/spread functions (unit-tested)
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
The per-leg sizing (`
|
|
62
|
+
The per-leg sizing (`marginPct`, `leverage`, `maxSlots`) rides on each recipe's
|
|
63
63
|
`inputs:` block, so the one `scan.py` emits correctly-sized signals for whichever
|
|
64
64
|
leg supervises it.
|
|
65
65
|
|
|
@@ -127,9 +127,10 @@ The source computed `effective_slots = min(maxSlots, account_value /
|
|
|
127
127
|
margin_per_slot)` and emitted at most that many signals per tick. In v2 the
|
|
128
128
|
runtime owns slot count (`strategy.slots`) and affordability (`risk.guard_rails`),
|
|
129
129
|
so `scan()` emits all candidates clearing the gates (held + cooldown + spread),
|
|
130
|
-
carrying `
|
|
131
|
-
at `maxSlots` candidates (the rotation only advances
|
|
132
|
-
scanner doesn't flood the queue; the runtime makes the
|
|
130
|
+
carrying `marginPct` (percent of withdrawable) + `leverage` on each signal's top
|
|
131
|
+
level. It still caps a tick at `maxSlots` candidates (the rotation only advances
|
|
132
|
+
that many times) so the scanner doesn't flood the queue; the runtime makes the
|
|
133
|
+
final open/skip decision.
|
|
133
134
|
|
|
134
135
|
### Kept: non-deterministic `random` picks
|
|
135
136
|
|
|
@@ -161,6 +162,8 @@ v2 recipes use `decision_mode: rule` directly.
|
|
|
161
162
|
### Sizing source of truth
|
|
162
163
|
|
|
163
164
|
The source had margin/slot drift across files (700/1300 in config v3.3 vs
|
|
164
|
-
500/950 producer defaults vs YAML). This port uses **config v3.3
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
500/950 producer defaults vs YAML). This port uses **config v3.3** proportions:
|
|
166
|
+
volume 7 slots, runners 2 slots, both 5x, `xyzWeight 0.80`, spread main 3 bps /
|
|
167
|
+
xyz 10 bps. Sizing is now `marginPct` (percent of withdrawable) set in each
|
|
168
|
+
recipe's `inputs:` block (default 20); the old fixed-USD amounts can't be
|
|
169
|
+
preserved as a percent without knowing account size.
|
|
@@ -23,7 +23,7 @@ description: >
|
|
|
23
23
|
strategy:
|
|
24
24
|
wallet: "${TURBINE_RUNNERS_WALLET}"
|
|
25
25
|
slots: 2 # source slots.runners 2
|
|
26
|
-
margin_per_slot: 100 # FALLBACK sizing — used only if a signal omits
|
|
26
|
+
margin_per_slot: 100 # FALLBACK sizing — used only if a signal omits marginPct. scan.py emits per-signal marginPct (% of withdrawable, from inputs below), which WINS. TEST 100; prod source margin.runners 1300 (config v3.3)
|
|
27
27
|
default_leverage: 5 # source leverage.runners 5 (clamped per-asset in scan.py)
|
|
28
28
|
trading_risk: moderate # source trading_risk balanced → nearest v2 tier moderate
|
|
29
29
|
enabled: true
|
|
@@ -48,7 +48,7 @@ scanners:
|
|
|
48
48
|
spreadXyzBps: 10 # source spread.xyzBps 10
|
|
49
49
|
# ── per-leg sizing (runners) ──
|
|
50
50
|
leverage: 5 # source leverage.runners 5
|
|
51
|
-
|
|
51
|
+
marginPct: 20 # per-signal % of withdrawable; scan.py emits it TOP-LEVEL → runtime honors it as the EFFECTIVE sizing (overrides margin_per_slot). 20 is an example default; prod source 1300 USD intent must be sized as a percent
|
|
52
52
|
maxSlots: 2 # source slots.runners 2 (per-tick emission ceiling)
|
|
53
53
|
signal_data_schema:
|
|
54
54
|
thesis: { type: string }
|
|
@@ -19,7 +19,7 @@ description: >
|
|
|
19
19
|
strategy:
|
|
20
20
|
wallet: "${TURBINE_VOLUME_WALLET}"
|
|
21
21
|
slots: 7 # source slots.volume 7
|
|
22
|
-
margin_per_slot: 100 # FALLBACK sizing — used only if a signal omits
|
|
22
|
+
margin_per_slot: 100 # FALLBACK sizing — used only if a signal omits marginPct. scan.py emits per-signal marginPct (% of withdrawable, from inputs below), which WINS. TEST 100; prod source margin.volume 700 (config v3.3)
|
|
23
23
|
default_leverage: 5 # source leverage.volume 5 (clamped per-asset in scan.py)
|
|
24
24
|
trading_risk: aggressive # source trading_risk aggressive
|
|
25
25
|
enabled: true
|
|
@@ -44,7 +44,7 @@ scanners:
|
|
|
44
44
|
spreadXyzBps: 10 # source spread.xyzBps 10
|
|
45
45
|
# ── per-leg sizing (volume) ──
|
|
46
46
|
leverage: 5 # source leverage.volume 5
|
|
47
|
-
|
|
47
|
+
marginPct: 20 # per-signal % of withdrawable; scan.py emits it TOP-LEVEL → runtime honors it as the EFFECTIVE sizing (overrides margin_per_slot). 20 is an example default; prod source 700 USD intent must be sized as a percent
|
|
48
48
|
maxSlots: 7 # source slots.volume 7 (per-tick emission ceiling)
|
|
49
49
|
signal_data_schema:
|
|
50
50
|
thesis: { type: string }
|
|
@@ -7,7 +7,7 @@ ONE scanner, TWO recipes. Turbine's two legs (volume + runners) ran the IDENTICA
|
|
|
7
7
|
rotation alpha on the source; only the DSL exit preset and the per-slot sizing differed, and
|
|
8
8
|
those live entirely in the recipe YAMLs. So both recipe-volume.yaml and recipe-runners.yaml
|
|
9
9
|
point `path: ./scanners` + `entrypoint: scan.py` at THIS one module. The `inputs` block carries
|
|
10
|
-
the per-leg sizing (
|
|
10
|
+
the per-leg sizing (marginPct, leverage, slots) so the same code emits correctly-sized signals
|
|
11
11
|
for whichever leg supervises it.
|
|
12
12
|
|
|
13
13
|
What stayed faithful to the source (see scoring.py — ported verbatim):
|
|
@@ -39,9 +39,10 @@ FLAGS — behaviors that changed under the v2 contract (do NOT read as silent dr
|
|
|
39
39
|
computed effective_slots = min(maxSlots, account_value / margin_per_slot) and emitted at
|
|
40
40
|
most that many signals per tick. In v2 the runtime owns slot count (strategy.slots) and
|
|
41
41
|
affordability (risk gates), so scan() emits ALL candidates clearing the gates (held +
|
|
42
|
-
cooldown + spread), carrying
|
|
43
|
-
at most `maxSlots` candidates per tick (the rotation only advances
|
|
44
|
-
scanner doesn't flood the queue, but the runtime makes the final
|
|
42
|
+
cooldown + spread), carrying marginPct (percent of withdrawable) + leverage at each signal's
|
|
43
|
+
TOP LEVEL. We still emit at most `maxSlots` candidates per tick (the rotation only advances
|
|
44
|
+
that many times) so the scanner doesn't flood the queue, but the runtime makes the final
|
|
45
|
+
open/skip decision.
|
|
45
46
|
|
|
46
47
|
3. random pool/direction picks are non-deterministic — kept verbatim (this is the source's
|
|
47
48
|
design: rotation desync + neutral-regime coin flip). Tests assert STRUCTURE (valid gated
|
|
@@ -186,7 +187,10 @@ def scan(inputs, ctx):
|
|
|
186
187
|
spread_main_bps = float(inputs.get("spreadMainBps", 3))
|
|
187
188
|
spread_xyz_bps = float(inputs.get("spreadXyzBps", 10))
|
|
188
189
|
leg_leverage = float(inputs.get("leverage", 5))
|
|
189
|
-
|
|
190
|
+
# marginPct: percent of withdrawable to size each slot (0–100). Default 20 is
|
|
191
|
+
# an example; the old fixed-USD intent can't be preserved as a percent without
|
|
192
|
+
# knowing account size. Set this in the recipe inputs: block.
|
|
193
|
+
margin_pct = float(inputs.get("marginPct", 20))
|
|
190
194
|
max_slots = int(inputs.get("maxSlots", 7))
|
|
191
195
|
|
|
192
196
|
held_set, _account_value = _get_held(ctx)
|
|
@@ -246,7 +250,7 @@ def scan(inputs, ctx):
|
|
|
246
250
|
out.append({
|
|
247
251
|
"asset": asset,
|
|
248
252
|
"direction": direction,
|
|
249
|
-
"
|
|
253
|
+
"marginPct": float(margin_pct),
|
|
250
254
|
"leverage": float(leverage),
|
|
251
255
|
"data": {
|
|
252
256
|
"thesis": thesis,
|
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.5",
|
|
6
6
|
"commandAliases": [
|
|
7
7
|
{
|
|
8
8
|
"name": "senpi"
|