@quantform/core 0.7.0-beta.42 → 0.7.0-beta.44

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.
@@ -1 +1 @@
1
- {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/cli/internal/script.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAU,MAAM,aAAa,CAAC;AAIjD,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,UAAU,EAAE;IAGvC,GAAG;CAyBV"}
1
+ {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/cli/internal/script.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAU,MAAM,aAAa,CAAC;AAKjD,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,UAAU,EAAE;IAGvC,GAAG;CA0BV"}
@@ -37,6 +37,7 @@ const path_1 = require("path");
37
37
  const rxjs_1 = require("rxjs");
38
38
  const core_1 = require("../../core");
39
39
  const module_1 = require("../../module");
40
+ const replay_1 = require("../../replay");
40
41
  const workspace_1 = require("./workspace");
41
42
  class Script {
42
43
  constructor(name, dependencies) {
@@ -50,7 +51,7 @@ class Script {
50
51
  const { act } = yield module.awake();
51
52
  return yield act(() => {
52
53
  process.stdin.resume();
53
- return (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)(script.onAwake().pipe((0, rxjs_1.last)()), (0, rxjs_1.fromEvent)(process, 'exit'), (0, rxjs_1.fromEvent)(process, 'SIGINT'), (0, rxjs_1.fromEvent)(process, 'SIGUSR1'), (0, rxjs_1.fromEvent)(process, 'SIGUSR2'), (0, rxjs_1.fromEvent)(process, 'uncaughtException')).pipe((0, rxjs_1.take)(1), (0, rxjs_1.switchMap)(it => { var _a; return (_a = script.onExit()) !== null && _a !== void 0 ? _a : (0, rxjs_1.of)(it); }), (0, rxjs_1.finalize)(() => process.exit(0))));
54
+ return (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)(script.onAwake().pipe((0, rxjs_1.last)()), (0, replay_1.whenReplayFinished)().pipe((0, rxjs_1.last)()), (0, rxjs_1.fromEvent)(process, 'exit'), (0, rxjs_1.fromEvent)(process, 'SIGINT'), (0, rxjs_1.fromEvent)(process, 'SIGUSR1'), (0, rxjs_1.fromEvent)(process, 'SIGUSR2'), (0, rxjs_1.fromEvent)(process, 'uncaughtException')).pipe((0, rxjs_1.take)(1), (0, rxjs_1.switchMap)(it => { var _a; return (_a = script.onExit()) !== null && _a !== void 0 ? _a : (0, rxjs_1.of)(it); }), (0, rxjs_1.finalize)(() => process.exit(0))));
54
55
  });
55
56
  });
56
57
  }
@@ -4,6 +4,7 @@ export * from './use-replay-options';
4
4
  export * from './use-replay-storage';
5
5
  export * from './use-replay-storage-buffer';
6
6
  export * from './use-replay-manager';
7
+ export * from './when-replay-finished';
7
8
  export * from './replay';
8
9
  export * from './replay-guard';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
@@ -20,5 +20,6 @@ __exportStar(require("./use-replay-options"), exports);
20
20
  __exportStar(require("./use-replay-storage"), exports);
21
21
  __exportStar(require("./use-replay-storage-buffer"), exports);
22
22
  __exportStar(require("./use-replay-manager"), exports);
23
+ __exportStar(require("./when-replay-finished"), exports);
23
24
  __exportStar(require("./replay"), exports);
24
25
  __exportStar(require("./replay-guard"), exports);
@@ -1,6 +1,22 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { dependency } from '../use-hash';
3
3
  export declare const useReplayManager: () => {
4
+ stream: Observable<[{
5
+ size(): number;
6
+ peek(): {
7
+ timestamp: number;
8
+ payload: any;
9
+ };
10
+ dequeue(): {
11
+ timestamp: number;
12
+ payload: any;
13
+ };
14
+ completed(): boolean;
15
+ fetchNextPage(from: number, to: number): Promise<void>;
16
+ }, {
17
+ timestamp: number;
18
+ payload: any;
19
+ }]>;
4
20
  timestamp(): number;
5
21
  stop(): void;
6
22
  tryContinue: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"use-replay-manager.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAW,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAOpD,eAAO,MAAM,gBAAgB;;;;0BA8EH,UAAU,EAAE;mBAA2B,MAAM;;;CAkBrE,CAAC"}
