@reefclaw/connect 0.1.10 → 0.1.12

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.
Files changed (396) hide show
  1. package/assets/bridge/gateway/event-parser.d.ts +6 -1
  2. package/assets/bridge/gateway/event-parser.js +19 -2
  3. package/assets/bridge/gateway/heartbeat-cron.d.ts +27 -0
  4. package/assets/bridge/gateway/heartbeat-cron.js +85 -0
  5. package/assets/bridge/gateway/poller.d.ts +1 -0
  6. package/assets/bridge/gateway/poller.js +14 -2
  7. package/assets/bridge/providers/gateway.d.ts +24 -2
  8. package/assets/bridge/providers/gateway.js +124 -25
  9. package/assets/bridge/setup.js +6 -51
  10. package/assets/shared/signals/conditions/registry.js +11 -2
  11. package/assets/shared/signals/strategy-adapter.js +17 -7
  12. package/assets/skill/SKILL.md +2 -0
  13. package/dist/deps.js +2 -2
  14. package/dist/plugin.js +35 -7
  15. package/package.json +1 -1
  16. package/assets/plugin/audit/mode-transition-audit.d.ts +0 -11
  17. package/assets/plugin/audit/mode-transition-audit.js +0 -29
  18. package/assets/plugin/balance-utils.d.ts +0 -36
  19. package/assets/plugin/balance-utils.js +0 -98
  20. package/assets/plugin/ccxt/binance-ban-gate.d.ts +0 -47
  21. package/assets/plugin/ccxt/binance-ban-gate.js +0 -420
  22. package/assets/plugin/ccxt/binance-private.d.ts +0 -346
  23. package/assets/plugin/ccxt/binance-private.js +0 -1525
  24. package/assets/plugin/ccxt/binance-public.d.ts +0 -34
  25. package/assets/plugin/ccxt/binance-public.js +0 -180
  26. package/assets/plugin/ccxt/intel-public.d.ts +0 -25
  27. package/assets/plugin/ccxt/intel-public.js +0 -80
  28. package/assets/plugin/ccxt/public-market-data-api.d.ts +0 -12
  29. package/assets/plugin/ccxt/public-market-data-api.js +0 -9
  30. package/assets/plugin/config/agent-config-client.d.ts +0 -77
  31. package/assets/plugin/config/agent-config-client.js +0 -188
  32. package/assets/plugin/config/agent-config-poller.d.ts +0 -32
  33. package/assets/plugin/config/agent-config-poller.js +0 -101
  34. package/assets/plugin/config/brackets-config.d.ts +0 -22
  35. package/assets/plugin/config/brackets-config.js +0 -58
  36. package/assets/plugin/config/entitlement-gate.d.ts +0 -51
  37. package/assets/plugin/config/entitlement-gate.js +0 -137
  38. package/assets/plugin/config/gate-store.d.ts +0 -18
  39. package/assets/plugin/config/gate-store.js +0 -61
  40. package/assets/plugin/config/plugin-config-io.d.ts +0 -215
  41. package/assets/plugin/config/plugin-config-io.js +0 -111
  42. package/assets/plugin/config/position-review-config.d.ts +0 -35
  43. package/assets/plugin/config/position-review-config.js +0 -105
  44. package/assets/plugin/config/tool-gate.d.ts +0 -53
  45. package/assets/plugin/config/tool-gate.js +0 -128
  46. package/assets/plugin/config/user-data-stream-config.d.ts +0 -89
  47. package/assets/plugin/config/user-data-stream-config.js +0 -239
  48. package/assets/plugin/connector-supervisor.d.ts +0 -36
  49. package/assets/plugin/connector-supervisor.js +0 -149
  50. package/assets/plugin/exchange-adapter.d.ts +0 -65
  51. package/assets/plugin/exchange-adapter.js +0 -4
  52. package/assets/plugin/index.d.ts +0 -30
  53. package/assets/plugin/index.js +0 -2678
  54. package/assets/plugin/ingest/pending-entry-metadata.d.ts +0 -74
  55. package/assets/plugin/ingest/pending-entry-metadata.js +0 -236
  56. package/assets/plugin/ingest/position-auto-capture.d.ts +0 -103
  57. package/assets/plugin/ingest/position-auto-capture.js +0 -411
  58. package/assets/plugin/ingest/position-decisions-client.d.ts +0 -322
  59. package/assets/plugin/ingest/position-decisions-client.js +0 -296
  60. package/assets/plugin/ingest/readiness-reporter.d.ts +0 -42
  61. package/assets/plugin/ingest/readiness-reporter.js +0 -163
  62. package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +0 -13
  63. package/assets/plugin/ingest/reconcile-db-vs-exchange.js +0 -114
  64. package/assets/plugin/ingest/reconciler-cleanup.d.ts +0 -37
  65. package/assets/plugin/ingest/reconciler-cleanup.js +0 -147
  66. package/assets/plugin/ingest/rest-gap-filler.d.ts +0 -191
  67. package/assets/plugin/ingest/rest-gap-filler.js +0 -565
  68. package/assets/plugin/ingest/touched-symbols-store.d.ts +0 -25
  69. package/assets/plugin/ingest/touched-symbols-store.js +0 -96
  70. package/assets/plugin/ingest/trade-store-client.d.ts +0 -40
  71. package/assets/plugin/ingest/trade-store-client.js +0 -125
  72. package/assets/plugin/ingest/ws-ingest.d.ts +0 -43
  73. package/assets/plugin/ingest/ws-ingest.js +0 -126
  74. package/assets/plugin/learning/setup-family.d.ts +0 -21
  75. package/assets/plugin/learning/setup-family.js +0 -103
  76. package/assets/plugin/lifecycle/install-signal-handlers.d.ts +0 -33
  77. package/assets/plugin/lifecycle/install-signal-handlers.js +0 -112
  78. package/assets/plugin/lifecycle/shutdown-coordinator.d.ts +0 -43
  79. package/assets/plugin/lifecycle/shutdown-coordinator.js +0 -131
  80. package/assets/plugin/lifecycle/trading-operation-lock.d.ts +0 -17
  81. package/assets/plugin/lifecycle/trading-operation-lock.js +0 -14
  82. package/assets/plugin/live/bracket-id.d.ts +0 -26
  83. package/assets/plugin/live/bracket-id.js +0 -112
  84. package/assets/plugin/live/bracket-ledger.d.ts +0 -54
  85. package/assets/plugin/live/bracket-ledger.js +0 -267
  86. package/assets/plugin/live/bracket-manager.d.ts +0 -82
  87. package/assets/plugin/live/bracket-manager.js +0 -478
  88. package/assets/plugin/live/bracket-params.d.ts +0 -22
  89. package/assets/plugin/live/bracket-params.js +0 -124
  90. package/assets/plugin/live/bracket-reconciler.d.ts +0 -95
  91. package/assets/plugin/live/bracket-reconciler.js +0 -573
  92. package/assets/plugin/live/bracket-types.d.ts +0 -102
  93. package/assets/plugin/live/bracket-types.js +0 -8
  94. package/assets/plugin/live/deposit-tracker.d.ts +0 -62
  95. package/assets/plugin/live/deposit-tracker.js +0 -97
  96. package/assets/plugin/live/emergency-controls.d.ts +0 -32
  97. package/assets/plugin/live/emergency-controls.js +0 -226
  98. package/assets/plugin/live/exchange-errors.d.ts +0 -12
  99. package/assets/plugin/live/exchange-errors.js +0 -130
  100. package/assets/plugin/live/exchange-info-cache.d.ts +0 -37
  101. package/assets/plugin/live/exchange-info-cache.js +0 -134
  102. package/assets/plugin/live/fact-subscriber.d.ts +0 -78
  103. package/assets/plugin/live/fact-subscriber.js +0 -182
  104. package/assets/plugin/live/intent-journal.d.ts +0 -42
  105. package/assets/plugin/live/intent-journal.js +0 -122
  106. package/assets/plugin/live/listen-key-manager.d.ts +0 -70
  107. package/assets/plugin/live/listen-key-manager.js +0 -169
  108. package/assets/plugin/live/live-adapter.d.ts +0 -287
  109. package/assets/plugin/live/live-adapter.js +0 -1777
  110. package/assets/plugin/live/live-balance-enricher.d.ts +0 -32
  111. package/assets/plugin/live/live-balance-enricher.js +0 -104
  112. package/assets/plugin/live/live-bracket-api.d.ts +0 -13
  113. package/assets/plugin/live/live-bracket-api.js +0 -20
  114. package/assets/plugin/live/live-state-store.d.ts +0 -194
  115. package/assets/plugin/live/live-state-store.js +0 -450
  116. package/assets/plugin/live/local-signal-service.d.ts +0 -57
  117. package/assets/plugin/live/local-signal-service.js +0 -151
  118. package/assets/plugin/live/local-strategy-evaluator.d.ts +0 -62
  119. package/assets/plugin/live/local-strategy-evaluator.js +0 -131
  120. package/assets/plugin/live/microstructure-assembler.d.ts +0 -54
  121. package/assets/plugin/live/microstructure-assembler.js +0 -148
  122. package/assets/plugin/live/order-poller.d.ts +0 -29
  123. package/assets/plugin/live/order-poller.js +0 -125
  124. package/assets/plugin/live/position-state-store.d.ts +0 -83
  125. package/assets/plugin/live/position-state-store.js +0 -237
  126. package/assets/plugin/live/proposal-decision-listener.d.ts +0 -70
  127. package/assets/plugin/live/proposal-decision-listener.js +0 -292
  128. package/assets/plugin/live/proposal-manager.d.ts +0 -76
  129. package/assets/plugin/live/proposal-manager.js +0 -140
  130. package/assets/plugin/live/rate-limiter.d.ts +0 -47
  131. package/assets/plugin/live/rate-limiter.js +0 -159
  132. package/assets/plugin/live/reconciler.d.ts +0 -39
  133. package/assets/plugin/live/reconciler.js +0 -175
  134. package/assets/plugin/live/setup-buckets.d.ts +0 -7
  135. package/assets/plugin/live/setup-buckets.js +0 -33
  136. package/assets/plugin/live/slippage-tracker.d.ts +0 -45
  137. package/assets/plugin/live/slippage-tracker.js +0 -78
  138. package/assets/plugin/live/stop-watcher.d.ts +0 -60
  139. package/assets/plugin/live/stop-watcher.js +0 -215
  140. package/assets/plugin/live/user-data-active-probe.d.ts +0 -54
  141. package/assets/plugin/live/user-data-active-probe.js +0 -180
  142. package/assets/plugin/live/user-data-stream-controller.d.ts +0 -200
  143. package/assets/plugin/live/user-data-stream-controller.js +0 -579
  144. package/assets/plugin/live/user-data-stream-ws.d.ts +0 -22
  145. package/assets/plugin/live/user-data-stream-ws.js +0 -63
  146. package/assets/plugin/live/user-data-stream.d.ts +0 -243
  147. package/assets/plugin/live/user-data-stream.js +0 -704
  148. package/assets/plugin/logger.d.ts +0 -2
  149. package/assets/plugin/logger.js +0 -2
  150. package/assets/plugin/mfe.d.ts +0 -21
  151. package/assets/plugin/mfe.js +0 -68
  152. package/assets/plugin/onboarding/mode-ladder.d.ts +0 -1
  153. package/assets/plugin/onboarding/mode-ladder.js +0 -3
  154. package/assets/plugin/onboarding/runtime.d.ts +0 -84
  155. package/assets/plugin/onboarding/runtime.js +0 -173
  156. package/assets/plugin/openclaw.plugin.json +0 -92
  157. package/assets/plugin/paper-adapter.d.ts +0 -24
  158. package/assets/plugin/paper-adapter.js +0 -91
  159. package/assets/plugin/persistence/state-manager.d.ts +0 -66
  160. package/assets/plugin/persistence/state-manager.js +0 -222
  161. package/assets/plugin/pinned-plan.d.ts +0 -9
  162. package/assets/plugin/pinned-plan.js +0 -23
  163. package/assets/plugin/portfolio/wave9-admission.d.ts +0 -67
  164. package/assets/plugin/portfolio/wave9-admission.js +0 -262
  165. package/assets/plugin/portfolio/wave9-policy.d.ts +0 -36
  166. package/assets/plugin/portfolio/wave9-policy.js +0 -183
  167. package/assets/plugin/risk/pre-trade-check.d.ts +0 -38
  168. package/assets/plugin/risk/pre-trade-check.js +0 -345
  169. package/assets/plugin/risk/pre-trade-types.d.ts +0 -60
  170. package/assets/plugin/risk/pre-trade-types.js +0 -3
  171. package/assets/plugin/shadow/shadow-tracker.d.ts +0 -36
  172. package/assets/plugin/shadow/shadow-tracker.js +0 -151
  173. package/assets/plugin/shadow/types.d.ts +0 -42
  174. package/assets/plugin/shadow/types.js +0 -20
  175. package/assets/plugin/shared/indicators-extended.d.ts +0 -52
  176. package/assets/plugin/shared/indicators-extended.js +0 -291
  177. package/assets/plugin/shared/indicators.d.ts +0 -15
  178. package/assets/plugin/shared/indicators.js +0 -114
  179. package/assets/plugin/signals/conditions/registry.d.ts +0 -16
  180. package/assets/plugin/signals/conditions/registry.js +0 -1324
  181. package/assets/plugin/signals/conditions/types.d.ts +0 -1
  182. package/assets/plugin/signals/conditions/types.js +0 -4
  183. package/assets/plugin/signals/direction-rules.d.ts +0 -3
  184. package/assets/plugin/signals/direction-rules.js +0 -24
  185. package/assets/plugin/signals/entry-rules.d.ts +0 -6
  186. package/assets/plugin/signals/entry-rules.js +0 -33
  187. package/assets/plugin/signals/serialize-context.d.ts +0 -4
  188. package/assets/plugin/signals/serialize-context.js +0 -39
  189. package/assets/plugin/signals/stop-rules.d.ts +0 -3
  190. package/assets/plugin/signals/stop-rules.js +0 -48
  191. package/assets/plugin/signals/strategy-adapter.d.ts +0 -47
  192. package/assets/plugin/signals/strategy-adapter.js +0 -199
  193. package/assets/plugin/signals/types.d.ts +0 -1
  194. package/assets/plugin/signals/types.js +0 -8
  195. package/assets/plugin/simulator/exchange-simulator.d.ts +0 -93
  196. package/assets/plugin/simulator/exchange-simulator.js +0 -689
  197. package/assets/plugin/simulator/fill-engine.d.ts +0 -53
  198. package/assets/plugin/simulator/fill-engine.js +0 -280
  199. package/assets/plugin/simulator/paper-market-feed.d.ts +0 -26
  200. package/assets/plugin/simulator/paper-market-feed.js +0 -104
  201. package/assets/plugin/simulator/realistic-fills.d.ts +0 -59
  202. package/assets/plugin/simulator/realistic-fills.js +0 -175
  203. package/assets/plugin/simulator/types.d.ts +0 -224
  204. package/assets/plugin/simulator/types.js +0 -43
  205. package/assets/plugin/strategy/builtin-strategies.d.ts +0 -2
  206. package/assets/plugin/strategy/builtin-strategies.js +0 -113
  207. package/assets/plugin/strategy/condition-registry.d.ts +0 -3
  208. package/assets/plugin/strategy/condition-registry.js +0 -153
  209. package/assets/plugin/strategy/evaluator.d.ts +0 -70
  210. package/assets/plugin/strategy/evaluator.js +0 -98
  211. package/assets/plugin/tools/assessment-validation.d.ts +0 -120
  212. package/assets/plugin/tools/assessment-validation.js +0 -415
  213. package/assets/plugin/tools/attach-brackets.d.ts +0 -39
  214. package/assets/plugin/tools/attach-brackets.js +0 -399
  215. package/assets/plugin/tools/audit-bracket-protection.d.ts +0 -49
  216. package/assets/plugin/tools/audit-bracket-protection.js +0 -527
  217. package/assets/plugin/tools/cancel-all-orders.d.ts +0 -9
  218. package/assets/plugin/tools/cancel-all-orders.js +0 -8
  219. package/assets/plugin/tools/cancel-order.d.ts +0 -14
  220. package/assets/plugin/tools/cancel-order.js +0 -60
  221. package/assets/plugin/tools/check-position-health.d.ts +0 -46
  222. package/assets/plugin/tools/check-position-health.js +0 -194
  223. package/assets/plugin/tools/clear-exchange-credentials.d.ts +0 -24
  224. package/assets/plugin/tools/clear-exchange-credentials.js +0 -70
  225. package/assets/plugin/tools/close-position.d.ts +0 -45
  226. package/assets/plugin/tools/close-position.js +0 -722
  227. package/assets/plugin/tools/create-order.d.ts +0 -82
  228. package/assets/plugin/tools/create-order.js +0 -1516
  229. package/assets/plugin/tools/exit-gate.d.ts +0 -58
  230. package/assets/plugin/tools/exit-gate.js +0 -162
  231. package/assets/plugin/tools/fetch-balance.d.ts +0 -5
  232. package/assets/plugin/tools/fetch-balance.js +0 -4
  233. package/assets/plugin/tools/fetch-ohlcv.d.ts +0 -11
  234. package/assets/plugin/tools/fetch-ohlcv.js +0 -8
  235. package/assets/plugin/tools/fetch-open-orders.d.ts +0 -7
  236. package/assets/plugin/tools/fetch-open-orders.js +0 -4
  237. package/assets/plugin/tools/fetch-positions.d.ts +0 -7
  238. package/assets/plugin/tools/fetch-positions.js +0 -4
  239. package/assets/plugin/tools/fetch-ticker.d.ts +0 -11
  240. package/assets/plugin/tools/fetch-ticker.js +0 -5
  241. package/assets/plugin/tools/get-agent-profile.d.ts +0 -4
  242. package/assets/plugin/tools/get-agent-profile.js +0 -6
  243. package/assets/plugin/tools/get-analytics.d.ts +0 -6
  244. package/assets/plugin/tools/get-analytics.js +0 -7
  245. package/assets/plugin/tools/get-backtest.d.ts +0 -12
  246. package/assets/plugin/tools/get-backtest.js +0 -91
  247. package/assets/plugin/tools/get-basis.d.ts +0 -7
  248. package/assets/plugin/tools/get-basis.js +0 -7
  249. package/assets/plugin/tools/get-bracket-config.d.ts +0 -11
  250. package/assets/plugin/tools/get-bracket-config.js +0 -24
  251. package/assets/plugin/tools/get-cascade-risk.d.ts +0 -7
  252. package/assets/plugin/tools/get-cascade-risk.js +0 -8
  253. package/assets/plugin/tools/get-crypto-metrics.d.ts +0 -18
  254. package/assets/plugin/tools/get-crypto-metrics.js +0 -62
  255. package/assets/plugin/tools/get-cvd.d.ts +0 -6
  256. package/assets/plugin/tools/get-cvd.js +0 -6
  257. package/assets/plugin/tools/get-divergences.d.ts +0 -6
  258. package/assets/plugin/tools/get-divergences.js +0 -6
  259. package/assets/plugin/tools/get-funding-context.d.ts +0 -6
  260. package/assets/plugin/tools/get-funding-context.js +0 -16
  261. package/assets/plugin/tools/get-liquidation-levels.d.ts +0 -7
  262. package/assets/plugin/tools/get-liquidation-levels.js +0 -7
  263. package/assets/plugin/tools/get-liquidation-pulse.d.ts +0 -9
  264. package/assets/plugin/tools/get-liquidation-pulse.js +0 -22
  265. package/assets/plugin/tools/get-market-breadth.d.ts +0 -6
  266. package/assets/plugin/tools/get-market-breadth.js +0 -8
  267. package/assets/plugin/tools/get-market-intel.d.ts +0 -19
  268. package/assets/plugin/tools/get-market-intel.js +0 -116
  269. package/assets/plugin/tools/get-market-structure.d.ts +0 -47
  270. package/assets/plugin/tools/get-market-structure.js +0 -198
  271. package/assets/plugin/tools/get-my-mined-patterns.d.ts +0 -20
  272. package/assets/plugin/tools/get-my-mined-patterns.js +0 -61
  273. package/assets/plugin/tools/get-my-proposed-learnings.d.ts +0 -20
  274. package/assets/plugin/tools/get-my-proposed-learnings.js +0 -55
  275. package/assets/plugin/tools/get-my-recent-reviews.d.ts +0 -22
  276. package/assets/plugin/tools/get-my-recent-reviews.js +0 -66
  277. package/assets/plugin/tools/get-orderbook.d.ts +0 -21
  278. package/assets/plugin/tools/get-orderbook.js +0 -32
  279. package/assets/plugin/tools/get-pattern-scan.d.ts +0 -7
  280. package/assets/plugin/tools/get-pattern-scan.js +0 -8
  281. package/assets/plugin/tools/get-regime.d.ts +0 -6
  282. package/assets/plugin/tools/get-regime.js +0 -7
  283. package/assets/plugin/tools/get-relevant-learnings.d.ts +0 -21
  284. package/assets/plugin/tools/get-relevant-learnings.js +0 -65
  285. package/assets/plugin/tools/get-resting-liquidity.d.ts +0 -6
  286. package/assets/plugin/tools/get-resting-liquidity.js +0 -11
  287. package/assets/plugin/tools/get-risk-scenario.d.ts +0 -29
  288. package/assets/plugin/tools/get-risk-scenario.js +0 -47
  289. package/assets/plugin/tools/get-risk-summary.d.ts +0 -51
  290. package/assets/plugin/tools/get-risk-summary.js +0 -118
  291. package/assets/plugin/tools/get-sentiment.d.ts +0 -4
  292. package/assets/plugin/tools/get-sentiment.js +0 -6
  293. package/assets/plugin/tools/get-session-review.d.ts +0 -7
  294. package/assets/plugin/tools/get-session-review.js +0 -8
  295. package/assets/plugin/tools/get-setup-detail.d.ts +0 -7
  296. package/assets/plugin/tools/get-setup-detail.js +0 -311
  297. package/assets/plugin/tools/get-signals.d.ts +0 -15
  298. package/assets/plugin/tools/get-signals.js +0 -54
  299. package/assets/plugin/tools/get-sizing.d.ts +0 -6
  300. package/assets/plugin/tools/get-sizing.js +0 -6
  301. package/assets/plugin/tools/get-trade-feedback.d.ts +0 -7
  302. package/assets/plugin/tools/get-trade-feedback.js +0 -8
  303. package/assets/plugin/tools/get-trade-flow.d.ts +0 -7
  304. package/assets/plugin/tools/get-trade-flow.js +0 -7
  305. package/assets/plugin/tools/get-volume-analysis.d.ts +0 -21
  306. package/assets/plugin/tools/get-volume-analysis.js +0 -74
  307. package/assets/plugin/tools/get-volume-profile.d.ts +0 -7
  308. package/assets/plugin/tools/get-volume-profile.js +0 -7
  309. package/assets/plugin/tools/get-wave9-status.d.ts +0 -127
  310. package/assets/plugin/tools/get-wave9-status.js +0 -796
  311. package/assets/plugin/tools/helpers.d.ts +0 -26
  312. package/assets/plugin/tools/helpers.js +0 -39
  313. package/assets/plugin/tools/intel-api.d.ts +0 -34
  314. package/assets/plugin/tools/intel-api.js +0 -119
  315. package/assets/plugin/tools/intel-cache.d.ts +0 -25
  316. package/assets/plugin/tools/intel-cache.js +0 -148
  317. package/assets/plugin/tools/list-strategies.d.ts +0 -17
  318. package/assets/plugin/tools/list-strategies.js +0 -23
  319. package/assets/plugin/tools/modify-stop.d.ts +0 -21
  320. package/assets/plugin/tools/modify-stop.js +0 -120
  321. package/assets/plugin/tools/modify-target.d.ts +0 -21
  322. package/assets/plugin/tools/modify-target.js +0 -110
  323. package/assets/plugin/tools/propose-learning.d.ts +0 -22
  324. package/assets/plugin/tools/propose-learning.js +0 -65
  325. package/assets/plugin/tools/query-review-outcomes.d.ts +0 -30
  326. package/assets/plugin/tools/query-review-outcomes.js +0 -64
  327. package/assets/plugin/tools/query-trades.d.ts +0 -21
  328. package/assets/plugin/tools/query-trades.js +0 -37
  329. package/assets/plugin/tools/record-position-reviews.d.ts +0 -38
  330. package/assets/plugin/tools/record-position-reviews.js +0 -147
  331. package/assets/plugin/tools/save-strategy.d.ts +0 -16
  332. package/assets/plugin/tools/save-strategy.js +0 -46
  333. package/assets/plugin/tools/scan-pairs.d.ts +0 -18
  334. package/assets/plugin/tools/scan-pairs.js +0 -231
  335. package/assets/plugin/tools/score-setup.d.ts +0 -31
  336. package/assets/plugin/tools/score-setup.js +0 -268
  337. package/assets/plugin/tools/set-bracket-requirement.d.ts +0 -18
  338. package/assets/plugin/tools/set-bracket-requirement.js +0 -81
  339. package/assets/plugin/tools/set-exchange-credentials.d.ts +0 -25
  340. package/assets/plugin/tools/set-exchange-credentials.js +0 -80
  341. package/assets/plugin/tools/set-trading-mode.d.ts +0 -26
  342. package/assets/plugin/tools/set-trading-mode.js +0 -135
  343. package/assets/plugin/tools/test-exchange-credentials.d.ts +0 -16
  344. package/assets/plugin/tools/test-exchange-credentials.js +0 -100
  345. package/assets/plugin/tools/toggle-strategy.d.ts +0 -8
  346. package/assets/plugin/tools/toggle-strategy.js +0 -15
  347. package/assets/plugin/trading-params-cache.d.ts +0 -26
  348. package/assets/plugin/trading-params-cache.js +0 -52
  349. package/assets/plugin/types.d.ts +0 -134
  350. package/assets/plugin/types.js +0 -7
  351. package/assets/plugin/util/plugin-paths.d.ts +0 -3
  352. package/assets/plugin/util/plugin-paths.js +0 -15
  353. package/assets/plugin/venues/hyperliquid/hl-balance.d.ts +0 -116
  354. package/assets/plugin/venues/hyperliquid/hl-balance.js +0 -145
  355. package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +0 -102
  356. package/assets/plugin/venues/hyperliquid/hl-brackets.js +0 -172
  357. package/assets/plugin/venues/hyperliquid/hl-cloid.d.ts +0 -22
  358. package/assets/plugin/venues/hyperliquid/hl-cloid.js +0 -82
  359. package/assets/plugin/venues/hyperliquid/hl-info-cache.d.ts +0 -46
  360. package/assets/plugin/venues/hyperliquid/hl-info-cache.js +0 -125
  361. package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +0 -88
  362. package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +0 -353
  363. package/assets/plugin/venues/hyperliquid/hl-precision.d.ts +0 -61
  364. package/assets/plugin/venues/hyperliquid/hl-precision.js +0 -176
  365. package/assets/plugin/venues/hyperliquid/hl-private.d.ts +0 -88
  366. package/assets/plugin/venues/hyperliquid/hl-private.js +0 -357
  367. package/assets/plugin/venues/hyperliquid/hl-public.d.ts +0 -79
  368. package/assets/plugin/venues/hyperliquid/hl-public.js +0 -429
  369. package/assets/plugin/venues/hyperliquid/hl-rate-gate.d.ts +0 -57
  370. package/assets/plugin/venues/hyperliquid/hl-rate-gate.js +0 -220
  371. package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +0 -90
  372. package/assets/plugin/venues/hyperliquid/hl-user-stream.js +0 -220
  373. package/assets/plugin/venues/registry.d.ts +0 -38
  374. package/assets/plugin/venues/registry.js +0 -46
  375. package/assets/plugin/venues/symbols.d.ts +0 -43
  376. package/assets/plugin/venues/symbols.js +0 -107
  377. package/assets/plugin/wave9/live-account-capture.d.ts +0 -67
  378. package/assets/plugin/wave9/live-account-capture.js +0 -435
  379. package/assets/plugin/wave9/live-autonomous-protection.d.ts +0 -39
  380. package/assets/plugin/wave9/live-autonomous-protection.js +0 -112
  381. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.d.ts +0 -33
  382. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.js +0 -115
  383. package/assets/plugin/wave9/live-execution-ledger.d.ts +0 -107
  384. package/assets/plugin/wave9/live-execution-ledger.js +0 -498
  385. package/assets/plugin/wave9/live-position-confirmation.d.ts +0 -18
  386. package/assets/plugin/wave9/live-position-confirmation.js +0 -111
  387. package/assets/plugin/wave9/live-residual-protection.d.ts +0 -18
  388. package/assets/plugin/wave9/live-residual-protection.js +0 -250
  389. package/assets/plugin/wave9/live-startup-reconciliation.d.ts +0 -38
  390. package/assets/plugin/wave9/live-startup-reconciliation.js +0 -454
  391. package/assets/plugin/wave9/live-symbol-ownership.d.ts +0 -20
  392. package/assets/plugin/wave9/live-symbol-ownership.js +0 -132
  393. package/assets/plugin/wave9/paper-admission-guard.d.ts +0 -199
  394. package/assets/plugin/wave9/paper-admission-guard.js +0 -650
  395. package/assets/plugin/wave9/usdm-evidence-provider.d.ts +0 -42
  396. package/assets/plugin/wave9/usdm-evidence-provider.js +0 -133
