@quantform/core 0.7.0-beta.49 → 0.7.0-beta.50

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 (273) hide show
  1. package/jest.config.ts +1 -1
  2. package/{dist → lib}/cli/index.js +9 -6
  3. package/lib/cli/live.d.ts +5 -0
  4. package/lib/cli/live.d.ts.map +1 -0
  5. package/{dist/cli/replay.js → lib/cli/live.js} +4 -3
  6. package/lib/cli/paper.d.ts +5 -0
  7. package/lib/cli/paper.d.ts.map +1 -0
  8. package/{dist/cli/dev.js → lib/cli/paper.js} +6 -1
  9. package/{dist → lib}/cli/pull.js +1 -1
  10. package/lib/cli/replay.d.ts +6 -0
  11. package/lib/cli/replay.d.ts.map +1 -0
  12. package/{dist/cli/run.js → lib/cli/replay.js} +10 -1
  13. package/{dist → lib}/core.js +3 -3
  14. package/{dist → lib}/index.d.ts +1 -0
  15. package/{dist → lib}/index.d.ts.map +1 -1
  16. package/{dist → lib}/index.js +1 -0
  17. package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts.map +1 -1
  18. package/{dist → lib}/replay/storage/use-replay-storage-buffer.js +1 -0
  19. package/lib/session/use-session.d.ts +13 -0
  20. package/lib/session/use-session.d.ts.map +1 -0
  21. package/lib/session/use-session.js +14 -0
  22. package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
  23. package/lib/storage/use-storage-factory.d.ts +10 -0
  24. package/lib/storage/use-storage-factory.d.ts.map +1 -0
  25. package/lib/storage/use-storage-factory.js +13 -0
  26. package/lib/use-execution-mode.d.ts +20 -0
  27. package/lib/use-execution-mode.d.ts.map +1 -0
  28. package/lib/use-execution-mode.js +33 -0
  29. package/{dist → lib}/use-logger.js +1 -1
  30. package/{dist → lib}/use-memo.d.ts +4 -7
  31. package/lib/use-memo.d.ts.map +1 -0
  32. package/{dist → lib}/use-memo.js +5 -11
  33. package/package.json +4 -4
  34. package/src/cli/index.ts +11 -8
  35. package/src/cli/live.ts +22 -0
  36. package/src/cli/paper.ts +22 -0
  37. package/src/cli/pull.ts +2 -2
  38. package/src/cli/replay.ts +12 -4
  39. package/src/core.ts +6 -6
  40. package/src/index.ts +1 -0
  41. package/src/replay/storage/use-replay-storage-buffer.ts +2 -0
  42. package/src/replay/use-replay.spec.ts +0 -1
  43. package/src/session/use-session.ts +16 -4
  44. package/src/simulator/use-simulator.spec.ts +10 -26
  45. package/src/storage/use-storage-factory.ts +7 -7
  46. package/src/use-execution-mode.ts +23 -31
  47. package/src/use-logger.ts +3 -3
  48. package/src/use-memo.ts +6 -11
  49. package/tsconfig.json +2 -2
  50. package/dist/cli/dev.d.ts +0 -2
  51. package/dist/cli/dev.d.ts.map +0 -1
  52. package/dist/cli/replay.d.ts +0 -2
  53. package/dist/cli/replay.d.ts.map +0 -1
  54. package/dist/cli/run.d.ts +0 -2
  55. package/dist/cli/run.d.ts.map +0 -1
  56. package/dist/session/use-session.d.ts +0 -4
  57. package/dist/session/use-session.d.ts.map +0 -1
  58. package/dist/session/use-session.js +0 -7
  59. package/dist/storage/use-storage-factory.d.ts +0 -10
  60. package/dist/storage/use-storage-factory.d.ts.map +0 -1
  61. package/dist/storage/use-storage-factory.js +0 -14
  62. package/dist/use-execution-mode.d.ts +0 -34
  63. package/dist/use-execution-mode.d.ts.map +0 -1
  64. package/dist/use-execution-mode.js +0 -45
  65. package/dist/use-memo.d.ts.map +0 -1
  66. package/src/cli/dev.ts +0 -15
  67. package/src/cli/run.ts +0 -15
  68. /package/{dist → lib}/asset/asset.d.ts +0 -0
  69. /package/{dist → lib}/asset/asset.d.ts.map +0 -0
  70. /package/{dist → lib}/asset/asset.js +0 -0
  71. /package/{dist → lib}/asset/asset.spec.d.ts +0 -0
  72. /package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
  73. /package/{dist → lib}/asset/asset.spec.js +0 -0
  74. /package/{dist → lib}/asset/index.d.ts +0 -0
  75. /package/{dist → lib}/asset/index.d.ts.map +0 -0
  76. /package/{dist → lib}/asset/index.js +0 -0
  77. /package/{dist → lib}/cli/build.d.ts +0 -0
  78. /package/{dist → lib}/cli/build.d.ts.map +0 -0
  79. /package/{dist → lib}/cli/build.js +0 -0
  80. /package/{dist → lib}/cli/index.d.ts +0 -0
  81. /package/{dist → lib}/cli/index.d.ts.map +0 -0
  82. /package/{dist → lib}/cli/internal/script.d.ts +0 -0
  83. /package/{dist → lib}/cli/internal/script.d.ts.map +0 -0
  84. /package/{dist → lib}/cli/internal/script.js +0 -0
  85. /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
  86. /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
  87. /package/{dist → lib}/cli/internal/workspace.js +0 -0
  88. /package/{dist → lib}/cli/pull.d.ts +0 -0
  89. /package/{dist → lib}/cli/pull.d.ts.map +0 -0
  90. /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
  91. /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +0 -0
  92. /package/{dist → lib}/component/distinct-until-timesamp-changed.js +0 -0
  93. /package/{dist → lib}/component/error.d.ts +0 -0
  94. /package/{dist → lib}/component/error.d.ts.map +0 -0
  95. /package/{dist → lib}/component/error.js +0 -0
  96. /package/{dist → lib}/component/index.d.ts +0 -0
  97. /package/{dist → lib}/component/index.d.ts.map +0 -0
  98. /package/{dist → lib}/component/index.js +0 -0
  99. /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
  100. /package/{dist → lib}/component/ohlc-operator.d.ts.map +0 -0
  101. /package/{dist → lib}/component/ohlc-operator.js +0 -0
  102. /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
  103. /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
  104. /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
  105. /package/{dist → lib}/component/ohlc.d.ts +0 -0
  106. /package/{dist → lib}/component/ohlc.d.ts.map +0 -0
  107. /package/{dist → lib}/component/ohlc.js +0 -0
  108. /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
  109. /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
  110. /package/{dist → lib}/component/ohlc.spec.js +0 -0
  111. /package/{dist → lib}/component/timeframe.d.ts +0 -0
  112. /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
  113. /package/{dist → lib}/component/timeframe.js +0 -0
  114. /package/{dist → lib}/core.d.ts +0 -0
  115. /package/{dist → lib}/core.d.ts.map +0 -0
  116. /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
  117. /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
  118. /package/{dist → lib}/instrument/commission/commission.js +0 -0
  119. /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
  120. /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
  121. /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
  122. /package/{dist → lib}/instrument/index.d.ts +0 -0
  123. /package/{dist → lib}/instrument/index.d.ts.map +0 -0
  124. /package/{dist → lib}/instrument/index.js +0 -0
  125. /package/{dist → lib}/instrument/instrument.d.ts +0 -0
  126. /package/{dist → lib}/instrument/instrument.d.ts.map +0 -0
  127. /package/{dist → lib}/instrument/instrument.js +0 -0
  128. /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
  129. /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
  130. /package/{dist → lib}/instrument/instrument.spec.js +0 -0
  131. /package/{dist → lib}/make-test-module.d.ts +0 -0
  132. /package/{dist → lib}/make-test-module.d.ts.map +0 -0
  133. /package/{dist → lib}/make-test-module.js +0 -0
  134. /package/{dist → lib}/module.d.ts +0 -0
  135. /package/{dist → lib}/module.d.ts.map +0 -0
  136. /package/{dist → lib}/module.js +0 -0
  137. /package/{dist → lib}/module.spec.d.ts +0 -0
  138. /package/{dist → lib}/module.spec.d.ts.map +0 -0
  139. /package/{dist → lib}/module.spec.js +0 -0
  140. /package/{dist → lib}/operators.d.ts +0 -0
  141. /package/{dist → lib}/operators.d.ts.map +0 -0
  142. /package/{dist → lib}/operators.js +0 -0
  143. /package/{dist → lib}/replay/index.d.ts +0 -0
  144. /package/{dist → lib}/replay/index.d.ts.map +0 -0
  145. /package/{dist → lib}/replay/index.js +0 -0
  146. /package/{dist → lib}/replay/replay-guard.d.ts +0 -0
  147. /package/{dist → lib}/replay/replay-guard.d.ts.map +0 -0
  148. /package/{dist → lib}/replay/replay-guard.js +0 -0
  149. /package/{dist → lib}/replay/replay.d.ts +0 -0
  150. /package/{dist → lib}/replay/replay.d.ts.map +0 -0
  151. /package/{dist → lib}/replay/replay.js +0 -0
  152. /package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts +0 -0
  153. /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts +0 -0
  154. /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts.map +0 -0
  155. /package/{dist → lib}/replay/storage/use-replay-storage-cursor.js +0 -0
  156. /package/{dist → lib}/replay/storage/use-replay-storage.d.ts +0 -0
  157. /package/{dist → lib}/replay/storage/use-replay-storage.d.ts.map +0 -0
  158. /package/{dist → lib}/replay/storage/use-replay-storage.js +0 -0
  159. /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts +0 -0
  160. /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts.map +0 -0
  161. /package/{dist → lib}/replay/storage/use-replay-storage.spec.js +0 -0
  162. /package/{dist → lib}/replay/use-replay-breakpoint.d.ts +0 -0
  163. /package/{dist → lib}/replay/use-replay-breakpoint.d.ts.map +0 -0
  164. /package/{dist → lib}/replay/use-replay-breakpoint.js +0 -0
  165. /package/{dist → lib}/replay/use-replay-manager.d.ts +0 -0
  166. /package/{dist → lib}/replay/use-replay-manager.d.ts.map +0 -0
  167. /package/{dist → lib}/replay/use-replay-manager.js +0 -0
  168. /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
  169. /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
  170. /package/{dist → lib}/replay/use-replay-options.js +0 -0
  171. /package/{dist → lib}/replay/use-replay.d.ts +0 -0
  172. /package/{dist → lib}/replay/use-replay.d.ts.map +0 -0
  173. /package/{dist → lib}/replay/use-replay.js +0 -0
  174. /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
  175. /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
  176. /package/{dist → lib}/replay/use-replay.spec.js +0 -0
  177. /package/{dist → lib}/replay/when-replay-finished.d.ts +0 -0
  178. /package/{dist → lib}/replay/when-replay-finished.d.ts.map +0 -0
  179. /package/{dist → lib}/replay/when-replay-finished.js +0 -0
  180. /package/{dist → lib}/session/index.d.ts +0 -0
  181. /package/{dist → lib}/session/index.d.ts.map +0 -0
  182. /package/{dist → lib}/session/index.js +0 -0
  183. /package/{dist → lib}/session/use-session-object.d.ts +0 -0
  184. /package/{dist → lib}/session/use-session-object.d.ts.map +0 -0
  185. /package/{dist → lib}/session/use-session-object.js +0 -0
  186. /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
  187. /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
  188. /package/{dist → lib}/session/use-session-storage.js +0 -0
  189. /package/{dist → lib}/shared/datetime.d.ts +0 -0
  190. /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
  191. /package/{dist → lib}/shared/datetime.js +0 -0
  192. /package/{dist → lib}/shared/decimals.d.ts +0 -0
  193. /package/{dist → lib}/shared/decimals.d.ts.map +0 -0
  194. /package/{dist → lib}/shared/decimals.js +0 -0
  195. /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
  196. /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
  197. /package/{dist → lib}/shared/decimals.spec.js +0 -0
  198. /package/{dist → lib}/shared/environment.d.ts +0 -0
  199. /package/{dist → lib}/shared/environment.d.ts.map +0 -0
  200. /package/{dist → lib}/shared/environment.js +0 -0
  201. /package/{dist → lib}/shared/index.d.ts +0 -0
  202. /package/{dist → lib}/shared/index.d.ts.map +0 -0
  203. /package/{dist → lib}/shared/index.js +0 -0
  204. /package/{dist → lib}/simulator/index.d.ts +0 -0
  205. /package/{dist → lib}/simulator/index.d.ts.map +0 -0
  206. /package/{dist → lib}/simulator/index.js +0 -0
  207. /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
  208. /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
  209. /package/{dist → lib}/simulator/use-simulator.js +0 -0
  210. /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
  211. /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
  212. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
  213. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
  214. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
  215. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
  216. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +0 -0
  217. /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
  218. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
  219. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
  220. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
  221. /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
  222. /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
  223. /package/{dist → lib}/storage/in-memory/index.js +0 -0
  224. /package/{dist → lib}/storage/index.d.ts +0 -0
  225. /package/{dist → lib}/storage/index.d.ts.map +0 -0
  226. /package/{dist → lib}/storage/index.js +0 -0
  227. /package/{dist → lib}/storage/storage.d.ts +0 -0
  228. /package/{dist → lib}/storage/storage.d.ts.map +0 -0
  229. /package/{dist → lib}/storage/storage.js +0 -0
  230. /package/{dist → lib}/storage/use-cache.d.ts +0 -0
  231. /package/{dist → lib}/storage/use-cache.d.ts.map +0 -0
  232. /package/{dist → lib}/storage/use-cache.js +0 -0
  233. /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
  234. /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
  235. /package/{dist → lib}/storage/use-cache.spec.js +0 -0
  236. /package/{dist → lib}/storage/use-storage.d.ts +0 -0
  237. /package/{dist → lib}/storage/use-storage.d.ts.map +0 -0
  238. /package/{dist → lib}/storage/use-storage.js +0 -0
  239. /package/{dist → lib}/strategy.d.ts +0 -0
  240. /package/{dist → lib}/strategy.d.ts.map +0 -0
  241. /package/{dist → lib}/strategy.js +0 -0
  242. /package/{dist → lib}/strategy.spec.d.ts +0 -0
  243. /package/{dist → lib}/strategy.spec.d.ts.map +0 -0
  244. /package/{dist → lib}/strategy.spec.js +0 -0
  245. /package/{dist → lib}/use-hash.d.ts +0 -0
  246. /package/{dist → lib}/use-hash.d.ts.map +0 -0
  247. /package/{dist → lib}/use-hash.js +0 -0
  248. /package/{dist → lib}/use-hash.spec.d.ts +0 -0
  249. /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
  250. /package/{dist → lib}/use-hash.spec.js +0 -0
  251. /package/{dist → lib}/use-logger.d.ts +0 -0
  252. /package/{dist → lib}/use-logger.d.ts.map +0 -0
  253. /package/{dist → lib}/use-memo.spec.d.ts +0 -0
  254. /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
  255. /package/{dist → lib}/use-memo.spec.js +0 -0
  256. /package/{dist → lib}/use-socket.d.ts +0 -0
  257. /package/{dist → lib}/use-socket.d.ts.map +0 -0
  258. /package/{dist → lib}/use-socket.js +0 -0
  259. /package/{dist → lib}/use-timestamp.d.ts +0 -0
  260. /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
  261. /package/{dist → lib}/use-timestamp.js +0 -0
  262. /package/{dist → lib}/when-socket.d.ts +0 -0
  263. /package/{dist → lib}/when-socket.d.ts.map +0 -0
  264. /package/{dist → lib}/when-socket.js +0 -0
  265. /package/{dist → lib}/with-memo.d.ts +0 -0
  266. /package/{dist → lib}/with-memo.d.ts.map +0 -0
  267. /package/{dist → lib}/with-memo.js +0 -0
  268. /package/{dist → lib}/with-memo.spec.d.ts +0 -0
  269. /package/{dist → lib}/with-memo.spec.d.ts.map +0 -0
  270. /package/{dist → lib}/with-memo.spec.js +0 -0
  271. /package/{dist → lib}/with-request.d.ts +0 -0
  272. /package/{dist → lib}/with-request.d.ts.map +0 -0
  273. /package/{dist → lib}/with-request.js +0 -0