1
+ {"version":3,"file":"use-replay-manager.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAW,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAOpD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;mBASqC,MAAM;iBAAW,GAAG;;;;;0BAsE5D,UAAU,EAAE;mBAA2B,MAAM;;;CAkBrE,CAAC"}
@@ -66,6 +66,7 @@ exports.useReplayManager = (0, with_memo_1.withMemo)(() => {
66
66
  next();
67
67
  };
68
68
  return {
69
+ stream: stream$.asObservable(),
69
70
  timestamp() {
70
71
  return timestamp;
71
72
  },
@@ -0,0 +1,2 @@
1
+ export declare function whenReplayFinished(): import("rxjs").Observable<boolean>;
2
+ //# sourceMappingURL=when-replay-finished.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when-replay-finished.d.ts","sourceRoot":"","sources":["../../src/replay/when-replay-finished.ts"],"names":[],"mappings":"AAMA,wBAAgB,kBAAkB,uCAajC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.whenReplayFinished = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const use_execution_mode_1 = require("../use-execution-mode");
6
+ const use_replay_manager_1 = require("./use-replay-manager");
7
+ function whenReplayFinished() {
8
+ const { isReplay } = (0, use_execution_mode_1.useExecutionMode)();
9
+ if (!isReplay) {
10
+ return new rxjs_1.Subject().asObservable();
11
+ }
12
+ const { stream } = (0, use_replay_manager_1.useReplayManager)();
13
+ return (0, rxjs_1.from)(stream).pipe((0, rxjs_1.last)(), (0, rxjs_1.map)(() => true));
14
+ }
15
+ exports.whenReplayFinished = whenReplayFinished;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantform/core",
3
- "version": "0.7.0-beta.42",
3
+ "version": "0.7.0-beta.44",
4
4
  "license": "MIT",
5
5
  "author": "Mateusz Majchrzak",
6
6
  "description": "Node.js library for building systematic trading strategies in reactive way.",
@@ -12,6 +12,7 @@ import {
12
12
 
13
13
  import { core } from '@lib/core';
14
14
  import { Dependency, Module } from '@lib/module';
15
+ import { whenReplayFinished } from '@lib/replay';
15
16
 
16
17
  import { buildDirectory } from './workspace';
17
18
 
@@ -33,6 +34,7 @@ export class Script {
33
34
  return firstValueFrom(
34
35
  merge(
35
36
  script.onAwake().pipe(last()),
37
+ whenReplayFinished().pipe(last()),
36
38
  fromEvent(process, 'exit'),
37
39
  fromEvent(process, 'SIGINT'),
38
40
  fromEvent(process, 'SIGUSR1'),
@@ -4,5 +4,6 @@ export * from './use-replay-options';
4
4
  export * from './use-replay-storage';
5
5
  export * from './use-replay-storage-buffer';
6
6
  export * from './use-replay-manager';
7
+ export * from './when-replay-finished';
7
8
  export * from './replay';
8
9
  export * from './replay-guard';
@@ -78,6 +78,7 @@ export const useReplayManager = withMemo(() => {
78
78
  };
79
79
 
80
80
  return {
81
+ stream: stream$.asObservable(),
81
82
  timestamp() {
82
83
  return timestamp;
83
84
  },
@@ -0,0 +1,20 @@
1
+ import { from, last, map, Subject } from 'rxjs';
2
+
3
+ import { useExecutionMode } from '@lib/use-execution-mode';
4
+
5
+ import { useReplayManager } from './use-replay-manager';
6
+
7
+ export function whenReplayFinished() {
8
+ const { isReplay } = useExecutionMode();
9
+
10
+ if (!isReplay) {
11
+ return new Subject<boolean>().asObservable();
12
+ }
13
+
14
+ const { stream } = useReplayManager();
15
+
16
+ return from(stream).pipe(
17
+ last(),
18
+ map(() => true)
19
+ );
20
+ }