@@ -1 +0,0 @@
1
- export type { ConditionResult, ConditionContext, ConditionFn, ConditionConfig, EntryRuleConfig, StopRuleConfig, DirectionRule, PrimaryTimeframe, StrategyConfig, } from '@reefclaw/shared';
@@ -1,4 +0,0 @@
1
- // Re-export shim — see ../types.ts. The condition + strategy-config contracts
2
- // the generated registry/rules import from `./types.js`. Canonical definitions
3
- // live in @reefclaw/shared (type-only → erased at runtime).
4
- export {};
@@ -1,3 +0,0 @@
1
- import type { MarketContext, Direction } from './types.js';
2
- import type { ConditionContext, DirectionRule } from './conditions/types.js';
3
- export declare function resolveDirection(rule: DirectionRule, ctx: MarketContext, condCtx: ConditionContext): Direction | null;
@@ -1,24 +0,0 @@
1
- // ⚠️ GENERATED FILE — DO NOT EDIT.
2
- // Canonical source of truth: shared/src/signals/direction-rules.ts
3
- // Regenerate: node scripts/sync-shared-code.mjs (enforced by shared-code-sync.test.ts)
4
- //
5
- // This copy exists because this package builds with tsc and deploys as a
6
- // self-contained tree that strips workspace deps, so it cannot import
7
- // @reefclaw/shared runtime code across the deploy boundary.
8
- export function resolveDirection(rule, ctx, condCtx) {
9
- switch (rule) {
10
- case 'from_regime':
11
- return ctx.regime === 'TREND_UP' ? 'LONG' : ctx.regime === 'TREND_DOWN' ? 'SHORT' : null;
12
- case 'from_sweep':
13
- return condCtx.sweptDirection ?? null;
14
- case 'from_funding':
15
- // funding_extreme condition sets sweptDirection to the contra direction
16
- return condCtx.sweptDirection ?? null;
17
- case 'fixed_long':
18
- return 'LONG';
19
- case 'fixed_short':
20
- return 'SHORT';
21
- default:
22
- return null;
23
- }
24
- }
@@ -1,6 +0,0 @@
1
- import type { MarketContext, Direction } from './types.js';
2
- import type { EntryRuleConfig, ConditionContext } from './conditions/types.js';
3
- export declare function computeEntry(rule: EntryRuleConfig, ctx: MarketContext, direction: Direction, condCtx: ConditionContext): {
4
- low: number;
5
- high: number;
6
- };
@@ -1,33 +0,0 @@
1
- // ⚠️ GENERATED FILE — DO NOT EDIT.
2
- // Canonical source of truth: shared/src/signals/entry-rules.ts
3
- // Regenerate: node scripts/sync-shared-code.mjs (enforced by shared-code-sync.test.ts)
4
- //
5
- // This copy exists because this package builds with tsc and deploys as a
6
- // self-contained tree that strips workspace deps, so it cannot import
7
- // @reefclaw/shared runtime code across the deploy boundary.
8
- // Entry zone calculation for declarative strategies.
9
- import { computeEMA } from '../shared/indicators.js';
10
- export function computeEntry(rule, ctx, direction, condCtx) {
11
- switch (rule.type) {
12
- case 'ema_offset': {
13
- const period = rule.params.period ?? 21;
14
- const atrFraction = (rule.params.atrFraction ?? 0.3) * ctx.atr14;
15
- const ema = condCtx.ema21 && period === 21
16
- ? condCtx.ema21
17
- : computeEMA(ctx.ohlcv1h.map(b => b.close), period);
18
- return { low: ema - atrFraction, high: ema + atrFraction };
19
- }
20
- case 'sweep_range': {
21
- const sweepLevel = condCtx.sweepLevel ?? ctx.currentPrice;
22
- return direction === 'LONG'
23
- ? { low: sweepLevel, high: ctx.currentPrice }
24
- : { low: ctx.currentPrice, high: sweepLevel };
25
- }
26
- case 'atr_offset': {
27
- const atrFraction = (rule.params.atrFraction ?? 0.2) * ctx.atr14;
28
- return { low: ctx.currentPrice - atrFraction, high: ctx.currentPrice + atrFraction };
29
- }
30
- default:
31
- return { low: ctx.currentPrice - ctx.atr14 * 0.3, high: ctx.currentPrice + ctx.atr14 * 0.3 };
32
- }
33
- }
@@ -1,4 +0,0 @@
1
- import type { MarketContext } from './types.js';
2
- export declare function serializeContext(ctx: MarketContext): string;
3
- /** Parse a streamed context and rehydrate every Date field. Throws on bad JSON. */
4
- export declare function deserializeContext(raw: string): MarketContext;
@@ -1,39 +0,0 @@
1
- // ⚠️ GENERATED FILE — DO NOT EDIT.
2
- // Canonical source of truth: shared/src/signals/serialize-context.ts
3
- // Regenerate: node scripts/sync-shared-code.mjs (enforced by shared-code-sync.test.ts)
4
- //
5
- // This copy exists because this package builds with tsc and deploys as a
6
- // self-contained tree that strips workspace deps, so it cannot import
7
- // @reefclaw/shared runtime code across the deploy boundary.
8
- export function serializeContext(ctx) {
9
- return JSON.stringify(ctx);
10
- }
11
- function reviveBars(bars) {
12
- if (!Array.isArray(bars))
13
- return undefined;
14
- return bars.map((b) => ({ ...b, time: new Date(b.time) }));
15
- }
16
- /** Parse a streamed context and rehydrate every Date field. Throws on bad JSON. */
17
- export function deserializeContext(raw) {
18
- const o = JSON.parse(raw);
19
- o.timestamp = new Date(o.timestamp);
20
- const oh1 = reviveBars(o.ohlcv1h);
21
- if (oh1)
22
- o.ohlcv1h = oh1;
23
- const oh5 = reviveBars(o.ohlcv5m);
24
- if (oh5)
25
- o.ohlcv5m = oh5;
26
- const oh4 = reviveBars(o.ohlcv4h);
27
- if (oh4)
28
- o.ohlcv4h = oh4;
29
- const oh1d = reviveBars(o.ohlcv1d);
30
- if (oh1d)
31
- o.ohlcv1d = oh1d;
32
- if (Array.isArray(o.tradeFlow)) {
33
- o.tradeFlow = o.tradeFlow.map((t) => ({ ...t, bucket: new Date(t.bucket) }));
34
- }
35
- if (o.globalContext?.btcRsi14_1d_at) {
36
- o.globalContext.btcRsi14_1d_at = new Date(o.globalContext.btcRsi14_1d_at);
37
- }
38
- return o;
39
- }
@@ -1,3 +0,0 @@
1
- import type { MarketContext, Direction } from './types.js';
2
- import type { StopRuleConfig, ConditionContext } from './conditions/types.js';
3
- export declare function computeStop(rule: StopRuleConfig, ctx: MarketContext, direction: Direction, condCtx: ConditionContext): number;
@@ -1,48 +0,0 @@
1
- // ⚠️ GENERATED FILE — DO NOT EDIT.
2
- // Canonical source of truth: shared/src/signals/stop-rules.ts
3
- // Regenerate: node scripts/sync-shared-code.mjs (enforced by shared-code-sync.test.ts)
4
- //
5
- // This copy exists because this package builds with tsc and deploys as a
6
- // self-contained tree that strips workspace deps, so it cannot import
7
- // @reefclaw/shared runtime code across the deploy boundary.
8
- // Stop level calculation for declarative strategies.
9
- import { findSwingPoints } from '../shared/indicators.js';
10
- export function computeStop(rule, ctx, direction, condCtx) {
11
- switch (rule.type) {
12
- case 'swing_atr': {
13
- const swingCount = rule.params.swingCount ?? 3;
14
- const atrFraction = (rule.params.atrFraction ?? 0.3) * ctx.atr14;
15
- const fallbackAtrMult = rule.params.fallbackAtrMultiple ?? 2;
16
- const swings = findSwingPoints(ctx.ohlcv1h.slice(-48), 3);
17
- if (direction === 'LONG') {
18
- return swings.lows.length > 0
19
- ? Math.min(...swings.lows.slice(-swingCount)) - atrFraction
20
- : ctx.currentPrice - ctx.atr14 * fallbackAtrMult;
21
- }
22
- else {
23
- return swings.highs.length > 0
24
- ? Math.max(...swings.highs.slice(-swingCount)) + atrFraction
25
- : ctx.currentPrice + ctx.atr14 * fallbackAtrMult;
26
- }
27
- }
28
- case 'recent_extreme_atr': {
29
- const atrFraction = (rule.params.atrFraction ?? 0.5) * ctx.atr14;
30
- if (direction === 'LONG') {
31
- return (condCtx.recentLow ?? ctx.currentPrice - ctx.atr14) - atrFraction;
32
- }
33
- else {
34
- return (condCtx.recentHigh ?? ctx.currentPrice + ctx.atr14) + atrFraction;
35
- }
36
- }
37
- case 'fixed_atr': {
38
- const atrMultiple = rule.params.atrMultiple ?? 1.5;
39
- return direction === 'LONG'
40
- ? ctx.currentPrice - ctx.atr14 * atrMultiple
41
- : ctx.currentPrice + ctx.atr14 * atrMultiple;
42
- }
43
- default:
44
- return direction === 'LONG'
45
- ? ctx.currentPrice - ctx.atr14 * 2
46
- : ctx.currentPrice + ctx.atr14 * 2;
47
- }
48
- }
@@ -1,47 +0,0 @@
1
- import type { StrategyDefinition, MarketContext, OhlcvBar } from './types.js';
2
- import type { StrategyConfig, PrimaryTimeframe } from './conditions/types.js';
3
- export declare function clearStrategyGatingState(): void;
4
- /**
5
- * Live parity for higher-timeframe strategies (the tfHours-aware-stops fix,
6
- * 2026-07 — see docs/STRATEGY_RESEARCH_2026-07.md §6.4 / CLAUDE.md ★).
7
- *
8
- * Every implicit bar read in this engine — stop rules
9
- * (`findSwingPoints(ctx.ohlcv1h.slice(-48))`), entry rules
10
- * (`computeEMA(ctx.ohlcv1h…)`), conditions without a `tfHours` param
11
- * (ema_proximity, stoch_rsi_extreme, adx_*, …) and `ctx.atr14` — targets the
12
- * `ohlcv1h` slot. The backtest engine feeds MAIN-timeframe bars into that
13
- * slot (and computes atr14 from them), so a 4h/1d strategy backtests against
14
- * primary-timeframe geometry. LIVE contexts put real 1h bars there, so the
15
- * same strategy would compute stops/EMAs/ATR from 1h data — a 1d ATR is ~8×
16
- * the 1h ATR, so live stops came out ~8× too tight. This helper gives the
17
- * evaluation the exact context shape the backtest validated: primary bars in
18
- * the `ohlcv1h` slot, atr14 recomputed from them (same computeATR the
19
- * backtest and live context builders use).
20
- *
21
- * Detection, not configuration: when the `ohlcv1h` slot already carries
22
- * primary-cadence bars (median spacing ≥ 90% of the primary bar duration —
23
- * i.e. a backtest context), the context is returned UNTOUCHED, so backtest
24
- * behaviour is byte-identical by construction (including warm-up: the
25
- * backtest engine already refuses to build a context below 50 main bars).
26
- * A live 1h series can only look primary-spaced through a data gap, in
27
- * which case we fall back to the untouched context (pre-fix behaviour)
28
- * rather than guessing.
29
- *
30
- * Returns null for a LIVE context whose primary-timeframe history is below
31
- * the backtest's 50-bar warm-up — the caller skips evaluation, mirroring
32
- * the backtest's null-context warm-up window.
33
- *
34
- * Exported for tests.
35
- */
36
- export declare function resolvePrimaryContext(ctx: MarketContext, tf: PrimaryTimeframe, tfBars: OhlcvBar[]): MarketContext | null;
37
- /**
38
- * Convert a declarative StrategyConfig into a StrategyDefinition
39
- * that the signal engine and backtest engine can evaluate.
40
- *
41
- * `gateNamespace` scopes the module-global HTF tick-gate to the calling tenant
42
- * (pass the strategy-cache key — `global` for the background pass, the user key
43
- * for a per-user pass). Omit it for single-tenant callers (backtests, the
44
- * plugin's local evaluator) — they keep the original un-namespaced gate key,
45
- * so their behaviour is byte-identical.
46
- */
47
- export declare function adaptStrategy(config: StrategyConfig, gateNamespace?: string): StrategyDefinition;
@@ -1,199 +0,0 @@
1
- // ⚠️ GENERATED FILE — DO NOT EDIT.
2
- // Canonical source of truth: shared/src/signals/strategy-adapter.ts
3
- // Regenerate: node scripts/sync-shared-code.mjs (enforced by shared-code-sync.test.ts)
4
- //
5
- // This copy exists because this package builds with tsc and deploys as a
6
- // self-contained tree that strips workspace deps, so it cannot import
7
- // @reefclaw/shared runtime code across the deploy boundary.
8
- import { evaluateConditions } from './conditions/registry.js';
9
- import { resolveDirection } from './direction-rules.js';
10
- import { computeEntry } from './entry-rules.js';
11
- import { computeStop } from './stop-rules.js';
12
- import { computeATR } from '../shared/indicators.js';
13
- /**
14
- * Higher-timeframe tick gating state, keyed by
15
- * `${gateNamespace}\x1f${strategyName}:${symbol}`.
16
- *
17
- * Lives at module scope because the strategy cache (strategy-store.ts) builds
18
- * a fresh adapter every 60s, so closure-based state would reset constantly
19
- * and 1d-primary strategies would re-evaluate on every tick instead of once
20
- * per closed bar. Module-level state survives the cache refresh.
21
- *
22
- * ★ Multi-tenant: because the map is module-global, the key MUST carry a
23
- * per-tenant `gateNamespace` (the caller's strategy-cache key — `global` vs a
24
- * per-user key). Without it, two tenants running same-named strategies on the
25
- * same symbol shared ONE gate: whichever evaluated first marked the bar
26
- * consumed and the other tenant's strategy was silently SKIPPED until the next
27
- * primary-timeframe bar closed (a full day for a 1d strategy). A `\x1f` (unit
28
- * separator, never present in a UUID / strategy name / symbol) joins the
29
- * namespace so distinct tenants can never collide.
30
- *
31
- * Backtests should call `clearStrategyGatingState()` between runs to avoid
32
- * leakage across tests / sequential backtests.
33
- */
34
- const lastEvaluatedBarTime = new Map();
35
- export function clearStrategyGatingState() {
36
- lastEvaluatedBarTime.clear();
37
- }
38
- function pickTimeframeBars(ctx, tf) {
39
- if (tf === '1d')
40
- return ctx.ohlcv1d ?? [];
41
- if (tf === '4h')
42
- return ctx.ohlcv4h ?? [];
43
- return ctx.ohlcv1h;
44
- }
45
- const TF_MS = {
46
- '1h': 3_600_000,
47
- '4h': 4 * 3_600_000,
48
- '1d': 24 * 3_600_000,
49
- };
50
- /** Median spacing of the last few bars — robust bar-cadence probe. */
51
- function barSpacingMs(bars) {
52
- const n = bars.length;
53
- if (n < 2)
54
- return 0;
55
- const deltas = [];
56
- for (let i = Math.max(1, n - 4); i < n; i++) {
57
- deltas.push(bars[i].time.getTime() - bars[i - 1].time.getTime());
58
- }
59
- deltas.sort((a, b) => a - b);
60
- return deltas[Math.floor(deltas.length / 2)];
61
- }
62
- /**
63
- * Live parity for higher-timeframe strategies (the tfHours-aware-stops fix,
64
- * 2026-07 — see docs/STRATEGY_RESEARCH_2026-07.md §6.4 / CLAUDE.md ★).
65
- *
66
- * Every implicit bar read in this engine — stop rules
67
- * (`findSwingPoints(ctx.ohlcv1h.slice(-48))`), entry rules
68
- * (`computeEMA(ctx.ohlcv1h…)`), conditions without a `tfHours` param
69
- * (ema_proximity, stoch_rsi_extreme, adx_*, …) and `ctx.atr14` — targets the
70
- * `ohlcv1h` slot. The backtest engine feeds MAIN-timeframe bars into that
71
- * slot (and computes atr14 from them), so a 4h/1d strategy backtests against
72
- * primary-timeframe geometry. LIVE contexts put real 1h bars there, so the
73
- * same strategy would compute stops/EMAs/ATR from 1h data — a 1d ATR is ~8×
74
- * the 1h ATR, so live stops came out ~8× too tight. This helper gives the
75
- * evaluation the exact context shape the backtest validated: primary bars in
76
- * the `ohlcv1h` slot, atr14 recomputed from them (same computeATR the
77
- * backtest and live context builders use).
78
- *
79
- * Detection, not configuration: when the `ohlcv1h` slot already carries
80
- * primary-cadence bars (median spacing ≥ 90% of the primary bar duration —
81
- * i.e. a backtest context), the context is returned UNTOUCHED, so backtest
82
- * behaviour is byte-identical by construction (including warm-up: the
83
- * backtest engine already refuses to build a context below 50 main bars).
84
- * A live 1h series can only look primary-spaced through a data gap, in
85
- * which case we fall back to the untouched context (pre-fix behaviour)
86
- * rather than guessing.
87
- *
88
- * Returns null for a LIVE context whose primary-timeframe history is below
89
- * the backtest's 50-bar warm-up — the caller skips evaluation, mirroring
90
- * the backtest's null-context warm-up window.
91
- *
92
- * Exported for tests.
93
- */
94
- export function resolvePrimaryContext(ctx, tf, tfBars) {
95
- if (tf === '1h')
96
- return ctx;
97
- const spacing = barSpacingMs(ctx.ohlcv1h);
98
- if (spacing === 0 || spacing >= TF_MS[tf] * 0.9)
99
- return ctx; // already primary (backtest) or undecidable
100
- if (tfBars.length < 50)
101
- return null; // live warm-up parity with the backtest engine
102
- const highs = tfBars.map(b => b.high);
103
- const lows = tfBars.map(b => b.low);
104
- const closes = tfBars.map(b => b.close);
105
- const atr14 = computeATR(highs, lows, closes, 14);
106
- return {
107
- ...ctx,
108
- ohlcv1h: tfBars,
109
- atr14: Number.isFinite(atr14) && atr14 > 0 ? atr14 : ctx.atr14,
110
- };
111
- }
112
- /** Empty no-signal evaluation — used when gating skips a strategy. */
113
- const SKIPPED = { direction: null, conditions: [], trade: undefined };
114
- /**
115
- * Convert a declarative StrategyConfig into a StrategyDefinition
116
- * that the signal engine and backtest engine can evaluate.
117
- *
118
- * `gateNamespace` scopes the module-global HTF tick-gate to the calling tenant
119
- * (pass the strategy-cache key — `global` for the background pass, the user key
120
- * for a per-user pass). Omit it for single-tenant callers (backtests, the
121
- * plugin's local evaluator) — they keep the original un-namespaced gate key,
122
- * so their behaviour is byte-identical.
123
- */
124
- export function adaptStrategy(config, gateNamespace) {
125
- return {
126
- name: config.name,
127
- regimeWhitelist: config.regimeWhitelist,
128
- minConfidence: config.minConfidence,
129
- async evaluate(ctx) {
130
- // ─── Tick gating ───────────────────────────────────────────────
131
- // Only re-evaluate when a new bar of the strategy's primary
132
- // timeframe has closed since the last evaluation for this
133
- // strategy/symbol pair. Defaults to '1h' so existing strategies
134
- // are unaffected.
135
- const tf = config.primaryTimeframe ?? '1h';
136
- const tfBars = pickTimeframeBars(ctx, tf);
137
- if (tfBars.length === 0)
138
- return SKIPPED;
139
- const latestBarTime = tfBars[tfBars.length - 1].time.getTime();
140
- // Namespaced per tenant (see lastEvaluatedBarTime doc) so same-named
141
- // strategies across tenants never share a gate. Un-namespaced when
142
- // gateNamespace is omitted — byte-identical to the original key.
143
- const gateKey = gateNamespace
144
- ? `${gateNamespace}\x1f${config.name}:${ctx.symbol}`
145
- : `${config.name}:${ctx.symbol}`;
146
- const lastBarTime = lastEvaluatedBarTime.get(gateKey);
147
- if (lastBarTime !== undefined && latestBarTime === lastBarTime) {
148
- return SKIPPED;
149
- }
150
- lastEvaluatedBarTime.set(gateKey, latestBarTime);
151
- // ─── Higher-timeframe live parity ──────────────────────────────
152
- // Evaluate against a context whose implicit-1h slot carries
153
- // primary-timeframe bars — see resolvePrimaryContext. Backtest
154
- // contexts pass through untouched; only live contexts for 4h/1d
155
- // strategies are adapted, and a live context below the backtest's
156
- // 50-bar warm-up resolves to null → skip.
157
- const ectx = resolvePrimaryContext(ctx, tf, tfBars);
158
- if (ectx === null)
159
- return SKIPPED;
160
- // ─── SkipIf gates ──────────────────────────────────────────────
161
- // Portfolio-wide / cross-symbol filters. If any are met the
162
- // strategy is skipped this tick. Evaluated before main conditions
163
- // so the bulk of the work is short-circuited.
164
- if (config.skipIf && config.skipIf.length > 0) {
165
- const { conditions: skipResults } = evaluateConditions(config.skipIf, ectx, null);
166
- if (skipResults.some(c => c.met))
167
- return SKIPPED;
168
- }
169
- // Pass 1: evaluate conditions with direction = null
170
- const { conditions: pass1, condCtx } = evaluateConditions(config.conditions, ectx, null);
171
- // Determine direction
172
- const direction = resolveDirection(config.directionRule, ectx, condCtx);
173
- // Pass 2: re-evaluate direction-sensitive conditions now that we know direction
174
- // (orderbook_imbalance and funding_contrarian behave differently per direction)
175
- const directionSensitive = new Set(['orderbook_imbalance', 'funding_contrarian', 'funding_extreme_skip', 'funding_position_ok', 'return_momentum']);
176
- const hasDirSensitive = config.conditions.some(c => directionSensitive.has(c.type));
177
- let finalConditions = pass1;
178
- if (direction && hasDirSensitive) {
179
- const { conditions: pass2 } = evaluateConditions(config.conditions, ectx, direction);
180
- // Merge: use pass2 results for direction-sensitive, pass1 for others
181
- finalConditions = pass1.map((c, i) => directionSensitive.has(config.conditions[i].type) ? pass2[i] : c);
182
- }
183
- const allMet = finalConditions.every(c => c.met);
184
- let trade;
185
- if (allMet && direction) {
186
- const entryZone = computeEntry(config.entryRule, ectx, direction, condCtx);
187
- const stopLevel = computeStop(config.stopRule, ectx, direction, condCtx);
188
- const risk = direction === 'LONG'
189
- ? ectx.currentPrice - stopLevel
190
- : stopLevel - ectx.currentPrice;
191
- const targets = config.targetRMultiples.map(rm => direction === 'LONG'
192
- ? ectx.currentPrice + risk * rm
193
- : ectx.currentPrice - risk * rm);
194
- trade = { entryZone, stopLevel, targets };
195
- }
196
- return { direction, conditions: finalConditions, trade };
197
- },
198
- };
199
- }
@@ -1 +0,0 @@
1
- export type { Direction, OhlcvBar, TradeFlowBucket, GlobalMarketContext, MarketContext, SignalCondition, StrategyEvaluation, StrategyDefinition, SignalEvent, StrategyState, SignalSnapshot, } from '@reefclaw/shared';
@@ -1,8 +0,0 @@
1
- // Re-export shim for the plugin-side strategy evaluator (facts-out).
2
- //
3
- // The generated eval-core copies (registry, strategy-adapter, direction/entry/
4
- // stop-rules) import their types from `./types.js`. The canonical definitions
5
- // live in @reefclaw/shared (type-only → erased at runtime), so this shim makes
6
- // those relative imports resolve inside the plugin tree without pulling any
7
- // runtime dependency into the emitted JS. See docs/FACTS_OUT_ARCHITECTURE.md.
8
- export {};
@@ -1,93 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import type { SimulatorState, OrderBookDepth, SimulationConfig, ExecutionStats, PositionMetadata, CloseReason } from './types.js';
3
- import type { CcxtOrder, CcxtBalance, CcxtPosition, CcxtTicker } from '../types.js';
4
- export declare class ExchangeSimulator extends EventEmitter {
5
- private state;
6
- private lastTicker;
7
- private lastOrderBook;
8
- private simulationConfig;
9
- /** Metadata for pending limit orders, keyed by order ID. Cleaned up on fill/cancel. */
10
- private pendingOrderMetadata;
11
- private cachedVolFactor;
12
- private baselineAtr;
13
- private atrSampleCount;
14
- private readonly startupTime;
15
- private readonly hadPositionsAtStartup;
16
- private static readonly STARTUP_LOCKOUT_MS;
17
- constructor(initialState: SimulatorState, config?: SimulationConfig);
18
- getSimulationConfig(): SimulationConfig;
19
- setVolFactor(factor: number): void;
20
- getVolFactor(): number;
21
- /** Update baseline ATR using exponential moving average of samples. */
22
- updateBaselineAtr(atr14: number): void;
23
- getBaselineAtr(): number;
24
- /**
25
- * Returns today's session-start NAV, lazily seeding it from current equity
26
- * if unset or stale (different UTC day). This is the plugin-side anchor used
27
- * by the pre-trade risk gate; a stale/missing anchor silently disables the
28
- * drawdown zones, so callers must never see a zero.
29
- */
30
- getSessionStartNav(): number;
31
- setSessionStartNav(nav: number): void;
32
- /** Seed sessionStartNav from current equity on the first check of each UTC day.
33
- * Safe to call repeatedly — no-op once the anchor matches today's date. */
34
- private ensureSessionAnchor;
35
- /** Mark-to-market equity = walletTotal + for each open position, the
36
- * collateral locked at entry + current unrealized P&L. Paper simulator is
37
- * SPOT-collateral style: the full entry notional was deducted from wallet
38
- * on open and is released on close, so we must add it back here. */
39
- computeEquity(): number;
40
- private getQuoteCurrency;
41
- getBalance(): CcxtBalance;
42
- getPositions(symbol?: string): CcxtPosition[];
43
- getOpenOrders(symbol?: string): CcxtOrder[];
44
- /** Get cumulative execution quality stats. */
45
- getExecutionStats(): ExecutionStats | undefined;
46
- /** Cache the latest order book snapshot for a symbol. */
47
- updateOrderBook(symbol: string, orderbook: OrderBookDepth): void;
48
- getLastOrderBook(symbol: string): OrderBookDepth | undefined;
49
- createOrder(symbol: string, side: 'buy' | 'sell', type: 'market' | 'limit', amount: number, price?: number, metadata?: PositionMetadata): CcxtOrder;
50
- cancelOrder(orderId: string): CcxtOrder;
51
- cancelAllOrders(symbol?: string): CcxtOrder[];
52
- closePosition(symbol: string, closeReason?: CloseReason): CcxtOrder;
53
- /** Paper-only: move an open position's MUTABLE protective levels (stopPrice /
54
- * targetPrice) in place and persist, WITHOUT the close+reopen round-trip
55
- * (which pays an extra taker fee and resets the R/MFE denominators). The
56
- * frozen originalStopPrice / originalEntryPrice are intentionally left
57
- * untouched so R-multiples stay anchored at entry. The paper stop-watcher
58
- * and getPositions both read metadata.stopPrice, so a moved stop takes
59
- * effect on the next watcher tick. Throws if there is no open position. (M9) */
60
- updatePositionMetadata(symbol: string, patch: {
61
- stopPrice?: number;
62
- targetPrice?: number;
63
- }): void;
64
- updateTicker(ticker: CcxtTicker): void;
65
- getLastTicker(symbol: string): CcxtTicker | undefined;
66
- /** Walk every position for `symbol` and refresh MFE / give-back from the
67
- * latest mark. Idempotent — pure update of `metadata.mfePeakPrice` (only
68
- * ratchets favourably) plus derived `mfeR` and `giveBackRatio`. Safe to
69
- * call before any positions exist (no-op). */
70
- private refreshMfeForSymbol;
71
- /** Replace internal state with a fresh copy from disk.
72
- * Used by the gateway process to pick up state saved by the agent process.
73
- *
74
- * Non-destructive for the MFE ratchet (M3): the disk copy can lag the live
75
- * peak (refreshMfeForSymbol ratchets every tick; persistence coalesces), so
76
- * a wholesale swap would discard it. For each position present in BOTH
77
- * snapshots (same symbol+side+openedAt) we carry over the MORE-favourable
78
- * monotone peak and recompute mfeR/giveBackRatio from the current mark, so a
79
- * reload never regresses the agent's give-back signal. */
80
- replaceState(newState: SimulatorState): void;
81
- getState(): SimulatorState;
82
- private shouldFillLimit;
83
- private executeMarketFill;
84
- private executeLimitFill;
85
- /** Apply a fill result: update positions, record trade, track stats, emit state change. */
86
- private applyFillResult;
87
- private updatePosition;
88
- private addTrade;
89
- /** Update cumulative execution stats from a fill's execution quality. */
90
- private updateExecutionStats;
91
- private emitStateChanged;
92
- private toCcxtOrder;
93
- }