@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.
- package/jest.config.ts +1 -1
- package/{dist → lib}/cli/index.js +9 -6
- package/lib/cli/live.d.ts +5 -0
- package/lib/cli/live.d.ts.map +1 -0
- package/{dist/cli/replay.js → lib/cli/live.js} +4 -3
- package/lib/cli/paper.d.ts +5 -0
- package/lib/cli/paper.d.ts.map +1 -0
- package/{dist/cli/dev.js → lib/cli/paper.js} +6 -1
- package/{dist → lib}/cli/pull.js +1 -1
- package/lib/cli/replay.d.ts +6 -0
- package/lib/cli/replay.d.ts.map +1 -0
- package/{dist/cli/run.js → lib/cli/replay.js} +10 -1
- package/{dist → lib}/core.js +3 -3
- package/{dist → lib}/index.d.ts +1 -0
- package/{dist → lib}/index.d.ts.map +1 -1
- package/{dist → lib}/index.js +1 -0
- package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts.map +1 -1
- package/{dist → lib}/replay/storage/use-replay-storage-buffer.js +1 -0
- package/lib/session/use-session.d.ts +13 -0
- package/lib/session/use-session.d.ts.map +1 -0
- package/lib/session/use-session.js +14 -0
- package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
- package/lib/storage/use-storage-factory.d.ts +10 -0
- package/lib/storage/use-storage-factory.d.ts.map +1 -0
- package/lib/storage/use-storage-factory.js +13 -0
- package/lib/use-execution-mode.d.ts +20 -0
- package/lib/use-execution-mode.d.ts.map +1 -0
- package/lib/use-execution-mode.js +33 -0
- package/{dist → lib}/use-logger.js +1 -1
- package/{dist → lib}/use-memo.d.ts +4 -7
- package/lib/use-memo.d.ts.map +1 -0
- package/{dist → lib}/use-memo.js +5 -11
- package/package.json +4 -4
- package/src/cli/index.ts +11 -8
- package/src/cli/live.ts +22 -0
- package/src/cli/paper.ts +22 -0
- package/src/cli/pull.ts +2 -2
- package/src/cli/replay.ts +12 -4
- package/src/core.ts +6 -6
- package/src/index.ts +1 -0
- package/src/replay/storage/use-replay-storage-buffer.ts +2 -0
- package/src/replay/use-replay.spec.ts +0 -1
- package/src/session/use-session.ts +16 -4
- package/src/simulator/use-simulator.spec.ts +10 -26
- package/src/storage/use-storage-factory.ts +7 -7
- package/src/use-execution-mode.ts +23 -31
- package/src/use-logger.ts +3 -3
- package/src/use-memo.ts +6 -11
- package/tsconfig.json +2 -2
- package/dist/cli/dev.d.ts +0 -2
- package/dist/cli/dev.d.ts.map +0 -1
- package/dist/cli/replay.d.ts +0 -2
- package/dist/cli/replay.d.ts.map +0 -1
- package/dist/cli/run.d.ts +0 -2
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/session/use-session.d.ts +0 -4
- package/dist/session/use-session.d.ts.map +0 -1
- package/dist/session/use-session.js +0 -7
- package/dist/storage/use-storage-factory.d.ts +0 -10
- package/dist/storage/use-storage-factory.d.ts.map +0 -1
- package/dist/storage/use-storage-factory.js +0 -14
- package/dist/use-execution-mode.d.ts +0 -34
- package/dist/use-execution-mode.d.ts.map +0 -1
- package/dist/use-execution-mode.js +0 -45
- package/dist/use-memo.d.ts.map +0 -1
- package/src/cli/dev.ts +0 -15
- package/src/cli/run.ts +0 -15
- /package/{dist → lib}/asset/asset.d.ts +0 -0
- /package/{dist → lib}/asset/asset.d.ts.map +0 -0
- /package/{dist → lib}/asset/asset.js +0 -0
- /package/{dist → lib}/asset/asset.spec.d.ts +0 -0
- /package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
- /package/{dist → lib}/asset/asset.spec.js +0 -0
- /package/{dist → lib}/asset/index.d.ts +0 -0
- /package/{dist → lib}/asset/index.d.ts.map +0 -0
- /package/{dist → lib}/asset/index.js +0 -0
- /package/{dist → lib}/cli/build.d.ts +0 -0
- /package/{dist → lib}/cli/build.d.ts.map +0 -0
- /package/{dist → lib}/cli/build.js +0 -0
- /package/{dist → lib}/cli/index.d.ts +0 -0
- /package/{dist → lib}/cli/index.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/script.d.ts +0 -0
- /package/{dist → lib}/cli/internal/script.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/script.js +0 -0
- /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
- /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/workspace.js +0 -0
- /package/{dist → lib}/cli/pull.d.ts +0 -0
- /package/{dist → lib}/cli/pull.d.ts.map +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.js +0 -0
- /package/{dist → lib}/component/error.d.ts +0 -0
- /package/{dist → lib}/component/error.d.ts.map +0 -0
- /package/{dist → lib}/component/error.js +0 -0
- /package/{dist → lib}/component/index.d.ts +0 -0
- /package/{dist → lib}/component/index.d.ts.map +0 -0
- /package/{dist → lib}/component/index.js +0 -0
- /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
- /package/{dist → lib}/component/ohlc-operator.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc-operator.js +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
- /package/{dist → lib}/component/ohlc.d.ts +0 -0
- /package/{dist → lib}/component/ohlc.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc.js +0 -0
- /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
- /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc.spec.js +0 -0
- /package/{dist → lib}/component/timeframe.d.ts +0 -0
- /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
- /package/{dist → lib}/component/timeframe.js +0 -0
- /package/{dist → lib}/core.d.ts +0 -0
- /package/{dist → lib}/core.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
- /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.js +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
- /package/{dist → lib}/instrument/index.d.ts +0 -0
- /package/{dist → lib}/instrument/index.d.ts.map +0 -0
- /package/{dist → lib}/instrument/index.js +0 -0
- /package/{dist → lib}/instrument/instrument.d.ts +0 -0
- /package/{dist → lib}/instrument/instrument.d.ts.map +0 -0
- /package/{dist → lib}/instrument/instrument.js +0 -0
- /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
- /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
- /package/{dist → lib}/instrument/instrument.spec.js +0 -0
- /package/{dist → lib}/make-test-module.d.ts +0 -0
- /package/{dist → lib}/make-test-module.d.ts.map +0 -0
- /package/{dist → lib}/make-test-module.js +0 -0
- /package/{dist → lib}/module.d.ts +0 -0
- /package/{dist → lib}/module.d.ts.map +0 -0
- /package/{dist → lib}/module.js +0 -0
- /package/{dist → lib}/module.spec.d.ts +0 -0
- /package/{dist → lib}/module.spec.d.ts.map +0 -0
- /package/{dist → lib}/module.spec.js +0 -0
- /package/{dist → lib}/operators.d.ts +0 -0
- /package/{dist → lib}/operators.d.ts.map +0 -0
- /package/{dist → lib}/operators.js +0 -0
- /package/{dist → lib}/replay/index.d.ts +0 -0
- /package/{dist → lib}/replay/index.d.ts.map +0 -0
- /package/{dist → lib}/replay/index.js +0 -0
- /package/{dist → lib}/replay/replay-guard.d.ts +0 -0
- /package/{dist → lib}/replay/replay-guard.d.ts.map +0 -0
- /package/{dist → lib}/replay/replay-guard.js +0 -0
- /package/{dist → lib}/replay/replay.d.ts +0 -0
- /package/{dist → lib}/replay/replay.d.ts.map +0 -0
- /package/{dist → lib}/replay/replay.js +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts.map +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-cursor.js +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.d.ts.map +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.js +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts.map +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.spec.js +0 -0
- /package/{dist → lib}/replay/use-replay-breakpoint.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-breakpoint.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-breakpoint.js +0 -0
- /package/{dist → lib}/replay/use-replay-manager.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-manager.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-manager.js +0 -0
- /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-options.js +0 -0
- /package/{dist → lib}/replay/use-replay.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay.js +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay.spec.js +0 -0
- /package/{dist → lib}/replay/when-replay-finished.d.ts +0 -0
- /package/{dist → lib}/replay/when-replay-finished.d.ts.map +0 -0
- /package/{dist → lib}/replay/when-replay-finished.js +0 -0
- /package/{dist → lib}/session/index.d.ts +0 -0
- /package/{dist → lib}/session/index.d.ts.map +0 -0
- /package/{dist → lib}/session/index.js +0 -0
- /package/{dist → lib}/session/use-session-object.d.ts +0 -0
- /package/{dist → lib}/session/use-session-object.d.ts.map +0 -0
- /package/{dist → lib}/session/use-session-object.js +0 -0
- /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
- /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
- /package/{dist → lib}/session/use-session-storage.js +0 -0
- /package/{dist → lib}/shared/datetime.d.ts +0 -0
- /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
- /package/{dist → lib}/shared/datetime.js +0 -0
- /package/{dist → lib}/shared/decimals.d.ts +0 -0
- /package/{dist → lib}/shared/decimals.d.ts.map +0 -0
- /package/{dist → lib}/shared/decimals.js +0 -0
- /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
- /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
- /package/{dist → lib}/shared/decimals.spec.js +0 -0
- /package/{dist → lib}/shared/environment.d.ts +0 -0
- /package/{dist → lib}/shared/environment.d.ts.map +0 -0
- /package/{dist → lib}/shared/environment.js +0 -0
- /package/{dist → lib}/shared/index.d.ts +0 -0
- /package/{dist → lib}/shared/index.d.ts.map +0 -0
- /package/{dist → lib}/shared/index.js +0 -0
- /package/{dist → lib}/simulator/index.d.ts +0 -0
- /package/{dist → lib}/simulator/index.d.ts.map +0 -0
- /package/{dist → lib}/simulator/index.js +0 -0
- /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
- /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
- /package/{dist → lib}/simulator/use-simulator.js +0 -0
- /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
- /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
- /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/index.js +0 -0
- /package/{dist → lib}/storage/index.d.ts +0 -0
- /package/{dist → lib}/storage/index.d.ts.map +0 -0
- /package/{dist → lib}/storage/index.js +0 -0
- /package/{dist → lib}/storage/storage.d.ts +0 -0
- /package/{dist → lib}/storage/storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/storage.js +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-cache.js +0 -0
- /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
- /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-cache.spec.js +0 -0
- /package/{dist → lib}/storage/use-storage.d.ts +0 -0
- /package/{dist → lib}/storage/use-storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-storage.js +0 -0
- /package/{dist → lib}/strategy.d.ts +0 -0
- /package/{dist → lib}/strategy.d.ts.map +0 -0
- /package/{dist → lib}/strategy.js +0 -0
- /package/{dist → lib}/strategy.spec.d.ts +0 -0
- /package/{dist → lib}/strategy.spec.d.ts.map +0 -0
- /package/{dist → lib}/strategy.spec.js +0 -0
- /package/{dist → lib}/use-hash.d.ts +0 -0
- /package/{dist → lib}/use-hash.d.ts.map +0 -0
- /package/{dist → lib}/use-hash.js +0 -0
- /package/{dist → lib}/use-hash.spec.d.ts +0 -0
- /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
- /package/{dist → lib}/use-hash.spec.js +0 -0
- /package/{dist → lib}/use-logger.d.ts +0 -0
- /package/{dist → lib}/use-logger.d.ts.map +0 -0
- /package/{dist → lib}/use-memo.spec.d.ts +0 -0
- /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
- /package/{dist → lib}/use-memo.spec.js +0 -0
- /package/{dist → lib}/use-socket.d.ts +0 -0
- /package/{dist → lib}/use-socket.d.ts.map +0 -0
- /package/{dist → lib}/use-socket.js +0 -0
- /package/{dist → lib}/use-timestamp.d.ts +0 -0
- /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
- /package/{dist → lib}/use-timestamp.js +0 -0
- /package/{dist → lib}/when-socket.d.ts +0 -0
- /package/{dist → lib}/when-socket.d.ts.map +0 -0
- /package/{dist → lib}/when-socket.js +0 -0
- /package/{dist → lib}/with-memo.d.ts +0 -0
- /package/{dist → lib}/with-memo.d.ts.map +0 -0
- /package/{dist → lib}/with-memo.js +0 -0
- /package/{dist → lib}/with-memo.spec.d.ts +0 -0
- /package/{dist → lib}/with-memo.spec.d.ts.map +0 -0
- /package/{dist → lib}/with-memo.spec.js +0 -0
- /package/{dist → lib}/with-request.d.ts +0 -0
- /package/{dist → lib}/with-request.d.ts.map +0 -0
- /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>/
|
|
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
|
|
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('
|
|
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(
|
|
37
|
+
.action(live_1.default);
|
|
37
38
|
commander_1.program
|
|
38
|
-
.command('
|
|
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(
|
|
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 @@
|
|
|
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
|
|
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
|
-
|
|
26
|
-
(
|
|
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 @@
|
|
|
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, [
|
|
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
|
});
|
package/{dist → lib}/cli/pull.js
RENAMED
|
@@ -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, [
|
|
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 @@
|
|
|
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
|
|
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
|
});
|
package/{dist → lib}/core.js
RENAMED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
package/{dist → lib}/index.d.ts
RENAMED
|
@@ -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"}
|
package/{dist → lib}/index.js
RENAMED
|
@@ -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;;;
|
|
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
|
-
|
|
22
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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.
|
|
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"}
|
package/{dist → lib}/use-memo.js
RENAMED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMemo = exports.
|
|
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.
|
|
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": "./
|
|
15
|
+
"qf": "./lib/cli/index.js"
|
|
16
16
|
},
|
|
17
|
-
"main": "
|
|
18
|
-
"typings": "
|
|
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
|
|
8
|
+
import live from '@lib/cli/live';
|
|
9
|
+
import paper from '@lib/cli/paper';
|
|
9
10
|
import pull from '@lib/cli/pull';
|
|
10
|
-
import
|
|
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('
|
|
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(
|
|
27
|
+
.action(live);
|
|
27
28
|
|
|
28
29
|
program
|
|
29
|
-
.command('
|
|
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(
|
|
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(
|
|
46
|
+
.action(replay);
|
|
44
47
|
|
|
45
48
|
program
|
|
46
49
|
.command('pull')
|
package/src/cli/live.ts
ADDED
|
@@ -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
|
+
}
|
package/src/cli/paper.ts
ADDED
|
@@ -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 {
|
|
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, [
|
|
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 {
|
|
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 (
|
|
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
|
-
|
|
14
|
-
|
|
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
|
|