@quantform/core 0.7.0-beta.8 → 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 -5
  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 -44
  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/exclude.d.ts +0 -3
  195. package/dist/exclude.d.ts.map +0 -1
  196. package/dist/exclude.js +0 -8
  197. package/dist/index.d.ts +0 -28
  198. package/dist/index.d.ts.map +0 -1
  199. package/dist/instrument/instrument.d.ts.map +0 -1
  200. package/dist/make-test-module.d.ts +0 -13
  201. package/dist/make-test-module.d.ts.map +0 -1
  202. package/dist/missed.d.ts +0 -2
  203. package/dist/missed.d.ts.map +0 -1
  204. package/dist/missed.js +0 -4
  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/exclude.ts +0 -9
  276. package/src/missed.ts +0 -1
  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
@@ -1,119 +0,0 @@
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.useReplayCoordinator = void 0;
13
- const rxjs_1 = require("rxjs");
14
- const use_memo_1 = require("../use-memo");
15
- const __1 = require("..");
16
- const use_replay_options_1 = require("./use-replay-options");
17
- const use_replay_reader_1 = require("./use-replay-reader");
18
- function useReplayCoordinator() {
19
- const options = (0, use_replay_options_1.useReplayOptions)();
20
- return (0, use_memo_1.useMemo)(() => {
21
- let timestamp = options.from;
22
- let stopAcquire = 1;
23
- let sequence = 0;
24
- const subscriptions = Array.of();
25
- const stream$ = new rxjs_1.Subject();
26
- const subscribe = (dependencies) => {
27
- const cursor = useSampleCursor(dependencies);
28
- if (!subscriptions.includes(cursor)) {
29
- subscriptions.push(cursor);
30
- }
31
- return (0, rxjs_1.defer)(() => {
32
- tryContinue();
33
- return stream$.pipe((0, rxjs_1.filter)(([cur]) => cur === cursor), (0, rxjs_1.map)(([, it]) => it));
34
- });
35
- };
36
- const current = () => __awaiter(this, void 0, void 0, function* () {
37
- let next;
38
- for (const cursor of subscriptions) {
39
- if (cursor.size() == 0 && !cursor.completed) {
40
- yield cursor.fetchNextPage(timestamp, options.to + 1);
41
- }
42
- if (cursor.peek()) {
43
- if (!next || next.peek().timestamp > cursor.peek().timestamp) {
44
- next = cursor;
45
- }
46
- }
47
- }
48
- return next;
49
- });
50
- const processNext = () => __awaiter(this, void 0, void 0, function* () {
51
- const cursor = yield current();
52
- if (!cursor || !cursor.peek()) {
53
- stream$.complete();
54
- return false;
55
- }
56
- const sample = cursor.dequeue();
57
- timestamp = sample.timestamp;
58
- sequence++;
59
- stream$.next([cursor, sample]);
60
- return true;
61
- });
62
- const next = () => __awaiter(this, void 0, void 0, function* () {
63
- if (yield processNext()) {
64
- if (stopAcquire === 0) {
65
- setImmediate(next);
66
- }
67
- }
68
- });
69
- const stop = () => stopAcquire++;
70
- const tryContinue = () => {
71
- if (stopAcquire == 0) {
72
- return;
73
- }
74
- stopAcquire = Math.max(0, stopAcquire - 1);
75
- if (stopAcquire != 0) {
76
- return;
77
- }
78
- next();
79
- };
80
- return {
81
- timestamp: () => timestamp,
82
- stop,
83
- tryContinue,
84
- subscribe
85
- };
86
- }, [useReplayCoordinator.name]);
87
- }
88
- exports.useReplayCoordinator = useReplayCoordinator;
89
- function useSampleCursor(dependencies) {
90
- return (0, use_memo_1.useMemo)(() => {
91
- const read = (0, use_replay_reader_1.useReplayReader)(dependencies);
92
- let page = new Array();
93
- let index = 0;
94
- let completed = false;
95
- const size = () => page.length - index;
96
- const peek = () => page[index];
97
- const dequeue = () => page[index++];
98
- const fetchNextPage = (from, to) => __awaiter(this, void 0, void 0, function* () {
99
- if (completed) {
100
- return;
101
- }
102
- index = 0;
103
- page = yield read({
104
- where: {
105
- timestamp: (0, __1.between)(from, to)
106
- },
107
- limit: 10000
108
- });
109
- completed = page.length == 0;
110
- });
111
- return {
112
- size,
113
- peek,
114
- dequeue,
115
- fetchNextPage,
116
- completed
117
- };
118
- }, [useSampleCursor.name, ...dependencies]);
119
- }
@@ -1,7 +0,0 @@
1
- import { Query, QueryObject } from '../storage';
2
- import { dependency } from '../use-hash';
3
- export declare function useReplayReader<T>(dependencies: dependency[]): (query: Query<QueryObject>) => Promise<{
4
- timestamp: number;
5
- payload: T;
6
- }[]>;
7
- //# sourceMappingURL=use-replay-reader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-replay-reader.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAIpD,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,WAItC,MAAM,WAAW,CAAC;;;KAaxC"}
@@ -1,32 +0,0 @@
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.useReplayReader = void 0;
13
- const use_hash_1 = require("../use-hash");
14
- const use_replay_storage_1 = require("./use-replay-storage");
15
- function useReplayReader(dependencies) {
16
- const storage = (0, use_replay_storage_1.useReplayStorage)();
17
- const key = (0, use_hash_1.useHash)(dependencies);
18
- return (query) => __awaiter(this, void 0, void 0, function* () {
19
- var _a;
20
- return (yield storage.query((0, use_replay_storage_1.replaySerializableObject)(key), {
21
- where: {
22
- timestamp: (_a = query.where) === null || _a === void 0 ? void 0 : _a.timestamp
23
- },
24
- limit: query.limit,
25
- orderBy: query.orderBy
26
- })).map(it => ({
27
- timestamp: it.timestamp,
28
- payload: JSON.parse(it.json)
29
- }));
30
- });
31
- }
32
- exports.useReplayReader = useReplayReader;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=use-replay-reader.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-replay-reader.spec.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-reader.spec.ts"],"names":[],"mappings":""}
@@ -1,58 +0,0 @@
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
- const make_test_module_1 = require("../make-test-module");
13
- const storage_1 = require("../storage");
14
- const use_replay_reader_1 = require("./use-replay-reader");
15
- const use_replay_storage_1 = require("./use-replay-storage");
16
- jest.mock('./use-replay-storage', () => (Object.assign(Object.assign({}, jest.requireActual('./use-replay-storage')), { useReplayStorage: jest.fn() })));
17
- describe(use_replay_reader_1.useReplayReader.name, () => {
18
- let fixtures;
19
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
20
- fixtures = yield getFixtures();
21
- }));
22
- test('read sample candle data from storage', () => __awaiter(void 0, void 0, void 0, function* () {
23
- yield fixtures.givenDataStored(fixtures.sample);
24
- const data = yield fixtures.whenDataRequested();
25
- expect(data).toEqual(fixtures.sample);
26
- }));
27
- });
28
- function getFixtures() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const { act } = yield (0, make_test_module_1.makeTestModule)([]);
31
- const dependencies = ['binance:btc-usdt', 'candle', 'h1'];
32
- const query = jest.fn();
33
- (0, make_test_module_1.mockedFunc)(use_replay_storage_1.useReplayStorage).mockReturnValue({ query });
34
- return {
35
- sample: [
36
- { timestamp: 1, payload: { o: 1.1, h: 1.1, l: 1.1, c: 1.1 } },
37
- { timestamp: 2, payload: { o: 1.1, h: 2.2, l: 1.1, c: 2.2 } },
38
- { timestamp: 3, payload: { o: 1.1, h: 3.3, l: 1.1, c: 3.3 } }
39
- ],
40
- givenDataStored(data) {
41
- return query.mockReturnValue(Promise.resolve(data.map(it => ({
42
- kind: 'sample',
43
- timestamp: it.timestamp,
44
- json: JSON.stringify(it.payload)
45
- }))));
46
- },
47
- whenDataRequested() {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return yield act(() => (0, use_replay_reader_1.useReplayReader)(dependencies)({
50
- where: {
51
- timestamp: (0, storage_1.gt)(0)
52
- }
53
- }));
54
- });
55
- }
56
- };
57
- });
58
- }
@@ -1,10 +0,0 @@
1
- import { Storage } from '../storage';
2
- export declare const replaySerializableObject: (key: string) => {
3
- discriminator: string;
4
- type: {
5
- timestamp: "number";
6
- json: "string";
7
- };
8
- };
9
- export declare function useReplayStorage(): Storage;
10
- //# sourceMappingURL=use-replay-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-replay-storage.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAc,MAAM,cAAc,CAAC;AAEnD,eAAO,MAAM,wBAAwB,QAAS,MAAM;;;;;;CACgB,CAAC;AAErE,wBAAgB,gBAAgB,YAE/B"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useReplayStorage = exports.replaySerializableObject = void 0;
4
- const storage_1 = require("../storage");
5
- const replaySerializableObject = (key) => storage_1.Storage.createObject(key, { timestamp: 'number', json: 'string' });
6
- exports.replaySerializableObject = replaySerializableObject;
7
- function useReplayStorage() {
8
- return (0, storage_1.useStorage)(['replay']);
9
- }
10
- exports.useReplayStorage = useReplayStorage;
@@ -1,6 +0,0 @@
1
- import { dependency } from '../use-hash';
2
- export declare function useReplayWriter<T>(dependencies: dependency[]): (samples: {
3
- timestamp: number;
4
- payload: T;
5
- }[]) => Promise<void>;
6
- //# sourceMappingURL=use-replay-writer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-replay-writer.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAIpD,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,aAI1C;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,EAAE,mBAQrD"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useReplayWriter = void 0;
4
- const use_hash_1 = require("../use-hash");
5
- const use_replay_storage_1 = require("./use-replay-storage");
6
- function useReplayWriter(dependencies) {
7
- const storage = (0, use_replay_storage_1.useReplayStorage)();
8
- const key = (0, use_hash_1.useHash)(dependencies);
9
- return (samples) => storage.save((0, use_replay_storage_1.replaySerializableObject)(key), samples.map(it => ({
10
- timestamp: it.timestamp,
11
- json: JSON.stringify(it.payload)
12
- })));
13
- }
14
- exports.useReplayWriter = useReplayWriter;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=use-replay-writer.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-replay-writer.spec.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-writer.spec.ts"],"names":[],"mappings":""}
@@ -1,53 +0,0 @@
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
- const make_test_module_1 = require("../make-test-module");
13
- const use_hash_1 = require("../use-hash");
14
- const use_replay_storage_1 = require("./use-replay-storage");
15
- const use_replay_writer_1 = require("./use-replay-writer");
16
- jest.mock('./use-replay-storage', () => (Object.assign(Object.assign({}, jest.requireActual('./use-replay-storage')), { useReplayStorage: jest.fn() })));
17
- describe.skip(use_replay_writer_1.useReplayWriter.name, () => {
18
- let fixtures;
19
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
20
- fixtures = yield getFixtures();
21
- }));
22
- test('write sample candle data to storage', () => __awaiter(void 0, void 0, void 0, function* () {
23
- yield fixtures.whenReplayDataWritten(fixtures.sample);
24
- yield fixtures.thenReplayDataSaved(fixtures.sample);
25
- }));
26
- });
27
- function getFixtures() {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const { act } = yield (0, make_test_module_1.makeTestModule)([]);
30
- const dependencies = ['binance:btc-usdt', 'candle', 'h1'];
31
- const save = jest.fn();
32
- (0, make_test_module_1.mockedFunc)(use_replay_storage_1.useReplayStorage).mockReturnValue({ save });
33
- return {
34
- sample: [
35
- { timestamp: 1, payload: { o: 1.1, h: 1.1, l: 1.1, c: 1.1 } },
36
- { timestamp: 2, payload: { o: 1.1, h: 2.2, l: 1.1, c: 2.2 } },
37
- { timestamp: 3, payload: { o: 1.1, h: 3.3, l: 1.1, c: 3.3 } }
38
- ],
39
- whenReplayDataWritten(data) {
40
- return act(() => (0, use_replay_writer_1.useReplayWriter)(dependencies)(data));
41
- },
42
- thenReplayDataSaved(data) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- expect(save).toHaveBeenCalledWith((0, use_hash_1.useHash)(dependencies), data.map(it => ({
45
- kind: 'sample',
46
- timestamp: it.timestamp,
47
- json: JSON.stringify(it.payload)
48
- })));
49
- });
50
- }
51
- };
52
- });
53
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-replay.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,eAAO,MAAM,SAAS;eACW,MAAM;;kBACvB,UAAU,EAAE;eADK,MAAM;;EAwBtC,CAAC"}
@@ -1,32 +0,0 @@
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.useReplay = void 0;
13
- const rxjs_1 = require("rxjs");
14
- const use_replay_coordinator_1 = require("../replay/use-replay-coordinator");
15
- const use_execution_mode_1 = require("../use-execution-mode");
16
- const use_replay_writer_1 = require("./use-replay-writer");
17
- const useReplay = (input, dependencies) => {
18
- const { isReplay, recording } = (0, use_execution_mode_1.useExecutionMode)();
19
- if (isReplay) {
20
- const { subscribe } = (0, use_replay_coordinator_1.useReplayCoordinator)();
21
- return subscribe(dependencies).pipe((0, rxjs_1.map)(it => it));
22
- }
23
- if (recording) {
24
- const writer = (0, use_replay_writer_1.useReplayWriter)(dependencies);
25
- return input.pipe((0, rxjs_1.concatMap)((it) => __awaiter(void 0, void 0, void 0, function* () {
26
- yield writer([it]);
27
- return it;
28
- })));
29
- }
30
- return input;
31
- };
32
- exports.useReplay = useReplay;
@@ -1,106 +0,0 @@
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
- const rxjs_1 = require("rxjs");
13
- const make_test_module_1 = require("../make-test-module");
14
- const use_replay_coordinator_1 = require("../replay/use-replay-coordinator");
15
- const use_execution_mode_1 = require("../use-execution-mode");
16
- const __1 = require("..");
17
- const use_replay_1 = require("./use-replay");
18
- const use_replay_options_1 = require("./use-replay-options");
19
- const use_replay_reader_1 = require("./use-replay-reader");
20
- const use_replay_writer_1 = require("./use-replay-writer");
21
- describe.skip(use_replay_coordinator_1.useReplayCoordinator.name, () => {
22
- let fixtures;
23
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
24
- fixtures = yield getFixtures();
25
- }));
26
- test('return single data stream for single data source', () => __awaiter(void 0, void 0, void 0, function* () {
27
- fixtures.givenRecordingEnabled(false);
28
- yield fixtures.givenSampleStored(fixtures.sample1, ['sample1']);
29
- const sample1 = fixtures.whenUseReplayCalled(fixtures.sample1, ['sample']);
30
- yield fixtures.whenUseSampleStreamerStarted();
31
- expect(yield sample1).toEqual(fixtures.sample1);
32
- }));
33
- test('return combined data stream for multiple data sources', () => __awaiter(void 0, void 0, void 0, function* () {
34
- fixtures.givenRecordingEnabled(false);
35
- yield fixtures.givenSampleStored(fixtures.sample1, ['sample1']);
36
- yield fixtures.givenSampleStored(fixtures.sample2, ['sample2']);
37
- const sample1 = fixtures.whenUseReplayCalled(fixtures.sample1, ['sample1']);
38
- const sample2 = fixtures.whenUseReplayCalled(fixtures.sample2, ['sample2']);
39
- yield fixtures.whenUseSampleStreamerStarted();
40
- expect(yield sample1).toEqual(fixtures.sample1);
41
- expect(yield sample2).toEqual(fixtures.sample2);
42
- }));
43
- test('record and write data stream into storage', () => __awaiter(void 0, void 0, void 0, function* () {
44
- fixtures.givenRecordingEnabled(true);
45
- const sample1 = yield fixtures.whenUseReplayCalled(fixtures.sample1, ['sample1x']);
46
- const sample2 = yield fixtures.whenUseReplayCalled(fixtures.sample2, ['sample2x']);
47
- fixtures.thenReplaySampleStored(sample1, ['sample1x']);
48
- fixtures.thenReplaySampleStored(sample2, ['sample2x']);
49
- }));
50
- });
51
- function getFixtures() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const executionMode = (0, use_execution_mode_1.replayExecutionMode)();
54
- const { act } = yield (0, make_test_module_1.makeTestModule)([
55
- executionMode,
56
- (0, use_replay_options_1.replayOptions)({ from: 0, to: Number.MAX_VALUE })
57
- ]);
58
- return {
59
- sample1: [
60
- { timestamp: 1, payload: { o: 111, h: 112, l: 113, c: 114 } },
61
- { timestamp: 2, payload: { o: 121, h: 122, l: 123, c: 124 } },
62
- { timestamp: 3, payload: { o: 131, h: 132, l: 133, c: 134 } }
63
- ],
64
- sample2: [
65
- { timestamp: 1, payload: { o: 211, h: 212, l: 213, c: 214 } },
66
- { timestamp: 2, payload: { o: 221, h: 222, l: 223, c: 224 } },
67
- { timestamp: 3, payload: { o: 231, h: 232, l: 233, c: 234 } }
68
- ],
69
- givenRecordingEnabled(recording) {
70
- executionMode.useValue.recording = recording;
71
- },
72
- givenSampleStored(sample, dependencies) {
73
- return act(() => {
74
- const writer = (0, use_replay_writer_1.useReplayWriter)(dependencies);
75
- return writer(sample);
76
- });
77
- },
78
- whenUseReplayCalled(input, dependencies) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- const sample = Array.of();
81
- yield act(() => (0, rxjs_1.lastValueFrom)((0, use_replay_1.useReplay)((0, rxjs_1.from)(input), dependencies).pipe((0, rxjs_1.tap)(it => sample.push(it)))));
82
- return sample;
83
- });
84
- },
85
- whenUseSampleStreamerStarted() {
86
- act(() => {
87
- const { tryContinue } = (0, use_replay_coordinator_1.useReplayCoordinator)();
88
- tryContinue();
89
- });
90
- },
91
- thenReplaySampleStored(sample, dependencies) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const stored = yield act(() => {
94
- const reader = (0, use_replay_reader_1.useReplayReader)(dependencies);
95
- return reader({
96
- where: {
97
- timestamp: (0, __1.between)(sample[0].timestamp, sample[sample.length - 1].timestamp + 1)
98
- }
99
- });
100
- });
101
- expect(stored).toEqual(sample);
102
- });
103
- }
104
- };
105
- });
106
- }
@@ -1,4 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { dependency } from '../use-hash';
3
- export declare function withReplay<T extends Array<dependency>, U extends Observable<K>, K>(fn: (...args: T) => U): (...args: T) => U;
4
- //# sourceMappingURL=with-replay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-replay.d.ts","sourceRoot":"","sources":["../../src/replay/with-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAChF,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAEnB"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withReplay = void 0;
4
- const use_1 = require("../use");
5
- function withReplay(fn) {
6
- return (0, use_1.use)(fn);
7
- }
8
- exports.withReplay = withReplay;
@@ -1,18 +0,0 @@
1
- import { InferQueryObject, Query, QueryMappingType, QueryObject, Storage } from '../storage';
2
- export declare const useSessionObject: <K extends QueryObject, T extends { [key in keyof K]: QueryMappingType; }>(object: {
3
- discriminator: string;
4
- type: T;
5
- }) => {
6
- query: (query: Query<InferQueryObject<{
7
- discriminator: string;
8
- type: T;
9
- }>>) => import("rxjs").Observable<InferQueryObject<{
10
- discriminator: string;
11
- type: T;
12
- }>[]>;
13
- save: (objects: InferQueryObject<{
14
- discriminator: string;
15
- type: T;
16
- }>[]) => Promise<void>;
17
- };
18
- //# sourceMappingURL=use-session-object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-session-object.d.ts","sourceRoot":"","sources":["../../src/session/use-session-object.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,OAAO,EACR,MAAM,cAAc,CAAC;AAItB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAa5B,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const useSession: () => {
2
- id: string;
3
- };
4
- //# sourceMappingURL=use-session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-session.d.ts","sourceRoot":"","sources":["../../src/session/use-session.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;CAEpB,CAAC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSession = void 0;
4
- const use_1 = require("../use");
5
- exports.useSession = (0, use_1.use)(() => ({
6
- id: 'ttt' //Date.now()
7
- }));
@@ -1,30 +0,0 @@
1
- import { Decimal } from 'decimal.js';
2
- declare module 'decimal.js' {
3
- interface Decimal {
4
- toFloor(decimalPlaces: number): Decimal;
5
- toCeil(decimalPlaces: number): Decimal;
6
- }
7
- }
8
- export declare class decimal extends Decimal {
9
- }
10
- export declare function d(value: Decimal.Value): decimal;
11
- export declare namespace d {
12
- var Zero: decimal;
13
- }
14
- export declare function weightedMean(values: decimal[], weights: decimal[]): decimal;
15
- export declare function pnl(entryRate: decimal, exitRate: decimal, amount: decimal): Decimal;
16
- /**
17
- *
18
- * @param timestamp
19
- * @param timeframe
20
- * @returns nearest timestamp to the given timeframe
21
- */
22
- export declare function candledown(timestamp: number, timeframe: number): number;
23
- /**
24
- *
25
- * @param timestamp
26
- * @param timeframe
27
- * @returns nearest timestamp to the given timeframe
28
- */
29
- export declare function candleup(timestamp: number, timeframe: number): number;
30
- //# sourceMappingURL=decimals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decimals.d.ts","sourceRoot":"","sources":["../../src/shared/decimals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,OAAO;QACf,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;KACxC;CACF;AAUD,qBAAa,OAAQ,SAAQ,OAAO;CAAG;AAOvC,wBAAgB,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,WAErC;yBAFe,CAAC;;;AAMjB,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAc3E;AAED,wBAAgB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,WAEzE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAErE"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.candleup = exports.candledown = exports.pnl = exports.weightedMean = exports.d = exports.decimal = void 0;
4
- const decimal_js_1 = require("decimal.js");
5
- decimal_js_1.Decimal.prototype.toFloor = function (decimalPlaces) {
6
- return this.toDecimalPlaces(decimalPlaces, decimal_js_1.Decimal.ROUND_FLOOR);
7
- };
8
- decimal_js_1.Decimal.prototype.toCeil = function (decimalPlaces) {
9
- return this.toDecimalPlaces(decimalPlaces, decimal_js_1.Decimal.ROUND_CEIL);
10
- };
11
- class decimal extends decimal_js_1.Decimal {
12
- }
13
- exports.decimal = decimal;
14
- /*
15
- decimal.prototype.toJSON = function () {
16
- return '444';
17
- };
18
- */
19
- function d(value) {
20
- return new decimal(value);
21
- }
22
- exports.d = d;
23
- d.Zero = new decimal(0);
24
- function weightedMean(values, weights) {
25
- const result = values
26
- .map((value, i) => {
27
- const weight = weights[i];
28
- const sum = value.mul(weight);
29
- return [sum, weight];
30
- })
31
- .reduce((p, c) => [p[0].add(c[0]), p[1].add(c[1])], [d.Zero, d.Zero]);
32
- if (!result[1]) {
33
- return d.Zero;
34
- }
35
- return result[0].div(result[1]);
36
- }
37
- exports.weightedMean = weightedMean;
38
- function pnl(entryRate, exitRate, amount) {
39
- return exitRate.div(entryRate).minus(1).mul(amount);
40
- }
41
- exports.pnl = pnl;
42
- /**
43
- *
44
- * @param timestamp
45
- * @param timeframe
46
- * @returns nearest timestamp to the given timeframe
47
- */
48
- function candledown(timestamp, timeframe) {
49
- return timestamp - (timestamp % timeframe);
50
- }
51
- exports.candledown = candledown;
52
- /**
53
- *
54
- * @param timestamp
55
- * @param timeframe
56
- * @returns nearest timestamp to the given timeframe
57
- */
58
- function candleup(timestamp, timeframe) {
59
- return candledown(timestamp, timeframe) + timeframe;
60
- }
61
- exports.candleup = candleup;