@reefclaw/connect 0.1.0
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/bridge/bridge.d.ts +96 -0
- package/assets/bridge/bridge.js +969 -0
- package/assets/bridge/config.d.ts +43 -0
- package/assets/bridge/config.js +176 -0
- package/assets/bridge/connector.d.ts +52 -0
- package/assets/bridge/connector.js +293 -0
- package/assets/bridge/event-replay-buffer.d.ts +43 -0
- package/assets/bridge/event-replay-buffer.js +109 -0
- package/assets/bridge/gateway/event-parser.d.ts +209 -0
- package/assets/bridge/gateway/event-parser.js +793 -0
- package/assets/bridge/gateway/gateway-config.d.ts +39 -0
- package/assets/bridge/gateway/gateway-config.js +86 -0
- package/assets/bridge/gateway/gateway-http-client.d.ts +50 -0
- package/assets/bridge/gateway/gateway-http-client.js +165 -0
- package/assets/bridge/gateway/gateway-ws-client.d.ts +116 -0
- package/assets/bridge/gateway/gateway-ws-client.js +417 -0
- package/assets/bridge/gateway/poller.d.ts +146 -0
- package/assets/bridge/gateway/poller.js +505 -0
- package/assets/bridge/gateway/tool-discovery.d.ts +25 -0
- package/assets/bridge/gateway/tool-discovery.js +198 -0
- package/assets/bridge/index.d.ts +2 -0
- package/assets/bridge/index.js +253 -0
- package/assets/bridge/logger.d.ts +2 -0
- package/assets/bridge/logger.js +2 -0
- package/assets/bridge/provider.d.ts +156 -0
- package/assets/bridge/provider.js +2 -0
- package/assets/bridge/providers/emergency-commands.d.ts +54 -0
- package/assets/bridge/providers/emergency-commands.js +235 -0
- package/assets/bridge/providers/gateway.d.ts +322 -0
- package/assets/bridge/providers/gateway.js +2302 -0
- package/assets/bridge/providers/mock.d.ts +37 -0
- package/assets/bridge/providers/mock.js +385 -0
- package/assets/bridge/providers/onboarding-commands.d.ts +83 -0
- package/assets/bridge/providers/onboarding-commands.js +213 -0
- package/assets/bridge/providers/risk-calculator.d.ts +96 -0
- package/assets/bridge/providers/risk-calculator.js +369 -0
- package/assets/bridge/setup.d.ts +32 -0
- package/assets/bridge/setup.js +226 -0
- package/assets/bridge/types.d.ts +584 -0
- package/assets/bridge/types.js +50 -0
- package/assets/bridge/utils/reconnect.d.ts +6 -0
- package/assets/bridge/utils/reconnect.js +6 -0
- package/assets/bridge/utils/skill-signing.d.ts +51 -0
- package/assets/bridge/utils/skill-signing.js +138 -0
- package/assets/bridge/utils/skill-version.d.ts +17 -0
- package/assets/bridge/utils/skill-version.js +71 -0
- 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 +409 -0
- package/assets/plugin/ccxt/binance-private.d.ts +325 -0
- package/assets/plugin/ccxt/binance-private.js +1415 -0
- package/assets/plugin/ccxt/binance-public.d.ts +18 -0
- package/assets/plugin/ccxt/binance-public.js +147 -0
- package/assets/plugin/config/agent-config-client.d.ts +55 -0
- package/assets/plugin/config/agent-config-client.js +145 -0
- package/assets/plugin/config/agent-config-poller.d.ts +25 -0
- package/assets/plugin/config/agent-config-poller.js +100 -0
- package/assets/plugin/config/brackets-config.d.ts +22 -0
- package/assets/plugin/config/brackets-config.js +58 -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 +175 -0
- package/assets/plugin/config/plugin-config-io.js +84 -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 +125 -0
- package/assets/plugin/config/user-data-stream-config.d.ts +85 -0
- package/assets/plugin/config/user-data-stream-config.js +224 -0
- package/assets/plugin/exchange-adapter.d.ts +49 -0
- package/assets/plugin/exchange-adapter.js +4 -0
- package/assets/plugin/index.d.ts +30 -0
- package/assets/plugin/index.js +1989 -0
- package/assets/plugin/ingest/pending-entry-metadata.d.ts +52 -0
- package/assets/plugin/ingest/pending-entry-metadata.js +182 -0
- package/assets/plugin/ingest/position-auto-capture.d.ts +98 -0
- package/assets/plugin/ingest/position-auto-capture.js +394 -0
- package/assets/plugin/ingest/position-decisions-client.d.ts +318 -0
- package/assets/plugin/ingest/position-decisions-client.js +296 -0
- package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +13 -0
- package/assets/plugin/ingest/reconcile-db-vs-exchange.js +114 -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/live/bracket-id.d.ts +18 -0
- package/assets/plugin/live/bracket-id.js +81 -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 +35 -0
- package/assets/plugin/live/exchange-info-cache.js +119 -0
- package/assets/plugin/live/fact-subscriber.d.ts +78 -0
- package/assets/plugin/live/fact-subscriber.js +182 -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 +264 -0
- package/assets/plugin/live/live-adapter.js +1665 -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 +146 -0
- package/assets/plugin/live/local-strategy-evaluator.d.ts +62 -0
- package/assets/plugin/live/local-strategy-evaluator.js +127 -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 +83 -0
- package/assets/plugin/live/position-state-store.js +237 -0
- package/assets/plugin/live/proposal-decision-listener.d.ts +64 -0
- package/assets/plugin/live/proposal-decision-listener.js +288 -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 +34 -0
- package/assets/plugin/live/stop-watcher.js +158 -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 +71 -0
- package/assets/plugin/onboarding/runtime.js +153 -0
- package/assets/plugin/openclaw.plugin.json +91 -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 +42 -0
- package/assets/plugin/persistence/state-manager.js +164 -0
- package/assets/plugin/pinned-plan.d.ts +9 -0
- package/assets/plugin/pinned-plan.js +23 -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 +1274 -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 +14 -0
- package/assets/plugin/signals/strategy-adapter.js +122 -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 +93 -0
- package/assets/plugin/simulator/exchange-simulator.js +684 -0
- package/assets/plugin/simulator/fill-engine.d.ts +53 -0
- package/assets/plugin/simulator/fill-engine.js +276 -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 +219 -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 +109 -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 +67 -0
- package/assets/plugin/strategy/evaluator.js +93 -0
- package/assets/plugin/tools/assessment-validation.d.ts +118 -0
- package/assets/plugin/tools/assessment-validation.js +415 -0
- package/assets/plugin/tools/attach-brackets.d.ts +34 -0
- package/assets/plugin/tools/attach-brackets.js +363 -0
- package/assets/plugin/tools/audit-bracket-protection.d.ts +49 -0
- package/assets/plugin/tools/audit-bracket-protection.js +527 -0
- package/assets/plugin/tools/cancel-all-orders.d.ts +7 -0
- package/assets/plugin/tools/cancel-all-orders.js +5 -0
- package/assets/plugin/tools/cancel-order.d.ts +10 -0
- package/assets/plugin/tools/cancel-order.js +14 -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 +22 -0
- package/assets/plugin/tools/close-position.js +449 -0
- package/assets/plugin/tools/create-order.d.ts +54 -0
- package/assets/plugin/tools/create-order.js +338 -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 +45 -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 +303 -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/helpers.d.ts +25 -0
- package/assets/plugin/tools/helpers.js +38 -0
- package/assets/plugin/tools/intel-api.d.ts +14 -0
- package/assets/plugin/tools/intel-api.js +52 -0
- package/assets/plugin/tools/intel-cache.d.ts +25 -0
- package/assets/plugin/tools/intel-cache.js +133 -0
- package/assets/plugin/tools/list-strategies.d.ts +7 -0
- package/assets/plugin/tools/list-strategies.js +6 -0
- package/assets/plugin/tools/modify-stop.d.ts +17 -0
- package/assets/plugin/tools/modify-stop.js +81 -0
- package/assets/plugin/tools/modify-target.d.ts +17 -0
- package/assets/plugin/tools/modify-target.js +71 -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 +18 -0
- package/assets/plugin/tools/scan-pairs.js +220 -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 +135 -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 +8 -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 +110 -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/shared/fills.d.ts +36 -0
- package/assets/shared/fills.js +20 -0
- package/assets/shared/index.d.ts +10 -0
- package/assets/shared/index.js +5 -0
- package/assets/shared/logger.d.ts +10 -0
- package/assets/shared/logger.js +34 -0
- package/assets/shared/protocol.d.ts +29 -0
- package/assets/shared/protocol.js +14 -0
- package/assets/shared/redact.d.ts +6 -0
- package/assets/shared/redact.js +31 -0
- package/assets/shared/shared/indicators-extended.d.ts +52 -0
- package/assets/shared/shared/indicators-extended.js +284 -0
- package/assets/shared/shared/indicators.d.ts +15 -0
- package/assets/shared/shared/indicators.js +107 -0
- package/assets/shared/signals/conditions/registry.d.ts +16 -0
- package/assets/shared/signals/conditions/registry.js +1267 -0
- package/assets/shared/signals/conditions/types.d.ts +65 -0
- package/assets/shared/signals/conditions/types.js +8 -0
- package/assets/shared/signals/direction-rules.d.ts +3 -0
- package/assets/shared/signals/direction-rules.js +18 -0
- package/assets/shared/signals/entry-rules.d.ts +6 -0
- package/assets/shared/signals/entry-rules.js +26 -0
- package/assets/shared/signals/indicators-extended.d.ts +52 -0
- package/assets/shared/signals/indicators-extended.js +284 -0
- package/assets/shared/signals/indicators.d.ts +15 -0
- package/assets/shared/signals/indicators.js +107 -0
- package/assets/shared/signals/serialize-context.d.ts +4 -0
- package/assets/shared/signals/serialize-context.js +41 -0
- package/assets/shared/signals/stop-rules.d.ts +3 -0
- package/assets/shared/signals/stop-rules.js +41 -0
- package/assets/shared/signals/strategy-adapter.d.ts +14 -0
- package/assets/shared/signals/strategy-adapter.js +117 -0
- package/assets/shared/signals/types.d.ts +187 -0
- package/assets/shared/signals/types.js +9 -0
- package/assets/shared/trading-mode.d.ts +16 -0
- package/assets/shared/trading-mode.js +49 -0
- package/assets/skill/SKILL.md +1357 -0
- package/dist/bridge.js +25 -0
- package/dist/bundle.js +33 -0
- package/dist/cli.js +120 -0
- package/dist/daemon.js +104 -0
- package/dist/deps.js +41 -0
- package/dist/exec.js +28 -0
- package/dist/openclaw.js +153 -0
- package/dist/paths.js +23 -0
- package/dist/plugin.js +48 -0
- package/dist/skill.js +35 -0
- package/dist/ui.js +29 -0
- package/dist/validate.js +28 -0
- package/package.json +32 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Stop level calculation for declarative strategies.
|
|
2
|
+
import { findSwingPoints } from '../shared/indicators.js';
|
|
3
|
+
export function computeStop(rule, ctx, direction, condCtx) {
|
|
4
|
+
switch (rule.type) {
|
|
5
|
+
case 'swing_atr': {
|
|
6
|
+
const swingCount = rule.params.swingCount ?? 3;
|
|
7
|
+
const atrFraction = (rule.params.atrFraction ?? 0.3) * ctx.atr14;
|
|
8
|
+
const fallbackAtrMult = rule.params.fallbackAtrMultiple ?? 2;
|
|
9
|
+
const swings = findSwingPoints(ctx.ohlcv1h.slice(-48), 3);
|
|
10
|
+
if (direction === 'LONG') {
|
|
11
|
+
return swings.lows.length > 0
|
|
12
|
+
? Math.min(...swings.lows.slice(-swingCount)) - atrFraction
|
|
13
|
+
: ctx.currentPrice - ctx.atr14 * fallbackAtrMult;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return swings.highs.length > 0
|
|
17
|
+
? Math.max(...swings.highs.slice(-swingCount)) + atrFraction
|
|
18
|
+
: ctx.currentPrice + ctx.atr14 * fallbackAtrMult;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
case 'recent_extreme_atr': {
|
|
22
|
+
const atrFraction = (rule.params.atrFraction ?? 0.5) * ctx.atr14;
|
|
23
|
+
if (direction === 'LONG') {
|
|
24
|
+
return (condCtx.recentLow ?? ctx.currentPrice - ctx.atr14) - atrFraction;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return (condCtx.recentHigh ?? ctx.currentPrice + ctx.atr14) + atrFraction;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
case 'fixed_atr': {
|
|
31
|
+
const atrMultiple = rule.params.atrMultiple ?? 1.5;
|
|
32
|
+
return direction === 'LONG'
|
|
33
|
+
? ctx.currentPrice - ctx.atr14 * atrMultiple
|
|
34
|
+
: ctx.currentPrice + ctx.atr14 * atrMultiple;
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
return direction === 'LONG'
|
|
38
|
+
? ctx.currentPrice - ctx.atr14 * 2
|
|
39
|
+
: ctx.currentPrice + ctx.atr14 * 2;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StrategyDefinition } from './types.js';
|
|
2
|
+
import type { StrategyConfig } from './conditions/types.js';
|
|
3
|
+
export declare function clearStrategyGatingState(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Convert a declarative StrategyConfig into a StrategyDefinition
|
|
6
|
+
* that the signal engine and backtest engine can evaluate.
|
|
7
|
+
*
|
|
8
|
+
* `gateNamespace` scopes the module-global HTF tick-gate to the calling tenant
|
|
9
|
+
* (pass the strategy-cache key — `global` for the background pass, the user key
|
|
10
|
+
* for a per-user pass). Omit it for single-tenant callers (backtests, the
|
|
11
|
+
* plugin's local evaluator) — they keep the original un-namespaced gate key,
|
|
12
|
+
* so their behaviour is byte-identical.
|
|
13
|
+
*/
|
|
14
|
+
export declare function adaptStrategy(config: StrategyConfig, gateNamespace?: string): StrategyDefinition;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Strategy adapter — converts declarative StrategyConfig (JSON) to StrategyDefinition.
|
|
2
|
+
// This bridges the DB-stored configs to the evaluate() interface the engines use.
|
|
3
|
+
import { evaluateConditions } from './conditions/registry.js';
|
|
4
|
+
import { resolveDirection } from './direction-rules.js';
|
|
5
|
+
import { computeEntry } from './entry-rules.js';
|
|
6
|
+
import { computeStop } from './stop-rules.js';
|
|
7
|
+
/**
|
|
8
|
+
* Higher-timeframe tick gating state, keyed by
|
|
9
|
+
* `${gateNamespace}\x1f${strategyName}:${symbol}`.
|
|
10
|
+
*
|
|
11
|
+
* Lives at module scope because the strategy cache (strategy-store.ts) builds
|
|
12
|
+
* a fresh adapter every 60s, so closure-based state would reset constantly
|
|
13
|
+
* and 1d-primary strategies would re-evaluate on every tick instead of once
|
|
14
|
+
* per closed bar. Module-level state survives the cache refresh.
|
|
15
|
+
*
|
|
16
|
+
* ★ Multi-tenant: because the map is module-global, the key MUST carry a
|
|
17
|
+
* per-tenant `gateNamespace` (the caller's strategy-cache key — `global` vs a
|
|
18
|
+
* per-user key). Without it, two tenants running same-named strategies on the
|
|
19
|
+
* same symbol shared ONE gate: whichever evaluated first marked the bar
|
|
20
|
+
* consumed and the other tenant's strategy was silently SKIPPED until the next
|
|
21
|
+
* primary-timeframe bar closed (a full day for a 1d strategy). A `\x1f` (unit
|
|
22
|
+
* separator, never present in a UUID / strategy name / symbol) joins the
|
|
23
|
+
* namespace so distinct tenants can never collide.
|
|
24
|
+
*
|
|
25
|
+
* Backtests should call `clearStrategyGatingState()` between runs to avoid
|
|
26
|
+
* leakage across tests / sequential backtests.
|
|
27
|
+
*/
|
|
28
|
+
const lastEvaluatedBarTime = new Map();
|
|
29
|
+
export function clearStrategyGatingState() {
|
|
30
|
+
lastEvaluatedBarTime.clear();
|
|
31
|
+
}
|
|
32
|
+
function pickTimeframeBars(ctx, tf) {
|
|
33
|
+
if (tf === '1d')
|
|
34
|
+
return ctx.ohlcv1d ?? [];
|
|
35
|
+
if (tf === '4h')
|
|
36
|
+
return ctx.ohlcv4h ?? [];
|
|
37
|
+
return ctx.ohlcv1h;
|
|
38
|
+
}
|
|
39
|
+
/** Empty no-signal evaluation — used when gating skips a strategy. */
|
|
40
|
+
const SKIPPED = { direction: null, conditions: [], trade: undefined };
|
|
41
|
+
/**
|
|
42
|
+
* Convert a declarative StrategyConfig into a StrategyDefinition
|
|
43
|
+
* that the signal engine and backtest engine can evaluate.
|
|
44
|
+
*
|
|
45
|
+
* `gateNamespace` scopes the module-global HTF tick-gate to the calling tenant
|
|
46
|
+
* (pass the strategy-cache key — `global` for the background pass, the user key
|
|
47
|
+
* for a per-user pass). Omit it for single-tenant callers (backtests, the
|
|
48
|
+
* plugin's local evaluator) — they keep the original un-namespaced gate key,
|
|
49
|
+
* so their behaviour is byte-identical.
|
|
50
|
+
*/
|
|
51
|
+
export function adaptStrategy(config, gateNamespace) {
|
|
52
|
+
return {
|
|
53
|
+
name: config.name,
|
|
54
|
+
regimeWhitelist: config.regimeWhitelist,
|
|
55
|
+
minConfidence: config.minConfidence,
|
|
56
|
+
async evaluate(ctx) {
|
|
57
|
+
// ─── Tick gating ───────────────────────────────────────────────
|
|
58
|
+
// Only re-evaluate when a new bar of the strategy's primary
|
|
59
|
+
// timeframe has closed since the last evaluation for this
|
|
60
|
+
// strategy/symbol pair. Defaults to '1h' so existing strategies
|
|
61
|
+
// are unaffected.
|
|
62
|
+
const tf = config.primaryTimeframe ?? '1h';
|
|
63
|
+
const tfBars = pickTimeframeBars(ctx, tf);
|
|
64
|
+
if (tfBars.length === 0)
|
|
65
|
+
return SKIPPED;
|
|
66
|
+
const latestBarTime = tfBars[tfBars.length - 1].time.getTime();
|
|
67
|
+
// Namespaced per tenant (see lastEvaluatedBarTime doc) so same-named
|
|
68
|
+
// strategies across tenants never share a gate. Un-namespaced when
|
|
69
|
+
// gateNamespace is omitted — byte-identical to the original key.
|
|
70
|
+
const gateKey = gateNamespace
|
|
71
|
+
? `${gateNamespace}\x1f${config.name}:${ctx.symbol}`
|
|
72
|
+
: `${config.name}:${ctx.symbol}`;
|
|
73
|
+
const lastBarTime = lastEvaluatedBarTime.get(gateKey);
|
|
74
|
+
if (lastBarTime !== undefined && latestBarTime === lastBarTime) {
|
|
75
|
+
return SKIPPED;
|
|
76
|
+
}
|
|
77
|
+
lastEvaluatedBarTime.set(gateKey, latestBarTime);
|
|
78
|
+
// ─── SkipIf gates ──────────────────────────────────────────────
|
|
79
|
+
// Portfolio-wide / cross-symbol filters. If any are met the
|
|
80
|
+
// strategy is skipped this tick. Evaluated before main conditions
|
|
81
|
+
// so the bulk of the work is short-circuited.
|
|
82
|
+
if (config.skipIf && config.skipIf.length > 0) {
|
|
83
|
+
const { conditions: skipResults } = evaluateConditions(config.skipIf, ctx, null);
|
|
84
|
+
if (skipResults.some(c => c.met))
|
|
85
|
+
return SKIPPED;
|
|
86
|
+
}
|
|
87
|
+
// Pass 1: evaluate conditions with direction = null
|
|
88
|
+
const { conditions: pass1, condCtx } = evaluateConditions(config.conditions, ctx, null);
|
|
89
|
+
// Determine direction
|
|
90
|
+
const direction = resolveDirection(config.directionRule, ctx, condCtx);
|
|
91
|
+
// Pass 2: re-evaluate direction-sensitive conditions now that we know direction
|
|
92
|
+
// (orderbook_imbalance and funding_contrarian behave differently per direction)
|
|
93
|
+
const directionSensitive = new Set(['orderbook_imbalance', 'funding_contrarian', 'funding_extreme_skip', 'funding_position_ok', 'return_momentum']);
|
|
94
|
+
const hasDirSensitive = config.conditions.some(c => directionSensitive.has(c.type));
|
|
95
|
+
let finalConditions = pass1;
|
|
96
|
+
if (direction && hasDirSensitive) {
|
|
97
|
+
const { conditions: pass2 } = evaluateConditions(config.conditions, ctx, direction);
|
|
98
|
+
// Merge: use pass2 results for direction-sensitive, pass1 for others
|
|
99
|
+
finalConditions = pass1.map((c, i) => directionSensitive.has(config.conditions[i].type) ? pass2[i] : c);
|
|
100
|
+
}
|
|
101
|
+
const allMet = finalConditions.every(c => c.met);
|
|
102
|
+
let trade;
|
|
103
|
+
if (allMet && direction) {
|
|
104
|
+
const entryZone = computeEntry(config.entryRule, ctx, direction, condCtx);
|
|
105
|
+
const stopLevel = computeStop(config.stopRule, ctx, direction, condCtx);
|
|
106
|
+
const risk = direction === 'LONG'
|
|
107
|
+
? ctx.currentPrice - stopLevel
|
|
108
|
+
: stopLevel - ctx.currentPrice;
|
|
109
|
+
const targets = config.targetRMultiples.map(rm => direction === 'LONG'
|
|
110
|
+
? ctx.currentPrice + risk * rm
|
|
111
|
+
: ctx.currentPrice - risk * rm);
|
|
112
|
+
trade = { entryZone, stopLevel, targets };
|
|
113
|
+
}
|
|
114
|
+
return { direction, conditions: finalConditions, trade };
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export type Direction = 'LONG' | 'SHORT';
|
|
2
|
+
export interface OhlcvBar {
|
|
3
|
+
time: Date;
|
|
4
|
+
open: number;
|
|
5
|
+
high: number;
|
|
6
|
+
low: number;
|
|
7
|
+
close: number;
|
|
8
|
+
volume: number;
|
|
9
|
+
}
|
|
10
|
+
export interface TradeFlowBucket {
|
|
11
|
+
bucket: Date;
|
|
12
|
+
buyVolume: number;
|
|
13
|
+
sellVolume: number;
|
|
14
|
+
netDelta: number;
|
|
15
|
+
largeBuyVolume: number;
|
|
16
|
+
largeSellVolume: number;
|
|
17
|
+
}
|
|
18
|
+
/** Market-wide signals not tied to a single symbol. Computed once per tick
|
|
19
|
+
* by the engine and attached to every per-symbol MarketContext. */
|
|
20
|
+
export interface GlobalMarketContext {
|
|
21
|
+
/** RSI(14) of BTCUSDT on the 1d timeframe, latest closed bar. */
|
|
22
|
+
btcRsi14_1d?: number;
|
|
23
|
+
/** Timestamp of the latest 1d BTC bar used for the RSI calc. */
|
|
24
|
+
btcRsi14_1d_at?: Date;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Market data context shared across all strategy evaluations in a single tick.
|
|
28
|
+
* Fetched once per tick, shared across strategies to avoid duplicate queries.
|
|
29
|
+
*/
|
|
30
|
+
export interface MarketContext {
|
|
31
|
+
symbol: string;
|
|
32
|
+
timestamp: Date;
|
|
33
|
+
/** 1h OHLCV bars, oldest first */
|
|
34
|
+
ohlcv1h: OhlcvBar[];
|
|
35
|
+
/** 5m OHLCV bars, oldest first (for swing detection) */
|
|
36
|
+
ohlcv5m: OhlcvBar[];
|
|
37
|
+
/** Current price */
|
|
38
|
+
currentPrice: number;
|
|
39
|
+
/** Current ATR(14) on 1h */
|
|
40
|
+
atr14: number;
|
|
41
|
+
/** Order book imbalance ratio (0-1, 0.5 = balanced) */
|
|
42
|
+
obImbalance: number;
|
|
43
|
+
/** Funding rates, newest first */
|
|
44
|
+
fundingRates: number[];
|
|
45
|
+
/** Funding rate stats */
|
|
46
|
+
fundingMean: number;
|
|
47
|
+
fundingStd: number;
|
|
48
|
+
/** OI data points, newest first */
|
|
49
|
+
oiValues: number[];
|
|
50
|
+
/** Recent liquidation total USD near current price (within 1%) */
|
|
51
|
+
liqNearEntry: number;
|
|
52
|
+
/** Trade flow: net delta, buy/sell volumes for last 10 minutes */
|
|
53
|
+
tradeFlow: TradeFlowBucket[];
|
|
54
|
+
/** Current regime */
|
|
55
|
+
regime: string;
|
|
56
|
+
regimeConfidence: number;
|
|
57
|
+
/** When true, conditions using unavailable data (orderbook, liquidations) should auto-pass */
|
|
58
|
+
backtestMode?: boolean;
|
|
59
|
+
/** CVD (Cumulative Volume Delta) indicators — Phase 16a */
|
|
60
|
+
cvd?: {
|
|
61
|
+
cvd1h: number;
|
|
62
|
+
cvd4h: number;
|
|
63
|
+
cvdSlope5m: number;
|
|
64
|
+
cvdSlope1h: number;
|
|
65
|
+
cvdDivergence: 'bullish' | 'bearish' | null;
|
|
66
|
+
cvdDivergenceStrength: number;
|
|
67
|
+
cvdZScore: number;
|
|
68
|
+
};
|
|
69
|
+
/** 4h OHLCV bars, oldest first. Optional — populated for strategies that
|
|
70
|
+
* need higher-timeframe confirmation. Live tick fills this; legacy
|
|
71
|
+
* contexts may omit it. */
|
|
72
|
+
ohlcv4h?: OhlcvBar[];
|
|
73
|
+
/** 1d OHLCV bars, oldest first. Optional — populated for daily-primary
|
|
74
|
+
* strategies. */
|
|
75
|
+
ohlcv1d?: OhlcvBar[];
|
|
76
|
+
/** Cross-symbol / portfolio-wide signals fetched once per tick and shared
|
|
77
|
+
* across all per-symbol contexts. Used by skipIf clauses (e.g. block
|
|
78
|
+
* longs when BTC daily RSI is overbought). */
|
|
79
|
+
globalContext?: GlobalMarketContext;
|
|
80
|
+
/** Cross-market liquidation pulse — sub-second classification over a
|
|
81
|
+
* rolling 60 s window. Only present when microstructure.liquidationPulse
|
|
82
|
+
* is on. See docs/MARKET_MICROSTRUCTURE_STREAMS.md §3. */
|
|
83
|
+
cascadePulse60s?: 'quiet' | 'elevated' | 'active_cascade';
|
|
84
|
+
/** Same classification but aggregated across the majors group
|
|
85
|
+
* (BTC + ETH + BNB + SOL + XRP). Captures market-wide stress that
|
|
86
|
+
* precedes correlated alt moves. */
|
|
87
|
+
majorsCascadePulse60s?: 'quiet' | 'elevated' | 'active_cascade';
|
|
88
|
+
/** Which side is being flushed in the 60 s window: 'long' = longs
|
|
89
|
+
* liquidated (force SELL), 'short' = shorts liquidated (force BUY),
|
|
90
|
+
* 'balanced' = neither side dominant. */
|
|
91
|
+
cascadeDominantSide?: 'long' | 'short' | 'balanced';
|
|
92
|
+
/** Bid share of resting USD notional in the (mid, mid + 0.5%] band, 0-1.
|
|
93
|
+
* 0.5 = balanced. > 0.5 = more bids than asks (support). < 0.5 = more
|
|
94
|
+
* asks than bids (overhead). Only present when bandedLiquidity flag on. */
|
|
95
|
+
restingBandImbalance05?: number;
|
|
96
|
+
/** Same ratio for the 1.0% band — wider lens, smoother signal. */
|
|
97
|
+
restingBandImbalance10?: number;
|
|
98
|
+
/** Symmetric depth coverage in % units. Mirrors order_book_snapshots
|
|
99
|
+
* column. Below the band you're querying = data unreliable. */
|
|
100
|
+
restingCoveragePct?: number;
|
|
101
|
+
/** 30-day funding-rate percentile context. Only present when
|
|
102
|
+
* FUNDING_OVERLAY=on (the helper returns enabled:false otherwise and
|
|
103
|
+
* fetchMarketContext leaves this undefined). Used by the
|
|
104
|
+
* funding_extreme_skip condition. */
|
|
105
|
+
fundingPercentile?: {
|
|
106
|
+
current: number;
|
|
107
|
+
p10: number;
|
|
108
|
+
p50: number;
|
|
109
|
+
p90: number;
|
|
110
|
+
/** 0..1 rank of `current` in the 30d distribution. */
|
|
111
|
+
percentileRank: number;
|
|
112
|
+
sampleSize: number;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** One evaluated condition's result, as surfaced on a signal. */
|
|
116
|
+
export interface SignalCondition {
|
|
117
|
+
name: string;
|
|
118
|
+
met: boolean;
|
|
119
|
+
currentValue: number;
|
|
120
|
+
threshold: number;
|
|
121
|
+
description: string;
|
|
122
|
+
}
|
|
123
|
+
/** Output of evaluating one strategy against a MarketContext. */
|
|
124
|
+
export interface StrategyEvaluation {
|
|
125
|
+
direction: Direction | null;
|
|
126
|
+
conditions: SignalCondition[];
|
|
127
|
+
/** Provided when all conditions are met */
|
|
128
|
+
trade?: {
|
|
129
|
+
entryZone: {
|
|
130
|
+
low: number;
|
|
131
|
+
high: number;
|
|
132
|
+
};
|
|
133
|
+
stopLevel: number;
|
|
134
|
+
targets: number[];
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A strategy definition: which regimes it operates in, minimum regime
|
|
139
|
+
* confidence, and a function that evaluates conditions against a MarketContext.
|
|
140
|
+
* Produced from a declarative StrategyConfig by adaptStrategy().
|
|
141
|
+
*/
|
|
142
|
+
export interface StrategyDefinition {
|
|
143
|
+
name: string;
|
|
144
|
+
regimeWhitelist: string[];
|
|
145
|
+
minConfidence: number;
|
|
146
|
+
evaluate: (ctx: MarketContext) => Promise<StrategyEvaluation>;
|
|
147
|
+
}
|
|
148
|
+
/** A fired signal — produced by the central engine and (facts-out) the plugin
|
|
149
|
+
* evaluator. This is the shape the agent's get_signals tool surfaces. */
|
|
150
|
+
export interface SignalEvent {
|
|
151
|
+
signalId: string;
|
|
152
|
+
timestamp: string;
|
|
153
|
+
symbol: string;
|
|
154
|
+
strategy: string;
|
|
155
|
+
direction: 'LONG' | 'SHORT';
|
|
156
|
+
regime: string;
|
|
157
|
+
regimeConfidence: number;
|
|
158
|
+
confluenceScore: number;
|
|
159
|
+
conditions: SignalCondition[];
|
|
160
|
+
entryZone: {
|
|
161
|
+
low: number;
|
|
162
|
+
high: number;
|
|
163
|
+
};
|
|
164
|
+
stopLevel: number;
|
|
165
|
+
targets: number[];
|
|
166
|
+
}
|
|
167
|
+
/** Per-strategy state for a symbol (whether or not it fired) — the
|
|
168
|
+
* `activeStrategies` view in a SignalSnapshot. */
|
|
169
|
+
export interface StrategyState {
|
|
170
|
+
strategy: string;
|
|
171
|
+
direction: 'LONG' | 'SHORT' | null;
|
|
172
|
+
regimeGated: boolean;
|
|
173
|
+
regimeRequired: string[];
|
|
174
|
+
currentRegime: string;
|
|
175
|
+
regimeConfidence: number;
|
|
176
|
+
confluenceScore: number;
|
|
177
|
+
conditions: SignalCondition[];
|
|
178
|
+
}
|
|
179
|
+
/** The full per-symbol signal snapshot the get_signals tool returns. */
|
|
180
|
+
export interface SignalSnapshot {
|
|
181
|
+
activeStrategies: StrategyState[];
|
|
182
|
+
recentSignals: SignalEvent[];
|
|
183
|
+
timestamp: string;
|
|
184
|
+
/** 'user' = derived from per-user state, 'global' = system background tick,
|
|
185
|
+
* 'local' = produced by the plugin-side evaluator (facts-out). */
|
|
186
|
+
scope?: 'user' | 'global' | 'local';
|
|
187
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Market-snapshot + direction types — the canonical source of truth shared by
|
|
2
|
+
// the intel signal engine (intelligence/src/signals/types.ts re-exports these)
|
|
3
|
+
// and, via facts-out, the plugin-side strategy evaluator.
|
|
4
|
+
//
|
|
5
|
+
// PURE TYPES ONLY — no runtime code. Type imports erase at compile time, so a
|
|
6
|
+
// consumer importing these from @reefclaw/shared keeps a self-contained runtime
|
|
7
|
+
// (no @reefclaw/shared dependency in the emitted JS). The condition registry
|
|
8
|
+
// (runtime code) is shared separately via scripts/sync-shared-code.mjs.
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type TradingMode = 'PAPER' | 'SHADOW' | 'MICRO_LIVE' | 'LIVE';
|
|
2
|
+
export declare const VALID_TRADING_MODES: readonly TradingMode[];
|
|
3
|
+
/** Type guard — narrows `unknown` to `TradingMode`. */
|
|
4
|
+
export declare function isTradingMode(value: unknown): value is TradingMode;
|
|
5
|
+
export interface ModeTransitionResult {
|
|
6
|
+
allowed: boolean;
|
|
7
|
+
reason?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Check whether transitioning from `from` to `to` is allowed by the ladder.
|
|
10
|
+
* - Same mode is a no-op (allowed).
|
|
11
|
+
* - De-escalation (lower rank) is always allowed.
|
|
12
|
+
* - Escalation must be exactly one rung.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateModeTransition(from: TradingMode, to: TradingMode): ModeTransitionResult;
|
|
15
|
+
/** Whether the target mode requires real exchange credentials. */
|
|
16
|
+
export declare function modeRequiresCredentials(mode: TradingMode): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Canonical TradingMode + mode-ladder rules, shared by plugin, skill, and webapp.
|
|
2
|
+
//
|
|
3
|
+
// Ladder: PAPER → MICRO_LIVE → LIVE. Escalation must be one rung at a time.
|
|
4
|
+
// De-escalating (e.g. LIVE → PAPER) is always allowed.
|
|
5
|
+
// SHADOW was removed (Apr 16 2026) — redundant with MICRO_LIVE, confused the agent.
|
|
6
|
+
export const VALID_TRADING_MODES = ['PAPER', 'MICRO_LIVE', 'LIVE'];
|
|
7
|
+
const VALID_SET = new Set([...VALID_TRADING_MODES, 'SHADOW']);
|
|
8
|
+
/** Type guard — narrows `unknown` to `TradingMode`. */
|
|
9
|
+
export function isTradingMode(value) {
|
|
10
|
+
return typeof value === 'string' && VALID_SET.has(value);
|
|
11
|
+
}
|
|
12
|
+
const RANK = {
|
|
13
|
+
PAPER: 0,
|
|
14
|
+
SHADOW: 0, // Treated as PAPER if somehow encountered
|
|
15
|
+
MICRO_LIVE: 1,
|
|
16
|
+
LIVE: 2,
|
|
17
|
+
};
|
|
18
|
+
/** Check whether transitioning from `from` to `to` is allowed by the ladder.
|
|
19
|
+
* - Same mode is a no-op (allowed).
|
|
20
|
+
* - De-escalation (lower rank) is always allowed.
|
|
21
|
+
* - Escalation must be exactly one rung.
|
|
22
|
+
*/
|
|
23
|
+
export function validateModeTransition(from, to) {
|
|
24
|
+
if (from === to)
|
|
25
|
+
return { allowed: true };
|
|
26
|
+
const fromRank = RANK[from];
|
|
27
|
+
const toRank = RANK[to];
|
|
28
|
+
if (toRank < fromRank)
|
|
29
|
+
return { allowed: true };
|
|
30
|
+
if (toRank - fromRank === 1)
|
|
31
|
+
return { allowed: true };
|
|
32
|
+
return {
|
|
33
|
+
allowed: false,
|
|
34
|
+
reason: `Cannot jump ${from} → ${to}: must progress one rung at a time (PAPER → MICRO_LIVE → LIVE). Transition to ${adjacentUp(from)} first.`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The next rung up from `mode`, used in error messages. */
|
|
38
|
+
function adjacentUp(mode) {
|
|
39
|
+
switch (mode) {
|
|
40
|
+
case 'PAPER': return 'MICRO_LIVE';
|
|
41
|
+
case 'SHADOW': return 'MICRO_LIVE'; // legacy — treated as PAPER
|
|
42
|
+
case 'MICRO_LIVE': return 'LIVE';
|
|
43
|
+
case 'LIVE': return 'LIVE';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Whether the target mode requires real exchange credentials. */
|
|
47
|
+
export function modeRequiresCredentials(mode) {
|
|
48
|
+
return mode !== 'PAPER';
|
|
49
|
+
}
|