@quantform/core 0.7.0-beta.34 → 0.7.0-beta.35

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":"pull.d.ts","sourceRoot":"","sources":["../../src/cli/pull.ts"],"names":[],"mappings":"AAQA,yBAA+B,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBA+D5E"}
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/cli/pull.ts"],"names":[],"mappings":"AAKA,yBAA+B,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBAS5E"}
package/dist/cli/pull.js CHANGED
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,71 +12,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
- const path_1 = require("path");
39
15
  const build_1 = __importDefault(require("../cli/build"));
40
- const workspace_1 = require("../cli/internal/workspace");
41
- const core_1 = require("../core");
42
- const module_1 = require("../module");
43
16
  const use_execution_mode_1 = require("../use-execution-mode");
17
+ const script_1 = require("./internal/script");
44
18
  function default_1(name, instrument, options) {
45
19
  return __awaiter(this, void 0, void 0, function* () {
46
20
  if (yield (0, build_1.default)()) {
47
21
  return;
48
22
  }
49
- yield Promise.resolve(`${(0, path_1.join)((0, workspace_1.buildDirectory)(), 'index')}`).then(s => __importStar(require(s)));
50
- const script = yield Promise.resolve(`${(0, path_1.join)((0, workspace_1.buildDirectory)(), name)}`).then(s => __importStar(require(s)));
51
- const module = new module_1.Module([
52
- ...(0, core_1.core)(),
53
- ...script.module,
54
- (0, use_execution_mode_1.paperExecutionMode)({ recording: false })
55
- ]);
56
- const { act } = yield module.awake();
57
- const output = yield act(() => script.default());
58
- /*const builder = new SessionBuilder().useSessionId(
59
- options.id ? Number(options.id) : now()
60
- );
61
-
62
- await spawn(name, builder);
63
-
64
- const session = builder.paper();
65
-
66
- console.time('Pulling completed in');
67
-
68
- await session.awake();
69
-
70
- const bar = new SingleBar(
71
- {
72
- format: `Pulling ${instrument} [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}`
73
- },
74
- Presets.rect
75
- );
76
-
77
- const feed = new Feed(builder.storage('feed'));
78
- const from = options.from ? Date.parse(options.from) : builder.period.from;
79
- const to = options.to ? Date.parse(options.to) : builder.period.to;
80
-
81
- bar.start(100, 0);
82
-
83
- await session.aggregate.feed(
84
- instrumentOf(instrument),
85
- from,
86
- to,
87
- async (timestamp, events) => {
88
- const duration = to - from;
89
- const completed = timestamp - from;
90
-
91
- await feed.save(events);
92
-
93
- bar.update(Math.floor((completed / duration) * 100));
94
- }
95
- );
96
-
97
- bar.update(100);
98
- bar.stop();
99
-
100
- await session.dispose();
101
-
102
- console.timeLog('Pulling completed in');*/
23
+ const script = new script_1.Script(name, [(0, use_execution_mode_1.idleExecutionMode)()]);
24
+ //const output = await script.run();
25
+ //console.log(output);
103
26
  });
104
27
  }
105
28
  exports.default = default_1;
@@ -1,5 +1,5 @@
1
1
  type ExecutionMode = {
2
- mode: 'replay' | 'paper' | 'live';
2
+ mode: 'replay' | 'paper' | 'live' | 'idle';
3
3
  recording: boolean;
4
4
  };
