@quantform/core 0.7.0-beta.9 → 0.7.9

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/jest.config.ts +1 -1
  2. package/{dist → lib}/asset/asset.d.ts +3 -0
  3. package/lib/asset/asset.d.ts.map +1 -0
  4. package/{dist → lib}/asset/asset.js +8 -2
  5. package/{dist → lib}/cli/index.js +9 -6
  6. package/lib/cli/internal/script.d.ts +8 -0
  7. package/lib/cli/internal/script.d.ts.map +1 -0
  8. package/lib/cli/internal/script.js +75 -0
  9. package/{dist → lib}/cli/internal/workspace.js +1 -2
  10. package/lib/cli/live.d.ts +5 -0
  11. package/lib/cli/live.d.ts.map +1 -0
  12. package/lib/cli/live.js +33 -0
  13. package/lib/cli/paper.d.ts +5 -0
  14. package/lib/cli/paper.d.ts.map +1 -0
  15. package/lib/cli/paper.js +33 -0
  16. package/lib/cli/pull.d.ts.map +1 -0
  17. package/lib/cli/pull.js +28 -0
  18. package/lib/cli/replay.d.ts +6 -0
  19. package/lib/cli/replay.d.ts.map +1 -0
  20. package/lib/cli/replay.js +37 -0
  21. package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +1 -1
  22. package/{dist → lib}/component/distinct-until-timesamp-changed.js +1 -2
  23. package/lib/component/ohlc-operator.d.ts.map +1 -0
  24. package/{dist → lib}/component/ohlc-operator.js +3 -4
  25. package/{dist → lib}/component/ohlc.d.ts.map +1 -1
  26. package/{dist → lib}/component/timeframe.js +3 -3
  27. package/{dist → lib}/core.js +4 -5
  28. package/lib/index.d.ts +21 -0
  29. package/lib/index.d.ts.map +1 -0
  30. package/{dist → lib}/index.js +6 -13
  31. package/{dist → lib}/instrument/commission/commission.js +3 -3
  32. package/{dist → lib}/instrument/instrument.d.ts +3 -0
  33. package/lib/instrument/instrument.d.ts.map +1 -0
  34. package/{dist → lib}/instrument/instrument.js +8 -2
  35. package/lib/make-test-module.d.ts +13 -0
  36. package/lib/make-test-module.d.ts.map +1 -0
  37. package/{dist → lib}/make-test-module.js +13 -4
  38. package/lib/module.d.ts.map +1 -0
  39. package/lib/operators.d.ts +5 -0
  40. package/lib/operators.d.ts.map +1 -0
  41. package/lib/operators.js +15 -0
  42. package/lib/replay/index.d.ts +10 -0
  43. package/lib/replay/index.d.ts.map +1 -0
  44. package/{dist → lib}/replay/index.js +7 -4
  45. package/lib/replay/replay-guard.d.ts +10 -0
  46. package/lib/replay/replay-guard.d.ts.map +1 -0
  47. package/lib/replay/replay-guard.js +7 -0
  48. package/lib/replay/replay.d.ts +10 -0
  49. package/lib/replay/replay.d.ts.map +1 -0
  50. package/lib/replay/replay.js +8 -0
  51. package/lib/replay/storage/use-replay-storage-buffer.d.ts +15 -0
  52. package/lib/replay/storage/use-replay-storage-buffer.d.ts.map +1 -0
  53. package/lib/replay/storage/use-replay-storage-buffer.js +57 -0
  54. package/lib/replay/storage/use-replay-storage-cursor.d.ts +30 -0
  55. package/lib/replay/storage/use-replay-storage-cursor.d.ts.map +1 -0
  56. package/lib/replay/storage/use-replay-storage-cursor.js +49 -0
  57. package/lib/replay/storage/use-replay-storage.d.ts +13 -0
  58. package/lib/replay/storage/use-replay-storage.d.ts.map +1 -0
  59. package/lib/replay/storage/use-replay-storage.js +38 -0
  60. package/lib/replay/storage/use-replay-storage.spec.d.ts +2 -0
  61. package/lib/replay/storage/use-replay-storage.spec.d.ts.map +1 -0
  62. package/lib/replay/storage/use-replay-storage.spec.js +74 -0
  63. package/lib/replay/use-replay-lock.d.ts +3 -0
  64. package/lib/replay/use-replay-lock.d.ts.map +1 -0
  65. package/lib/replay/use-replay-lock.js +21 -0
  66. package/lib/replay/use-replay-manager.d.ts +28 -0
  67. package/lib/replay/use-replay-manager.d.ts.map +1 -0
  68. package/lib/replay/use-replay-manager.js +68 -0
  69. package/{dist → lib}/replay/use-replay-options.js +2 -2
  70. package/{dist → lib}/replay/use-replay.d.ts +2 -2
  71. package/lib/replay/use-replay.d.ts.map +1 -0
  72. package/lib/replay/use-replay.js +19 -0
  73. package/lib/replay/use-replay.spec.js +130 -0
  74. package/lib/replay/when-replay-finished.d.ts +2 -0
  75. package/lib/replay/when-replay-finished.d.ts.map +1 -0
  76. package/lib/replay/when-replay-finished.js +14 -0
  77. package/lib/session/use-session-object.d.ts +9 -0
  78. package/lib/session/use-session-object.d.ts.map +1 -0
  79. package/{dist → lib}/session/use-session-storage.js +2 -2
  80. package/lib/session/use-session.d.ts +13 -0
  81. package/lib/session/use-session.d.ts.map +1 -0
  82. package/lib/session/use-session.js +14 -0
  83. package/{dist → lib}/shared/datetime.js +1 -2
  84. package/lib/shared/decimals.d.ts +14 -0
  85. package/lib/shared/decimals.d.ts.map +1 -0
  86. package/lib/shared/decimals.js +18 -0
  87. package/{dist → lib}/shared/environment.js +2 -3
  88. package/{dist → lib}/simulator/use-simulator.js +1 -2
  89. package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
  90. package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +2 -2
  91. package/{dist → lib}/storage/index.d.ts +1 -0
  92. package/{dist → lib}/storage/index.d.ts.map +1 -1
  93. package/{dist → lib}/storage/index.js +1 -0
  94. package/lib/storage/storage.d.ts.map +1 -0
  95. package/{dist → lib}/storage/use-cache.d.ts.map +1 -1
  96. package/lib/storage/use-storage-factory.d.ts +10 -0
  97. package/lib/storage/use-storage-factory.d.ts.map +1 -0
  98. package/lib/storage/use-storage-factory.js +12 -0
  99. package/lib/storage/use-storage.d.ts.map +1 -0
  100. package/{dist → lib}/storage/use-storage.js +2 -2
  101. package/lib/strategy.d.ts +15 -0
  102. package/lib/strategy.d.ts.map +1 -0
  103. package/lib/strategy.js +26 -0
  104. package/lib/strategy.spec.d.ts +2 -0
  105. package/lib/strategy.spec.d.ts.map +1 -0
  106. package/lib/strategy.spec.js +34 -0
  107. package/lib/use-execution-mode.d.ts +20 -0
  108. package/lib/use-execution-mode.d.ts.map +1 -0
  109. package/lib/use-execution-mode.js +32 -0
  110. package/{dist → lib}/use-hash.js +1 -2
  111. package/{dist → lib}/use-logger.js +5 -5
  112. package/lib/use-memo.d.ts +8 -0
  113. package/lib/use-memo.d.ts.map +1 -0
  114. package/lib/use-memo.js +19 -0
  115. package/lib/use-socket.d.ts +20 -0
  116. package/lib/use-socket.d.ts.map +1 -0
  117. package/lib/use-socket.js +82 -0
  118. package/{dist → lib}/use-timestamp.js +3 -4
  119. package/lib/when-socket.d.ts +8 -0
  120. package/lib/when-socket.d.ts.map +1 -0
  121. package/{dist/use-socket.js → lib/when-socket.js} +5 -6
  122. package/lib/with-memo.d.ts +5 -0
  123. package/lib/with-memo.d.ts.map +1 -0
  124. package/{dist/use.js → lib/with-memo.js} +4 -5
  125. package/lib/with-memo.spec.d.ts +2 -0
  126. package/lib/with-memo.spec.d.ts.map +1 -0
  127. package/{dist/use.spec.js → lib/with-memo.spec.js} +3 -3
  128. package/{dist/use-request.d.ts → lib/with-request.d.ts} +6 -6
  129. package/lib/with-request.d.ts.map +1 -0
  130. package/lib/with-request.js +68 -0
  131. package/package.json +5 -5
  132. package/src/asset/asset.ts +6 -0
  133. package/src/cli/index.ts +11 -8
  134. package/src/cli/internal/script.ts +70 -0
  135. package/src/cli/live.ts +22 -0
  136. package/src/cli/paper.ts +22 -0
  137. package/src/cli/pull.ts +6 -66
  138. package/src/cli/replay.ts +15 -19
  139. package/src/core.ts +6 -6
  140. package/src/index.ts +6 -13
  141. package/src/instrument/instrument.ts +6 -0
  142. package/src/make-test-module.ts +20 -4
  143. package/src/operators.ts +18 -0
  144. package/src/replay/index.ts +7 -4
  145. package/src/replay/replay-guard.ts +11 -0
  146. package/src/replay/replay.ts +13 -0
  147. package/src/replay/storage/use-replay-storage-buffer.ts +52 -0
  148. package/src/replay/storage/use-replay-storage-cursor.ts +44 -0
  149. package/src/replay/storage/use-replay-storage.spec.ts +84 -0
  150. package/src/replay/storage/use-replay-storage.ts +29 -0
  151. package/src/replay/use-replay-lock.ts +29 -0
  152. package/src/replay/use-replay-manager.ts +83 -0
  153. package/src/replay/use-replay.spec.ts +10 -4
  154. package/src/replay/use-replay.ts +11 -17
  155. package/src/replay/when-replay-finished.ts +20 -0
  156. package/src/session/use-session-storage.ts +2 -2
  157. package/src/session/use-session.ts +16 -4
  158. package/src/shared/decimals.ts +0 -45
  159. package/src/simulator/use-simulator.spec.ts +10 -26
  160. package/src/storage/index.ts +1 -0
  161. package/src/storage/use-storage-factory.ts +7 -7
  162. package/src/storage/use-storage.ts +2 -2
  163. package/src/strategy.spec.ts +42 -0
  164. package/src/strategy.ts +36 -0
  165. package/src/use-execution-mode.ts +27 -27
  166. package/src/use-logger.ts +7 -7
  167. package/src/use-memo.ts +6 -21
  168. package/src/use-socket.ts +82 -45
  169. package/src/use-timestamp.ts +2 -2
  170. package/src/when-socket.ts +61 -0
  171. package/src/{use.spec.ts → with-memo.spec.ts} +3 -3
  172. package/src/{use.ts → with-memo.ts} +4 -4
  173. package/src/with-request.ts +83 -0
  174. package/tsconfig.json +2 -2
  175. package/dist/as-readonly.d.ts +0 -3
  176. package/dist/as-readonly.d.ts.map +0 -1
  177. package/dist/as-readonly.js +0 -8
  178. package/dist/asset/asset.d.ts.map +0 -1
  179. package/dist/cli/dev.d.ts +0 -2
  180. package/dist/cli/dev.d.ts.map +0 -1
  181. package/dist/cli/dev.js +0 -61
  182. package/dist/cli/pull.d.ts.map +0 -1
  183. package/dist/cli/pull.js +0 -107
  184. package/dist/cli/replay.d.ts +0 -2
  185. package/dist/cli/replay.d.ts.map +0 -1
  186. package/dist/cli/replay.js +0 -64
  187. package/dist/cli/run.d.ts +0 -2
  188. package/dist/cli/run.d.ts.map +0 -1
  189. package/dist/cli/run.js +0 -62
  190. package/dist/component/ohlc-operator.d.ts.map +0 -1
  191. package/dist/defined.d.ts +0 -3
  192. package/dist/defined.d.ts.map +0 -1
  193. package/dist/defined.js +0 -8
  194. package/dist/errored.d.ts +0 -2
  195. package/dist/errored.d.ts.map +0 -1
  196. package/dist/errored.js +0 -4
  197. package/dist/exclude.d.ts +0 -3
  198. package/dist/exclude.d.ts.map +0 -1
  199. package/dist/exclude.js +0 -8
  200. package/dist/index.d.ts +0 -28
  201. package/dist/index.d.ts.map +0 -1
  202. package/dist/instrument/instrument.d.ts.map +0 -1
  203. package/dist/make-test-module.d.ts +0 -13
  204. package/dist/make-test-module.d.ts.map +0 -1
  205. package/dist/module.d.ts.map +0 -1
  206. package/dist/replay/index.d.ts +0 -7
  207. package/dist/replay/index.d.ts.map +0 -1
  208. package/dist/replay/use-replay-coordinator.d.ts +0 -10
  209. package/dist/replay/use-replay-coordinator.d.ts.map +0 -1
  210. package/dist/replay/use-replay-coordinator.js +0 -119
  211. package/dist/replay/use-replay-reader.d.ts +0 -7
  212. package/dist/replay/use-replay-reader.d.ts.map +0 -1
  213. package/dist/replay/use-replay-reader.js +0 -32
  214. package/dist/replay/use-replay-reader.spec.d.ts +0 -2
  215. package/dist/replay/use-replay-reader.spec.d.ts.map +0 -1
  216. package/dist/replay/use-replay-reader.spec.js +0 -58
  217. package/dist/replay/use-replay-storage.d.ts +0 -10
  218. package/dist/replay/use-replay-storage.d.ts.map +0 -1
  219. package/dist/replay/use-replay-storage.js +0 -10
  220. package/dist/replay/use-replay-writer.d.ts +0 -6
  221. package/dist/replay/use-replay-writer.d.ts.map +0 -1
  222. package/dist/replay/use-replay-writer.js +0 -14
  223. package/dist/replay/use-replay-writer.spec.d.ts +0 -2
  224. package/dist/replay/use-replay-writer.spec.d.ts.map +0 -1
  225. package/dist/replay/use-replay-writer.spec.js +0 -53
  226. package/dist/replay/use-replay.d.ts.map +0 -1
  227. package/dist/replay/use-replay.js +0 -32
  228. package/dist/replay/use-replay.spec.js +0 -106
  229. package/dist/replay/with-replay.d.ts +0 -4
  230. package/dist/replay/with-replay.d.ts.map +0 -1
  231. package/dist/replay/with-replay.js +0 -8
  232. package/dist/session/use-session-object.d.ts +0 -18
  233. package/dist/session/use-session-object.d.ts.map +0 -1
  234. package/dist/session/use-session.d.ts +0 -4
  235. package/dist/session/use-session.d.ts.map +0 -1
  236. package/dist/session/use-session.js +0 -7
  237. package/dist/shared/decimals.d.ts +0 -30
  238. package/dist/shared/decimals.d.ts.map +0 -1
  239. package/dist/shared/decimals.js +0 -61
  240. package/dist/storage/storage.d.ts.map +0 -1
  241. package/dist/storage/use-storage-factory.d.ts +0 -10
  242. package/dist/storage/use-storage-factory.d.ts.map +0 -1
  243. package/dist/storage/use-storage-factory.js +0 -14
  244. package/dist/storage/use-storage.d.ts.map +0 -1
  245. package/dist/strat.d.ts +0 -7
  246. package/dist/strat.d.ts.map +0 -1
  247. package/dist/strat.js +0 -7
  248. package/dist/use-execution-mode.d.ts +0 -29
  249. package/dist/use-execution-mode.d.ts.map +0 -1
  250. package/dist/use-execution-mode.js +0 -37
  251. package/dist/use-lock.d.ts +0 -9
  252. package/dist/use-lock.d.ts.map +0 -1
  253. package/dist/use-lock.js +0 -40
  254. package/dist/use-memo.d.ts +0 -21
  255. package/dist/use-memo.d.ts.map +0 -1
  256. package/dist/use-memo.js +0 -35
  257. package/dist/use-request.d.ts.map +0 -1
  258. package/dist/use-request.js +0 -27
  259. package/dist/use-socket.d.ts +0 -6
  260. package/dist/use-socket.d.ts.map +0 -1
  261. package/dist/use-state.d.ts +0 -4
  262. package/dist/use-state.d.ts.map +0 -1
  263. package/dist/use-state.js +0 -24
  264. package/dist/use-state.spec.d.ts +0 -2
  265. package/dist/use-state.spec.d.ts.map +0 -1
  266. package/dist/use-state.spec.js +0 -36
  267. package/dist/use.d.ts +0 -5
  268. package/dist/use.d.ts.map +0 -1
  269. package/dist/use.spec.d.ts +0 -2
  270. package/dist/use.spec.d.ts.map +0 -1
  271. package/src/as-readonly.ts +0 -5
  272. package/src/cli/dev.ts +0 -31
  273. package/src/cli/run.ts +0 -29
  274. package/src/defined.ts +0 -6
  275. package/src/errored.ts +0 -1
  276. package/src/exclude.ts +0 -9
  277. package/src/replay/use-replay-coordinator.ts +0 -142
  278. package/src/replay/use-replay-reader.spec.ts +0 -64
  279. package/src/replay/use-replay-reader.ts +0 -23
  280. package/src/replay/use-replay-storage.ts +0 -8
  281. package/src/replay/use-replay-writer.spec.ts +0 -56
  282. package/src/replay/use-replay-writer.ts +0 -17
  283. package/src/replay/with-replay.ts +0 -10
  284. package/src/strat.ts +0 -7
  285. package/src/use-lock.ts +0 -52
  286. package/src/use-request.ts +0 -47
  287. package/src/use-state.spec.ts +0 -31
  288. package/src/use-state.ts +0 -30
  289. package/{dist → lib}/asset/asset.spec.d.ts +0 -0
  290. package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
  291. package/{dist → lib}/asset/asset.spec.js +0 -0
  292. package/{dist → lib}/asset/index.d.ts +0 -0
  293. package/{dist → lib}/asset/index.d.ts.map +0 -0
  294. package/{dist → lib}/asset/index.js +0 -0
  295. package/{dist → lib}/cli/build.d.ts +0 -0
  296. package/{dist → lib}/cli/build.d.ts.map +0 -0
  297. package/{dist → lib}/cli/build.js +1 -1
  298. /package/{dist → lib}/cli/index.d.ts +0 -0
  299. /package/{dist → lib}/cli/index.d.ts.map +0 -0
  300. /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
  301. /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
  302. /package/{dist → lib}/cli/pull.d.ts +0 -0
  303. /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
  304. /package/{dist → lib}/component/error.d.ts +0 -0
  305. /package/{dist → lib}/component/error.d.ts.map +0 -0
  306. /package/{dist → lib}/component/error.js +0 -0
  307. /package/{dist → lib}/component/index.d.ts +0 -0
  308. /package/{dist → lib}/component/index.d.ts.map +0 -0
  309. /package/{dist → lib}/component/index.js +0 -0
  310. /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
  311. /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
  312. /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
  313. /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
  314. /package/{dist → lib}/component/ohlc.d.ts +0 -0
  315. /package/{dist → lib}/component/ohlc.js +0 -0
  316. /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
  317. /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
  318. /package/{dist → lib}/component/ohlc.spec.js +0 -0
  319. /package/{dist → lib}/component/timeframe.d.ts +0 -0
  320. /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
  321. /package/{dist → lib}/core.d.ts +0 -0
  322. /package/{dist → lib}/core.d.ts.map +0 -0
  323. /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
  324. /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
  325. /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
  326. /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
  327. /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
  328. /package/{dist → lib}/instrument/index.d.ts +0 -0
  329. /package/{dist → lib}/instrument/index.d.ts.map +0 -0
  330. /package/{dist → lib}/instrument/index.js +0 -0
  331. /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
  332. /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
  333. /package/{dist → lib}/instrument/instrument.spec.js +0 -0
  334. /package/{dist → lib}/module.d.ts +0 -0
  335. /package/{dist → lib}/module.js +0 -0
  336. /package/{dist → lib}/module.spec.d.ts +0 -0
  337. /package/{dist → lib}/module.spec.d.ts.map +0 -0
  338. /package/{dist → lib}/module.spec.js +0 -0
  339. /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
  340. /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
  341. /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
  342. /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
  343. /package/{dist → lib}/session/index.d.ts +0 -0
  344. /package/{dist → lib}/session/index.d.ts.map +0 -0
  345. /package/{dist → lib}/session/index.js +0 -0
  346. /package/{dist → lib}/session/use-session-object.js +0 -0
  347. /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
  348. /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
  349. /package/{dist → lib}/shared/datetime.d.ts +0 -0
  350. /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
  351. /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
  352. /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
  353. /package/{dist → lib}/shared/decimals.spec.js +0 -0
  354. /package/{dist → lib}/shared/environment.d.ts +0 -0
  355. /package/{dist → lib}/shared/environment.d.ts.map +0 -0
  356. /package/{dist → lib}/shared/index.d.ts +0 -0
  357. /package/{dist → lib}/shared/index.d.ts.map +0 -0
  358. /package/{dist → lib}/shared/index.js +0 -0
  359. /package/{dist → lib}/simulator/index.d.ts +0 -0
  360. /package/{dist → lib}/simulator/index.d.ts.map +0 -0
  361. /package/{dist → lib}/simulator/index.js +0 -0
  362. /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
  363. /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
  364. /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
  365. /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
  366. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
  367. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
  368. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
  369. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
  370. /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
  371. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
  372. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
  373. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
  374. /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
  375. /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
  376. /package/{dist → lib}/storage/in-memory/index.js +0 -0
  377. /package/{dist → lib}/storage/storage.d.ts +0 -0
  378. /package/{dist → lib}/storage/storage.js +0 -0
  379. /package/{dist → lib}/storage/use-cache.d.ts +0 -0
  380. /package/{dist → lib}/storage/use-cache.js +0 -0
  381. /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
  382. /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
  383. /package/{dist → lib}/storage/use-cache.spec.js +0 -0
  384. /package/{dist → lib}/storage/use-storage.d.ts +0 -0
  385. /package/{dist → lib}/use-hash.d.ts +0 -0
  386. /package/{dist → lib}/use-hash.d.ts.map +0 -0
  387. /package/{dist → lib}/use-hash.spec.d.ts +0 -0
  388. /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
  389. /package/{dist → lib}/use-hash.spec.js +0 -0
  390. /package/{dist → lib}/use-logger.d.ts +0 -0
  391. /package/{dist → lib}/use-logger.d.ts.map +0 -0
  392. /package/{dist → lib}/use-memo.spec.d.ts +0 -0
  393. /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
  394. /package/{dist → lib}/use-memo.spec.js +0 -0
  395. /package/{dist → lib}/use-timestamp.d.ts +0 -0
  396. /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.token = void 0;
