@reefclaw/openclaw-plugin 0.1.5 → 0.1.7
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/bridge/gateway/event-parser.d.ts +6 -1
- package/bridge/gateway/event-parser.js +19 -2
- package/bridge/gateway/poller.d.ts +1 -0
- package/bridge/gateway/poller.js +14 -2
- package/bridge/providers/gateway.d.ts +22 -2
- package/bridge/providers/gateway.js +67 -9
- package/ccxt/binance-private.d.ts +21 -0
- package/ccxt/binance-private.js +132 -22
- package/ccxt/public-market-data-api.d.ts +14 -0
- package/ccxt/public-market-data-api.js +15 -1
- package/config/plugin-config-io.d.ts +13 -0
- package/config/plugin-config-io.js +15 -0
- package/config/tool-gate.js +3 -0
- package/exchange-adapter.d.ts +16 -0
- package/index.js +658 -83
- package/ingest/position-auto-capture.d.ts +68 -0
- package/ingest/position-auto-capture.js +321 -23
- package/ingest/position-decisions-client.d.ts +7 -2
- package/ingest/position-decisions-client.js +13 -3
- package/ingest/reconcile-db-vs-exchange.d.ts +39 -1
- package/ingest/reconcile-db-vs-exchange.js +66 -10
- package/lifecycle/trading-operation-lock.d.ts +17 -0
- package/lifecycle/trading-operation-lock.js +14 -0
- package/live/bracket-id.d.ts +2 -3
- package/live/bracket-id.js +22 -9
- package/live/fill-price.d.ts +13 -0
- package/live/fill-price.js +37 -0
- package/live/live-adapter.d.ts +57 -2
- package/live/live-adapter.js +290 -49
- package/live/local-signal-service.js +11 -6
- package/live/local-strategy-evaluator.js +4 -0
- package/live/position-state-store.d.ts +4 -0
- package/live/proposal-decision-listener.d.ts +6 -0
- package/live/proposal-decision-listener.js +4 -0
- package/live/stop-watcher.d.ts +35 -2
- package/live/stop-watcher.js +63 -3
- package/onboarding/runtime.d.ts +19 -0
- package/onboarding/runtime.js +34 -3
- package/openclaw.plugin.json +1 -0
- package/package.json +2 -2
- package/portfolio/reentry-tracker.d.ts +36 -0
- package/portfolio/reentry-tracker.js +127 -0
- package/portfolio/wave9-admission.d.ts +67 -0
- package/portfolio/wave9-admission.js +262 -0
- package/portfolio/wave9-policy.d.ts +36 -0
- package/portfolio/wave9-policy.js +183 -0
- package/signals/conditions/registry.js +61 -2
- package/signals/strategy-adapter.js +17 -7
- package/simulator/exchange-simulator.d.ts +12 -0
- package/simulator/exchange-simulator.js +78 -3
- package/simulator/fill-engine.js +5 -1
- package/simulator/types.d.ts +10 -1
- package/skills/reefclaw/SKILL.md +2 -0
- package/strategy/evaluator.d.ts +3 -0
- package/strategy/evaluator.js +5 -0
- package/tools/assessment-validation.d.ts +23 -0
- package/tools/assessment-validation.js +58 -0
- package/tools/attach-brackets.d.ts +7 -2
- package/tools/attach-brackets.js +201 -0
- package/tools/audit-bracket-protection.js +157 -1
- package/tools/bracket-control.d.ts +12 -0
- package/tools/bracket-control.js +35 -0
- package/tools/cancel-all-orders.d.ts +2 -0
- package/tools/cancel-all-orders.js +4 -1
- package/tools/cancel-order.d.ts +4 -0
- package/tools/cancel-order.js +49 -3
- package/tools/close-position.d.ts +23 -0
- package/tools/close-position.js +286 -13
- package/tools/create-order.d.ts +28 -0
- package/tools/create-order.js +1390 -190
- package/tools/get-analytics.js +2 -2
- package/tools/get-basis.js +2 -2
- package/tools/get-cascade-risk.js +2 -2
- package/tools/get-crypto-metrics.js +14 -4
- package/tools/get-cvd.js +2 -2
- package/tools/get-divergences.js +2 -2
- package/tools/get-funding-context.js +2 -2
- package/tools/get-liquidation-levels.js +2 -2
- package/tools/get-liquidation-pulse.js +2 -2
- package/tools/get-pattern-scan.js +2 -2
- package/tools/get-regime.js +2 -2
- package/tools/get-resting-liquidity.js +2 -2
- package/tools/get-risk-scenario.js +2 -2
- package/tools/get-session-review.js +2 -2
- package/tools/get-setup-detail.js +21 -2
- package/tools/get-signals.js +2 -2
- package/tools/get-sizing.js +2 -2
- package/tools/get-trade-feedback.js +2 -2
- package/tools/get-trade-flow.js +2 -2
- package/tools/get-volume-profile.js +2 -2
- package/tools/get-wave9-status.d.ts +127 -0
- package/tools/get-wave9-status.js +796 -0
- package/tools/intel-api.d.ts +20 -0
- package/tools/intel-api.js +67 -0
- package/tools/intel-cache.d.ts +1 -1
- package/tools/intel-cache.js +20 -5
- package/tools/list-strategies.d.ts +11 -1
- package/tools/list-strategies.js +17 -0
- package/tools/modify-stop.d.ts +4 -0
- package/tools/modify-stop.js +63 -24
- package/tools/modify-target.d.ts +4 -0
- package/tools/modify-target.js +62 -23
- package/tools/scan-pairs.d.ts +4 -0
- package/tools/scan-pairs.js +22 -8
- package/tools/toggle-strategy.js +7 -0
- package/types.d.ts +5 -0
- package/venues/hyperliquid/hl-balance.d.ts +116 -0
- package/venues/hyperliquid/hl-balance.js +145 -0
- package/venues/hyperliquid/hl-bracket-coordinator.d.ts +123 -0
- package/venues/hyperliquid/hl-bracket-coordinator.js +533 -0
- package/venues/hyperliquid/hl-brackets.d.ts +102 -0
- package/venues/hyperliquid/hl-brackets.js +172 -0
- package/venues/hyperliquid/hl-cloid.d.ts +22 -0
- package/venues/hyperliquid/hl-cloid.js +82 -0
- package/venues/hyperliquid/hl-info-cache.d.ts +46 -0
- package/venues/hyperliquid/hl-info-cache.js +125 -0
- package/venues/hyperliquid/hl-live-adapter.d.ts +146 -0
- package/venues/hyperliquid/hl-live-adapter.js +728 -0
- package/venues/hyperliquid/hl-precision.d.ts +61 -0
- package/venues/hyperliquid/hl-precision.js +176 -0
- package/venues/hyperliquid/hl-private.d.ts +88 -0
- package/venues/hyperliquid/hl-private.js +357 -0
- package/venues/hyperliquid/hl-public.d.ts +31 -4
- package/venues/hyperliquid/hl-public.js +163 -12
- package/venues/hyperliquid/hl-rate-gate.d.ts +57 -0
- package/venues/hyperliquid/hl-rate-gate.js +220 -0
- package/venues/hyperliquid/hl-user-stream.d.ts +90 -0
- package/venues/hyperliquid/hl-user-stream.js +220 -0
- package/venues/registry.d.ts +23 -9
- package/venues/registry.js +12 -13
- package/venues/symbols.d.ts +43 -0
- package/venues/symbols.js +107 -0
- package/wave9/live-account-capture.d.ts +67 -0
- package/wave9/live-account-capture.js +435 -0
- package/wave9/live-autonomous-protection.d.ts +39 -0
- package/wave9/live-autonomous-protection.js +112 -0
- package/wave9/live-durable-reconciliation-scheduler.d.ts +33 -0
- package/wave9/live-durable-reconciliation-scheduler.js +115 -0
- package/wave9/live-execution-ledger.d.ts +107 -0
- package/wave9/live-execution-ledger.js +498 -0
- package/wave9/live-position-confirmation.d.ts +18 -0
- package/wave9/live-position-confirmation.js +111 -0
- package/wave9/live-residual-protection.d.ts +18 -0
- package/wave9/live-residual-protection.js +250 -0
- package/wave9/live-startup-reconciliation.d.ts +38 -0
- package/wave9/live-startup-reconciliation.js +454 -0
- package/wave9/live-symbol-ownership.d.ts +20 -0
- package/wave9/live-symbol-ownership.js +132 -0
- package/wave9/paper-admission-guard.d.ts +199 -0
- package/wave9/paper-admission-guard.js +650 -0
- package/wave9/usdm-evidence-provider.d.ts +42 -0
- package/wave9/usdm-evidence-provider.js +133 -0
package/tools/get-analytics.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Tool: get_analytics — fetches edge analytics from the Intelligence API.
|
|
2
2
|
// Returns per-strategy performance metrics (win rate, expectancy, Sharpe),
|
|
3
3
|
// regime breakdown, equity curve, and degradation alerts.
|
|
4
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
4
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
5
5
|
export async function getAnalyticsTool(args, deps) {
|
|
6
|
-
return fetchIntelApi(`/api/analytics/${enc(args.symbol)}`, deps);
|
|
6
|
+
return fetchIntelApi(`/api/analytics/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
7
7
|
}
|
package/tools/get-basis.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Tool: get_basis — fetches spot-futures basis (mark-spot premium) analysis.
|
|
2
2
|
// Returns current premium/discount, historical basis, funding alignment, and dislocation detection.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getBasisTool(args, deps) {
|
|
5
5
|
const hours = args.hours ?? 24;
|
|
6
|
-
return fetchIntelApi(`/api/basis/${enc(args.symbol)}?hours=${hours}`, deps);
|
|
6
|
+
return fetchIntelApi(`/api/basis/${enc(resolveIntelSymbol(deps, args.symbol))}?hours=${hours}`, deps);
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Tool: get_cascade_risk — fetches liquidation cascade risk assessment.
|
|
2
2
|
// Returns proximity to liquidation clusters, cascade impact estimates,
|
|
3
3
|
// recent liquidation activity, and overall risk score.
|
|
4
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
4
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
5
5
|
export async function getCascadeRiskTool(args, deps) {
|
|
6
6
|
const hours = args.hours ?? 24;
|
|
7
|
-
return fetchIntelApi(`/api/cascade-risk/${enc(args.symbol)}?hours=${hours}`, deps);
|
|
7
|
+
return fetchIntelApi(`/api/cascade-risk/${enc(resolveIntelSymbol(deps, args.symbol))}?hours=${hours}`, deps);
|
|
8
8
|
}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
// Tool: get_crypto_metrics — funding rate + open interest from Binance perpetual futures
|
|
2
2
|
// Uses dedicated CCXT methods (fetchFundingRate + fetchOpenInterest) instead of fetchTicker,
|
|
3
3
|
// because Binance's 24hr ticker endpoint does NOT include funding/OI data.
|
|
4
|
+
import { fromIntelSymbol } from '../venues/symbols.js';
|
|
4
5
|
export async function getCryptoMetricsTool(args, deps) {
|
|
5
6
|
try {
|
|
7
|
+
// The agent routinely pastes intel-form ids into this tool ('ETHUSDT',
|
|
8
|
+
// 'HL_BTC' — ~100×/day live as of 2026-07-13). Handed to ccxt verbatim, a
|
|
9
|
+
// concatenated id resolves to the SPOT market and funding/OI fail
|
|
10
|
+
// ("supports linear and inverse contracts only"). Map both intel
|
|
11
|
+
// namespaces back to canonical BASE/QUOTE first; anything fromIntelSymbol
|
|
12
|
+
// can't map comes back verbatim (honest passthrough, no invented quote).
|
|
13
|
+
const canonical = args.symbol.includes('/') || args.symbol.includes(':')
|
|
14
|
+
? args.symbol
|
|
15
|
+
: fromIntelSymbol(args.symbol.trim()).canonical;
|
|
6
16
|
// Funding rate & OI only exist on perpetual futures. Convert a canonical
|
|
7
17
|
// symbol to its linear-perp ccxt form by settling in the QUOTE currency
|
|
8
18
|
// (BTC/USDT → BTC/USDT:USDT on Binance, BTC/USDC → BTC/USDC:USDC on
|
|
9
19
|
// Hyperliquid). A hardcoded :USDT suffix produced the nonsense form
|
|
10
20
|
// BTC/USDC:USDT on the HL venue (seen live, wisekid soak 2026-07-12) —
|
|
11
21
|
// never silently translate quote assets across venues.
|
|
12
|
-
const quote =
|
|
13
|
-
const perpSymbol =
|
|
14
|
-
?
|
|
15
|
-
: `${
|
|
22
|
+
const quote = canonical.split('/')[1];
|
|
23
|
+
const perpSymbol = canonical.includes(':') || !quote
|
|
24
|
+
? canonical
|
|
25
|
+
: `${canonical}:${quote}`;
|
|
16
26
|
// Fetch funding rate and open interest in parallel (separate API endpoints)
|
|
17
27
|
const [fundingData, oiData, tickerData] = await Promise.all([
|
|
18
28
|
deps.binanceApi.fetchFundingRate(perpSymbol),
|
package/tools/get-cvd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Tool: get_cvd — fetches CVD (Cumulative Volume Delta) analysis from the Intelligence API.
|
|
2
2
|
// Returns buy/sell pressure, divergence detection, slope, z-score, and interpretation.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getCvdTool(args, deps) {
|
|
5
|
-
return fetchIntelApi(`/api/cvd/${enc(args.symbol)}`, deps);
|
|
5
|
+
return fetchIntelApi(`/api/cvd/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
6
6
|
}
|
package/tools/get-divergences.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Tool: get_divergences — multi-timeframe RSI/MACD divergence scanner.
|
|
2
2
|
// Detects price-vs-indicator divergences across 15m, 1h, 4h, 1d timeframes.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getDivergencesTool(args, deps) {
|
|
5
|
-
return fetchIntelApi(`/api/divergences/${enc(args.symbol)}`, deps);
|
|
5
|
+
return fetchIntelApi(`/api/divergences/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
6
6
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Returns `{ enabled: false, reason }` when the intel-side
|
|
12
12
|
// FUNDING_OVERLAY flag is off or the symbol has < 100 30d samples.
|
|
13
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
13
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
14
14
|
export async function getFundingContextTool(args, deps) {
|
|
15
|
-
return fetchIntelApi(`/api/funding/${enc(args.symbol)}`, deps);
|
|
15
|
+
return fetchIntelApi(`/api/funding/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Tool: get_liquidation_levels — fetches liquidation levels from the Intelligence API.
|
|
2
2
|
// Returns historical liquidation clusters and estimated liquidation levels around current price.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getLiquidationLevelsTool(args, deps) {
|
|
5
5
|
const hours = args.hours ?? 24;
|
|
6
|
-
return fetchIntelApi(`/api/liquidation-levels/${enc(args.symbol)}?hours=${hours}`, deps);
|
|
6
|
+
return fetchIntelApi(`/api/liquidation-levels/${enc(resolveIntelSymbol(deps, args.symbol))}?hours=${hours}`, deps);
|
|
7
7
|
}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
// When the intel-side `microstructure.liquidationPulse` flag is off,
|
|
7
7
|
// returns `{ enabled: false, reason }` — operator hasn't enabled the
|
|
8
8
|
// feature yet.
|
|
9
|
-
import { fetchIntelApi } from './intel-api.js';
|
|
9
|
+
import { fetchIntelApi, resolveIntelSymbol } from './intel-api.js';
|
|
10
10
|
export async function getLiquidationPulseTool(args, deps) {
|
|
11
11
|
const params = new URLSearchParams();
|
|
12
12
|
if (args.symbol)
|
|
13
|
-
params.set('symbol', args.symbol);
|
|
13
|
+
params.set('symbol', resolveIntelSymbol(deps, args.symbol));
|
|
14
14
|
const windowSeconds = clamp(args.window_seconds ?? 60, 5, 300);
|
|
15
15
|
params.set('window_seconds', String(windowSeconds));
|
|
16
16
|
return fetchIntelApi(`/api/liquidation-pulse?${params.toString()}`, deps);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Tool: get_pattern_scan — automated chart pattern recognition from OHLCV data.
|
|
2
2
|
// Calls Intelligence API for swing points, trendlines, and 10 pattern types.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getPatternScanTool(args, deps) {
|
|
5
|
-
const intelSymbol = args.symbol
|
|
5
|
+
const intelSymbol = resolveIntelSymbol(deps, args.symbol);
|
|
6
6
|
const timeframe = args.timeframe ?? '1h';
|
|
7
7
|
return fetchIntelApi(`/api/patterns/${enc(intelSymbol)}?timeframe=${enc(timeframe)}&lookback=200`, deps);
|
|
8
8
|
}
|
package/tools/get-regime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Tool: get_regime — fetches regime classification from the Intelligence API.
|
|
2
2
|
// Returns current market regime (trend_up, trend_down, range_tight, etc.)
|
|
3
3
|
// with confidence, probabilities, and contributing features.
|
|
4
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
4
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
5
5
|
export async function getRegimeTool(args, deps) {
|
|
6
|
-
return fetchIntelApi(`/api/regime/${enc(args.symbol)}`, deps);
|
|
6
|
+
return fetchIntelApi(`/api/regime/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Returns `{ enabled: false, reason }` when the intel-side
|
|
7
7
|
// `microstructure.bandedLiquidity` flag is off (= columns are NULL).
|
|
8
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
8
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
9
9
|
export async function getRestingLiquidityTool(args, deps) {
|
|
10
|
-
return fetchIntelApi(`/api/resting-liquidity/${enc(args.symbol)}`, deps);
|
|
10
|
+
return fetchIntelApi(`/api/resting-liquidity/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
11
11
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Fetches positions + balance from simulator state, then calls Intelligence API for scenario analysis.
|
|
3
3
|
// Returns: per-scenario P&L, heat, drawdown zone, stops triggered, limits breached.
|
|
4
4
|
import { enc } from './intel-api.js';
|
|
5
|
-
import { fetchIntelApi } from './intel-api.js';
|
|
5
|
+
import { fetchIntelApi, resolveIntelSymbol } from './intel-api.js';
|
|
6
6
|
export async function getRiskScenarioTool(args, deps) {
|
|
7
7
|
const positions = deps.getPositions();
|
|
8
8
|
const wallet = deps.getWallet();
|
|
@@ -34,7 +34,7 @@ export async function getRiskScenarioTool(args, deps) {
|
|
|
34
34
|
})).filter(s => !isNaN(s.movePct));
|
|
35
35
|
}
|
|
36
36
|
// Normalize symbol for intelligence API (BTC/USDT → BTCUSDT)
|
|
37
|
-
const intelSymbol = args.symbol
|
|
37
|
+
const intelSymbol = resolveIntelSymbol(deps.intelApiDeps, args.symbol);
|
|
38
38
|
const body = {
|
|
39
39
|
positions: apiPositions,
|
|
40
40
|
balance,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Tool: get_session_review — automated end-of-session performance summary.
|
|
2
2
|
// Calls Intelligence API for trade stats, setup/regime breakdown, lessons, and session-over-session comparison.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getSessionReviewTool(args, deps) {
|
|
5
|
-
const intelSymbol = args.symbol
|
|
5
|
+
const intelSymbol = resolveIntelSymbol(deps, args.symbol);
|
|
6
6
|
const hours = args.hours ?? 24;
|
|
7
7
|
return fetchIntelApi(`/api/session-review/${enc(intelSymbol)}?hours=${hours}`, deps);
|
|
8
8
|
}
|
|
@@ -14,10 +14,18 @@
|
|
|
14
14
|
// that direction so long and short setups produce ladders that match.
|
|
15
15
|
// Cache is shared with scan_pairs (intel-cache.ts) so drill-down sees the
|
|
16
16
|
// same fact snapshot the scan ranked the symbol from.
|
|
17
|
+
import { resolveIntelSymbol } from './intel-api.js';
|
|
17
18
|
import { evaluateStrategy, } from '../strategy/evaluator.js';
|
|
18
19
|
import { getFactBySymbolCached, getStrategyRowsCached } from './intel-cache.js';
|
|
19
20
|
export async function getSetupDetailTool(args, deps) {
|
|
20
|
-
|
|
21
|
+
// Venue-aware symbol resolution (plan §5.3). Binance keeps the historical
|
|
22
|
+
// sanitizer byte-identically; the hyperliquid arm maps agent-facing forms
|
|
23
|
+
// ('BTC/USDC', 'BTCUSDC') to the HL_ intel namespace and must NOT uppercase
|
|
24
|
+
// or strip '_' — HL coins are case-sensitive ('kPEPE' is real, 'KPEPE' is
|
|
25
|
+
// not) and the legacy sanitizer would mangle 'HL_BTC' into 'HLBTC'.
|
|
26
|
+
const symbol = (deps.venue ?? 'binance') === 'hyperliquid'
|
|
27
|
+
? resolveIntelSymbol(deps, args.symbol)
|
|
28
|
+
: args.symbol.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
|
21
29
|
// 1. Fetch fact for this symbol — shared cache with scan_pairs, so a
|
|
22
30
|
// drill-down after a heartbeat scan hits the same snapshot the scan
|
|
23
31
|
// ranked the symbol from.
|
|
@@ -299,5 +307,16 @@ function computeStop(strategy, atr, entryPrice, direction) {
|
|
|
299
307
|
}
|
|
300
308
|
}
|
|
301
309
|
function roundPrice(p) {
|
|
302
|
-
|
|
310
|
+
// 2 decimals for $1+ prices; below that, 6 significant digits — a flat
|
|
311
|
+
// 2-decimal round collapses entry/stop/targets onto the same value for the
|
|
312
|
+
// sub-cent class (1000PEPE/1000SHIB/…, ATR below the $0.01 granularity),
|
|
313
|
+
// tripping the zero-risk guard and refusing every setup on those symbols.
|
|
314
|
+
if (!Number.isFinite(p) || p === 0)
|
|
315
|
+
return p;
|
|
316
|
+
const abs = Math.abs(p);
|
|
317
|
+
if (abs >= 1)
|
|
318
|
+
return Math.round(p * 100) / 100;
|
|
319
|
+
const decimals = 5 - Math.floor(Math.log10(abs));
|
|
320
|
+
const f = Math.pow(10, decimals);
|
|
321
|
+
return Math.round(p * f) / f;
|
|
303
322
|
}
|
package/tools/get-signals.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// comparison (zero behaviour change).
|
|
8
8
|
// enforce — return the locally-evaluated snapshot, falling back to central
|
|
9
9
|
// when the local service has no fact for the symbol yet.
|
|
10
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
10
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
11
11
|
async function central(args, deps) {
|
|
12
|
-
const s = enc(args.symbol);
|
|
12
|
+
const s = enc(resolveIntelSymbol(deps, args.symbol));
|
|
13
13
|
const [snapshot, history] = await Promise.all([
|
|
14
14
|
fetchIntelApi(`/api/signals/${s}`, deps),
|
|
15
15
|
fetchIntelApi(`/api/signals/${s}/history?hours=${args.hours ?? 24}`, deps),
|
package/tools/get-sizing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Tool: get_sizing — fetches Half-Kelly position sizing recommendation from Intelligence API.
|
|
2
2
|
// Returns recommended size as % of account, Kelly fraction, win rate, avg W/L ratio, vol adjustment.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getSizingTool(args, deps) {
|
|
5
|
-
return fetchIntelApi(`/api/sizing/${enc(args.symbol)}`, deps);
|
|
5
|
+
return fetchIntelApi(`/api/sizing/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
6
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Tool: get_trade_feedback — fetches structured performance feedback from Intelligence API.
|
|
2
2
|
// Returns per-setup-type win rates, regime breakdown, recent outcomes, and current streak.
|
|
3
3
|
// Designed for the agent to review before entering trades.
|
|
4
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
4
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
5
5
|
export async function getTradeFeedbackTool(args, deps) {
|
|
6
6
|
const hours = args.hours ?? 168;
|
|
7
|
-
return fetchIntelApi(`/api/analytics/${enc(args.symbol)}/feedback?hours=${hours}`, deps);
|
|
7
|
+
return fetchIntelApi(`/api/analytics/${enc(resolveIntelSymbol(deps, args.symbol))}/feedback?hours=${hours}`, deps);
|
|
8
8
|
}
|
package/tools/get-trade-flow.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Tool: get_trade_flow — fetches aggregated trade flow / institutional flow data.
|
|
2
2
|
// Returns buy/sell volume, large trade (whale) activity, net delta, and whale pressure verdict.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getTradeFlowTool(args, deps) {
|
|
5
5
|
const minutes = args.minutes ?? 5;
|
|
6
|
-
return fetchIntelApi(`/api/trade-flow/${enc(args.symbol)}?minutes=${minutes}`, deps);
|
|
6
|
+
return fetchIntelApi(`/api/trade-flow/${enc(resolveIntelSymbol(deps, args.symbol))}?minutes=${minutes}`, deps);
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Tool: get_volume_profile — fetches volume profile from the Intelligence API.
|
|
2
2
|
// Returns price buckets with buy/sell volume, POC, value area, and current price.
|
|
3
|
-
import { fetchIntelApi, enc } from './intel-api.js';
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
4
|
export async function getVolumeProfileTool(args, deps) {
|
|
5
5
|
const period = args.period ?? 24;
|
|
6
|
-
return fetchIntelApi(`/api/volume-profile/${enc(args.symbol)}?period=${period}`, deps);
|
|
6
|
+
return fetchIntelApi(`/api/volume-profile/${enc(resolveIntelSymbol(deps, args.symbol))}?period=${period}`, deps);
|
|
7
7
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { evaluateWave9Daily, type Wave9StrategyName } from '../portfolio/wave9-policy.js';
|
|
2
|
+
import { type Wave9EvidenceProvider } from '../wave9/usdm-evidence-provider.js';
|
|
3
|
+
import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
|
|
4
|
+
import type { Wave9NativeStopObservation } from '../wave9/live-account-capture.js';
|
|
5
|
+
import type { Wave9ExecutionMode } from '../wave9/paper-admission-guard.js';
|
|
6
|
+
import type { IntelApiDeps } from './intel-api.js';
|
|
7
|
+
export declare const WAVE9_BUNDLE_NAME = "wave9_28d_momentum_reversal";
|
|
8
|
+
export declare const WAVE9_EXECUTION_KERNEL = "wave9_shared_v1";
|
|
9
|
+
export declare const WAVE9_PAPER_ENTRY_WINDOW_MS: number;
|
|
10
|
+
export interface Wave9BundleActivation {
|
|
11
|
+
available: boolean;
|
|
12
|
+
name: typeof WAVE9_BUNDLE_NAME;
|
|
13
|
+
executionModel: typeof WAVE9_EXECUTION_KERNEL;
|
|
14
|
+
active: boolean;
|
|
15
|
+
source?: 'tenant_override' | 'global_default';
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Wave9ActivationClient {
|
|
19
|
+
getActivation(): Promise<Wave9BundleActivation>;
|
|
20
|
+
}
|
|
21
|
+
export declare class IntelWave9ActivationClient implements Wave9ActivationClient {
|
|
22
|
+
private readonly deps;
|
|
23
|
+
constructor(deps: IntelApiDeps);
|
|
24
|
+
getActivation(): Promise<Wave9BundleActivation>;
|
|
25
|
+
}
|
|
26
|
+
export interface Wave9ObservedPosition {
|
|
27
|
+
symbol: string;
|
|
28
|
+
side: 'long' | 'short';
|
|
29
|
+
quantity: number;
|
|
30
|
+
entryPrice: number;
|
|
31
|
+
markPrice: number;
|
|
32
|
+
stopPrice?: number;
|
|
33
|
+
missionId?: string;
|
|
34
|
+
setupType?: string;
|
|
35
|
+
/** Present only after an exact Wave 9 admission has recorded it. */
|
|
36
|
+
candidateId?: string;
|
|
37
|
+
/** Optional future durable geometry for authoritative open-book projection. */
|
|
38
|
+
strategy?: Wave9StrategyName;
|
|
39
|
+
accruedFundingUsd?: number;
|
|
40
|
+
openedAt?: string;
|
|
41
|
+
/** Exchange-native stop identity and liveness bound by LIVE capture. */
|
|
42
|
+
nativeStop?: Wave9NativeStopObservation;
|
|
43
|
+
/** Stable held-position geometry, excluding mark/MFE/wallet volatility. */
|
|
44
|
+
positionFingerprint?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface Wave9AccountSnapshot {
|
|
47
|
+
tradingMode: 'PAPER' | 'SHADOW' | 'MICRO_LIVE' | 'LIVE';
|
|
48
|
+
positionsAvailable: boolean;
|
|
49
|
+
openOrdersAvailable: boolean;
|
|
50
|
+
openOrderCount?: number;
|
|
51
|
+
/** Wallet cash after booked fees/realized PnL, not MTM account equity. */
|
|
52
|
+
cashEquityAvailable: boolean;
|
|
53
|
+
cashEquityUsd?: number;
|
|
54
|
+
positions?: Wave9ObservedPosition[];
|
|
55
|
+
/** Persisted closed Wave 9 identities; survives a gateway restart. */
|
|
56
|
+
executedCandidateIds?: string[];
|
|
57
|
+
source: string;
|
|
58
|
+
/** Exact process-local account geometry bound into short-lived guards. */
|
|
59
|
+
accountFingerprint?: string;
|
|
60
|
+
authoritative: boolean;
|
|
61
|
+
runtimeParity: false;
|
|
62
|
+
provenance: string;
|
|
63
|
+
adapterReadiness?: string;
|
|
64
|
+
nativeStopProtectionAvailable?: boolean;
|
|
65
|
+
reasons?: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface Wave9EntryAuthorizationInput {
|
|
68
|
+
batchId: string;
|
|
69
|
+
candidateId: string;
|
|
70
|
+
missionId: string;
|
|
71
|
+
symbol: string;
|
|
72
|
+
side: 'BUY' | 'SELL';
|
|
73
|
+
quantity: string;
|
|
74
|
+
stopPrice: string;
|
|
75
|
+
sequence: number;
|
|
76
|
+
notBeforeMs: number;
|
|
77
|
+
deadlineMs: number;
|
|
78
|
+
accountFingerprint: string;
|
|
79
|
+
tradingMode: Wave9ExecutionMode;
|
|
80
|
+
}
|
|
81
|
+
export interface Wave9IssuedEntryAuthorization {
|
|
82
|
+
token: string;
|
|
83
|
+
batchId: string;
|
|
84
|
+
candidateId: string;
|
|
85
|
+
missionId: string;
|
|
86
|
+
sequence: number;
|
|
87
|
+
deadlineMs: number;
|
|
88
|
+
accountFingerprint: string;
|
|
89
|
+
tradingMode: Wave9ExecutionMode;
|
|
90
|
+
}
|
|
91
|
+
export interface Wave9ExitAuthorizationInput {
|
|
92
|
+
candidateId: string;
|
|
93
|
+
missionId: string;
|
|
94
|
+
symbol: string;
|
|
95
|
+
positionSide: 'long' | 'short';
|
|
96
|
+
reason: 'signal_reversal';
|
|
97
|
+
notBeforeMs: number;
|
|
98
|
+
deadlineMs: number;
|
|
99
|
+
positionFingerprint: string;
|
|
100
|
+
tradingMode: Wave9ExecutionMode;
|
|
101
|
+
}
|
|
102
|
+
export interface Wave9IssuedExitAuthorization {
|
|
103
|
+
token: string;
|
|
104
|
+
candidateId: string;
|
|
105
|
+
missionId: string;
|
|
106
|
+
deadlineMs: number;
|
|
107
|
+
positionFingerprint?: string;
|
|
108
|
+
tradingMode: Wave9ExecutionMode;
|
|
109
|
+
}
|
|
110
|
+
/** Structural seam implemented by the process-local paper admission guard. */
|
|
111
|
+
export interface Wave9AdmissionAuthorizationIssuer {
|
|
112
|
+
issueBatch(decisions: readonly Wave9EntryAuthorizationInput[]): readonly Wave9IssuedEntryAuthorization[];
|
|
113
|
+
issueExitBatch(decisions: readonly Wave9ExitAuthorizationInput[]): readonly Wave9IssuedExitAuthorization[];
|
|
114
|
+
}
|
|
115
|
+
export interface GetWave9StatusDeps {
|
|
116
|
+
activationClient: Wave9ActivationClient;
|
|
117
|
+
getAccountSnapshot(): Promise<Wave9AccountSnapshot>;
|
|
118
|
+
operationLock: TradingOperationLock;
|
|
119
|
+
/** Wave 9 evidence and execution are pinned to Binance USD-M. */
|
|
120
|
+
executionVenue: string;
|
|
121
|
+
createEvidenceProvider?: () => Wave9EvidenceProvider;
|
|
122
|
+
authorizationIssuer?: Wave9AdmissionAuthorizationIssuer;
|
|
123
|
+
now?: () => Date;
|
|
124
|
+
evaluateDaily?: typeof evaluateWave9Daily;
|
|
125
|
+
}
|
|
126
|
+
export declare function wave9MissionId(candidateId: string): string;
|
|
127
|
+
export declare function getWave9StatusTool(deps: GetWave9StatusDeps): Promise<Record<string, unknown>>;
|