@reefclaw/connect 0.1.12 → 0.1.14
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/assets/plugin/audit/mode-transition-audit.d.ts +11 -0
- package/assets/plugin/audit/mode-transition-audit.js +29 -0
- package/assets/plugin/balance-utils.d.ts +36 -0
- package/assets/plugin/balance-utils.js +98 -0
- package/assets/plugin/ccxt/binance-ban-gate.d.ts +47 -0
- package/assets/plugin/ccxt/binance-ban-gate.js +420 -0
- package/assets/plugin/ccxt/binance-private.d.ts +346 -0
- package/assets/plugin/ccxt/binance-private.js +1525 -0
- package/assets/plugin/ccxt/binance-public.d.ts +34 -0
- package/assets/plugin/ccxt/binance-public.js +180 -0
- package/assets/plugin/ccxt/intel-public.d.ts +25 -0
- package/assets/plugin/ccxt/intel-public.js +80 -0
- package/assets/plugin/ccxt/public-market-data-api.d.ts +26 -0
- package/assets/plugin/ccxt/public-market-data-api.js +23 -0
- package/assets/plugin/config/agent-config-client.d.ts +77 -0
- package/assets/plugin/config/agent-config-client.js +188 -0
- package/assets/plugin/config/agent-config-poller.d.ts +32 -0
- package/assets/plugin/config/agent-config-poller.js +101 -0
- package/assets/plugin/config/brackets-config.d.ts +22 -0
- package/assets/plugin/config/brackets-config.js +58 -0
- package/assets/plugin/config/entitlement-gate.d.ts +51 -0
- package/assets/plugin/config/entitlement-gate.js +137 -0
- package/assets/plugin/config/gate-store.d.ts +18 -0
- package/assets/plugin/config/gate-store.js +61 -0
- package/assets/plugin/config/plugin-config-io.d.ts +222 -0
- package/assets/plugin/config/plugin-config-io.js +126 -0
- package/assets/plugin/config/position-review-config.d.ts +35 -0
- package/assets/plugin/config/position-review-config.js +105 -0
- package/assets/plugin/config/tool-gate.d.ts +53 -0
- package/assets/plugin/config/tool-gate.js +128 -0
- package/assets/plugin/config/user-data-stream-config.d.ts +89 -0
- package/assets/plugin/config/user-data-stream-config.js +239 -0
- package/assets/plugin/connector-supervisor.d.ts +36 -0
- package/assets/plugin/connector-supervisor.js +149 -0
- package/assets/plugin/exchange-adapter.d.ts +65 -0
- package/assets/plugin/exchange-adapter.js +4 -0
- package/assets/plugin/index.d.ts +30 -0
- package/assets/plugin/index.js +2763 -0
- package/assets/plugin/ingest/pending-entry-metadata.d.ts +74 -0
- package/assets/plugin/ingest/pending-entry-metadata.js +236 -0
- package/assets/plugin/ingest/position-auto-capture.d.ts +171 -0
- package/assets/plugin/ingest/position-auto-capture.js +709 -0
- package/assets/plugin/ingest/position-decisions-client.d.ts +327 -0
- package/assets/plugin/ingest/position-decisions-client.js +306 -0
- package/assets/plugin/ingest/readiness-reporter.d.ts +42 -0
- package/assets/plugin/ingest/readiness-reporter.js +163 -0
- package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +51 -0
- package/assets/plugin/ingest/reconcile-db-vs-exchange.js +170 -0
- package/assets/plugin/ingest/reconciler-cleanup.d.ts +37 -0
- package/assets/plugin/ingest/reconciler-cleanup.js +147 -0
- package/assets/plugin/ingest/rest-gap-filler.d.ts +191 -0
- package/assets/plugin/ingest/rest-gap-filler.js +565 -0
- package/assets/plugin/ingest/touched-symbols-store.d.ts +25 -0
- package/assets/plugin/ingest/touched-symbols-store.js +96 -0
- package/assets/plugin/ingest/trade-store-client.d.ts +40 -0
- package/assets/plugin/ingest/trade-store-client.js +125 -0
- package/assets/plugin/ingest/ws-ingest.d.ts +43 -0
- package/assets/plugin/ingest/ws-ingest.js +126 -0
- package/assets/plugin/learning/setup-family.d.ts +21 -0
- package/assets/plugin/learning/setup-family.js +103 -0
- package/assets/plugin/lifecycle/install-signal-handlers.d.ts +33 -0
- package/assets/plugin/lifecycle/install-signal-handlers.js +112 -0
- package/assets/plugin/lifecycle/shutdown-coordinator.d.ts +43 -0
- package/assets/plugin/lifecycle/shutdown-coordinator.js +131 -0
- package/assets/plugin/lifecycle/trading-operation-lock.d.ts +17 -0
- package/assets/plugin/lifecycle/trading-operation-lock.js +14 -0
- package/assets/plugin/live/bracket-id.d.ts +26 -0
- package/assets/plugin/live/bracket-id.js +112 -0
- package/assets/plugin/live/bracket-ledger.d.ts +54 -0
- package/assets/plugin/live/bracket-ledger.js +267 -0
- package/assets/plugin/live/bracket-manager.d.ts +82 -0
- package/assets/plugin/live/bracket-manager.js +478 -0
- package/assets/plugin/live/bracket-params.d.ts +22 -0
- package/assets/plugin/live/bracket-params.js +124 -0
- package/assets/plugin/live/bracket-reconciler.d.ts +95 -0
- package/assets/plugin/live/bracket-reconciler.js +573 -0
- package/assets/plugin/live/bracket-types.d.ts +102 -0
- package/assets/plugin/live/bracket-types.js +8 -0
- package/assets/plugin/live/deposit-tracker.d.ts +62 -0
- package/assets/plugin/live/deposit-tracker.js +97 -0
- package/assets/plugin/live/emergency-controls.d.ts +32 -0
- package/assets/plugin/live/emergency-controls.js +226 -0
- package/assets/plugin/live/exchange-errors.d.ts +12 -0
- package/assets/plugin/live/exchange-errors.js +130 -0
- package/assets/plugin/live/exchange-info-cache.d.ts +37 -0
- package/assets/plugin/live/exchange-info-cache.js +134 -0
- package/assets/plugin/live/fact-subscriber.d.ts +78 -0
- package/assets/plugin/live/fact-subscriber.js +182 -0
- package/assets/plugin/live/fill-price.d.ts +13 -0
- package/assets/plugin/live/fill-price.js +37 -0
- package/assets/plugin/live/intent-journal.d.ts +42 -0
- package/assets/plugin/live/intent-journal.js +122 -0
- package/assets/plugin/live/listen-key-manager.d.ts +70 -0
- package/assets/plugin/live/listen-key-manager.js +169 -0
- package/assets/plugin/live/live-adapter.d.ts +319 -0
- package/assets/plugin/live/live-adapter.js +1906 -0
- package/assets/plugin/live/live-balance-enricher.d.ts +32 -0
- package/assets/plugin/live/live-balance-enricher.js +104 -0
- package/assets/plugin/live/live-bracket-api.d.ts +13 -0
- package/assets/plugin/live/live-bracket-api.js +20 -0
- package/assets/plugin/live/live-state-store.d.ts +194 -0
- package/assets/plugin/live/live-state-store.js +450 -0
- package/assets/plugin/live/local-signal-service.d.ts +57 -0
- package/assets/plugin/live/local-signal-service.js +151 -0
- package/assets/plugin/live/local-strategy-evaluator.d.ts +62 -0
- package/assets/plugin/live/local-strategy-evaluator.js +131 -0
- package/assets/plugin/live/microstructure-assembler.d.ts +54 -0
- package/assets/plugin/live/microstructure-assembler.js +148 -0
- package/assets/plugin/live/order-poller.d.ts +29 -0
- package/assets/plugin/live/order-poller.js +125 -0
- package/assets/plugin/live/position-state-store.d.ts +87 -0
- package/assets/plugin/live/position-state-store.js +237 -0
- package/assets/plugin/live/proposal-decision-listener.d.ts +70 -0
- package/assets/plugin/live/proposal-decision-listener.js +292 -0
- package/assets/plugin/live/proposal-manager.d.ts +76 -0
- package/assets/plugin/live/proposal-manager.js +140 -0
- package/assets/plugin/live/rate-limiter.d.ts +47 -0
- package/assets/plugin/live/rate-limiter.js +159 -0
- package/assets/plugin/live/reconciler.d.ts +39 -0
- package/assets/plugin/live/reconciler.js +175 -0
- package/assets/plugin/live/setup-buckets.d.ts +7 -0
- package/assets/plugin/live/setup-buckets.js +33 -0
- package/assets/plugin/live/slippage-tracker.d.ts +45 -0
- package/assets/plugin/live/slippage-tracker.js +78 -0
- package/assets/plugin/live/stop-watcher.d.ts +67 -0
- package/assets/plugin/live/stop-watcher.js +218 -0
- package/assets/plugin/live/user-data-active-probe.d.ts +54 -0
- package/assets/plugin/live/user-data-active-probe.js +180 -0
- package/assets/plugin/live/user-data-stream-controller.d.ts +200 -0
- package/assets/plugin/live/user-data-stream-controller.js +579 -0
- package/assets/plugin/live/user-data-stream-ws.d.ts +22 -0
- package/assets/plugin/live/user-data-stream-ws.js +63 -0
- package/assets/plugin/live/user-data-stream.d.ts +243 -0
- package/assets/plugin/live/user-data-stream.js +704 -0
- package/assets/plugin/logger.d.ts +2 -0
- package/assets/plugin/logger.js +2 -0
- package/assets/plugin/mfe.d.ts +21 -0
- package/assets/plugin/mfe.js +68 -0
- package/assets/plugin/onboarding/mode-ladder.d.ts +1 -0
- package/assets/plugin/onboarding/mode-ladder.js +3 -0
- package/assets/plugin/onboarding/runtime.d.ts +102 -0
- package/assets/plugin/onboarding/runtime.js +215 -0
- package/assets/plugin/openclaw.plugin.json +92 -0
- package/assets/plugin/paper-adapter.d.ts +24 -0
- package/assets/plugin/paper-adapter.js +91 -0
- package/assets/plugin/persistence/state-manager.d.ts +66 -0
- package/assets/plugin/persistence/state-manager.js +222 -0
- package/assets/plugin/pinned-plan.d.ts +9 -0
- package/assets/plugin/pinned-plan.js +23 -0
- package/assets/plugin/portfolio/reentry-tracker.d.ts +36 -0
- package/assets/plugin/portfolio/reentry-tracker.js +127 -0
- package/assets/plugin/portfolio/wave9-admission.d.ts +67 -0
- package/assets/plugin/portfolio/wave9-admission.js +262 -0
- package/assets/plugin/portfolio/wave9-policy.d.ts +36 -0
- package/assets/plugin/portfolio/wave9-policy.js +183 -0
- package/assets/plugin/risk/pre-trade-check.d.ts +38 -0
- package/assets/plugin/risk/pre-trade-check.js +345 -0
- package/assets/plugin/risk/pre-trade-types.d.ts +60 -0
- package/assets/plugin/risk/pre-trade-types.js +3 -0
- package/assets/plugin/shadow/shadow-tracker.d.ts +36 -0
- package/assets/plugin/shadow/shadow-tracker.js +151 -0
- package/assets/plugin/shadow/types.d.ts +42 -0
- package/assets/plugin/shadow/types.js +20 -0
- package/assets/plugin/shared/indicators-extended.d.ts +52 -0
- package/assets/plugin/shared/indicators-extended.js +291 -0
- package/assets/plugin/shared/indicators.d.ts +15 -0
- package/assets/plugin/shared/indicators.js +114 -0
- package/assets/plugin/signals/conditions/registry.d.ts +16 -0
- package/assets/plugin/signals/conditions/registry.js +1333 -0
- package/assets/plugin/signals/conditions/types.d.ts +1 -0
- package/assets/plugin/signals/conditions/types.js +4 -0
- package/assets/plugin/signals/direction-rules.d.ts +3 -0
- package/assets/plugin/signals/direction-rules.js +24 -0
- package/assets/plugin/signals/entry-rules.d.ts +6 -0
- package/assets/plugin/signals/entry-rules.js +33 -0
- package/assets/plugin/signals/serialize-context.d.ts +4 -0
- package/assets/plugin/signals/serialize-context.js +39 -0
- package/assets/plugin/signals/stop-rules.d.ts +3 -0
- package/assets/plugin/signals/stop-rules.js +48 -0
- package/assets/plugin/signals/strategy-adapter.d.ts +47 -0
- package/assets/plugin/signals/strategy-adapter.js +209 -0
- package/assets/plugin/signals/types.d.ts +1 -0
- package/assets/plugin/signals/types.js +8 -0
- package/assets/plugin/simulator/exchange-simulator.d.ts +105 -0
- package/assets/plugin/simulator/exchange-simulator.js +759 -0
- package/assets/plugin/simulator/fill-engine.d.ts +53 -0
- package/assets/plugin/simulator/fill-engine.js +280 -0
- package/assets/plugin/simulator/paper-market-feed.d.ts +26 -0
- package/assets/plugin/simulator/paper-market-feed.js +104 -0
- package/assets/plugin/simulator/realistic-fills.d.ts +59 -0
- package/assets/plugin/simulator/realistic-fills.js +175 -0
- package/assets/plugin/simulator/types.d.ts +228 -0
- package/assets/plugin/simulator/types.js +43 -0
- package/assets/plugin/strategy/builtin-strategies.d.ts +2 -0
- package/assets/plugin/strategy/builtin-strategies.js +113 -0
- package/assets/plugin/strategy/condition-registry.d.ts +3 -0
- package/assets/plugin/strategy/condition-registry.js +153 -0
- package/assets/plugin/strategy/evaluator.d.ts +70 -0
- package/assets/plugin/strategy/evaluator.js +98 -0
- package/assets/plugin/tools/assessment-validation.d.ts +141 -0
- package/assets/plugin/tools/assessment-validation.js +473 -0
- package/assets/plugin/tools/attach-brackets.d.ts +39 -0
- package/assets/plugin/tools/attach-brackets.js +564 -0
- package/assets/plugin/tools/audit-bracket-protection.d.ts +49 -0
- package/assets/plugin/tools/audit-bracket-protection.js +683 -0
- package/assets/plugin/tools/bracket-control.d.ts +12 -0
- package/assets/plugin/tools/bracket-control.js +35 -0
- package/assets/plugin/tools/cancel-all-orders.d.ts +9 -0
- package/assets/plugin/tools/cancel-all-orders.js +8 -0
- package/assets/plugin/tools/cancel-order.d.ts +14 -0
- package/assets/plugin/tools/cancel-order.js +60 -0
- package/assets/plugin/tools/check-position-health.d.ts +46 -0
- package/assets/plugin/tools/check-position-health.js +194 -0
- package/assets/plugin/tools/clear-exchange-credentials.d.ts +24 -0
- package/assets/plugin/tools/clear-exchange-credentials.js +70 -0
- package/assets/plugin/tools/close-position.d.ts +45 -0
- package/assets/plugin/tools/close-position.js +722 -0
- package/assets/plugin/tools/create-order.d.ts +89 -0
- package/assets/plugin/tools/create-order.js +1555 -0
- package/assets/plugin/tools/exit-gate.d.ts +58 -0
- package/assets/plugin/tools/exit-gate.js +162 -0
- package/assets/plugin/tools/fetch-balance.d.ts +5 -0
- package/assets/plugin/tools/fetch-balance.js +4 -0
- package/assets/plugin/tools/fetch-ohlcv.d.ts +11 -0
- package/assets/plugin/tools/fetch-ohlcv.js +8 -0
- package/assets/plugin/tools/fetch-open-orders.d.ts +7 -0
- package/assets/plugin/tools/fetch-open-orders.js +4 -0
- package/assets/plugin/tools/fetch-positions.d.ts +7 -0
- package/assets/plugin/tools/fetch-positions.js +4 -0
- package/assets/plugin/tools/fetch-ticker.d.ts +11 -0
- package/assets/plugin/tools/fetch-ticker.js +5 -0
- package/assets/plugin/tools/get-agent-profile.d.ts +4 -0
- package/assets/plugin/tools/get-agent-profile.js +6 -0
- package/assets/plugin/tools/get-analytics.d.ts +6 -0
- package/assets/plugin/tools/get-analytics.js +7 -0
- package/assets/plugin/tools/get-backtest.d.ts +12 -0
- package/assets/plugin/tools/get-backtest.js +91 -0
- package/assets/plugin/tools/get-basis.d.ts +7 -0
- package/assets/plugin/tools/get-basis.js +7 -0
- package/assets/plugin/tools/get-bracket-config.d.ts +11 -0
- package/assets/plugin/tools/get-bracket-config.js +24 -0
- package/assets/plugin/tools/get-cascade-risk.d.ts +7 -0
- package/assets/plugin/tools/get-cascade-risk.js +8 -0
- package/assets/plugin/tools/get-crypto-metrics.d.ts +18 -0
- package/assets/plugin/tools/get-crypto-metrics.js +62 -0
- package/assets/plugin/tools/get-cvd.d.ts +6 -0
- package/assets/plugin/tools/get-cvd.js +6 -0
- package/assets/plugin/tools/get-divergences.d.ts +6 -0
- package/assets/plugin/tools/get-divergences.js +6 -0
- package/assets/plugin/tools/get-funding-context.d.ts +6 -0
- package/assets/plugin/tools/get-funding-context.js +16 -0
- package/assets/plugin/tools/get-liquidation-levels.d.ts +7 -0
- package/assets/plugin/tools/get-liquidation-levels.js +7 -0
- package/assets/plugin/tools/get-liquidation-pulse.d.ts +9 -0
- package/assets/plugin/tools/get-liquidation-pulse.js +22 -0
- package/assets/plugin/tools/get-market-breadth.d.ts +6 -0
- package/assets/plugin/tools/get-market-breadth.js +8 -0
- package/assets/plugin/tools/get-market-intel.d.ts +19 -0
- package/assets/plugin/tools/get-market-intel.js +116 -0
- package/assets/plugin/tools/get-market-structure.d.ts +47 -0
- package/assets/plugin/tools/get-market-structure.js +198 -0
- package/assets/plugin/tools/get-my-mined-patterns.d.ts +20 -0
- package/assets/plugin/tools/get-my-mined-patterns.js +61 -0
- package/assets/plugin/tools/get-my-proposed-learnings.d.ts +20 -0
- package/assets/plugin/tools/get-my-proposed-learnings.js +55 -0
- package/assets/plugin/tools/get-my-recent-reviews.d.ts +22 -0
- package/assets/plugin/tools/get-my-recent-reviews.js +66 -0
- package/assets/plugin/tools/get-orderbook.d.ts +21 -0
- package/assets/plugin/tools/get-orderbook.js +32 -0
- package/assets/plugin/tools/get-pattern-scan.d.ts +7 -0
- package/assets/plugin/tools/get-pattern-scan.js +8 -0
- package/assets/plugin/tools/get-regime.d.ts +6 -0
- package/assets/plugin/tools/get-regime.js +7 -0
- package/assets/plugin/tools/get-relevant-learnings.d.ts +21 -0
- package/assets/plugin/tools/get-relevant-learnings.js +65 -0
- package/assets/plugin/tools/get-resting-liquidity.d.ts +6 -0
- package/assets/plugin/tools/get-resting-liquidity.js +11 -0
- package/assets/plugin/tools/get-risk-scenario.d.ts +29 -0
- package/assets/plugin/tools/get-risk-scenario.js +47 -0
- package/assets/plugin/tools/get-risk-summary.d.ts +51 -0
- package/assets/plugin/tools/get-risk-summary.js +118 -0
- package/assets/plugin/tools/get-sentiment.d.ts +4 -0
- package/assets/plugin/tools/get-sentiment.js +6 -0
- package/assets/plugin/tools/get-session-review.d.ts +7 -0
- package/assets/plugin/tools/get-session-review.js +8 -0
- package/assets/plugin/tools/get-setup-detail.d.ts +7 -0
- package/assets/plugin/tools/get-setup-detail.js +322 -0
- package/assets/plugin/tools/get-signals.d.ts +15 -0
- package/assets/plugin/tools/get-signals.js +54 -0
- package/assets/plugin/tools/get-sizing.d.ts +6 -0
- package/assets/plugin/tools/get-sizing.js +6 -0
- package/assets/plugin/tools/get-trade-feedback.d.ts +7 -0
- package/assets/plugin/tools/get-trade-feedback.js +8 -0
- package/assets/plugin/tools/get-trade-flow.d.ts +7 -0
- package/assets/plugin/tools/get-trade-flow.js +7 -0
- package/assets/plugin/tools/get-volume-analysis.d.ts +21 -0
- package/assets/plugin/tools/get-volume-analysis.js +74 -0
- package/assets/plugin/tools/get-volume-profile.d.ts +7 -0
- package/assets/plugin/tools/get-volume-profile.js +7 -0
- package/assets/plugin/tools/get-wave9-status.d.ts +127 -0
- package/assets/plugin/tools/get-wave9-status.js +796 -0
- package/assets/plugin/tools/helpers.d.ts +26 -0
- package/assets/plugin/tools/helpers.js +39 -0
- package/assets/plugin/tools/intel-api.d.ts +34 -0
- package/assets/plugin/tools/intel-api.js +119 -0
- package/assets/plugin/tools/intel-cache.d.ts +25 -0
- package/assets/plugin/tools/intel-cache.js +148 -0
- package/assets/plugin/tools/list-strategies.d.ts +17 -0
- package/assets/plugin/tools/list-strategies.js +23 -0
- package/assets/plugin/tools/modify-stop.d.ts +21 -0
- package/assets/plugin/tools/modify-stop.js +120 -0
- package/assets/plugin/tools/modify-target.d.ts +21 -0
- package/assets/plugin/tools/modify-target.js +110 -0
- package/assets/plugin/tools/propose-learning.d.ts +22 -0
- package/assets/plugin/tools/propose-learning.js +65 -0
- package/assets/plugin/tools/query-review-outcomes.d.ts +30 -0
- package/assets/plugin/tools/query-review-outcomes.js +64 -0
- package/assets/plugin/tools/query-trades.d.ts +21 -0
- package/assets/plugin/tools/query-trades.js +37 -0
- package/assets/plugin/tools/record-position-reviews.d.ts +38 -0
- package/assets/plugin/tools/record-position-reviews.js +147 -0
- package/assets/plugin/tools/save-strategy.d.ts +16 -0
- package/assets/plugin/tools/save-strategy.js +46 -0
- package/assets/plugin/tools/scan-pairs.d.ts +22 -0
- package/assets/plugin/tools/scan-pairs.js +234 -0
- package/assets/plugin/tools/score-setup.d.ts +31 -0
- package/assets/plugin/tools/score-setup.js +268 -0
- package/assets/plugin/tools/set-bracket-requirement.d.ts +18 -0
- package/assets/plugin/tools/set-bracket-requirement.js +81 -0
- package/assets/plugin/tools/set-exchange-credentials.d.ts +25 -0
- package/assets/plugin/tools/set-exchange-credentials.js +80 -0
- package/assets/plugin/tools/set-trading-mode.d.ts +26 -0
- package/assets/plugin/tools/set-trading-mode.js +152 -0
- package/assets/plugin/tools/test-exchange-credentials.d.ts +16 -0
- package/assets/plugin/tools/test-exchange-credentials.js +100 -0
- package/assets/plugin/tools/toggle-strategy.d.ts +8 -0
- package/assets/plugin/tools/toggle-strategy.js +15 -0
- package/assets/plugin/trading-params-cache.d.ts +26 -0
- package/assets/plugin/trading-params-cache.js +52 -0
- package/assets/plugin/types.d.ts +134 -0
- package/assets/plugin/types.js +7 -0
- package/assets/plugin/util/plugin-paths.d.ts +3 -0
- package/assets/plugin/util/plugin-paths.js +15 -0
- package/assets/plugin/venues/hyperliquid/hl-balance.d.ts +116 -0
- package/assets/plugin/venues/hyperliquid/hl-balance.js +145 -0
- package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.d.ts +123 -0
- package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.js +533 -0
- package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +102 -0
- package/assets/plugin/venues/hyperliquid/hl-brackets.js +172 -0
- package/assets/plugin/venues/hyperliquid/hl-cloid.d.ts +22 -0
- package/assets/plugin/venues/hyperliquid/hl-cloid.js +82 -0
- package/assets/plugin/venues/hyperliquid/hl-info-cache.d.ts +46 -0
- package/assets/plugin/venues/hyperliquid/hl-info-cache.js +125 -0
- package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +146 -0
- package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +728 -0
- package/assets/plugin/venues/hyperliquid/hl-precision.d.ts +61 -0
- package/assets/plugin/venues/hyperliquid/hl-precision.js +176 -0
- package/assets/plugin/venues/hyperliquid/hl-private.d.ts +88 -0
- package/assets/plugin/venues/hyperliquid/hl-private.js +357 -0
- package/assets/plugin/venues/hyperliquid/hl-public.d.ts +79 -0
- package/assets/plugin/venues/hyperliquid/hl-public.js +436 -0
- package/assets/plugin/venues/hyperliquid/hl-rate-gate.d.ts +57 -0
- package/assets/plugin/venues/hyperliquid/hl-rate-gate.js +220 -0
- package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +90 -0
- package/assets/plugin/venues/hyperliquid/hl-user-stream.js +220 -0
- package/assets/plugin/venues/registry.d.ts +38 -0
- package/assets/plugin/venues/registry.js +46 -0
- package/assets/plugin/venues/symbols.d.ts +43 -0
- package/assets/plugin/venues/symbols.js +107 -0
- package/assets/plugin/wave9/live-account-capture.d.ts +67 -0
- package/assets/plugin/wave9/live-account-capture.js +435 -0
- package/assets/plugin/wave9/live-autonomous-protection.d.ts +39 -0
- package/assets/plugin/wave9/live-autonomous-protection.js +112 -0
- package/assets/plugin/wave9/live-durable-reconciliation-scheduler.d.ts +33 -0
- package/assets/plugin/wave9/live-durable-reconciliation-scheduler.js +115 -0
- package/assets/plugin/wave9/live-execution-ledger.d.ts +107 -0
- package/assets/plugin/wave9/live-execution-ledger.js +498 -0
- package/assets/plugin/wave9/live-position-confirmation.d.ts +18 -0
- package/assets/plugin/wave9/live-position-confirmation.js +111 -0
- package/assets/plugin/wave9/live-residual-protection.d.ts +18 -0
- package/assets/plugin/wave9/live-residual-protection.js +250 -0
- package/assets/plugin/wave9/live-startup-reconciliation.d.ts +38 -0
- package/assets/plugin/wave9/live-startup-reconciliation.js +454 -0
- package/assets/plugin/wave9/live-symbol-ownership.d.ts +20 -0
- package/assets/plugin/wave9/live-symbol-ownership.js +132 -0
- package/assets/plugin/wave9/paper-admission-guard.d.ts +199 -0
- package/assets/plugin/wave9/paper-admission-guard.js +650 -0
- package/assets/plugin/wave9/usdm-evidence-provider.d.ts +42 -0
- package/assets/plugin/wave9/usdm-evidence-provider.js +133 -0
- package/dist/plugin.js +24 -15
- package/package.json +1 -1
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
// Tool: get_setup_detail — detailed setup info for a specific symbol.
|
|
2
|
+
// Fetches the symbol's fact, evaluates best-matching strategy,
|
|
3
|
+
// computes entry/stop/targets, returns full detail (~500 tokens).
|
|
4
|
+
//
|
|
5
|
+
// 2026-05-15 hardening: this tool used to (a) silently zero entry/stop/target
|
|
6
|
+
// when `currentPrice` or `atr14` were missing from the fact (the 1000PEPE
|
|
7
|
+
// "zeroed levels" pattern, ~5 occurrences in one session) and (b) always
|
|
8
|
+
// compute a LONG-style ladder regardless of the strategy's directionRule
|
|
9
|
+
// (the AVAX/SUI/TIA "TREND_DOWN label + LONG geometry" pattern). Both surface
|
|
10
|
+
// as the agent rejecting setups as "data integrity failure" or "directionally
|
|
11
|
+
// inconsistent" and standing down. Now we (1) refuse-to-emit when key
|
|
12
|
+
// indicators are missing, (2) resolve direction via the strategy's
|
|
13
|
+
// directionRule + fact context, and (3) compute stop/target geometry from
|
|
14
|
+
// that direction so long and short setups produce ladders that match.
|
|
15
|
+
// Cache is shared with scan_pairs (intel-cache.ts) so drill-down sees the
|
|
16
|
+
// same fact snapshot the scan ranked the symbol from.
|
|
17
|
+
import { resolveIntelSymbol } from './intel-api.js';
|
|
18
|
+
import { evaluateStrategy, } from '../strategy/evaluator.js';
|
|
19
|
+
import { getFactBySymbolCached, getStrategyRowsCached } from './intel-cache.js';
|
|
20
|
+
export async function getSetupDetailTool(args, deps) {
|
|
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, '');
|
|
29
|
+
// 1. Fetch fact for this symbol — shared cache with scan_pairs, so a
|
|
30
|
+
// drill-down after a heartbeat scan hits the same snapshot the scan
|
|
31
|
+
// ranked the symbol from.
|
|
32
|
+
const factRes = await getFactBySymbolCached(symbol, deps);
|
|
33
|
+
if ('error' in factRes)
|
|
34
|
+
return factRes;
|
|
35
|
+
const fact = factRes;
|
|
36
|
+
if (!fact.symbol) {
|
|
37
|
+
return { error: `No facts available for ${symbol}` };
|
|
38
|
+
}
|
|
39
|
+
// 2. Fetch user's active strategy rows (cached, shared with scan_pairs).
|
|
40
|
+
const rowsRes = await getStrategyRowsCached(deps);
|
|
41
|
+
if ('error' in rowsRes)
|
|
42
|
+
return rowsRes;
|
|
43
|
+
const strategyRows = rowsRes;
|
|
44
|
+
// 3. Evaluate all strategies, pick best match
|
|
45
|
+
let bestResult = null;
|
|
46
|
+
let bestScore = -1;
|
|
47
|
+
for (const row of strategyRows) {
|
|
48
|
+
const result = evaluateStrategy(row.config, fact);
|
|
49
|
+
if (result && result.score > bestScore) {
|
|
50
|
+
bestScore = result.score;
|
|
51
|
+
bestResult = result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Validate indicators BEFORE branching on bestResult — even the "no setup"
|
|
55
|
+
// path returns price, and a zero/missing price is misleading.
|
|
56
|
+
const price = readNumericIndicator(fact, 'currentPrice');
|
|
57
|
+
if (price === null) {
|
|
58
|
+
return {
|
|
59
|
+
error: `Fact for ${symbol} is missing currentPrice — intelligence fact-computer ` +
|
|
60
|
+
`may still be warming up, or this symbol has no recent klines. Retry on ` +
|
|
61
|
+
`next heartbeat; do not size a trade off this payload.`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (!bestResult) {
|
|
65
|
+
return {
|
|
66
|
+
symbol,
|
|
67
|
+
price,
|
|
68
|
+
regime: fact.regime,
|
|
69
|
+
regime_confidence: fact.regime_confidence,
|
|
70
|
+
setup: 'none',
|
|
71
|
+
note: 'No active strategy matches this symbol\'s current conditions.',
|
|
72
|
+
indicators: buildIndicatorSummary(fact),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// 4. Validate that the inputs needed for stop/target geometry are present.
|
|
76
|
+
const atr = readNumericIndicator(fact, 'atr14');
|
|
77
|
+
if (atr === null || atr <= 0) {
|
|
78
|
+
return {
|
|
79
|
+
error: `Fact for ${symbol} is missing atr14 (got ${atr ?? 'undefined'}) — cannot ` +
|
|
80
|
+
`compute stop/target geometry without ATR. Retry on next heartbeat.`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// 5. Resolve direction from the strategy's directionRule. Refuse to emit a
|
|
84
|
+
// setup when direction is ambiguous — better to return no setup than to
|
|
85
|
+
// fabricate a long ladder for what might be a short trade.
|
|
86
|
+
const strategyConfig = strategyRows.find(r => r.config.name === bestResult.strategy)?.config;
|
|
87
|
+
if (!strategyConfig) {
|
|
88
|
+
return {
|
|
89
|
+
error: `Internal: strategy ${bestResult.strategy} matched but its config ` +
|
|
90
|
+
`disappeared between scan and drill-down. Retry on next heartbeat.`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const direction = resolveDirection(strategyConfig, fact);
|
|
94
|
+
if (direction === null) {
|
|
95
|
+
return {
|
|
96
|
+
symbol: fact.symbol,
|
|
97
|
+
price,
|
|
98
|
+
regime: fact.regime,
|
|
99
|
+
regime_confidence: fact.regime_confidence,
|
|
100
|
+
strategy: bestResult.strategy,
|
|
101
|
+
score: bestResult.score,
|
|
102
|
+
setup: 'ambiguous_direction',
|
|
103
|
+
note: `Strategy ${bestResult.strategy} matched but its directionRule ` +
|
|
104
|
+
`(${strategyConfig.directionRule}) could not resolve a clean long/short ` +
|
|
105
|
+
`from the current fact (regime=${fact.regime}). Skip — wait for cleaner ` +
|
|
106
|
+
`context or run score_setup with an explicit direction if you want to force the trade.`,
|
|
107
|
+
indicators: buildIndicatorSummary(fact),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// 6. Compute entry/stop/targets from the matching strategy + direction.
|
|
111
|
+
const entry = computeEntry(strategyConfig, fact, atr, price);
|
|
112
|
+
const stop = computeStop(strategyConfig, atr, entry.price, direction);
|
|
113
|
+
const risk = Math.abs(entry.price - stop.price);
|
|
114
|
+
// Sanity check: if risk collapsed to zero (rounding pathology, weird ATR),
|
|
115
|
+
// refuse rather than emit zeroed targets that look executable.
|
|
116
|
+
if (!Number.isFinite(risk) || risk <= 0) {
|
|
117
|
+
return {
|
|
118
|
+
error: `Computed risk for ${symbol} is ${risk} — entry=${entry.price} stop=${stop.price} ` +
|
|
119
|
+
`collapsed to a zero-risk ladder. Likely cause: ATR=${atr} too small relative to ` +
|
|
120
|
+
`rounding precision. Skip this symbol.`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const sign = direction === 'long' ? 1 : -1;
|
|
124
|
+
const targets = (strategyConfig.targetRMultiples ?? [1.5, 2.5]).map(r => ({
|
|
125
|
+
price: roundPrice(entry.price + risk * r * sign),
|
|
126
|
+
r_multiple: r,
|
|
127
|
+
}));
|
|
128
|
+
// 7. Build risks list
|
|
129
|
+
const risks = [];
|
|
130
|
+
const ind = fact.indicators;
|
|
131
|
+
if (readNumericIndicator(fact, 'obImbalance') === 0.5) {
|
|
132
|
+
risks.push('Orderbook neutral - no clear bid/ask dominance');
|
|
133
|
+
}
|
|
134
|
+
const bb = ind.bb;
|
|
135
|
+
if (bb && bb.bandwidth && bb.bandwidth > 6) {
|
|
136
|
+
risks.push(`High volatility - BB bandwidth ${bb.bandwidth.toFixed(1)}%`);
|
|
137
|
+
}
|
|
138
|
+
const fundingZ = readNumericIndicator(fact, 'fundingZScore');
|
|
139
|
+
if (fundingZ !== null && Math.abs(fundingZ) > 2) {
|
|
140
|
+
risks.push(`Elevated funding z-score: ${fundingZ.toFixed(1)}σ`);
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
symbol: fact.symbol,
|
|
144
|
+
price,
|
|
145
|
+
regime: fact.regime,
|
|
146
|
+
regime_confidence: fact.regime_confidence,
|
|
147
|
+
strategy: bestResult.strategy,
|
|
148
|
+
direction,
|
|
149
|
+
score: bestResult.score,
|
|
150
|
+
entry: { price: entry.price, type: entry.type, rationale: entry.rationale },
|
|
151
|
+
stop: { price: stop.price, type: stop.type, rationale: stop.rationale },
|
|
152
|
+
targets,
|
|
153
|
+
indicators: buildIndicatorSummary(fact),
|
|
154
|
+
conditions: `${bestResult.conditionsMet}/${bestResult.conditionsTotal} met`,
|
|
155
|
+
risks: risks.length > 0 ? risks : ['No significant risks identified'],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// ─── Helpers ────────────────────────────────────────────────────────────
|
|
159
|
+
/** Read an indicator as a finite number. Returns null when the value is
|
|
160
|
+
* missing, NaN, or non-finite — callers MUST handle null explicitly rather
|
|
161
|
+
* than treating it as zero (the pre-fix `?? 0` behaviour was the root cause
|
|
162
|
+
* of the 1000PEPE zeroed-levels bug). */
|
|
163
|
+
function readNumericIndicator(fact, key) {
|
|
164
|
+
const raw = fact.indicators[key];
|
|
165
|
+
if (typeof raw === 'number' && Number.isFinite(raw))
|
|
166
|
+
return raw;
|
|
167
|
+
if (typeof raw === 'string') {
|
|
168
|
+
const n = Number(raw);
|
|
169
|
+
if (Number.isFinite(n))
|
|
170
|
+
return n;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/** Resolve a clean long/short for a strategy given the current fact. Returns
|
|
175
|
+
* null when the directionRule cannot be unambiguously satisfied — the caller
|
|
176
|
+
* must refuse to emit a setup in that case rather than guess. */
|
|
177
|
+
function resolveDirection(strategy, fact) {
|
|
178
|
+
switch (strategy.directionRule) {
|
|
179
|
+
case 'fixed_long':
|
|
180
|
+
return 'long';
|
|
181
|
+
case 'fixed_short':
|
|
182
|
+
return 'short';
|
|
183
|
+
case 'from_regime': {
|
|
184
|
+
const r = (fact.regime || '').toUpperCase();
|
|
185
|
+
if (r === 'TREND_UP')
|
|
186
|
+
return 'long';
|
|
187
|
+
if (r === 'TREND_DOWN')
|
|
188
|
+
return 'short';
|
|
189
|
+
// RANGE_TIGHT / RANGE_WIDE / VOLATILITY_EXPANSION / UNKNOWN: ambiguous.
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
case 'from_funding': {
|
|
193
|
+
const z = readNumericIndicator(fact, 'fundingZScore');
|
|
194
|
+
if (z === null)
|
|
195
|
+
return null;
|
|
196
|
+
// Crowded longs (positive z) → contrarian short; crowded shorts → long.
|
|
197
|
+
if (z >= 1)
|
|
198
|
+
return 'short';
|
|
199
|
+
if (z <= -1)
|
|
200
|
+
return 'long';
|
|
201
|
+
return null; // Z between -1 and 1: no edge.
|
|
202
|
+
}
|
|
203
|
+
case 'from_sweep': {
|
|
204
|
+
// The sweep direction lives inside the price_sweep condition's metadata,
|
|
205
|
+
// which evaluateStrategy doesn't surface to us as a single field. Without
|
|
206
|
+
// that signal we'd be guessing; refuse to emit and let the agent run
|
|
207
|
+
// score_setup with an explicit direction.
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
default:
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function buildIndicatorSummary(fact) {
|
|
215
|
+
const ind = fact.indicators;
|
|
216
|
+
const macd = ind.macd;
|
|
217
|
+
const stochRsi = ind.stochRsi;
|
|
218
|
+
const supertrend = ind.supertrend;
|
|
219
|
+
const price = readNumericIndicator(fact, 'currentPrice');
|
|
220
|
+
const vwap = readNumericIndicator(fact, 'vwap');
|
|
221
|
+
const fundingZ = readNumericIndicator(fact, 'fundingZScore');
|
|
222
|
+
const oi = readNumericIndicator(fact, 'oiRatio');
|
|
223
|
+
return {
|
|
224
|
+
rsi: ind.rsi14,
|
|
225
|
+
adx: ind.adx,
|
|
226
|
+
macd: macd?.crossover && macd.crossover !== 'none'
|
|
227
|
+
? `${macd.crossover} cross`
|
|
228
|
+
: `histogram ${macd?.histogram ?? 0}`,
|
|
229
|
+
vwap: price !== null && vwap !== null && vwap !== 0
|
|
230
|
+
? `price ${price > vwap ? 'above' : 'below'} (${((price - vwap) / vwap * 100).toFixed(2)}%)`
|
|
231
|
+
: 'vwap unavailable',
|
|
232
|
+
supertrend: supertrend?.direction,
|
|
233
|
+
stochRsi: stochRsi?.k,
|
|
234
|
+
funding: fundingZ !== null
|
|
235
|
+
? `${fundingZ > 0 ? '+' : ''}${fundingZ.toFixed(1)}σ`
|
|
236
|
+
: 'unavailable',
|
|
237
|
+
oi: oi !== null ? `${oi.toFixed(2)}x avg` : 'unavailable',
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function computeEntry(strategy, fact, atr, currentPrice) {
|
|
241
|
+
const ind = fact.indicators;
|
|
242
|
+
const { type, params } = strategy.entryRule;
|
|
243
|
+
switch (type) {
|
|
244
|
+
case 'ema_offset': {
|
|
245
|
+
const emaKey = `ema${params.period ?? 20}`;
|
|
246
|
+
const emaRaw = ind[emaKey];
|
|
247
|
+
const ema = typeof emaRaw === 'number' && Number.isFinite(emaRaw) ? emaRaw : currentPrice;
|
|
248
|
+
const offset = atr * (params.atrFraction ?? 0.3);
|
|
249
|
+
return {
|
|
250
|
+
price: roundPrice(ema),
|
|
251
|
+
type: 'ema_offset',
|
|
252
|
+
rationale: `EMA${params.period ?? 20} pullback (±${offset.toFixed(0)} ATR offset)`,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
case 'atr_offset': {
|
|
256
|
+
const fraction = params.atrFraction ?? 0.2;
|
|
257
|
+
return {
|
|
258
|
+
price: roundPrice(currentPrice),
|
|
259
|
+
type: 'atr_offset',
|
|
260
|
+
rationale: `Current price ±${(fraction * atr).toFixed(0)} ATR offset`,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
case 'sweep_range':
|
|
264
|
+
default:
|
|
265
|
+
return {
|
|
266
|
+
price: roundPrice(currentPrice),
|
|
267
|
+
type: type || 'market',
|
|
268
|
+
rationale: 'At current price',
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function computeStop(strategy, atr, entryPrice, direction) {
|
|
273
|
+
const { type, params } = strategy.stopRule;
|
|
274
|
+
// Direction sign: long → stop below entry (entry - ATR*mult), short → above.
|
|
275
|
+
const sign = direction === 'long' ? -1 : 1;
|
|
276
|
+
switch (type) {
|
|
277
|
+
case 'swing_atr': {
|
|
278
|
+
const mult = params.atrFraction ?? 0.5;
|
|
279
|
+
return {
|
|
280
|
+
price: roundPrice(entryPrice + sign * atr * (1 + mult)),
|
|
281
|
+
type: 'swing_atr',
|
|
282
|
+
rationale: `${direction === 'long' ? 'Below' : 'Above'} swing - ${mult} ATR buffer`,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
case 'fixed_atr': {
|
|
286
|
+
const mult = params.atrMultiple ?? 1.5;
|
|
287
|
+
return {
|
|
288
|
+
price: roundPrice(entryPrice + sign * atr * mult),
|
|
289
|
+
type: 'fixed_atr',
|
|
290
|
+
rationale: `${mult}x ATR ${direction === 'long' ? 'below' : 'above'} entry`,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
case 'recent_extreme_atr': {
|
|
294
|
+
const mult = params.atrFraction ?? 0.3;
|
|
295
|
+
return {
|
|
296
|
+
price: roundPrice(entryPrice + sign * atr * (1 + mult)),
|
|
297
|
+
type: 'recent_extreme_atr',
|
|
298
|
+
rationale: `Recent extreme - ${mult} ATR`,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
default:
|
|
302
|
+
return {
|
|
303
|
+
price: roundPrice(entryPrice + sign * atr * 1.5),
|
|
304
|
+
type: type || 'default',
|
|
305
|
+
rationale: `1.5x ATR default stop (${direction === 'long' ? 'below' : 'above'} entry)`,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function roundPrice(p) {
|
|
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;
|
|
322
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntelApiDeps } from './intel-api.js';
|
|
2
|
+
import type { LocalSignalService } from '../live/local-signal-service.js';
|
|
3
|
+
export interface GetSignalsDeps extends IntelApiDeps {
|
|
4
|
+
evaluatorMode?: 'central' | 'shadow' | 'enforce';
|
|
5
|
+
localSignalService?: LocalSignalService | null;
|
|
6
|
+
logger?: {
|
|
7
|
+
info: (tag: string, msg: string) => void;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function getSignalsTool(args: {
|
|
11
|
+
symbol: string;
|
|
12
|
+
hours?: number;
|
|
13
|
+
}, deps: GetSignalsDeps): Promise<Record<string, unknown> | {
|
|
14
|
+
error: string;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Tool: get_signals — active trading signals for a symbol.
|
|
2
|
+
//
|
|
3
|
+
// Default (`central`): fetches the snapshot + recent history from the intel
|
|
4
|
+
// engine, exactly as before. With facts-out (docs/FACTS_OUT_ARCHITECTURE.md
|
|
5
|
+
// step 5) the operator can flip `signals.evaluator`:
|
|
6
|
+
// shadow — return central, but ALSO log the locally-evaluated snapshot for
|
|
7
|
+
// comparison (zero behaviour change).
|
|
8
|
+
// enforce — return the locally-evaluated snapshot, falling back to central
|
|
9
|
+
// when the local service has no fact for the symbol yet.
|
|
10
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
11
|
+
async function central(args, deps) {
|
|
12
|
+
const s = enc(resolveIntelSymbol(deps, args.symbol));
|
|
13
|
+
const [snapshot, history] = await Promise.all([
|
|
14
|
+
fetchIntelApi(`/api/signals/${s}`, deps),
|
|
15
|
+
fetchIntelApi(`/api/signals/${s}/history?hours=${args.hours ?? 24}`, deps),
|
|
16
|
+
]);
|
|
17
|
+
if ('error' in snapshot)
|
|
18
|
+
return snapshot;
|
|
19
|
+
if ('error' in history)
|
|
20
|
+
return { ...snapshot, history: [] };
|
|
21
|
+
return { ...snapshot, history };
|
|
22
|
+
}
|
|
23
|
+
export async function getSignalsTool(args, deps) {
|
|
24
|
+
const mode = deps.evaluatorMode ?? 'central';
|
|
25
|
+
const svc = deps.localSignalService ?? null;
|
|
26
|
+
// ENFORCE — serve the local snapshot; fall back to central if no fact yet
|
|
27
|
+
// (or the streamed fact has gone stale — getSnapshot refuses those).
|
|
28
|
+
if (mode === 'enforce' && svc) {
|
|
29
|
+
const local = svc.getSnapshot(args.symbol);
|
|
30
|
+
if (local) {
|
|
31
|
+
return { ...local, history: local.recentSignals, source: 'local' };
|
|
32
|
+
}
|
|
33
|
+
// Fail open to central, but LOUDLY and tagged: during rollout the
|
|
34
|
+
// operator needs to see how often enforce actually serves local vs
|
|
35
|
+
// silently falling back (otherwise the capture rate is unmeasurable).
|
|
36
|
+
deps.logger?.info('signal-enforce-fallback', `${args.symbol} no fresh local fact — serving central`);
|
|
37
|
+
const fallback = await central(args, deps);
|
|
38
|
+
if (!('error' in fallback))
|
|
39
|
+
return { ...fallback, source: 'central_fallback' };
|
|
40
|
+
return fallback;
|
|
41
|
+
}
|
|
42
|
+
const result = await central(args, deps);
|
|
43
|
+
// SHADOW — central authoritative; log the local snapshot alongside for compare.
|
|
44
|
+
if (mode === 'shadow' && svc && !('error' in result)) {
|
|
45
|
+
const local = svc.getSnapshot(args.symbol);
|
|
46
|
+
const centralStrats = Array.isArray(result.activeStrategies)
|
|
47
|
+
? result.activeStrategies.length
|
|
48
|
+
: 0;
|
|
49
|
+
deps.logger?.info('signal-shadow', `${args.symbol} central_strategies=${centralStrats} ` +
|
|
50
|
+
`local_strategies=${local ? local.activeStrategies.length : 'no-fact'} ` +
|
|
51
|
+
`local_signals=${local ? local.recentSignals.length : 'n/a'}`);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Tool: get_sizing — fetches Half-Kelly position sizing recommendation from Intelligence API.
|
|
2
|
+
// Returns recommended size as % of account, Kelly fraction, win rate, avg W/L ratio, vol adjustment.
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
|
+
export async function getSizingTool(args, deps) {
|
|
5
|
+
return fetchIntelApi(`/api/sizing/${enc(resolveIntelSymbol(deps, args.symbol))}`, deps);
|
|
6
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Tool: get_trade_feedback — fetches structured performance feedback from Intelligence API.
|
|
2
|
+
// Returns per-setup-type win rates, regime breakdown, recent outcomes, and current streak.
|
|
3
|
+
// Designed for the agent to review before entering trades.
|
|
4
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
5
|
+
export async function getTradeFeedbackTool(args, deps) {
|
|
6
|
+
const hours = args.hours ?? 168;
|
|
7
|
+
return fetchIntelApi(`/api/analytics/${enc(resolveIntelSymbol(deps, args.symbol))}/feedback?hours=${hours}`, deps);
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Tool: get_trade_flow — fetches aggregated trade flow / institutional flow data.
|
|
2
|
+
// Returns buy/sell volume, large trade (whale) activity, net delta, and whale pressure verdict.
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
|
+
export async function getTradeFlowTool(args, deps) {
|
|
5
|
+
const minutes = args.minutes ?? 5;
|
|
6
|
+
return fetchIntelApi(`/api/trade-flow/${enc(resolveIntelSymbol(deps, args.symbol))}?minutes=${minutes}`, deps);
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PublicMarketDataApi } from '../ccxt/public-market-data-api.js';
|
|
2
|
+
export interface VolumeAnalysisResult {
|
|
3
|
+
symbol: string;
|
|
4
|
+
timeframe: string;
|
|
5
|
+
volumeExpansion: number;
|
|
6
|
+
closePosition: number;
|
|
7
|
+
directionalThrust: number;
|
|
8
|
+
buyVolEstimate: number;
|
|
9
|
+
latestVolume: number;
|
|
10
|
+
avgVolume: number;
|
|
11
|
+
interpretation: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getVolumeAnalysisTool(args: {
|
|
15
|
+
symbol: string;
|
|
16
|
+
timeframe?: string;
|
|
17
|
+
}, deps: {
|
|
18
|
+
binanceApi: PublicMarketDataApi;
|
|
19
|
+
}): Promise<VolumeAnalysisResult | {
|
|
20
|
+
error: string;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Tool: get_volume_analysis — volume expansion, directional thrust, close position
|
|
2
|
+
// Fetches 25 bars of 5m OHLCV and computes volume metrics for the latest bar.
|
|
3
|
+
export async function getVolumeAnalysisTool(args, deps) {
|
|
4
|
+
const timeframe = args.timeframe ?? '5m';
|
|
5
|
+
try {
|
|
6
|
+
const candles = await deps.binanceApi.fetchOHLCV(args.symbol, timeframe, 25);
|
|
7
|
+
if (!candles || candles.length < 3) {
|
|
8
|
+
return { error: `Insufficient OHLCV data for ${args.symbol} ${timeframe}` };
|
|
9
|
+
}
|
|
10
|
+
// Filter valid bars (volume > 0)
|
|
11
|
+
const valid = candles.filter((c) => c[5] > 0);
|
|
12
|
+
if (valid.length < 3) {
|
|
13
|
+
return { error: `Insufficient valid bars for ${args.symbol} ${timeframe}` };
|
|
14
|
+
}
|
|
15
|
+
// Latest bar
|
|
16
|
+
const latest = valid[valid.length - 1];
|
|
17
|
+
const [, , latestHigh, latestLow, latestClose, latestVolume] = latest;
|
|
18
|
+
// 20-bar average volume (excluding latest bar)
|
|
19
|
+
const lookback = valid.slice(Math.max(0, valid.length - 21), valid.length - 1);
|
|
20
|
+
const avgVolume = lookback.length > 0
|
|
21
|
+
? lookback.reduce((sum, r) => sum + r[5], 0) / lookback.length
|
|
22
|
+
: latestVolume;
|
|
23
|
+
// Volume expansion ratio
|
|
24
|
+
const volumeExpansion = avgVolume > 0 ? latestVolume / avgVolume : 1;
|
|
25
|
+
// Close position: where close sits in the bar's range (0 = low, 1 = high)
|
|
26
|
+
const range = latestHigh - latestLow;
|
|
27
|
+
const closePosition = range > 0 ? (latestClose - latestLow) / range : 0.5;
|
|
28
|
+
// Directional thrust: combines volume expansion with close position
|
|
29
|
+
// -1 = high volume bearish (close at low), +1 = high volume bullish (close at high)
|
|
30
|
+
const dirMultiplier = (closePosition - 0.5) * 2;
|
|
31
|
+
const cappedExpansion = Math.min(volumeExpansion, 5);
|
|
32
|
+
const directionalThrust = dirMultiplier * Math.min(1, cappedExpansion / 2);
|
|
33
|
+
// Buy volume estimate (proxy)
|
|
34
|
+
const buyVolEstimate = closePosition;
|
|
35
|
+
// Human-readable interpretation
|
|
36
|
+
let interpretation;
|
|
37
|
+
if (volumeExpansion > 2 && directionalThrust > 0.3) {
|
|
38
|
+
interpretation = 'Strong bullish volume surge — buyers aggressive';
|
|
39
|
+
}
|
|
40
|
+
else if (volumeExpansion > 2 && directionalThrust < -0.3) {
|
|
41
|
+
interpretation = 'Strong bearish volume surge — sellers aggressive';
|
|
42
|
+
}
|
|
43
|
+
else if (volumeExpansion > 1.5 && Math.abs(directionalThrust) < 0.15) {
|
|
44
|
+
interpretation = 'High volume indecision — battle between buyers and sellers';
|
|
45
|
+
}
|
|
46
|
+
else if (volumeExpansion < 0.5) {
|
|
47
|
+
interpretation = 'Low volume — lack of participation, potential breakout setup';
|
|
48
|
+
}
|
|
49
|
+
else if (directionalThrust > 0.2) {
|
|
50
|
+
interpretation = 'Moderate bullish bias — close near highs';
|
|
51
|
+
}
|
|
52
|
+
else if (directionalThrust < -0.2) {
|
|
53
|
+
interpretation = 'Moderate bearish bias — close near lows';
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
interpretation = 'Normal volume, neutral positioning';
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
symbol: args.symbol,
|
|
60
|
+
timeframe,
|
|
61
|
+
volumeExpansion: +volumeExpansion.toFixed(2),
|
|
62
|
+
closePosition: +closePosition.toFixed(3),
|
|
63
|
+
directionalThrust: +directionalThrust.toFixed(3),
|
|
64
|
+
buyVolEstimate: +buyVolEstimate.toFixed(3),
|
|
65
|
+
latestVolume: Math.round(latestVolume),
|
|
66
|
+
avgVolume: Math.round(avgVolume),
|
|
67
|
+
interpretation,
|
|
68
|
+
timestamp: new Date().toISOString(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return { error: `get_volume_analysis failed: ${err instanceof Error ? err.message : String(err)}` };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Tool: get_volume_profile — fetches volume profile from the Intelligence API.
|
|
2
|
+
// Returns price buckets with buy/sell volume, POC, value area, and current price.
|
|
3
|
+
import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
|
|
4
|
+
export async function getVolumeProfileTool(args, deps) {
|
|
5
|
+
const period = args.period ?? 24;
|
|
6
|
+
return fetchIntelApi(`/api/volume-profile/${enc(resolveIntelSymbol(deps, args.symbol))}?period=${period}`, deps);
|
|
7
|
+
}
|