4
+ exports.useMemo = useMemo;
5
+ const module_1 = require("./module");
6
+ const use_hash_1 = require("./use-hash");
7
+ exports.token = Symbol('memo-token');
8
+ function useMemo(calculateValue, dependencies) {
9
+ const memory = (0, module_1.useContext)(exports.token);
10
+ const hash = (0, use_hash_1.useHash)(dependencies);
11
+ if (memory[hash]) {
12
+ return memory[hash];
13
+ }
14
+ return (memory[hash] = calculateValue());
15
+ }
16
+ useMemo.options = () => ({
17
+ provide: exports.token,
18
+ useValue: {}
19
+ });
@@ -0,0 +1,20 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare function useSocket(url: string, options?: {
3
+ pingInterval?: number;
4
+ }): {
5
+ /**
6
+ * Observes socket events and handles connection health monitoring via ping/pong
7
+ * @returns observable emitting message events with timestamps and parsed payloads
8
+ */
9
+ watch(): Observable<{
10
+ timestamp: number;
11
+ payload: unknown;
12
+ }>;
13
+ send(message: {
14
+ payload: unknown;
15
+ }): Observable<{
16
+ timestamp: number;
17
+ }>;
18
+ monitor(): Observable<"opened" | "closed" | "errored">;
19
+ };
20
+ //# sourceMappingURL=use-socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-socket.d.ts","sourceRoot":"","sources":["../src/use-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAqB,MAAM,MAAM,CAAC;AAM5D,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAA2B;IAsBzD;;;OAGG;aACM,UAAU,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;kBAgD9C;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,UAAU,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;;EAczE"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSocket = useSocket;
4
+ const rxjs_1 = require("rxjs");
5
+ const ws_1 = require("ws");
6
+ const use_logger_1 = require("./use-logger");
7
+ const use_timestamp_1 = require("./use-timestamp");
8
+ function useSocket(url, options = { pingInterval: 5000 }) {
9
+ const { debug } = (0, use_logger_1.useLogger)('useSocket');
10
+ const socket = new ws_1.WebSocket(url);
11
+ const monitor = new rxjs_1.ReplaySubject();
12
+ socket.on('error', e => {
13
+ debug('errored', url, e);
14
+ monitor.next('errored');
15
+ });
16
+ socket.on('close', () => {
17
+ debug('closed', url);
18
+ monitor.next('closed');
19
+ });
20
+ socket.on('open', () => {
21
+ debug('opened', url);
22
+ monitor.next('opened');
23
+ });
24
+ return {
25
+ /**
26
+ * Observes socket events and handles connection health monitoring via ping/pong
27
+ * @returns observable emitting message events with timestamps and parsed payloads
28
+ */
29
+ watch() {
30
+ let isAlive = false;
31
+ let interval;
32
+ return new rxjs_1.Observable(stream => {
33
+ socket.onmessage = it => stream.next({
34
+ timestamp: (0, use_timestamp_1.useTimestamp)(),
35
+ payload: JSON.parse(it.data)
36
+ });
37
+ socket.onerror = it => {
38
+ clearInterval(interval);
39
+ stream.error(it);
40
+ };
41
+ socket.onclose = () => {
42
+ clearInterval(interval);
43
+ stream.error();
44
+ };
45
+ socket.onopen = () => {
46
+ isAlive = true;
47
+ interval = setInterval(() => {
48
+ if (isAlive) {
49
+ isAlive = false;
50
+ socket.ping();
51
+ }
52
+ else {
53
+ socket.terminate();
54
+ clearInterval(interval);
55
+ }
56
+ }, options.pingInterval);
57
+ socket.on('pong', () => {
58
+ isAlive = true;
59
+ });
60
+ socket.on('ping', () => {
61
+ isAlive = true;
62
+ socket.pong();
63
+ });
64
+ };
65
+ return () => {
66
+ clearInterval(interval);
67
+ socket.terminate();
68
+ };
69
+ });
70
+ },
71
+ send(message) {
72
+ return (0, rxjs_1.defer)(() => {
73
+ debug('sent', url, message.payload);
74
+ socket.send(JSON.stringify(message.payload));
75
+ return (0, rxjs_1.of)({ timestamp: (0, use_timestamp_1.useTimestamp)() });
76
+ });
77
+ },
78
+ monitor() {
79
+ return monitor.asObservable();
80
+ }
81
+ };
82
+ }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTimestamp = void 0;
4
- const use_replay_coordinator_1 = require("./replay/use-replay-coordinator");
3
+ exports.useTimestamp = useTimestamp;
4
+ const replay_1 = require("./replay");
5
5
  const use_execution_mode_1 = require("./use-execution-mode");
