@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,151 +0,0 @@
1
- // Shadow Tracker — compares paper fills against live exchange estimates.
2
- // Listens for fill events from the simulator, fetches real order book,
3
- // computes what the live fill would have been, logs the comparison.
4
- import { EventEmitter } from 'node:events';
5
- import { logger } from '../logger.js';
6
- import { priceToBps } from '../simulator/types.js';
7
- import { computeBookAwareFillPrice } from '../simulator/realistic-fills.js';
8
- import { createEmptyShadowMetrics, DEFAULT_SHADOW_CONFIG } from './types.js';
9
- const TAG = 'shadow-tracker';
10
- /** Maximum recent comparisons to keep in memory. */
11
- const MAX_RECENT_COMPARISONS = 100;
12
- /**
13
- * ShadowTracker hooks into the ExchangeSimulator to compute
14
- * shadow estimates for every paper fill.
15
- *
16
- * Events emitted:
17
- * - 'shadowComparison': ShadowComparison — after each fill comparison
18
- */
19
- export class ShadowTracker extends EventEmitter {
20
- privateApi;
21
- simulator;
22
- metrics;
23
- config;
24
- recentComparisons = [];
25
- active = false;
26
- constructor(privateApi, simulator, config, existingMetrics) {
27
- super();
28
- this.privateApi = privateApi;
29
- this.simulator = simulator;
30
- this.config = config ?? DEFAULT_SHADOW_CONFIG;
31
- this.metrics = existingMetrics ?? createEmptyShadowMetrics();
32
- }
33
- /** Start listening for simulator fill events. */
34
- start() {
35
- if (this.active)
36
- return;
37
- this.active = true;
38
- this.simulator.on('fill', this.onFill);
39
- logger.info(TAG, `Shadow tracker started (${this.metrics.totalShadowTrades} prior comparisons)`);
40
- }
41
- /** Stop listening. */
42
- stop() {
43
- if (!this.active)
44
- return;
45
- this.active = false;
46
- this.simulator.off('fill', this.onFill);
47
- logger.info(TAG, 'Shadow tracker stopped');
48
- }
49
- /** Get current shadow metrics. */
50
- getMetrics() {
51
- return { ...this.metrics };
52
- }
53
- /** Get recent comparisons. */
54
- getRecentComparisons() {
55
- return [...this.recentComparisons];
56
- }
57
- /** Check if shadow mode criteria are met for mode upgrade. */
58
- isReadyForUpgrade() {
59
- const reasons = [];
60
- if (this.metrics.totalShadowTrades < this.config.minTrades) {
61
- reasons.push(`Need ${this.config.minTrades} shadow trades, have ${this.metrics.totalShadowTrades}`);
62
- }
63
- if (this.metrics.tradingDays < this.config.minDays) {
64
- reasons.push(`Need ${this.config.minDays} trading days, have ${this.metrics.tradingDays}`);
65
- }
66
- if (this.metrics.avgDeltaBps > this.config.maxAvgDeltaBps) {
67
- reasons.push(`Avg delta ${this.metrics.avgDeltaBps.toFixed(2)}bps exceeds max ${this.config.maxAvgDeltaBps}bps`);
68
- }
69
- return { ready: reasons.length === 0, reasons };
70
- }
71
- // Arrow function to preserve `this` binding when used as event listener
72
- onFill = (fillData) => {
73
- // Only compare market order fills (limit orders fill at limit price, no comparison needed)
74
- if (fillData.type !== 'market')
75
- return;
76
- // Fire and forget — shadow comparison is async but doesn't block the fill
77
- this.computeShadowComparison(fillData).catch(err => {
78
- logger.warn(TAG, `Shadow comparison failed: ${err instanceof Error ? err.message : String(err)}`);
79
- });
80
- };
81
- async computeShadowComparison(fillData) {
82
- // Fetch fresh order book from the exchange (authenticated path)
83
- const liveBook = await this.privateApi.fetchOrderBook(fillData.symbol, 20);
84
- let shadowPrice;
85
- let bookDepthUsed = 0;
86
- let bookDepthAvailable = false;
87
- if (liveBook && liveBook.asks.length > 0 && liveBook.bids.length > 0) {
88
- // Walk the live book to compute shadow VWAP
89
- const { vwap, levelsConsumed } = computeBookAwareFillPrice(fillData.side, fillData.amount, liveBook);
90
- shadowPrice = vwap;
91
- bookDepthUsed = levelsConsumed;
92
- bookDepthAvailable = true;
93
- }
94
- else {
95
- // No live book available — use paper fill as shadow estimate
96
- shadowPrice = fillData.fillPrice;
97
- logger.warn(TAG, `No live order book for ${fillData.symbol} — shadow estimate equals paper`);
98
- }
99
- // Compute shadow fee (same taker rate as paper for fair comparison)
100
- const simConfig = this.simulator.getSimulationConfig();
101
- const shadowFee = fillData.amount * shadowPrice * simConfig.fees.takerRate;
102
- // Delta: positive = live would be worse (pay more for buy, receive less for sell)
103
- const deltaBps = priceToBps(shadowPrice, fillData.fillPrice);
104
- const comparison = {
105
- orderId: fillData.orderId,
106
- symbol: fillData.symbol,
107
- side: fillData.side,
108
- type: fillData.type,
109
- amount: fillData.amount,
110
- paperFillPrice: fillData.fillPrice,
111
- shadowEstimatePrice: shadowPrice,
112
- deltaBps,
113
- paperFee: fillData.fee,
114
- shadowEstimateFee: shadowFee,
115
- bookDepthUsed,
116
- bookDepthAvailable,
117
- timestamp: new Date().toISOString(),
118
- };
119
- // Update metrics
120
- this.updateMetrics(comparison);
121
- // Store recent comparison (match webapp slice pattern — slice instead of shift)
122
- this.recentComparisons = [
123
- ...this.recentComparisons.slice(-(MAX_RECENT_COMPARISONS - 1)),
124
- comparison,
125
- ];
126
- // Emit event for skill/bridge pipeline
127
- this.emit('shadowComparison', comparison);
128
- logger.info(TAG, `Shadow comparison: ${fillData.side} ${fillData.amount} ${fillData.symbol}` +
129
- ` | Paper: ${fillData.fillPrice.toFixed(2)} | Shadow: ${shadowPrice.toFixed(2)}` +
130
- ` | Delta: ${deltaBps.toFixed(2)}bps` +
131
- ` | Book: ${bookDepthAvailable ? `${bookDepthUsed} levels` : 'unavailable'}`);
132
- }
133
- updateMetrics(comparison) {
134
- const m = this.metrics;
135
- m.totalShadowTrades++;
136
- const absDelta = Math.abs(comparison.deltaBps);
137
- m.totalDeltaBpsSum += absDelta;
138
- m.avgDeltaBps = m.totalDeltaBpsSum / m.totalShadowTrades;
139
- if (absDelta > m.worstDeltaBps) {
140
- m.worstDeltaBps = absDelta;
141
- }
142
- m.paperTotalFees += comparison.paperFee;
143
- m.shadowTotalFees += comparison.shadowEstimateFee;
144
- // Track trading days
145
- const today = comparison.timestamp.slice(0, 10);
146
- if (today !== m.lastTradeDate) {
147
- m.tradingDays++;
148
- m.lastTradeDate = today;
149
- }
150
- }
151
- }
@@ -1,42 +0,0 @@
1
- import type { TradingMode } from '../types.js';
2
- export type { TradingMode };
3
- /** A single shadow comparison record: paper fill vs live estimate. */
4
- export interface ShadowComparison {
5
- orderId: string;
6
- symbol: string;
7
- side: 'buy' | 'sell';
8
- type: 'market' | 'limit';
9
- amount: number;
10
- paperFillPrice: number;
11
- shadowEstimatePrice: number;
12
- deltaBps: number;
13
- paperFee: number;
14
- shadowEstimateFee: number;
15
- bookDepthUsed: number;
16
- bookDepthAvailable: boolean;
17
- timestamp: string;
18
- }
19
- /** Aggregate shadow metrics across all shadow comparisons. */
20
- export interface ShadowMetrics {
21
- totalShadowTrades: number;
22
- avgDeltaBps: number;
23
- worstDeltaBps: number;
24
- totalDeltaBpsSum: number;
25
- paperTotalFees: number;
26
- shadowTotalFees: number;
27
- startedAt: string;
28
- tradingDays: number;
29
- lastTradeDate: string;
30
- }
31
- /** Shadow mode configuration thresholds. */
32
- export interface ShadowConfig {
33
- /** Minimum shadow trades before allowing mode upgrade (default: 50) */
34
- minTrades: number;
35
- /** Minimum days in shadow mode (default: 7) */
36
- minDays: number;
37
- /** Max acceptable average delta in bps (default: 5) */
38
- maxAvgDeltaBps: number;
39
- }
40
- export declare const DEFAULT_SHADOW_CONFIG: ShadowConfig;
41
- /** Create empty shadow metrics. */
42
- export declare function createEmptyShadowMetrics(): ShadowMetrics;
@@ -1,20 +0,0 @@
1
- // Shadow mode types — tracking paper vs live fill comparison.
2
- export const DEFAULT_SHADOW_CONFIG = {
3
- minTrades: 50,
4
- minDays: 7,
5
- maxAvgDeltaBps: 5,
6
- };
7
- /** Create empty shadow metrics. */
8
- export function createEmptyShadowMetrics() {
9
- return {
10
- totalShadowTrades: 0,
11
- avgDeltaBps: 0,
12
- worstDeltaBps: 0,
13
- totalDeltaBpsSum: 0,
14
- paperTotalFees: 0,
15
- shadowTotalFees: 0,
16
- startedAt: new Date().toISOString(),
17
- tradingDays: 0,
18
- lastTradeDate: '',
19
- };
20
- }
@@ -1,52 +0,0 @@
1
- export interface OhlcvInput {
2
- open: number;
3
- high: number;
4
- low: number;
5
- close: number;
6
- volume: number;
7
- }
8
- export interface MACDResult {
9
- line: number;
10
- signal: number;
11
- histogram: number;
12
- crossover: 'bullish' | 'bearish' | 'none';
13
- }
14
- export interface BollingerResult {
15
- upper: number;
16
- middle: number;
17
- lower: number;
18
- bandwidth: number;
19
- percentB: number;
20
- }
21
- export interface StochRSIResult {
22
- k: number;
23
- d: number;
24
- }
25
- export interface IchimokuResult {
26
- tenkan: number;
27
- kijun: number;
28
- senkouA: number;
29
- senkouB: number;
30
- chikou: number;
31
- cloudPosition: 'above' | 'below' | 'inside';
32
- }
33
- export interface SupertrendResult {
34
- value: number;
35
- direction: 'bullish' | 'bearish';
36
- }
37
- export declare function computeMACD(closes: number[], fast?: number, slow?: number, signal?: number): MACDResult;
38
- export declare function computeBollingerBands(closes: number[], period?: number, stdDev?: number): BollingerResult;
39
- export declare function computeVWAP(bars: OhlcvInput[]): number;
40
- export declare function computeStochRSI(closes: number[], rsiPeriod?: number, stochPeriod?: number, kSmooth?: number, dSmooth?: number): StochRSIResult;
41
- export declare function computeADX(highs: number[], lows: number[], closes: number[], period?: number): {
42
- adx: number;
43
- plusDI: number;
44
- minusDI: number;
45
- };
46
- export declare function computeIchimoku(highs: number[], lows: number[], closes: number[], tenkanPeriod?: number, kijunPeriod?: number, senkouBPeriod?: number): IchimokuResult;
47
- export declare function computeOBV(closes: number[], volumes: number[]): {
48
- obv: number;
49
- slope: 'rising' | 'falling' | 'flat';
50
- };
51
- export declare function computeSupertrend(highs: number[], lows: number[], closes: number[], period?: number, multiplier?: number): SupertrendResult;
52
- export declare function computeWilliamsR(highs: number[], lows: number[], closes: number[], period?: number): number;
@@ -1,291 +0,0 @@
1
- // ⚠️ GENERATED FILE — DO NOT EDIT.
2
- // Canonical source of truth: shared/src/shared/indicators-extended.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
- // Extended indicator computations for Phase 13 — Expanded Indicators.
9
- // Wraps technicalindicators library + custom implementations.
10
- // All functions take OHLCV arrays (oldest first) and return latest values.
11
- import { computeATRSeries, computeRSI, mean, computeStd } from './indicators.js';
12
- // ─── MACD (12, 26, 9) ──────────────────────────────────────────────────
13
- export function computeMACD(closes, fast = 12, slow = 26, signal = 9) {
14
- if (closes.length < slow + signal) {
15
- return { line: 0, signal: 0, histogram: 0, crossover: 'none' };
16
- }
17
- // Compute full EMA series (both aligned to start at index `slow - 1`)
18
- const emaFastSeries = emaSeries(closes, fast);
19
- const emaSlowSeries = emaSeries(closes, slow);
20
- // Align: fast series starts earlier, so take the tail matching slow series length
21
- const offset = emaFastSeries.length - emaSlowSeries.length;
22
- const macdLine = [];
23
- for (let i = 0; i < emaSlowSeries.length; i++) {
24
- macdLine.push(emaFastSeries[i + offset] - emaSlowSeries[i]);
25
- }
26
- // Signal line = EMA of MACD line
27
- const signalSeries = emaSeries(macdLine, signal);
28
- const sigOffset = macdLine.length - signalSeries.length;
29
- const currentLine = macdLine[macdLine.length - 1];
30
- const currentSignal = signalSeries[signalSeries.length - 1];
31
- const prevLine = macdLine.length >= 2 ? macdLine[macdLine.length - 2] : currentLine;
32
- const prevSignalIdx = signalSeries.length >= 2 ? signalSeries.length - 2 : signalSeries.length - 1;
33
- const prevSignal = signalSeries[prevSignalIdx];
34
- let crossover = 'none';
35
- if (prevLine <= prevSignal && currentLine > currentSignal)
36
- crossover = 'bullish';
37
- else if (prevLine >= prevSignal && currentLine < currentSignal)
38
- crossover = 'bearish';
39
- return {
40
- line: currentLine,
41
- signal: currentSignal,
42
- histogram: currentLine - currentSignal,
43
- crossover,
44
- };
45
- }
46
- // ─── Bollinger Bands (20, 2σ) ───────────────────────────────────────────
47
- export function computeBollingerBands(closes, period = 20, stdDev = 2) {
48
- if (closes.length < period) {
49
- const p = closes[closes.length - 1] ?? 0;
50
- return { upper: p, middle: p, lower: p, bandwidth: 0, percentB: 0.5 };
51
- }
52
- const slice = closes.slice(-period);
53
- const middle = mean(slice);
54
- const std = computeStd(slice);
55
- const upper = middle + stdDev * std;
56
- const lower = middle - stdDev * std;
57
- const bandwidth = middle > 0 ? ((upper - lower) / middle) * 100 : 0;
58
- const price = closes[closes.length - 1];
59
- const percentB = upper !== lower ? (price - lower) / (upper - lower) : 0.5;
60
- return { upper, middle, lower, bandwidth, percentB };
61
- }
62
- // ─── VWAP ───────────────────────────────────────────────────────────────
63
- export function computeVWAP(bars) {
64
- if (bars.length === 0)
65
- return 0;
66
- let cumVolume = 0;
67
- let cumTPxVol = 0;
68
- for (const bar of bars) {
69
- const tp = (bar.high + bar.low + bar.close) / 3;
70
- cumVolume += bar.volume;
71
- cumTPxVol += tp * bar.volume;
72
- }
73
- return cumVolume > 0 ? cumTPxVol / cumVolume : bars[bars.length - 1].close;
74
- }
75
- // ─── Stochastic RSI (14, 14, 3, 3) ─────────────────────────────────────
76
- export function computeStochRSI(closes, rsiPeriod = 14, stochPeriod = 14, kSmooth = 3, dSmooth = 3) {
77
- if (closes.length < rsiPeriod + stochPeriod + dSmooth) {
78
- return { k: 50, d: 50 };
79
- }
80
- // Compute RSI series
81
- const rsiValues = [];
82
- for (let i = rsiPeriod + 1; i <= closes.length; i++) {
83
- rsiValues.push(computeRSI(closes.slice(0, i), rsiPeriod));
84
- }
85
- if (rsiValues.length < stochPeriod)
86
- return { k: 50, d: 50 };
87
- // Stochastic of RSI
88
- const rawK = [];
89
- for (let i = stochPeriod - 1; i < rsiValues.length; i++) {
90
- const window = rsiValues.slice(i - stochPeriod + 1, i + 1);
91
- const min = Math.min(...window);
92
- const max = Math.max(...window);
93
- rawK.push(max !== min ? ((rsiValues[i] - min) / (max - min)) * 100 : 50);
94
- }
95
- // %K = SMA of raw stochastic
96
- const kValues = sma(rawK, kSmooth);
97
- // %D = SMA of %K
98
- const dValues = sma(kValues, dSmooth);
99
- return {
100
- k: Math.round(kValues[kValues.length - 1] ?? 50),
101
- d: Math.round(dValues[dValues.length - 1] ?? 50),
102
- };
103
- }
104
- // ─── ADX (14) ───────────────────────────────────────────────────────────
105
- export function computeADX(highs, lows, closes, period = 14) {
106
- if (highs.length < period * 2 + 1) {
107
- return { adx: 0, plusDI: 0, minusDI: 0 };
108
- }
109
- const plusDM = [];
110
- const minusDM = [];
111
- const tr = [];
112
- for (let i = 1; i < highs.length; i++) {
113
- const upMove = highs[i] - highs[i - 1];
114
- const downMove = lows[i - 1] - lows[i];
115
- plusDM.push(upMove > downMove && upMove > 0 ? upMove : 0);
116
- minusDM.push(downMove > upMove && downMove > 0 ? downMove : 0);
117
- tr.push(Math.max(highs[i] - lows[i], Math.abs(highs[i] - closes[i - 1]), Math.abs(lows[i] - closes[i - 1])));
118
- }
119
- // Smooth with Wilder's smoothing (equivalent to EMA with alpha=1/period)
120
- const smoothPlusDM = wilderSmooth(plusDM, period);
121
- const smoothMinusDM = wilderSmooth(minusDM, period);
122
- const smoothTR = wilderSmooth(tr, period);
123
- // +DI and -DI series
124
- const plusDISeries = [];
125
- const minusDISeries = [];
126
- for (let i = 0; i < smoothTR.length; i++) {
127
- plusDISeries.push(smoothTR[i] > 0 ? (smoothPlusDM[i] / smoothTR[i]) * 100 : 0);
128
- minusDISeries.push(smoothTR[i] > 0 ? (smoothMinusDM[i] / smoothTR[i]) * 100 : 0);
129
- }
130
- // DX series
131
- const dxSeries = [];
132
- for (let i = 0; i < plusDISeries.length; i++) {
133
- const sum = plusDISeries[i] + minusDISeries[i];
134
- dxSeries.push(sum > 0 ? (Math.abs(plusDISeries[i] - minusDISeries[i]) / sum) * 100 : 0);
135
- }
136
- // ADX = Wilder smooth of DX
137
- const adxSeries = wilderSmooth(dxSeries, period);
138
- return {
139
- adx: Math.round(adxSeries[adxSeries.length - 1] ?? 0),
140
- plusDI: Math.round(plusDISeries[plusDISeries.length - 1] ?? 0),
141
- minusDI: Math.round(minusDISeries[minusDISeries.length - 1] ?? 0),
142
- };
143
- }
144
- // ─── Ichimoku Cloud ─────────────────────────────────────────────────────
145
- export function computeIchimoku(highs, lows, closes, tenkanPeriod = 9, kijunPeriod = 26, senkouBPeriod = 52) {
146
- const n = highs.length;
147
- if (n < senkouBPeriod) {
148
- const p = closes[n - 1] ?? 0;
149
- return { tenkan: p, kijun: p, senkouA: p, senkouB: p, chikou: p, cloudPosition: 'inside' };
150
- }
151
- const midpoint = (arr, period, end) => {
152
- const slice = arr.slice(Math.max(0, end - period + 1), end + 1);
153
- return (Math.max(...slice) + Math.min(...slice)) / 2;
154
- };
155
- const tenkan = midpoint(highs.concat().map((h, i) => Math.max(h, lows[i])), tenkanPeriod, n - 1);
156
- const kijun = midpoint(highs.concat().map((h, i) => Math.max(h, lows[i])), kijunPeriod, n - 1);
157
- // Recalculate properly using highs and lows separately
158
- const tenkanH = Math.max(...highs.slice(-tenkanPeriod));
159
- const tenkanL = Math.min(...lows.slice(-tenkanPeriod));
160
- const tenkanVal = (tenkanH + tenkanL) / 2;
161
- const kijunH = Math.max(...highs.slice(-kijunPeriod));
162
- const kijunL = Math.min(...lows.slice(-kijunPeriod));
163
- const kijunVal = (kijunH + kijunL) / 2;
164
- const senkouA = (tenkanVal + kijunVal) / 2;
165
- const senkouBH = Math.max(...highs.slice(-senkouBPeriod));
166
- const senkouBL = Math.min(...lows.slice(-senkouBPeriod));
167
- const senkouB = (senkouBH + senkouBL) / 2;
168
- const chikou = closes[n - 1]; // Current close (projected back 26 periods)
169
- const price = closes[n - 1];
170
- const cloudTop = Math.max(senkouA, senkouB);
171
- const cloudBottom = Math.min(senkouA, senkouB);
172
- const cloudPosition = price > cloudTop ? 'above' : price < cloudBottom ? 'below' : 'inside';
173
- return { tenkan: tenkanVal, kijun: kijunVal, senkouA, senkouB, chikou, cloudPosition };
174
- }
175
- // ─── OBV (On-Balance Volume) ────────────────────────────────────────────
176
- export function computeOBV(closes, volumes) {
177
- if (closes.length < 2)
178
- return { obv: 0, slope: 'flat' };
179
- let obv = 0;
180
- const obvSeries = [0];
181
- for (let i = 1; i < closes.length; i++) {
182
- if (closes[i] > closes[i - 1])
183
- obv += volumes[i];
184
- else if (closes[i] < closes[i - 1])
185
- obv -= volumes[i];
186
- obvSeries.push(obv);
187
- }
188
- // Slope over last 10 bars
189
- const lookback = Math.min(10, obvSeries.length);
190
- const recent = obvSeries.slice(-lookback);
191
- const first = recent[0];
192
- const last = recent[recent.length - 1];
193
- const threshold = Math.abs(first) * 0.01; // 1% threshold
194
- const slope = last - first > threshold ? 'rising' : last - first < -threshold ? 'falling' : 'flat';
195
- return { obv, slope };
196
- }
197
- // ─── Supertrend (10, 3) ─────────────────────────────────────────────────
198
- export function computeSupertrend(highs, lows, closes, period = 10, multiplier = 3) {
199
- const atrSeries = computeATRSeries(highs, lows, closes, period);
200
- if (atrSeries.length === 0) {
201
- return { value: closes[closes.length - 1] ?? 0, direction: 'bullish' };
202
- }
203
- // ATR series starts at index 1 (needs previous close for TR)
204
- // Align: atrSeries[i] corresponds to bar index i+1
205
- let upperBand = 0;
206
- let lowerBand = 0;
207
- let supertrend = 0;
208
- let direction = 'bullish';
209
- for (let i = 0; i < atrSeries.length; i++) {
210
- const barIdx = i + 1; // offset for TR calculation
211
- const hl2 = (highs[barIdx] + lows[barIdx]) / 2;
212
- const atr = atrSeries[i];
213
- const basicUpper = hl2 + multiplier * atr;
214
- const basicLower = hl2 - multiplier * atr;
215
- upperBand = i > 0 && basicUpper < upperBand && closes[barIdx - 1] > upperBand ? upperBand : basicUpper;
216
- lowerBand = i > 0 && basicLower > lowerBand && closes[barIdx - 1] < lowerBand ? lowerBand : basicLower;
217
- if (i === 0) {
218
- supertrend = closes[barIdx] > upperBand ? lowerBand : upperBand;
219
- direction = closes[barIdx] > upperBand ? 'bullish' : 'bearish';
220
- }
221
- else {
222
- if (direction === 'bullish') {
223
- if (closes[barIdx] < lowerBand) {
224
- direction = 'bearish';
225
- supertrend = upperBand;
226
- }
227
- else {
228
- supertrend = lowerBand;
229
- }
230
- }
231
- else {
232
- if (closes[barIdx] > upperBand) {
233
- direction = 'bullish';
234
- supertrend = lowerBand;
235
- }
236
- else {
237
- supertrend = upperBand;
238
- }
239
- }
240
- }
241
- }
242
- return { value: supertrend, direction };
243
- }
244
- // ─── Williams %R (14) ───────────────────────────────────────────────────
245
- export function computeWilliamsR(highs, lows, closes, period = 14) {
246
- if (highs.length < period)
247
- return -50;
248
- const recentHighs = highs.slice(-period);
249
- const recentLows = lows.slice(-period);
250
- const hh = Math.max(...recentHighs);
251
- const ll = Math.min(...recentLows);
252
- const close = closes[closes.length - 1];
253
- return hh !== ll ? ((hh - close) / (hh - ll)) * -100 : -50;
254
- }
255
- // ─── Helper: EMA series ─────────────────────────────────────────────────
256
- function emaSeries(data, period) {
257
- if (data.length === 0)
258
- return [];
259
- if (data.length < period)
260
- return [data[data.length - 1]];
261
- const k = 2 / (period + 1);
262
- const result = [];
263
- let ema = mean(data.slice(0, period));
264
- result.push(ema);
265
- for (let i = period; i < data.length; i++) {
266
- ema = data[i] * k + ema * (1 - k);
267
- result.push(ema);
268
- }
269
- return result;
270
- }
271
- // ─── Helper: SMA series ─────────────────────────────────────────────────
272
- function sma(data, period) {
273
- if (data.length < period)
274
- return data.length > 0 ? [mean(data)] : [];
275
- const result = [];
276
- for (let i = period - 1; i < data.length; i++) {
277
- result.push(mean(data.slice(i - period + 1, i + 1)));
278
- }
279
- return result;
280
- }
281
- // ─── Helper: Wilder's smoothing ─────────────────────────────────────────
282
- function wilderSmooth(data, period) {
283
- if (data.length < period)
284
- return [];
285
- const result = [];
286
- result.push(mean(data.slice(0, period)));
287
- for (let i = period; i < data.length; i++) {
288
- result.push((result[result.length - 1] * (period - 1) + data[i]) / period);
289
- }
290
- return result;
291
- }
@@ -1,15 +0,0 @@
1
- export declare function computeEMA(data: number[], period: number): number;
2
- export declare function computeATR(highs: number[], lows: number[], closes: number[], period: number): number;
3
- export declare function computeATRSeries(highs: number[], lows: number[], closes: number[], period: number): number[];
4
- export declare function computeRSI(closes: number[], period: number): number;
5
- export declare function linearSlope(y: number[], x?: number[]): number;
6
- export declare function computeStd(data: number[]): number;
7
- export declare function mean(data: number[]): number;
8
- /** Find swing highs and lows from OHLCV bars (simple pivot-point method). */
9
- export declare function findSwingPoints(bars: {
10
- high: number;
11
- low: number;
12
- }[], lookback?: number): {
13
- highs: number[];
14
- lows: number[];
15
- };