@quantform/create 0.7.0-beta.56

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Mateusz Majchrzak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/quantform/quantform/main/quantform.svg" alt="quantform-logo" width="220px" height="100px"/>
3
+ <br>
4
+ </p>
5
+ <h3 align="center">Node.js library for building systematic trading strategies in reactive way.</h3>
6
+ <p align="center">
7
+ <i>Use the power of TypeScript and Reactive Programming to research, develop and test your <br />market-winning short-term and long-term investments.</i>
8
+ <br>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.quantform.io"><strong>www.quantform.io</strong></a>
13
+ <br>
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="https://developer.quantform.io/">Documentation</a>
18
+ ·
19
+ <a href="CONTRIBUTING.md">Contributing Guidelines</a>
20
+ <br>
21
+ <br>
22
+ </p>
23
+
24
+ <p align="center">
25
+ <a href="https://www.npmjs.com/package/@quantform/create">
26
+ <img src="https://img.shields.io/npm/v/create-quantform-app.svg?logo=npm&logoColor=fff&label=create-quantform-app&color=03D1EB" alt="create-quantform-app on npm" />
27
+ </a>&nbsp;
28
+ <a href="LICENSE.md">
29
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="quantform on npm" />
30
+ </a>
31
+ </p>
32
+
33
+ <hr>
34
+
35
+ ## Usage
36
+
37
+ ```
38
+ npm init @quantform
39
+ ```
40
+
41
+ ## Risk Warning and Disclaimer
42
+
43
+ Trading Cryptocurrencies, Futures, Forex, CFDs and Stocks involves a risk of loss. Please consider carefully if such trading is appropriate for you. Past performance is not indicative of future results. Articles and content on this website are for entertainment purposes only and do not constitute investment recommendations or advice.
package/jest.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Config } from 'jest';
2
+
3
+ const config: Config = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'node',
6
+ testMatch: ['**/src/**/?(*.)+(spec|test).[jt]s?(x)'],
7
+ transform: {
8
+ '^.+\\.ts?$': 'ts-jest'
9
+ }
10
+ };
11
+
12
+ export default config;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@quantform/create",
3
+ "version": "0.7.0-beta.56",
4
+ "license": "MIT",
5
+ "author": "Mateusz Majchrzak",
6
+ "description": "Node.js library for building systematic trading strategies in reactive way.",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/quantform/quantform.git"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "bin": {
15
+ "create": "lib/index.js"
16
+ },
17
+ "dependencies": {
18
+ "commander": "^9.4.0",
19
+ "edit-json-file": "^1.7.0",
20
+ "promisify": "^0.0.3"
21
+ },
22
+ "main": "index.js",
23
+ "directories": {
24
+ "lib": "lib"
25
+ },
26
+ "keywords": [],
27
+ "bugs": {
28
+ "url": "https://github.com/quantform/quantform/issues"
29
+ },
30
+ "homepage": "https://github.com/quantform/quantform#readme",
31
+ "scripts": {
32
+ "build": "tsc && tsc-alias",
33
+ "test": "jest"
34
+ }
35
+ }
package/src/index.ts ADDED
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { exec } from 'child_process';
4
+ import { program } from 'commander';
5
+ import editJsonFile from 'edit-json-file';
6
+ import { copyFileSync, mkdirSync, writeFileSync } from 'fs';
7
+ import { chdir } from 'process';
8
+ import { promisify } from 'util';
9
+
10
+ const shell = promisify(exec);
11
+
12
+ program
13
+ .name('quantform')
14
+ .description('Setup the quantform project by running a single command.')
15
+ .argument('<dir>', 'directory to initialize')
16
+ .action(async dir => {
17
+ await createDirectory(dir);
18
+ await addPackageJson();
19
+ await addDependencies();
20
+ await addTypescript();
21
+ await addSWCConfig();
22
+ await copyTemplateFiles();
23
+ })
24
+ .parse(process.argv);
25
+
26
+ async function createDirectory(dir: string) {
27
+ mkdirSync(dir);
28
+ chdir(dir);
29
+ }
30
+
31
+ async function addPackageJson() {
32
+ await shell(`npm init --yes`);
33
+
34
+ const config = editJsonFile(`./package.json`);
35
+
36
+ config.set('main', 'pipeline.js');
37
+ config.set('scripts', {
38
+ live: 'qf live pipeline',
39
+ start: 'qf paper pipeline',
40
+ replay: 'qf replay pipeline',
41
+ pull: 'qf pull pipeline'
42
+ });
43
+
44
+ config.save();
45
+ }
46
+
47
+ async function addTypescript() {
48
+ //await shell(`npm tsc --init`);
49
+
50
+ const config = editJsonFile(`./tsconfig.json`);
51
+
52
+ config.set('compilerOptions.module', 'commonjs');
53
+ config.set('compilerOptions.declaration', true);
54
+ config.set('compilerOptions.removeComments', true);
55
+ config.set('compilerOptions.emitDecoratorMetadata', true);
56
+ config.set('compilerOptions.experimentalDecorators', true);
57
+ config.set('compilerOptions.allowSyntheticDefaultImports', true);
58
+ config.set('compilerOptions.target', 'es2017');
59
+ config.set('compilerOptions.outDir', './lib');
60
+ config.set('compilerOptions.baseUrl', './');
61
+ config.set('compilerOptions.incremental', true);
62
+ config.set('include', ['*.ts', 'src/*']);
63
+ config.set('exclude', ['node_modules', 'test', 'lib', '**/*spec.ts']);
64
+
65
+ config.save();
66
+ }
67
+
68
+ async function addSWCConfig() {
69
+ writeFileSync('./.swcrc', '{}');
70
+
71
+ const config = editJsonFile(`./.swcrc`);
72
+
73
+ config.set('$schema', 'http://json.schemastore.org/swcrc');
74
+ config.set('jsc.parser.syntax', 'typescript');
75
+ config.set('jsc.parser.tsx', false);
76
+ config.set('module.type', 'commonjs');
77
+ config.set('module.strict', false);
78
+ config.set('module.strictMode', true);
79
+ config.set('module.lazy', false);
80
+ config.set('module.noInterop', false);
81
+
82
+ config.save();
83
+ }
84
+
85
+ async function addDependencies() {
86
+ const devDependencies = ['typescript', '@types/node', '@swc/core', 'zod'];
87
+
88
+ const dependencies = ['@quantform/core@beta', '@quantform/binance@beta', 'rxjs'];
89
+
90
+ for (const dependency of devDependencies) {
91
+ await shell(`npm add -D ${dependency}`);
92
+ }
93
+
94
+ for (const dependency of dependencies) {
95
+ await shell(`npm add ${dependency}`);
96
+ }
97
+ }
98
+
99
+ async function copyTemplateFiles() {
100
+ mkdirSync('./src');
101
+ copyFileSync(`${__dirname}/../template/pipeline.ts`, './src/pipeline.ts');
102
+ }
@@ -0,0 +1,26 @@
1
+ import { tap } from 'rxjs';
2
+
3
+ import { binance, useBinance } from '@quantform/binance';
4
+ import { behavior, Commission, instrumentOf, strategy, useLogger } from '@quantform/core';
5
+
6
+ export default strategy(() => {
7
+ behavior(() => {
8
+ // watch binance spot orderbook
9
+ const { whenOrderbookTicker } = useBinance();
10
+ const { info } = useLogger('binance');
11
+
12
+ // subscribe for btc-usdt binance spot market and print ticker values
13
+ return whenOrderbookTicker(instrumentOf(`binance:btc-usdt`)).pipe(
14
+ tap(({ bids, asks }) => info(`current top bid: ${bids.rate}, ask: ${asks.rate}`))
15
+ );
16
+ });
17
+
18
+ return [
19
+ ...binance({
20
+ simulator: {
21
+ balance: {},
22
+ commission: Commission.Zero
23
+ }
24
+ })
25
+ ];
26
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../tsconfig.lib.json",
3
+ "compilerOptions": {
4
+ "outDir": "lib",
5
+ "noImplicitAny": false,
6
+ },
7
+ "include": [
8
+ "src/**/*",
9
+ ],
10
+ "exclude": [
11
+ "jest.config.ts",
12
+ "**/*.spec.ts",
13
+ "**/*.test.ts",
14
+ "lib/**/*"
15
+ ]
16
+ }