6
6
  function useTimestamp() {
7
7
  const { isReplay } = (0, use_execution_mode_1.useExecutionMode)();
8
8
  if (isReplay) {
9
- return (0, use_replay_coordinator_1.useReplayCoordinator)().timestamp();
9
+ return (0, replay_1.useReplayManager)().timestamp();
10
10
  }
11
11
  return Date.now();
12
12
  }
13
- exports.useTimestamp = useTimestamp;
@@ -0,0 +1,8 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare function whenSocket(url: string, options?: {
3
+ pingInterval?: number;
4
+ }): [Observable<{
5
+ timestamp: number;
6
+ payload: unknown;
7
+ }>, (message: unknown) => void];
8
+ //# sourceMappingURL=when-socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when-socket.d.ts","sourceRoot":"","sources":["../src/when-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAA2B,GAC1D,CAAC,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,CAmDnF"}
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSocket = void 0;
3
+ exports.whenSocket = whenSocket;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const ws_1 = require("ws");
6
6
  const use_logger_1 = require("./use-logger");
7
7
  const use_timestamp_1 = require("./use-timestamp");
8
- function useSocket(url) {
9
- const { debug } = (0, use_logger_1.useLogger)('useSocket');
8
+ function whenSocket(url, options = { pingInterval: 5000 }) {
9
+ const { debug } = (0, use_logger_1.useLogger)('whenSocket');
10
10
  const message = new rxjs_1.Observable(stream => {
11
11
  const socket = new ws_1.WebSocket(url);
12
12
  let isAlive = false;
@@ -18,7 +18,7 @@ function useSocket(url) {
18
18
  stream.error(it);
19
19
  };
20
20
  socket.onclose = () => {
21
- debug('errored', url);
21
+ debug('closed', url);
22
22
  clearInterval(interval);
23
23
  stream.error();
24
24
  };
@@ -34,7 +34,7 @@ function useSocket(url) {
34
34
  socket.terminate();
35
35
  clearInterval(interval);
36
36
  }
37
- }, 5000);
37
+ }, options.pingInterval);
38
38
  socket.on('pong', () => {
39
39
  isAlive = true;
40
40
  });