5
5
  export declare function replayExecutionMode(): {
@@ -18,10 +18,15 @@ export declare function liveExecutionMode(options: {
18
18
  provide: symbol;
19
19
  useValue: ExecutionMode;
20
20
  };
21
+ export declare function idleExecutionMode(): {
22
+ provide: symbol;
23
+ useValue: ExecutionMode;
24
+ };
21
25
  export declare const useExecutionMode: () => {
22
26
  isReplay: boolean;
23
27
  isPaper: boolean;
24
28
  isLive: boolean;
29
+ isIdle: boolean;
25
30
  isSimulation: boolean;
26
31
  recording: boolean;
27
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-execution-mode.d.ts","sourceRoot":"","sources":["../src/use-execution-mode.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,mBAAmB;;;EAKlC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE;;;EAKjE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE;;;EAKhE;AAED,eAAO,MAAM,gBAAgB;;;;;;CAU5B,CAAC"}
1
+ {"version":3,"file":"use-execution-mode.d.ts","sourceRoot":"","sources":["../src/use-execution-mode.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC3C,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,mBAAmB;;;EAKlC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE;;;EAKjE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE;;;EAKhE;AAED,wBAAgB,iBAAiB;;;EAKhC;AAED,eAAO,MAAM,gBAAgB;;;;;;;CAW5B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useExecutionMode = exports.liveExecutionMode = exports.paperExecutionMode = exports.replayExecutionMode = void 0;
3
+ exports.useExecutionMode = exports.idleExecutionMode = exports.liveExecutionMode = exports.paperExecutionMode = exports.replayExecutionMode = void 0;
4
4
  const module_1 = require("./module");
5
5
  const injectionToken = Symbol('execution-mode');
6
6
  function replayExecutionMode() {
@@ -24,12 +24,20 @@ function liveExecutionMode(options) {
24
24
  };
25
25
  }
26
26
  exports.liveExecutionMode = liveExecutionMode;
27
+ function idleExecutionMode() {
28
+ return {
29
+ provide: injectionToken,
30
+ useValue: { mode: 'idle', recording: false }
31
+ };
32
+ }
33
+ exports.idleExecutionMode = idleExecutionMode;
27
34
  const useExecutionMode = () => {
28
35
  const mode = (0, module_1.useContext)(injectionToken);
29
36
  return {
30
37
  isReplay: mode.mode === 'replay',
31
38
  isPaper: mode.mode === 'paper',
32
39
  isLive: mode.mode === 'live',
40
+ isIdle: mode.mode === 'idle',
33
41
  isSimulation: mode.mode !== 'live',
34
42
  recording: mode.recording
35
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantform/core",
3
- "version": "0.7.0-beta.34",
3
+ "version": "0.7.0-beta.35",
4
4
  "license": "MIT",
5
5
  "author": "Mateusz Majchrzak",
6
6
  "description": "Node.js library for building systematic trading strategies in reactive way.",
package/src/cli/pull.ts CHANGED
@@ -1,72 +1,15 @@
1
- import { join } from 'path';
2
-
3
1
  import build from '@lib/cli/build';
4
- import { buildDirectory } from '@lib/cli/internal/workspace';
5
- import { core } from '@lib/core';
6
- import { Module } from '@lib/module';
7
- import { paperExecutionMode } from '@lib/use-execution-mode';
2
+ import { idleExecutionMode } from '@lib/use-execution-mode';
3
+
4
+ import { Script } from './internal/script';
8
5
 
9
6
  export default async function (name: string, instrument: string, options: any) {
10
7
  if (await build()) {
11
8
  return;
12
9
  }
13
- await import(join(buildDirectory(), 'index'));
14
-
15
- const script = await import(join(buildDirectory(), name));
16
-
17
- const module = new Module([
18
- ...core(),
19
- ...script.module,
20
- paperExecutionMode({ recording: false })
21
- ]);
22
-
23
- const { act } = await module.awake();
24
-
25
- const output = await act(() => script.default());
26
-
27
- /*const builder = new SessionBuilder().useSessionId(
28
- options.id ? Number(options.id) : now()
29
- );
30
-
31
- await spawn(name, builder);
32
-
33
- const session = builder.paper();
34
-
35
- console.time('Pulling completed in');
36
-
37
- await session.awake();
38
-
39
- const bar = new SingleBar(
40
- {
41
- format: `Pulling ${instrument} [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}`
42
- },
43
- Presets.rect
44
- );
45
-
46
- const feed = new Feed(builder.storage('feed'));
47
- const from = options.from ? Date.parse(options.from) : builder.period.from;
48
- const to = options.to ? Date.parse(options.to) : builder.period.to;
49
-
50
- bar.start(100, 0);
51
-
52
- await session.aggregate.feed(
53
- instrumentOf(instrument),
54
- from,
55
- to,
56
- async (timestamp, events) => {
57
- const duration = to - from;
58
- const completed = timestamp - from;
59
-
60
- await feed.save(events);
61
-
62
- bar.update(Math.floor((completed / duration) * 100));
63
- }
64
- );
65
-
66
- bar.update(100);
67
- bar.stop();
68
10
 
69
- await session.dispose();
11
+ const script = new Script(name, [idleExecutionMode()]);
12
+ //const output = await script.run();
70
13
 
71
- console.timeLog('Pulling completed in');*/
14
+ //console.log(output);
72
15
  }
@@ -3,7 +3,7 @@ import { useContext } from '@lib/module';
3
3
  const injectionToken = Symbol('execution-mode');
4
4
 
5
5
  type ExecutionMode = {
6
- mode: 'replay' | 'paper' | 'live';
6
+ mode: 'replay' | 'paper' | 'live' | 'idle';
7
7
  recording: boolean;
8
8
  };
9
9
 
@@ -28,6 +28,13 @@ export function liveExecutionMode(options: { recording: boolean }) {
28
28
  };
29
29
  }
30
30
 
31
+ export function idleExecutionMode() {
32
+ return {
33
+ provide: injectionToken,
34
+ useValue: { mode: 'idle', recording: false } as ExecutionMode
35
+ };
36
+ }
37
+
31
38
  export const useExecutionMode = () => {
32
39
  const mode = useContext<ExecutionMode>(injectionToken);
33
40
 
@@ -35,6 +42,7 @@ export const useExecutionMode = () => {
35
42
  isReplay: mode.mode === 'replay',
36
43
  isPaper: mode.mode === 'paper',
37
44
  isLive: mode.mode === 'live',
45
+ isIdle: mode.mode === 'idle',
38
46
  isSimulation: mode.mode !== 'live',
39
47
  recording: mode.recording
40
48
  };