@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,12 @@
|
|
|
1
|
+
import type { IExchangeAdapter } from '../exchange-adapter.js';
|
|
2
|
+
import type { BracketLedger } from '../live/bracket-ledger.js';
|
|
3
|
+
export interface BracketControl {
|
|
4
|
+
venue: 'binance' | 'hyperliquid';
|
|
5
|
+
ledger: BracketLedger;
|
|
6
|
+
modifyStop(symbol: string, newStopPrice: number): Promise<void>;
|
|
7
|
+
modifyTarget(symbol: string, newTargetPrice: number): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** Resolve the venue's bracket-mutation surface, or null when brackets are
|
|
10
|
+
* not enabled (Binance with brackets.mode=off; never null on HL live —
|
|
11
|
+
* exchange-side legs are HL live's ONLY protection, so they are always on). */
|
|
12
|
+
export declare function resolveBracketControl(adapter: IExchangeAdapter): BracketControl | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Venue dispatch for the bracket-mutating tools (issue #209).
|
|
2
|
+
//
|
|
3
|
+
// modify_stop / modify_target need one seam: "give me the thing that can move
|
|
4
|
+
// a leg, plus the ledger that knows the current geometry". On Binance that is
|
|
5
|
+
// BracketManager (+ LiveAdapter's ledger); on Hyperliquid it is the
|
|
6
|
+
// HlBracketCoordinator (which owns its own venue-distinct ledger). The tools
|
|
7
|
+
// must never know which venue they are on beyond this resolver — the
|
|
8
|
+
// hard-cast-to-LiveAdapter pattern is exactly what left the HL arm returning
|
|
9
|
+
// "Bracket orders are not enabled" on every call (the #209 recovery gap).
|
|
10
|
+
import { HyperliquidLiveAdapter } from '../venues/hyperliquid/hl-live-adapter.js';
|
|
11
|
+
/** Resolve the venue's bracket-mutation surface, or null when brackets are
|
|
12
|
+
* not enabled (Binance with brackets.mode=off; never null on HL live —
|
|
13
|
+
* exchange-side legs are HL live's ONLY protection, so they are always on). */
|
|
14
|
+
export function resolveBracketControl(adapter) {
|
|
15
|
+
if (adapter instanceof HyperliquidLiveAdapter) {
|
|
16
|
+
const coordinator = adapter.getHlBracketCoordinator();
|
|
17
|
+
return {
|
|
18
|
+
venue: 'hyperliquid',
|
|
19
|
+
ledger: coordinator.getLedger(),
|
|
20
|
+
modifyStop: (symbol, px) => coordinator.modifyStop(symbol, px),
|
|
21
|
+
modifyTarget: (symbol, px) => coordinator.modifyTarget(symbol, px),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const live = adapter;
|
|
25
|
+
const mgr = live.getBracketManager?.();
|
|
26
|
+
const ledger = live.getBracketLedger?.();
|
|
27
|
+
if (!mgr || !ledger)
|
|
28
|
+
return null;
|
|
29
|
+
return {
|
|
30
|
+
venue: 'binance',
|
|
31
|
+
ledger,
|
|
32
|
+
modifyStop: (symbol, px) => mgr.modifyStop(symbol, px),
|
|
33
|
+
modifyTarget: (symbol, px) => mgr.modifyTarget(symbol, px),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IExchangeAdapter } from '../exchange-adapter.js';
|
|
2
|
+
import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
|
|
3
|
+
import type { CcxtOrder } from '../types.js';
|
|
4
|
+
export declare function cancelAllOrdersTool(args: {
|
|
5
|
+
symbol?: string;
|
|
6
|
+
}, deps: {
|
|
7
|
+
adapter: IExchangeAdapter;
|
|
8
|
+
operationLock?: TradingOperationLock;
|
|
9
|
+
}): Promise<CcxtOrder[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Tool: cancel_all_orders — cancel all open orders (paper or live)
|
|
2
|
+
// NO readiness gate — emergency control (kill switch), must always work.
|
|
3
|
+
export async function cancelAllOrdersTool(args, deps) {
|
|
4
|
+
const cancel = () => deps.adapter.cancelAllOrders(args.symbol);
|
|
5
|
+
return deps.adapter.isLive && deps.operationLock
|
|
6
|
+
? deps.operationLock.withAccountLock(`generic-cancel-all-orders-final:${args.symbol ?? 'all'}`, cancel)
|
|
7
|
+
: cancel();
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IExchangeAdapter } from '../exchange-adapter.js';
|
|
2
|
+
import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
|
|
3
|
+
import type { CcxtOrder } from '../types.js';
|
|
4
|
+
import type { Wave9LiveSymbolOwnershipCheck } from '../wave9/live-symbol-ownership.js';
|
|
5
|
+
export declare function cancelOrderTool(args: {
|
|
6
|
+
id: string;
|
|
7
|
+
symbol?: string;
|
|
8
|
+
}, deps: {
|
|
9
|
+
adapter: IExchangeAdapter;
|
|
10
|
+
operationLock?: TradingOperationLock;
|
|
11
|
+
checkWave9LiveSymbolOwnership?: Wave9LiveSymbolOwnershipCheck;
|
|
12
|
+
}): Promise<CcxtOrder | {
|
|
13
|
+
error: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Tool: cancel_order — cancel a single order (paper or live).
|
|
2
|
+
// There is no readiness gate, but LIVE cancellation cannot individually strip
|
|
3
|
+
// candidate-bound Wave 9 protection. The emergency escape is an explicit
|
|
4
|
+
// operator close, which reduces exposure instead of leaving it naked.
|
|
5
|
+
import { formatError } from '../logger.js';
|
|
6
|
+
export async function cancelOrderTool(args, deps) {
|
|
7
|
+
if (!args.id) {
|
|
8
|
+
return { error: 'Order ID is required.' };
|
|
9
|
+
}
|
|
10
|
+
if (!deps.adapter.isLive) {
|
|
11
|
+
try {
|
|
12
|
+
return await deps.adapter.cancelOrder(args.id, args.symbol);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return { error: formatError(err) };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (deps.checkWave9LiveSymbolOwnership && !deps.operationLock) {
|
|
19
|
+
return {
|
|
20
|
+
error: 'Live cancel_order refused: the shared trading operation lock is required ' +
|
|
21
|
+
'while Wave 9 LIVE ownership checks are enabled.',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const cancelLive = async () => {
|
|
25
|
+
let symbol = args.symbol?.trim();
|
|
26
|
+
if (!symbol) {
|
|
27
|
+
const matches = (await deps.adapter.getOpenOrders())
|
|
28
|
+
.filter((order) => order.id === args.id);
|
|
29
|
+
if (matches.length !== 1 || !matches[0].symbol) {
|
|
30
|
+
throw new Error(`cancel_order refused: order ${args.id} could not be resolved to exactly one ` +
|
|
31
|
+
`trusted open-order symbol (matches=${matches.length}).`);
|
|
32
|
+
}
|
|
33
|
+
symbol = matches[0].symbol;
|
|
34
|
+
}
|
|
35
|
+
if (deps.checkWave9LiveSymbolOwnership) {
|
|
36
|
+
let ownership;
|
|
37
|
+
try {
|
|
38
|
+
ownership = await deps.checkWave9LiveSymbolOwnership(symbol);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
throw new Error(`cancel_order refused at mutation boundary: Wave 9 LIVE ownership check failed ` +
|
|
42
|
+
`for ${symbol} (${formatError(err)}).`);
|
|
43
|
+
}
|
|
44
|
+
if (ownership.status === 'owned' || ownership.status === 'ambiguous') {
|
|
45
|
+
throw new Error(`cancel_order refused at mutation boundary: ${symbol} has ` +
|
|
46
|
+
`${ownership.status} Wave 9 LIVE ownership (${ownership.reason}). ` +
|
|
47
|
+
'Use operator_command to close the position instead of stripping candidate-bound protection.');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return deps.adapter.cancelOrder(args.id, symbol);
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
return deps.operationLock
|
|
54
|
+
? await deps.operationLock.withAccountLock(`generic-cancel-order-final:${args.id}`, cancelLive)
|
|
55
|
+
: await cancelLive();
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
return { error: formatError(err) };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
interface PositionInput {
|
|
2
|
+
symbol: string;
|
|
3
|
+
side: 'LONG' | 'SHORT';
|
|
4
|
+
entry_price: number;
|
|
5
|
+
current_price: number;
|
|
6
|
+
stop_price: number;
|
|
7
|
+
target_price?: number;
|
|
8
|
+
quantity: number;
|
|
9
|
+
entry_time: string;
|
|
10
|
+
}
|
|
11
|
+
interface CheckHealthArgs {
|
|
12
|
+
positions: PositionInput[];
|
|
13
|
+
account_balance: number;
|
|
14
|
+
}
|
|
15
|
+
interface PositionHealth {
|
|
16
|
+
symbol: string;
|
|
17
|
+
side: string;
|
|
18
|
+
pnl: number;
|
|
19
|
+
pnlPercent: number;
|
|
20
|
+
pnlR: number;
|
|
21
|
+
distanceToStopPercent: number;
|
|
22
|
+
distanceToStopR: number;
|
|
23
|
+
stopStatus: 'SAFE' | 'CLOSE' | 'CRITICAL' | 'BREACHED';
|
|
24
|
+
distanceToTargetPercent: number | null;
|
|
25
|
+
distanceToTargetR: number | null;
|
|
26
|
+
targetReached: boolean;
|
|
27
|
+
heatPercent: number;
|
|
28
|
+
notionalPercent: number;
|
|
29
|
+
timeInTradeMinutes: number;
|
|
30
|
+
timeInTradeFormatted: string;
|
|
31
|
+
timeStatus: 'FRESH' | 'NORMAL' | 'EXTENDED' | 'STALE';
|
|
32
|
+
alerts: string[];
|
|
33
|
+
}
|
|
34
|
+
interface HealthSummary {
|
|
35
|
+
positions: PositionHealth[];
|
|
36
|
+
portfolio: {
|
|
37
|
+
totalHeat: number;
|
|
38
|
+
totalNotional: number;
|
|
39
|
+
totalPnl: number;
|
|
40
|
+
positionCount: number;
|
|
41
|
+
heatStatus: 'LOW' | 'MODERATE' | 'ELEVATED' | 'HIGH' | 'CRITICAL';
|
|
42
|
+
alerts: string[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare function checkPositionHealthTool(args: CheckHealthArgs): HealthSummary;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Tool: check_position_health — Real-time position health monitor.
|
|
2
|
+
// Computes heat, stop proximity, time-in-trade, and risk flags for open positions.
|
|
3
|
+
// Pure local computation — no API calls needed.
|
|
4
|
+
export function checkPositionHealthTool(args) {
|
|
5
|
+
const { positions, account_balance } = args;
|
|
6
|
+
if (!positions || positions.length === 0) {
|
|
7
|
+
return {
|
|
8
|
+
positions: [],
|
|
9
|
+
portfolio: {
|
|
10
|
+
totalHeat: 0,
|
|
11
|
+
totalNotional: 0,
|
|
12
|
+
totalPnl: 0,
|
|
13
|
+
positionCount: 0,
|
|
14
|
+
heatStatus: 'LOW',
|
|
15
|
+
alerts: [],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (account_balance <= 0) {
|
|
20
|
+
return {
|
|
21
|
+
positions: [],
|
|
22
|
+
portfolio: {
|
|
23
|
+
totalHeat: 0,
|
|
24
|
+
totalNotional: 0,
|
|
25
|
+
totalPnl: 0,
|
|
26
|
+
positionCount: 0,
|
|
27
|
+
heatStatus: 'CRITICAL',
|
|
28
|
+
alerts: ['Account balance is zero or negative'],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
const portfolioAlerts = [];
|
|
34
|
+
let totalHeat = 0;
|
|
35
|
+
let totalNotional = 0;
|
|
36
|
+
let totalPnl = 0;
|
|
37
|
+
const healthResults = positions.map((pos) => {
|
|
38
|
+
const alerts = [];
|
|
39
|
+
const dirMul = pos.side === 'LONG' ? 1 : -1;
|
|
40
|
+
// ── P&L ──
|
|
41
|
+
const pnl = (pos.current_price - pos.entry_price) * pos.quantity * dirMul;
|
|
42
|
+
const notional = pos.entry_price * pos.quantity;
|
|
43
|
+
const pnlPercent = notional > 0 ? (pnl / notional) * 100 : 0;
|
|
44
|
+
// Risk per unit = distance from entry to stop
|
|
45
|
+
const riskPerUnit = Math.abs(pos.entry_price - pos.stop_price);
|
|
46
|
+
const riskAmount = riskPerUnit * pos.quantity;
|
|
47
|
+
const pnlR = riskAmount > 0 ? pnl / riskAmount : 0;
|
|
48
|
+
// ── Stop tracking ──
|
|
49
|
+
const distToStop = pos.side === 'LONG'
|
|
50
|
+
? pos.current_price - pos.stop_price
|
|
51
|
+
: pos.stop_price - pos.current_price;
|
|
52
|
+
const distanceToStopPercent = pos.current_price > 0 ? (distToStop / pos.current_price) * 100 : 0;
|
|
53
|
+
const distanceToStopR = riskPerUnit > 0 ? distToStop / riskPerUnit : 0;
|
|
54
|
+
let stopStatus;
|
|
55
|
+
if (distToStop <= 0) {
|
|
56
|
+
stopStatus = 'BREACHED';
|
|
57
|
+
alerts.push(`STOP BREACHED — price has passed stop level ($${pos.stop_price})`);
|
|
58
|
+
}
|
|
59
|
+
else if (distanceToStopR < 0.3) {
|
|
60
|
+
stopStatus = 'CRITICAL';
|
|
61
|
+
alerts.push(`Stop critically close (${distanceToStopR.toFixed(2)}R away)`);
|
|
62
|
+
}
|
|
63
|
+
else if (distanceToStopR < 0.7) {
|
|
64
|
+
stopStatus = 'CLOSE';
|
|
65
|
+
alerts.push(`Stop approaching (${distanceToStopR.toFixed(2)}R away)`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
stopStatus = 'SAFE';
|
|
69
|
+
}
|
|
70
|
+
// ── Target tracking ──
|
|
71
|
+
let distanceToTargetPercent = null;
|
|
72
|
+
let distanceToTargetR = null;
|
|
73
|
+
let targetReached = false;
|
|
74
|
+
if (pos.target_price != null) {
|
|
75
|
+
const distToTarget = pos.side === 'LONG'
|
|
76
|
+
? pos.target_price - pos.current_price
|
|
77
|
+
: pos.current_price - pos.target_price;
|
|
78
|
+
distanceToTargetPercent = pos.current_price > 0 ? (distToTarget / pos.current_price) * 100 : 0;
|
|
79
|
+
distanceToTargetR = riskPerUnit > 0 ? distToTarget / riskPerUnit : 0;
|
|
80
|
+
targetReached = distToTarget <= 0;
|
|
81
|
+
if (targetReached) {
|
|
82
|
+
alerts.push('TARGET REACHED — consider taking profit');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// If past target but still holding
|
|
86
|
+
if (pnlR >= 2 && !targetReached) {
|
|
87
|
+
alerts.push(`At ${pnlR.toFixed(1)}R profit — consider trailing stop or partial take-profit`);
|
|
88
|
+
}
|
|
89
|
+
// ── Heat (position risk as % of account) ──
|
|
90
|
+
const heatPercent = (riskAmount / account_balance) * 100;
|
|
91
|
+
const notionalPercent = (notional / account_balance) * 100;
|
|
92
|
+
if (heatPercent > 5) {
|
|
93
|
+
alerts.push(`High heat: ${heatPercent.toFixed(1)}% of account at risk in this position`);
|
|
94
|
+
}
|
|
95
|
+
else if (heatPercent > 3) {
|
|
96
|
+
alerts.push(`Elevated heat: ${heatPercent.toFixed(1)}% of account at risk`);
|
|
97
|
+
}
|
|
98
|
+
totalHeat += heatPercent;
|
|
99
|
+
totalNotional += notional;
|
|
100
|
+
totalPnl += pnl;
|
|
101
|
+
// ── Time in trade ──
|
|
102
|
+
const entryMs = new Date(pos.entry_time).getTime();
|
|
103
|
+
const elapsed = Math.max(0, now - entryMs);
|
|
104
|
+
const minutes = Math.floor(elapsed / 60_000);
|
|
105
|
+
const hours = Math.floor(minutes / 60);
|
|
106
|
+
let timeFormatted;
|
|
107
|
+
if (hours >= 24) {
|
|
108
|
+
const days = Math.floor(hours / 24);
|
|
109
|
+
timeFormatted = `${days}d ${hours % 24}h`;
|
|
110
|
+
}
|
|
111
|
+
else if (hours > 0) {
|
|
112
|
+
timeFormatted = `${hours}h ${minutes % 60}m`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
timeFormatted = `${minutes}m`;
|
|
116
|
+
}
|
|
117
|
+
let timeStatus;
|
|
118
|
+
if (minutes < 15)
|
|
119
|
+
timeStatus = 'FRESH';
|
|
120
|
+
else if (minutes < 240)
|
|
121
|
+
timeStatus = 'NORMAL';
|
|
122
|
+
else if (minutes < 720) {
|
|
123
|
+
timeStatus = 'EXTENDED';
|
|
124
|
+
if (pnlR < 0)
|
|
125
|
+
alerts.push(`Held ${timeFormatted} underwater — review thesis`);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
timeStatus = 'STALE';
|
|
129
|
+
alerts.push(`Position held ${timeFormatted} — is original thesis still valid?`);
|
|
130
|
+
}
|
|
131
|
+
// Underwater for too long
|
|
132
|
+
if (pnlR < -0.5 && minutes > 60) {
|
|
133
|
+
alerts.push(`Underwater (${pnlR.toFixed(1)}R) for ${timeFormatted} — thesis may be invalid`);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
symbol: pos.symbol,
|
|
137
|
+
side: pos.side,
|
|
138
|
+
pnl: +pnl.toFixed(2),
|
|
139
|
+
pnlPercent: +pnlPercent.toFixed(2),
|
|
140
|
+
pnlR: +pnlR.toFixed(2),
|
|
141
|
+
distanceToStopPercent: +distanceToStopPercent.toFixed(2),
|
|
142
|
+
distanceToStopR: +distanceToStopR.toFixed(2),
|
|
143
|
+
stopStatus,
|
|
144
|
+
distanceToTargetPercent: distanceToTargetPercent != null ? +distanceToTargetPercent.toFixed(2) : null,
|
|
145
|
+
distanceToTargetR: distanceToTargetR != null ? +distanceToTargetR.toFixed(2) : null,
|
|
146
|
+
targetReached,
|
|
147
|
+
heatPercent: +heatPercent.toFixed(2),
|
|
148
|
+
notionalPercent: +notionalPercent.toFixed(2),
|
|
149
|
+
timeInTradeMinutes: minutes,
|
|
150
|
+
timeInTradeFormatted: timeFormatted,
|
|
151
|
+
timeStatus,
|
|
152
|
+
alerts,
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
// ── Portfolio-level assessment ──
|
|
156
|
+
let heatStatus;
|
|
157
|
+
if (totalHeat >= 15) {
|
|
158
|
+
heatStatus = 'CRITICAL';
|
|
159
|
+
portfolioAlerts.push(`CRITICAL portfolio heat: ${totalHeat.toFixed(1)}% — reduce exposure immediately`);
|
|
160
|
+
}
|
|
161
|
+
else if (totalHeat >= 10) {
|
|
162
|
+
heatStatus = 'HIGH';
|
|
163
|
+
portfolioAlerts.push(`High portfolio heat: ${totalHeat.toFixed(1)}% — no new positions`);
|
|
164
|
+
}
|
|
165
|
+
else if (totalHeat >= 6) {
|
|
166
|
+
heatStatus = 'ELEVATED';
|
|
167
|
+
portfolioAlerts.push(`Elevated portfolio heat: ${totalHeat.toFixed(1)}% — be cautious with new entries`);
|
|
168
|
+
}
|
|
169
|
+
else if (totalHeat >= 3) {
|
|
170
|
+
heatStatus = 'MODERATE';
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
heatStatus = 'LOW';
|
|
174
|
+
}
|
|
175
|
+
const breachedCount = healthResults.filter(p => p.stopStatus === 'BREACHED').length;
|
|
176
|
+
if (breachedCount > 0) {
|
|
177
|
+
portfolioAlerts.push(`${breachedCount} position(s) past stop level — exit immediately`);
|
|
178
|
+
}
|
|
179
|
+
const criticalCount = healthResults.filter(p => p.stopStatus === 'CRITICAL').length;
|
|
180
|
+
if (criticalCount > 0) {
|
|
181
|
+
portfolioAlerts.push(`${criticalCount} position(s) critically close to stop`);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
positions: healthResults,
|
|
185
|
+
portfolio: {
|
|
186
|
+
totalHeat: +totalHeat.toFixed(2),
|
|
187
|
+
totalNotional: +totalNotional.toFixed(2),
|
|
188
|
+
totalPnl: +totalPnl.toFixed(2),
|
|
189
|
+
positionCount: positions.length,
|
|
190
|
+
heatStatus,
|
|
191
|
+
alerts: portfolioAlerts,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PluginRuntime } from '../onboarding/runtime.js';
|
|
2
|
+
import type { IExchangeAdapter } from '../exchange-adapter.js';
|
|
3
|
+
import type { TradingMode } from '../types.js';
|
|
4
|
+
export interface ClearExchangeCredentialsArgs {
|
|
5
|
+
/** Must be `true`. Required so the skill's tool-discovery probe (which
|
|
6
|
+
* passes empty args) never accidentally wipes credentials on startup. */
|
|
7
|
+
confirm?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ClearExchangeCredentialsResult {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
message: string;
|
|
12
|
+
modeBefore: TradingMode;
|
|
13
|
+
mode: TradingMode;
|
|
14
|
+
rolledBackToPaper: boolean;
|
|
15
|
+
readiness: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ClearExchangeCredentialsDeps {
|
|
18
|
+
runtime: PluginRuntime;
|
|
19
|
+
adapterDeps: {
|
|
20
|
+
adapter: IExchangeAdapter;
|
|
21
|
+
};
|
|
22
|
+
configPath?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function clearExchangeCredentialsTool(args: ClearExchangeCredentialsArgs, deps: ClearExchangeCredentialsDeps): Promise<ClearExchangeCredentialsResult>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// clear_exchange_credentials — operator-only plugin tool.
|
|
2
|
+
//
|
|
3
|
+
// Removes the `exchange` section from ~/.reefclaw/plugin-config.json and,
|
|
4
|
+
// if the plugin is currently running in a mode that requires credentials
|
|
5
|
+
// (SHADOW, MICRO_LIVE, LIVE), de-escalates to PAPER via runtime.reconnect().
|
|
6
|
+
// This is the "pull the plug" button for when the operator wants to
|
|
7
|
+
// remove Binance keys from the machine entirely.
|
|
8
|
+
//
|
|
9
|
+
// Security:
|
|
10
|
+
// - Does NOT accept a new secret — pure delete.
|
|
11
|
+
// - Always de-escalates to PAPER on mode rollback; never stays in a
|
|
12
|
+
// live mode without credentials (would crash the adapter on first
|
|
13
|
+
// order anyway).
|
|
14
|
+
import { updatePluginConfig } from '../config/plugin-config-io.js';
|
|
15
|
+
import { logger } from '../logger.js';
|
|
16
|
+
const TAG = 'clear-exchange-credentials';
|
|
17
|
+
export async function clearExchangeCredentialsTool(args, deps) {
|
|
18
|
+
const modeBefore = deps.runtime.mode;
|
|
19
|
+
if (args?.confirm !== true) {
|
|
20
|
+
return {
|
|
21
|
+
ok: false,
|
|
22
|
+
message: 'clear_exchange_credentials requires confirm: true (prevents accidental probe wipes)',
|
|
23
|
+
modeBefore,
|
|
24
|
+
mode: modeBefore,
|
|
25
|
+
rolledBackToPaper: false,
|
|
26
|
+
readiness: deps.runtime.adapter.readiness,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
updatePluginConfig({ exchange: undefined }, deps.configPath);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
34
|
+
logger.error(TAG, `Failed to clear credentials: ${msg}`);
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
message: `Failed to remove credentials from config: ${msg}`,
|
|
38
|
+
modeBefore,
|
|
39
|
+
mode: modeBefore,
|
|
40
|
+
rolledBackToPaper: false,
|
|
41
|
+
readiness: deps.runtime.adapter.readiness,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
logger.info(TAG, 'Exchange credentials cleared from plugin-config.json');
|
|
45
|
+
// If we were in a live mode, fall back to PAPER — running SHADOW or
|
|
46
|
+
// MICRO_LIVE without credentials is a guaranteed broken state.
|
|
47
|
+
let rolledBackToPaper = false;
|
|
48
|
+
if (modeBefore !== 'PAPER') {
|
|
49
|
+
try {
|
|
50
|
+
// Also persist the mode downgrade so a subsequent restart doesn't
|
|
51
|
+
// try to bring up a live adapter with no credentials.
|
|
52
|
+
updatePluginConfig({ tradingMode: 'PAPER' }, deps.configPath);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
logger.warn(TAG, `Failed to persist PAPER fallback: ${err instanceof Error ? err.message : String(err)}`);
|
|
56
|
+
}
|
|
57
|
+
await deps.runtime.reconnect({ mode: 'PAPER', exchange: null }, { adapterDeps: deps.adapterDeps });
|
|
58
|
+
rolledBackToPaper = true;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
message: rolledBackToPaper
|
|
63
|
+
? `Credentials cleared and trading mode rolled back from ${modeBefore} to PAPER`
|
|
64
|
+
: 'Credentials cleared',
|
|
65
|
+
modeBefore,
|
|
66
|
+
mode: deps.runtime.mode,
|
|
67
|
+
rolledBackToPaper,
|
|
68
|
+
readiness: deps.runtime.adapter.readiness,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PublicMarketDataApi } from '../ccxt/public-market-data-api.js';
|
|
2
|
+
import type { IExchangeAdapter } from '../exchange-adapter.js';
|
|
3
|
+
import type { CcxtOrder } from '../types.js';
|
|
4
|
+
import { type ClosePositionArgs } from './assessment-validation.js';
|
|
5
|
+
import { type AutoCaptureContext } from '../ingest/position-auto-capture.js';
|
|
6
|
+
import { type ExitGateMode } from '../config/position-review-config.js';
|
|
7
|
+
import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
|
|
8
|
+
import type { Wave9LiveExecutionLedger } from '../wave9/live-execution-ledger.js';
|
|
9
|
+
import type { Wave9LiveSymbolOwnershipCheck } from '../wave9/live-symbol-ownership.js';
|
|
10
|
+
import { type Wave9LiveResidualProtectionResult } from '../wave9/live-residual-protection.js';
|
|
11
|
+
import { type Wave9PaperAdmissionGuard } from '../wave9/paper-admission-guard.js';
|
|
12
|
+
export declare function closePositionTool(args: ClosePositionArgs, deps: {
|
|
13
|
+
binanceApi: PublicMarketDataApi;
|
|
14
|
+
adapter: IExchangeAdapter;
|
|
15
|
+
autoCapture?: AutoCaptureContext;
|
|
16
|
+
/** Override for tests — production reads from plugin-config.json on each
|
|
17
|
+
* call so the flag can be flipped without a restart. */
|
|
18
|
+
exitGateMode?: ExitGateMode;
|
|
19
|
+
wave9AdmissionGuard?: Wave9PaperAdmissionGuard;
|
|
20
|
+
refreshPaperState?: () => void;
|
|
21
|
+
wave9TradingModeCheck?: () => string;
|
|
22
|
+
wave9VenueCheck?: () => string;
|
|
23
|
+
captureWave9PositionFingerprint?: (symbol: string) => Promise<{
|
|
24
|
+
fingerprint: string;
|
|
25
|
+
position: {
|
|
26
|
+
candidateId?: string;
|
|
27
|
+
missionId?: string;
|
|
28
|
+
setupType?: string;
|
|
29
|
+
side: 'long' | 'short';
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
wave9LiveLedger?: Wave9LiveExecutionLedger;
|
|
33
|
+
checkWave9LiveSymbolOwnership?: Wave9LiveSymbolOwnershipCheck;
|
|
34
|
+
reprotectWave9LiveResidual?: (adapter: IExchangeAdapter, ledger: Wave9LiveExecutionLedger, candidateId: string, symbol: string) => Promise<Wave9LiveResidualProtectionResult>;
|
|
35
|
+
operationLock?: TradingOperationLock;
|
|
36
|
+
operationLockHeld?: boolean;
|
|
37
|
+
}): Promise<CcxtOrder | {
|
|
38
|
+
error: string;
|
|
39
|
+
}>;
|
|
40
|
+
/** Test seam — clears the circuit-breaker state between unit tests. */
|
|
41
|
+
export declare const __testing__: {
|
|
42
|
+
resetCircuitBreaker(): void;
|
|
43
|
+
/** Inspect current circuit-breaker state — for assertions. */
|
|
44
|
+
getCircuitBreakerCount(): number;
|
|
45
|
+
};
|