package/jest.config.ts CHANGED
@@ -23,7 +23,7 @@ const config: Config = {
23
23
  }
24
24
  ]
25
25
  },
26
- testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/src/cli/test.ts'],
26
+ testPathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/src/cli/test.ts'],
27
27
  roots: ['<rootDir>'],
28
28
  modulePaths: [compilerOptions.baseUrl],
29
29
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
@@ -17,10 +17,10 @@ const child_process_1 = require("child_process");
17
17
  const commander_1 = require("commander");
18
18
  const node_watch_1 = __importDefault(require("node-watch"));
19
19
  const build_1 = __importDefault(require("../cli/build"));
20
- const dev_1 = __importDefault(require("../cli/dev"));
20
+ const live_1 = __importDefault(require("../cli/live"));
21
+ const paper_1 = __importDefault(require("../cli/paper"));
21
22
  const pull_1 = __importDefault(require("../cli/pull"));
22
23
  const replay_1 = __importDefault(require("../cli/replay"));
23
- const run_1 = __importDefault(require("../cli/run"));
24
24
  commander_1.program
25
25
  .command('build')
26
26
  .description('builds a production version of the app')
@@ -28,23 +28,26 @@ commander_1.program
28
28
  yield (0, build_1.default)();
29
29
  }));
30
30
  commander_1.program