@@ -50,4 +50,3 @@ function useSocket(url) {
50
50
  });
51
51
  return [message, (message) => JSON.stringify(message)];
52
52
  }
53
- exports.useSocket = useSocket;
@@ -0,0 +1,5 @@
1
+ import { Observable } from 'rxjs';
2
+ import { dependency } from './use-hash';
3
+ export declare function withMemo<T extends Array<dependency>, U>(fn: (...args: T) => U): (...args: T) => U;
4
+ export declare function withMemo<T extends Array<dependency>, U>(fn: (...args: T) => Observable<U>): (...args: T) => Observable<U>;
5
+ //# sourceMappingURL=with-memo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-memo.d.ts","sourceRoot":"","sources":["../src/with-memo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAe,MAAM,MAAM,CAAC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EACrD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AACrB,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EACrD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAChC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC"}
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.use = void 0;
3
+ exports.withMemo = withMemo;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const uuid_1 = require("uuid");
6
- const as_readonly_1 = require("./as-readonly");
7
6
  const module_1 = require("./module");
7
+ const operators_1 = require("./operators");
8
8
  const use_memo_1 = require("./use-memo");
9
- function use(fn) {
9
+ function withMemo(fn) {
10
10
  (0, module_1.throwWithContext)();
11
11
  const uniqueId = (0, uuid_1.v4)();
12
12
  return (...args) => (0, use_memo_1.useMemo)(() => {
13
13
  const value = fn(...args);
14
14
  if ((0, rxjs_1.isObservable)(value)) {
15
- return value.pipe((0, as_readonly_1.asReadonly)(), (0, rxjs_1.shareReplay)(1));
15
+ return value.pipe((0, operators_1.asReadonly)(), (0, rxjs_1.shareReplay)(1));
16
16
  }
17
17
  return value;
18
18
  }, [uniqueId, ...args]);
19
19
  }
20
- exports.use = use;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with-memo.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-memo.spec.d.ts","sourceRoot":"","sources":["../src/with-memo.spec.ts"],"names":[],"mappings":""}
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const make_test_module_1 = require("./make-test-module");
13
13
  const instrument_1 = require("./instrument");
14
- const use_1 = require("./use");
15
- describe(use_1.use.name, () => {
14
+ const with_memo_1 = require("./with-memo");
15
+ describe(with_memo_1.withMemo.name, () => {
16
16
  let fixtures;
17
17
  beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
18
18
  fixtures = yield getFixtures();
@@ -38,7 +38,7 @@ describe(use_1.use.name, () => {
38
38
  function getFixtures() {
39
39
  return __awaiter(this, void 0, void 0, function* () {
40
40
  const { act } = yield (0, make_test_module_1.makeTestModule)([]);
41
- const getValue = (0, use_1.use)((instrument) => instrument.id);
41
+ const getValue = (0, with_memo_1.withMemo)((instrument) => instrument.id);
42
42
  return {
43
43
  act,
44
44
  getValue: act(() => (instrument) => getValue(instrument))
@@ -1,16 +1,16 @@
1
+ import { Observable } from 'rxjs';
1
2
  export type RequestMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
2
3
  export declare class RequestNetworkError extends Error {
3
4
  readonly statusCode: number;
4
- readonly json: () => Promise<string>;
5
- constructor(statusCode: number, json: () => Promise<string>);
5
+ constructor(statusCode: number);
6
6
  }
7
- export declare function useRequest(args: {
7
+ export declare function withRequest({ method, url, headers, body }: {
8
8
  method: RequestMethod;
9
9
  url: string;
10
10
  headers?: Record<string, any>;
11
11
  body?: string;
12
- }): import("rxjs").Observable<{
12
+ }): Observable<{
13
13
  timestamp: number;
14
- payload: any;
14
+ payload: unknown;
15
15
  }>;
16
- //# sourceMappingURL=use-request.d.ts.map
16
+ //# sourceMappingURL=with-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-request.d.ts","sourceRoot":"","sources":["../src/with-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ,qBAAa,mBAAoB,SAAQ,KAAK;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM;CAGxC;AAED,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACL,EAAE;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;eAGoC,MAAM;aAAW,OAAO;GA6C5D"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RequestNetworkError = void 0;
13
+ exports.withRequest = withRequest;
14
+ const node_crypto_1 = require("node:crypto");
15
+ const rxjs_1 = require("rxjs");
16
+ const undici_1 = require("undici");
17
+ const use_logger_1 = require("./use-logger");
18
+ const use_timestamp_1 = require("./use-timestamp");
19
+ class RequestNetworkError extends Error {
20
+ constructor(statusCode) {
21
+ super(`Request network error, received status code: ${statusCode}`);
22
+ this.statusCode = statusCode;
23
+ }
24
+ }
25
+ exports.RequestNetworkError = RequestNetworkError;
26
+ function withRequest({ method, url, headers, body }) {
27
+ const { error, debug } = (0, use_logger_1.useLogger)(withRequest.name);
28
+ return new rxjs_1.Observable(subscriber => {
29
+ const correlationId = (0, node_crypto_1.randomUUID)();
30
+ debug('requesting', { correlationId, method, url, headers, body });
31
+ (0, undici_1.request)(url, { method, headers, body })
32
+ .then((_a) => __awaiter(this, [_a], void 0, function* ({ statusCode, body }) {
33
+ const json = yield body.json();
34
+ debug('received', {
35
+ correlationId,
36
+ method,
37
+ url,
38
+ headers,
39
+ body: json,
40
+ statusCode
41
+ });
42
+ if (statusCode !== 200) {
43
+ error(`errored`, {
44
+ method,
45
+ url,
46
+ headers,
47
+ body,
48
+ statusCode
49
+ });
50
+ subscriber.error(new RequestNetworkError(statusCode));
51
+ }
52
+ else {
53
+ subscriber.next({ timestamp: (0, use_timestamp_1.useTimestamp)(), payload: json });
54
+ }
55
+ }))
56
+ .catch((e) => {
57
+ error(`errored`, {
58
+ method,
59
+ url,
60
+ headers,
61
+ body,
62
+ error: e
63
+ });
64
+ subscriber.error(error);
65
+ })
66
+ .finally(() => subscriber.complete());
67
+ });
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantform/core",
3
- "version": "0.7.0-beta.9",
3
+ "version": "0.7.9",
4
4
  "license": "MIT",
5
5
  "author": "Mateusz Majchrzak",
6
6
  "description": "Node.js library for building systematic trading strategies in reactive way.",
@@ -12,10 +12,10 @@
12
12
  "access": "public"
13
13
  },
14
14
  "bin": {
15
- "qf": "./dist/cli/index.js"
15
+ "qf": "./lib/cli/index.js"
16
16
  },
17
- "main": "dist/index.js",
18
- "typings": "dist/index.d.ts",
17
+ "main": "lib/index.js",
18
+ "typings": "lib/index.d.ts",
19
19
  "dependencies": {
20
20
  "@swc/cli": "^0.1.62",
21
21
  "@swc/core": "^1.3.44",
@@ -37,7 +37,7 @@
37
37
  "rxjs": "^7.8.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "rxjs": "^7.5.6"
40
+ "rxjs": "^7.8.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsc && tsc-alias",
@@ -3,6 +3,12 @@ import { d, decimal } from '@lib/shared';
3
3
 
4
4
  export const AssetSelectorSeparator = ':';
5
5
 
6
+ export class MissingAssetError extends Error {
7
+ constructor(asset: AssetSelector) {
8
+ super(`Missing asset: ${asset}`);
9
+ }
10
+ }
11
+
6
12
  /**
7
13
  * Supposed to query specific @see Asset based on string notation.
8
14
  */
package/src/cli/index.ts CHANGED
@@ -5,10 +5,10 @@ import { program } from 'commander';
5
5
  import watch from 'node-watch';
6
6
 
7
7
  import build from '@lib/cli/build';
8
- import dev from '@lib/cli/dev';
8
+ import live from '@lib/cli/live';
9
+ import paper from '@lib/cli/paper';
9
10
  import pull from '@lib/cli/pull';
10
- import test from '@lib/cli/replay';
11
- import run from '@lib/cli/run';
11
+ import replay from '@lib/cli/replay';
12
12
 
13
13
  program
14
14
  .command('build')
@@ -18,29 +18,32 @@ program
18
18
  });
19
19
 
20
20
  program
21
- .command('run')
21
+ .command('live')
22
22
  .argument('<name>', 'strategy to execute')
23
23
  .option('-i, --id <id>', 'session identifier')
24
+ .option('-r, --recording', 'recording mode for replay purposes')
24
25
  .option('-w', 'watch mode')
25
26
  .description('executes strategy in live trading mode')
26
- .action(run);
27
+ .action(live);
27
28
 
28
29
  program
29
- .command('dev')
30
+ .command('paper')
30
31
  .argument('<name>', 'strategy to execute')
31
32
  .option('-i, --id <id>', 'session identifier')
33
+ .option('-r, --recording', 'recording mode for replay purposes')
32
34
  .option('-w', 'watch mode')
33
35
  .description('executes strategy in paper e.g. simulation mode')
34
- .action(dev);
36
+ .action(paper);
35
37
 
36
38
  program
37
39
  .command('replay')
38
40
  .description('executes strategy in backtesting mode for specified period')
39
41
  .argument('<name>', 'strategy to execute')
42
+ .option('-i, --id <id>', 'session identifier')
40
43
  .option('-f, --from <from>', 'date from')
41
44
  .option('-t, --to <to>', 'date to')
42
45
  .option('-w', 'watch mode')
43
- .action(test);
46
+ .action(replay);
44
47
 
45
48
  program
46
49
  .command('pull')
@@ -0,0 +1,70 @@
1
+ import { join } from 'path';
2
+ import {
3
+ catchError,
4
+ finalize,
5
+ firstValueFrom,
6
+ forkJoin,
7
+ fromEvent,
8
+ last,
9
+ merge,
10
+ of,
11
+ switchMap,
12
+ take
13
+ } from 'rxjs';
14
+
15
+ import { core } from '@lib/core';
16
+ import { Dependency, Module } from '@lib/module';
17
+ import { whenReplayFinished } from '@lib/replay';
18
+ import { strategy } from '@lib/strategy';
19
+
20
+ import { buildDirectory } from './workspace';
21
+
22
+ export class Script {
23
+ constructor(
24
+ private readonly filename: string,
25
+ private readonly dependencies: Dependency[]
26
+ ) {}
27
+
28
+ async run() {
29
+ const script = await import(join(buildDirectory(), this.filename));
30
+
31
+ const { dependencies, description } = script.default as ReturnType<typeof strategy>;
32
+
33
+ const module = new Module([...core(), ...dependencies, ...this.dependencies]);
34
+
35
+ const { act } = await module.awake();
36
+
37
+ return await act(() => {
38
+ process.stdin.resume();
39
+
40
+ return firstValueFrom(
41
+ merge(
42
+ forkJoin(description.before.map(before => before()))
43
+ .pipe(
44
+ switchMap(() =>
45
+ forkJoin(description.behavior.map(behavior => behavior())).pipe(last())
46
+ )
47
+ )
48
+ .pipe(last()),
49
+ whenReplayFinished().pipe(last()),
50
+ fromEvent(process, 'exit'),
51
+ fromEvent(process, 'SIGINT'),
52
+ fromEvent(process, 'SIGUSR1'),
53
+ fromEvent(process, 'SIGUSR2'),
54
+ fromEvent(process, 'uncaughtException')
55
+ ).pipe(
56
+ catchError(e => {
57
+ console.error(e);
58
+
59
+ return of(e);
60
+ }),
61
+ take(1),
62
+ switchMap(
63
+ it => forkJoin(description.after.map(after => after())).pipe(last()) ?? of(it)
64
+ ),
65
+ finalize(() => process.exit(0))
66
+ )
67
+ );
68
+ });
69
+ }
70
+ }
@@ -0,0 +1,22 @@
1
+ import build from '@lib/cli/build';
2
+ import { useSession } from '@lib/session';
3
+ import { useExecutionMode } from '@lib/use-execution-mode';
4
+
5
+ import { Script } from './internal/script';
6
+
7
+ export default async function (
8
+ name: string,
9
+ options: { id?: string; recording?: boolean }
10
+ ) {
11
+ if (await build()) {
12
+ return;
13
+ }
14
+
15
+ const script = new Script(name, [
16
+ useSession.options({ id: options.id ?? Date.now().toString() }),
17
+ useExecutionMode.liveOptions({ recording: options.recording ?? false })
18
+ ]);
19
+ const output = await script.run();
20
+
21
+ console.log(output);
22
+ }
@@ -0,0 +1,22 @@
1
+ import build from '@lib/cli/build';
2
+ import { useSession } from '@lib/session';
3
+ import { useExecutionMode } from '@lib/use-execution-mode';
4
+
5
+ import { Script } from './internal/script';
6
+
7
+ export default async function (
8
+ name: string,
9
+ options: { id?: string; recording?: boolean }
10
+ ) {
11
+ if (await build()) {
12
+ return;
13
+ }
14
+
15
+ const script = new Script(name, [
16
+ useSession.options({ id: options.id ?? Date.now().toString() }),
17
+ useExecutionMode.paperOptions({ recording: options.recording ?? false })
18
+ ]);
19
+ const output = await script.run();
20
+
21
+ console.log(output);
22
+ }
package/src/cli/pull.ts CHANGED
@@ -1,75 +1,15 @@
1
- import { join } from 'path';
2
-
3
1
  import build from '@lib/cli/build';
4
- import { buildDirectory } from '@lib/cli/internal/workspace';
5
- import { core } from '@lib/core';
6
- import { Module } from '@lib/module';
7
- import { strat } from '@lib/strat';
8
- import { paperExecutionMode } from '@lib/use-execution-mode';
9
- import { token } from '@lib/use-memo';
2
+ import { useExecutionMode } from '@lib/use-execution-mode';
3
+
4
+ import { Script } from './internal/script';
10
5
 
11
6
  export default async function (name: string, instrument: string, options: any) {
12
7
  if (await build()) {
13
8
  return;
14
9
  }
15
- await import(join(buildDirectory(), 'index'));
16
-
17
- const script = (await import(join(buildDirectory(), name))) as ReturnType<typeof strat>;
18
-
19
- const module = new Module([
20
- ...core(),
21
- ...script.dependencies,
22
- paperExecutionMode({ recording: false })
23
- ]);
24
-
25
- const { act } = await module.awake();
26
-
27
- const o = await act(() => script.fn());
28
- console.log(module.get<any>(token));
29
-
30
- /*const builder = new SessionBuilder().useSessionId(
31
- options.id ? Number(options.id) : now()
32
- );
33
-
34
- await spawn(name, builder);
35
-
36
- const session = builder.paper();
37
-
38
- console.time('Pulling completed in');
39
-
40
- await session.awake();
41
-
42
- const bar = new SingleBar(
43
- {
44
- format: `Pulling ${instrument} [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}`
45
- },
46
- Presets.rect
47
- );
48
-
49
- const feed = new Feed(builder.storage('feed'));
50
- const from = options.from ? Date.parse(options.from) : builder.period.from;
51
- const to = options.to ? Date.parse(options.to) : builder.period.to;
52
-
53
- bar.start(100, 0);
54
-
55
- await session.aggregate.feed(
56
- instrumentOf(instrument),
57
- from,
58
- to,
59
- async (timestamp, events) => {
60
- const duration = to - from;
61
- const completed = timestamp - from;
62
-
63
- await feed.save(events);
64
-
65
- bar.update(Math.floor((completed / duration) * 100));
66
- }
67
- );
68
-
69
- bar.update(100);
70
- bar.stop();
71
10
 
72
- await session.dispose();
11
+ const script = new Script(name, [useExecutionMode.idleOptions()]);
12
+ //const output = await script.run();
73
13
 
74
- console.timeLog('Pulling completed in');*/
14
+ //console.log(output);
75
15
  }