31
- .command('run')
31
+ .command('live')
32
32
  .argument('<name>', 'strategy to execute')
33
33
  .option('-i, --id <id>', 'session identifier')
34
+ .option('-r, --recording', 'recording mode for replay purposes')
34
35
  .option('-w', 'watch mode')
35
36
  .description('executes strategy in live trading mode')
36
- .action(run_1.default);
37
+ .action(live_1.default);
37
38
  commander_1.program
38
- .command('dev')
39
+ .command('paper')
39
40
  .argument('<name>', 'strategy to execute')
40
41
  .option('-i, --id <id>', 'session identifier')
42
+ .option('-r, --recording', 'recording mode for replay purposes')
41
43
  .option('-w', 'watch mode')
42
44
  .description('executes strategy in paper e.g. simulation mode')
43
- .action(dev_1.default);
45
+ .action(paper_1.default);
44
46
  commander_1.program
45
47
  .command('replay')
46
48
  .description('executes strategy in backtesting mode for specified period')
47
49
  .argument('<name>', 'strategy to execute')
50
+ .option('-i, --id <id>', 'session identifier')
48
51
  .option('-f, --from <from>', 'date from')
49
52
  .option('-t, --to <to>', 'date to')
50
53
  .option('-w', 'watch mode')
@@ -0,0 +1,5 @@
1
+ export default function (name: string, options: {
2
+ id?: string;
3
+ recording?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../src/cli/live.ts"],"names":[],"mappings":"AAMA,yBACE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,iBAa9C"}
@@ -13,17 +13,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const build_1 = __importDefault(require("../cli/build"));
16
- const replay_1 = require("../replay");
16
+ const session_1 = require("../session");
17
17
  const use_execution_mode_1 = require("../use-execution-mode");
18
18
  const script_1 = require("./internal/script");
19
19
  function default_1(name, options) {
20
+ var _a, _b;
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  if (yield (0, build_1.default)()) {
22
23
  return;
23
24
  }
24
25
  const script = new script_1.Script(name, [
25
- (0, replay_1.replayOptions)({ from: 0, to: Number.MAX_VALUE }),
26
- (0, use_execution_mode_1.replayExecutionMode)()
26
+ session_1.useSession.options({ id: (_a = options.id) !== null && _a !== void 0 ? _a : Date.now().toString() }),
27
+ use_execution_mode_1.useExecutionMode.liveOptions({ recording: (_b = options.recording) !== null && _b !== void 0 ? _b : false })
27
28
  ]);
28
29
  const output = yield script.run();
29
30
  console.log(output);
@@ -0,0 +1,5 @@
1
+ export default function (name: string, options: {
2
+ id?: string;
3
+ recording?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=paper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paper.d.ts","sourceRoot":"","sources":["../../src/cli/paper.ts"],"names":[],"mappings":"AAMA,yBACE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,iBAa9C"}
@@ -13,14 +13,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const build_1 = __importDefault(require("../cli/build"));
16
+ const session_1 = require("../session");
16
17
  const use_execution_mode_1 = require("../use-execution-mode");
17
18
  const script_1 = require("./internal/script");
18
19
  function default_1(name, options) {
20
+ var _a, _b;
19
21
  return __awaiter(this, void 0, void 0, function* () {
20
22
  if (yield (0, build_1.default)()) {
21
23
  return;
22
24
  }
23
- const script = new script_1.Script(name, [(0, use_execution_mode_1.paperExecutionMode)({ recording: false })]);
25
+ const script = new script_1.Script(name, [
26
+ session_1.useSession.options({ id: (_a = options.id) !== null && _a !== void 0 ? _a : Date.now().toString() }),
27
+ use_execution_mode_1.useExecutionMode.paperOptions({ recording: (_b = options.recording) !== null && _b !== void 0 ? _b : false })
28
+ ]);
24
29
  const output = yield script.run();
25
30
  console.log(output);
26
31
  });
@@ -20,7 +20,7 @@ function default_1(name, instrument, options) {
20
20
  if (yield (0, build_1.default)()) {
21
21
  return;
22
22
  }
23
- const script = new script_1.Script(name, [(0, use_execution_mode_1.idleExecutionMode)()]);
23
+ const script = new script_1.Script(name, [use_execution_mode_1.useExecutionMode.idleOptions()]);
24
24
  //const output = await script.run();
25
25
  //console.log(output);
26
26
  });
@@ -0,0 +1,6 @@
1
+ export default function (name: string, options: {
2
+ id?: string;
3
+ from?: string;
4
+ to?: string;
5
+ }): Promise<void>;
6
+ //# sourceMappingURL=replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/cli/replay.ts"],"names":[],"mappings":"AAOA,yBACE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,iBAiBrD"}
@@ -13,14 +13,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const build_1 = __importDefault(require("../cli/build"));
16
+ const replay_1 = require("../replay");
17
+ const session_1 = require("../session");
16
18
  const use_execution_mode_1 = require("../use-execution-mode");
17
19
  const script_1 = require("./internal/script");
18
20
  function default_1(name, options) {
21
+ var _a;
19
22
  return __awaiter(this, void 0, void 0, function* () {
20
23
  if (yield (0, build_1.default)()) {
21
24
  return;
22
25
  }
23
- const script = new script_1.Script(name, [(0, use_execution_mode_1.liveExecutionMode)({ recording: true })]);
26
+ const from = options.from ? new Date(options.from).getTime() : 0;
27
+ const to = options.to ? new Date(options.to).getTime() : Number.MAX_VALUE;
28
+ const script = new script_1.Script(name, [
29
+ session_1.useSession.options({ id: (_a = options.id) !== null && _a !== void 0 ? _a : Date.now().toString() }),
30
+ (0, replay_1.replayOptions)({ from, to }),
31
+ use_execution_mode_1.useExecutionMode.replayOptions()
32
+ ]);
24
33
  const output = yield script.run();
25
34
  console.log(output);
26
35
  });
@@ -7,9 +7,9 @@ const use_storage_factory_1 = require("./storage/use-storage-factory");
7
7
  const use_execution_mode_1 = require("./use-execution-mode");
8
8
  function core() {
9
9
  return [
10
- (0, use_memo_1.memo)(),
11
- (0, use_execution_mode_1.paperExecutionMode)({ recording: false }),
12
- (0, use_storage_factory_1.storage)(new storage_1.InMemoryStorageFactory())
10
+ use_memo_1.useMemo.options(),
11
+ use_execution_mode_1.useExecutionMode.paperOptions({ recording: false }),
12
+ use_storage_factory_1.useStorageFactory.options(new storage_1.InMemoryStorageFactory())
13
13
  ];
14
14
  }
15
15
  exports.core = core;
@@ -11,6 +11,7 @@ export * from './use-execution-mode';
11
11
  export * from './storage';
12
12
  export * from './use-logger';
13
13
  export * from './replay';
14
+ export * from './use-socket';
14
15
  export * from './when-socket';
15
16
  export * from './with-request';
16
17
  export * from './with-memo';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
@@ -27,6 +27,7 @@ __exportStar(require("./use-execution-mode"), exports);
27
27
  __exportStar(require("./storage"), exports);
28
28
  __exportStar(require("./use-logger"), exports);
29
29
  __exportStar(require("./replay"), exports);
30
+ __exportStar(require("./use-socket"), exports);
30
31
  __exportStar(require("./when-socket"), exports);
31
32
  __exportStar(require("./with-request"), exports);
32
33
  __exportStar(require("./with-memo"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"use-replay-storage-buffer.d.ts","sourceRoot":"","sources":["../../../src/replay/storage/use-replay-storage-buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,eAAO,MAAM,sBAAsB;;;mBAIC,MAAM;;;;mBAAN,MAAM;;;;;CAsCxC,CAAC"}
1
+ {"version":3,"file":"use-replay-storage-buffer.d.ts","sourceRoot":"","sources":["../../../src/replay/storage/use-replay-storage-buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,eAAO,MAAM,sBAAsB;;;mBAMC,MAAM;;;;mBAAN,MAAM;;;;;CAsCxC,CAAC"}
@@ -17,6 +17,7 @@ const use_replay_storage_1 = require("./use-replay-storage");
17
17
  exports.useReplayStorageBuffer = (0, with_memo_1.withMemo)((dependencies) => {
18
18
  const { query } = (0, use_replay_storage_1.useReplayStorage)(dependencies);
19
19
  const { from, to } = (0, use_replay_options_1.useReplayOptions)();
20
+ console.log(from, to);
20
21
  let page = new Array();
21
22
  let index = 0;
22
23
  let completed = false;
@@ -0,0 +1,13 @@
1
+ import { Dependency } from '../module';
2
+ type SessionOptions = {
3
+ id: string;
4
+ };
5
+ /**
6
+ * Will return current replay execution options.
7
+ */
8
+ export declare const useSession: {
9
+ (): SessionOptions;
10
+ options(options: SessionOptions): Dependency;
11
+ };
12
+ export {};
13
+ //# sourceMappingURL=use-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-session.d.ts","sourceRoot":"","sources":["../../src/session/use-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAIrD,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU;;qBAEQ,cAAc,GAAG,UAAU;CAFO,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSession = void 0;
4
+ const module_1 = require("../module");
5
+ const token = Symbol('session-options');
6
+ /**
7
+ * Will return current replay execution options.
8
+ */
9
+ const useSession = () => (0, module_1.useContext)(token);
10
+ exports.useSession = useSession;
11
+ exports.useSession.options = (options) => ({
12
+ provide: token,
13
+ useValue: options
14
+ });
@@ -12,38 +12,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const make_test_module_1 = require("../make-test-module");
13
13
  const use_execution_mode_1 = require("../use-execution-mode");
14
14
  const use_simulator_1 = require("./use-simulator");
15
- jest.mock('@lib/use-execution-mode', () => (Object.assign(Object.assign({}, jest.requireActual('@lib/use-execution-mode')), { useExecutionMode: jest.fn() })));
16
15
  describe(use_simulator_1.useSimulator.name, () => {
17
16
  let fixtures;
18
17
  beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
19
18
  fixtures = yield getFixtures();
20
19
  }));
21
- afterEach(() => fixtures.clear());
22
- test('get real value when simulator mode disabled', () => {
23
- const { act } = fixtures;
24
- fixtures.givenSimulationEnabled(false);
20
+ test('get real value when simulator mode disabled', () => __awaiter(void 0, void 0, void 0, function* () {
21
+ const { act } = yield fixtures.givenModule(false);
25
22
  const value = act(() => (0, use_simulator_1.useSimulator)('simulator', 'real'));
26
23
  expect(value).toBe('real');
27
- });
28
- test('get simulation value when simulator mode enabled', () => {
29
- const { act } = fixtures;
30
- fixtures.givenSimulationEnabled(true);
24
+ }));
25
+ test('get simulation value when simulator mode enabled', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const { act } = yield fixtures.givenModule(true);
31
27
  const value = act(() => (0, use_simulator_1.useSimulator)('simulator', 'real'));
32
28
  expect(value).toBe('simulator');
33
- });
29
+ }));
34
30
  });
35
31
  function getFixtures() {
36
32
  return __awaiter(this, void 0, void 0, function* () {
37
- const { act } = yield (0, make_test_module_1.makeTestModule)([]);
38
33
  return {
39
- act,
40
- givenSimulationEnabled(isSimulation) {
41
- (0, make_test_module_1.mockedFunc)(use_execution_mode_1.useExecutionMode).mockReturnValue({
42
- isSimulation,
43
- recording: false
34
+ givenModule(isSimulation) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return isSimulation
37
+ ? yield (0, make_test_module_1.makeTestModule)([use_execution_mode_1.useExecutionMode.paperOptions({ recording: false })])
38
+ : yield (0, make_test_module_1.makeTestModule)([use_execution_mode_1.useExecutionMode.liveOptions({ recording: false })]);
44
39
  });
45
- },
46
- clear: jest.clearAllMocks
40
+ }
47
41
  };
48
42
  });
49
43
  }
@@ -0,0 +1,10 @@
1
+ import { Dependency } from '../module';
2
+ import { Storage } from '../storage';
3
+ export interface StorageFactory {
4
+ for(key: string): Storage;
5
+ }
6
+ export declare function useStorageFactory(): StorageFactory;
7
+ export declare namespace useStorageFactory {
8
+ var options: (factory: StorageFactory) => Dependency;
9
+ }
10
+ //# sourceMappingURL=use-storage-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storage-factory.d.ts","sourceRoot":"","sources":["../../src/storage/use-storage-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,mBAEhC;yBAFe,iBAAiB"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStorageFactory = void 0;
4
+ const module_1 = require("../module");
5
+ const token = Symbol('storage-factory-token');
6
+ function useStorageFactory() {
7
+ return (0, module_1.useContext)(token);
8
+ }
9
+ exports.useStorageFactory = useStorageFactory;
10
+ useStorageFactory.options = (factory) => ({
11
+ provide: token,
12
+ useValue: factory
13
+ });
@@ -0,0 +1,20 @@
1
+ import { Dependency } from './module';
2
+ export declare function useExecutionMode(): {
3
+ isReplay: boolean;
4
+ isPaper: boolean;
5
+ isLive: boolean;
6
+ isIdle: boolean;
7
+ isSimulation: boolean;
8
+ recording: boolean;
9
+ };
10
+ export declare namespace useExecutionMode {
11
+ var replayOptions: () => Dependency;
12
+ var paperOptions: (options: {
13
+ recording: boolean;
14
+ }) => Dependency;
15
+ var liveOptions: (options: {
16
+ recording: boolean;
17
+ }) => Dependency;
18
+ var idleOptions: () => Dependency;
19
+ }
20
+ //# sourceMappingURL=use-execution-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-execution-mode.d.ts","sourceRoot":"","sources":["../src/use-execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AASrD,wBAAgB,gBAAgB;;;;;;;EAW/B;yBAXe,gBAAgB"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useExecutionMode = void 0;
4
+ const module_1 = require("./module");
5
+ const injectionToken = Symbol('execution-mode');
6
+ function useExecutionMode() {
7
+ const { mode, recording } = (0, module_1.useContext)(injectionToken);
8
+ return {
9
+ isReplay: mode === 'replay',
10
+ isPaper: mode === 'paper',
11
+ isLive: mode === 'live',
12
+ isIdle: mode === 'idle',
13
+ isSimulation: mode !== 'live',
14
+ recording
15
+ };
16
+ }
17
+ exports.useExecutionMode = useExecutionMode;
18
+ useExecutionMode.replayOptions = () => ({
19
+ provide: injectionToken,
20
+ useValue: { mode: 'replay', recording: false }
21
+ });
22
+ useExecutionMode.paperOptions = (options) => ({
23
+ provide: injectionToken,
24
+ useValue: Object.assign({ mode: 'paper' }, options)
25
+ });
26
+ useExecutionMode.liveOptions = (options) => ({
27
+ provide: injectionToken,
28
+ useValue: Object.assign({ mode: 'live' }, options)
29
+ });
30
+ useExecutionMode.idleOptions = () => ({
31
+ provide: injectionToken,
32
+ useValue: { mode: 'idle', recording: false }
33
+ });
@@ -19,7 +19,7 @@ const colorize = (content) => {
19
19
  *
20
20
  */
21
21
  exports.useLogger = (0, with_memo_1.withMemo)((context, tint) => {
22
- const prefix = () => `${chalk_1.default.gray(new Date((0, use_timestamp_1.useTimestamp)()).toISOString())} ${chalk_1.default.hex(tint !== null && tint !== void 0 ? tint : colorize(context))(context)}`;
22
+ const prefix = () => `${chalk_1.default.hex(tint !== null && tint !== void 0 ? tint : colorize(context))(new Date((0, use_timestamp_1.useTimestamp)()).toISOString())} ${chalk_1.default.hex(tint !== null && tint !== void 0 ? tint : colorize(context))(context)}`;
23
23
  return {
24
24
  info: (message, ...params) => (params === null || params === void 0 ? void 0 : params.length)
25
25
  ? console.info(`${prefix()}: ${message}`, params)
@@ -1,11 +1,8 @@
1
+ import { Dependency } from './module';
1
2
  import { dependency } from './use-hash';
2
3
  export declare const token: unique symbol;
3
- /**
4
- *
5
- */
6
- export declare function memo(): {
7
- provide: symbol;
8
- useValue: {};
9
- };
10
4
  export declare function useMemo<T>(calculateValue: () => T, dependencies: dependency[]): T;
5
+ export declare namespace useMemo {
6
+ var options: () => Dependency;
7
+ }
11
8
  //# sourceMappingURL=use-memo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-memo.d.ts","sourceRoot":"","sources":["../src/use-memo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAEpD,eAAO,MAAM,KAAK,eAAuB,CAAC;AAE1C,wBAAgB,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,KAS7E;yBATe,OAAO"}
@@ -1,19 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMemo = exports.memo = exports.token = void 0;
3
+ exports.useMemo = exports.token = void 0;
4
4
  const module_1 = require("./module");
5
5
  const use_hash_1 = require("./use-hash");
6
6
  exports.token = Symbol('memo-token');
7
- /**
8
- *
9
- */
10
- function memo() {
11
- return {
12
- provide: exports.token,
13
- useValue: {}
14
- };
15
- }
16
- exports.memo = memo;
17
7
  function useMemo(calculateValue, dependencies) {
18
8
  const memory = (0, module_1.useContext)(exports.token);
19
9
  const hash = (0, use_hash_1.useHash)(dependencies);
@@ -23,3 +13,7 @@ function useMemo(calculateValue, dependencies) {
23
13
  return (memory[hash] = calculateValue());
24
14
  }
25
15
  exports.useMemo = useMemo;
16
+ useMemo.options = () => ({
17
+ provide: exports.token,
18
+ useValue: {}
19
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantform/core",
3
- "version": "0.7.0-beta.49",
3
+ "version": "0.7.0-beta.50",
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",
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,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,5 +1,5 @@
1
1
  import build from '@lib/cli/build';
2
- import { idleExecutionMode } from '@lib/use-execution-mode';
2
+ import { useExecutionMode } from '@lib/use-execution-mode';
3
3
 
4
4
  import { Script } from './internal/script';
5
5
 
@@ -8,7 +8,7 @@ export default async function (name: string, instrument: string, options: any) {
8
8
  return;
9
9
  }
10
10
 
11
- const script = new Script(name, [idleExecutionMode()]);
11
+ const script = new Script(name, [useExecutionMode.idleOptions()]);
12
12
  //const output = await script.run();
13
13
 
14
14
  //console.log(output);
package/src/cli/replay.ts CHANGED
@@ -1,17 +1,25 @@
1
1
  import build from '@lib/cli/build';
2
2
  import { replayOptions } from '@lib/replay';
3
- import { replayExecutionMode } from '@lib/use-execution-mode';
3
+ import { useSession } from '@lib/session';
4
+ import { useExecutionMode } from '@lib/use-execution-mode';
4
5
 
5
6
  import { Script } from './internal/script';
6
7
 
7
- export default async function (name: string, options: any) {
8
+ export default async function (
9
+ name: string,
10
+ options: { id?: string; from?: string; to?: string }
11
+ ) {
8
12
  if (await build()) {
9
13
  return;
10
14
  }
11
15
 
16
+ const from = options.from ? new Date(options.from).getTime() : 0;
17
+ const to = options.to ? new Date(options.to).getTime() : Number.MAX_VALUE;
18
+
12
19
  const script = new Script(name, [
13
- replayOptions({ from: 0, to: Number.MAX_VALUE }),
14
- replayExecutionMode()
20
+ useSession.options({ id: options.id ?? Date.now().toString() }),
21
+ replayOptions({ from, to }),
22
+ useExecutionMode.replayOptions()
15
23
  ]);
16
24
  const output = await script.run();
17
25