@backtest-kit/sidekick 0.0.2 → 0.0.5
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/package.json +67 -67
- package/scripts/init.mjs +250 -250
- package/template/package.mustache +3 -3
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@backtest-kit/sidekick",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "The easiest way to create a new Backtest Kit trading bot project. Like create-react-app, but for algorithmic trading with LLM integration and technical analysis.",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Petr Tripolsky",
|
|
7
|
-
"email": "tripolskypetr@gmail.com",
|
|
8
|
-
"url": "https://github.com/tripolskypetr"
|
|
9
|
-
},
|
|
10
|
-
"funding": {
|
|
11
|
-
"type": "individual",
|
|
12
|
-
"url": "http://paypal.me/tripolskypetr"
|
|
13
|
-
},
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"homepage": "https://backtest-kit.github.io/documents/example_02_first_backtest.html",
|
|
16
|
-
"keywords": [
|
|
17
|
-
"create-backtest-app",
|
|
18
|
-
"backtest-kit",
|
|
19
|
-
"scaffolding",
|
|
20
|
-
"generator",
|
|
21
|
-
"cli",
|
|
22
|
-
"trading-bot",
|
|
23
|
-
"algorithmic-trading",
|
|
24
|
-
"backtesting",
|
|
25
|
-
"llm",
|
|
26
|
-
"ai-trading",
|
|
27
|
-
"technical-analysis",
|
|
28
|
-
"crypto",
|
|
29
|
-
"forex",
|
|
30
|
-
"quantitative-trading",
|
|
31
|
-
"template",
|
|
32
|
-
"boilerplate",
|
|
33
|
-
"starter-kit",
|
|
34
|
-
"npx"
|
|
35
|
-
],
|
|
36
|
-
"files": [
|
|
37
|
-
"src",
|
|
38
|
-
"scripts",
|
|
39
|
-
"template",
|
|
40
|
-
"README.md"
|
|
41
|
-
],
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "https://github.com/tripolskypetr/backtest-kit",
|
|
45
|
-
"documentation": "https://github.com/tripolskypetr/backtest-kit/tree/master/docs"
|
|
46
|
-
},
|
|
47
|
-
"bugs": {
|
|
48
|
-
"url": "https://github.com/tripolskypetr/backtest-kit/issues"
|
|
49
|
-
},
|
|
50
|
-
"main": "./src/index.mjs",
|
|
51
|
-
"scripts": {
|
|
52
|
-
"start": "node ./src/index.mjs"
|
|
53
|
-
},
|
|
54
|
-
"bin": {
|
|
55
|
-
"sidekick": "./scripts/init.mjs"
|
|
56
|
-
},
|
|
57
|
-
"publishConfig": {
|
|
58
|
-
"access": "public"
|
|
59
|
-
},
|
|
60
|
-
"type": "module",
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"glob": "^11.0.1",
|
|
63
|
-
"log-symbols": "^7.0.0",
|
|
64
|
-
"mustache": "^4.2.0",
|
|
65
|
-
"picocolors": "^1.1.1"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@backtest-kit/sidekick",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "The easiest way to create a new Backtest Kit trading bot project. Like create-react-app, but for algorithmic trading with LLM integration and technical analysis.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Petr Tripolsky",
|
|
7
|
+
"email": "tripolskypetr@gmail.com",
|
|
8
|
+
"url": "https://github.com/tripolskypetr"
|
|
9
|
+
},
|
|
10
|
+
"funding": {
|
|
11
|
+
"type": "individual",
|
|
12
|
+
"url": "http://paypal.me/tripolskypetr"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://backtest-kit.github.io/documents/example_02_first_backtest.html",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"create-backtest-app",
|
|
18
|
+
"backtest-kit",
|
|
19
|
+
"scaffolding",
|
|
20
|
+
"generator",
|
|
21
|
+
"cli",
|
|
22
|
+
"trading-bot",
|
|
23
|
+
"algorithmic-trading",
|
|
24
|
+
"backtesting",
|
|
25
|
+
"llm",
|
|
26
|
+
"ai-trading",
|
|
27
|
+
"technical-analysis",
|
|
28
|
+
"crypto",
|
|
29
|
+
"forex",
|
|
30
|
+
"quantitative-trading",
|
|
31
|
+
"template",
|
|
32
|
+
"boilerplate",
|
|
33
|
+
"starter-kit",
|
|
34
|
+
"npx"
|
|
35
|
+
],
|
|
36
|
+
"files": [
|
|
37
|
+
"src",
|
|
38
|
+
"scripts",
|
|
39
|
+
"template",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/tripolskypetr/backtest-kit",
|
|
45
|
+
"documentation": "https://github.com/tripolskypetr/backtest-kit/tree/master/docs"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/tripolskypetr/backtest-kit/issues"
|
|
49
|
+
},
|
|
50
|
+
"main": "./src/index.mjs",
|
|
51
|
+
"scripts": {
|
|
52
|
+
"start": "node ./src/index.mjs"
|
|
53
|
+
},
|
|
54
|
+
"bin": {
|
|
55
|
+
"@backtest-kit/sidekick": "./scripts/init.mjs"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"type": "module",
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"glob": "^11.0.1",
|
|
63
|
+
"log-symbols": "^7.0.0",
|
|
64
|
+
"mustache": "^4.2.0",
|
|
65
|
+
"picocolors": "^1.1.1"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
68
|
|
package/scripts/init.mjs
CHANGED
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { promises as fs } from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import { spawn } from 'child_process';
|
|
7
|
-
import pc from 'picocolors';
|
|
8
|
-
import { glob } from 'glob';
|
|
9
|
-
import Mustache from 'mustache';
|
|
10
|
-
import logSymbols from 'log-symbols';
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = path.dirname(__filename);
|
|
14
|
-
|
|
15
|
-
const log = {
|
|
16
|
-
info: (msg) => console.log(`${pc.cyan(logSymbols.info)} ${msg}`),
|
|
17
|
-
success: (msg) => console.log(`${pc.green(logSymbols.success)} ${msg}`),
|
|
18
|
-
error: (msg) => console.log(`${pc.red(logSymbols.error)} ${msg}`),
|
|
19
|
-
warn: (msg) => console.log(`${pc.yellow(logSymbols.warning)} ${msg}`),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Copy files using glob patterns
|
|
24
|
-
*/
|
|
25
|
-
async function copyFiles(srcDir, destDir, pattern = '**/*') {
|
|
26
|
-
await fs.mkdir(destDir, { recursive: true });
|
|
27
|
-
|
|
28
|
-
const files = await glob(pattern, {
|
|
29
|
-
cwd: srcDir,
|
|
30
|
-
nodir: true,
|
|
31
|
-
dot: true,
|
|
32
|
-
absolute: false,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
for (const file of files) {
|
|
36
|
-
const srcPath = path.join(srcDir, file);
|
|
37
|
-
const destPath = path.join(destDir, file);
|
|
38
|
-
|
|
39
|
-
// Create destination directory if needed
|
|
40
|
-
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
41
|
-
|
|
42
|
-
// Copy file
|
|
43
|
-
await fs.copyFile(srcPath, destPath);
|
|
44
|
-
|
|
45
|
-
// Log copied file
|
|
46
|
-
console.log(` ${pc.dim('→')} ${file}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Check if directory exists and is empty
|
|
52
|
-
*/
|
|
53
|
-
async function isDirEmpty(dirPath) {
|
|
54
|
-
try {
|
|
55
|
-
const files = await fs.readdir(dirPath);
|
|
56
|
-
return files.length === 0;
|
|
57
|
-
} catch (error) {
|
|
58
|
-
if (error.code === 'ENOENT') {
|
|
59
|
-
return true; // Directory doesn't exist, treat as empty
|
|
60
|
-
}
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Run npm install
|
|
67
|
-
*/
|
|
68
|
-
function runNpmInstall(projectPath) {
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
log.info('Installing dependencies...');
|
|
71
|
-
|
|
72
|
-
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
73
|
-
const install = spawn(npm, ['install'], {
|
|
74
|
-
cwd: projectPath,
|
|
75
|
-
stdio: 'inherit',
|
|
76
|
-
shell: true,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
install.on('close', (code) => {
|
|
80
|
-
if (code !== 0) {
|
|
81
|
-
reject(new Error(`npm install exited with code ${code}`));
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
resolve();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
install.on('error', reject);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Load and render template file
|
|
93
|
-
*/
|
|
94
|
-
async function renderTemplate(templatePath, data) {
|
|
95
|
-
const template = await fs.readFile(templatePath, 'utf-8');
|
|
96
|
-
return Mustache.render(template, data);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Main function
|
|
101
|
-
*/
|
|
102
|
-
async function main() {
|
|
103
|
-
console.log();
|
|
104
|
-
console.log(`${pc.bold(pc.blue('🧿 Backtest Kit'))}`);
|
|
105
|
-
console.log();
|
|
106
|
-
|
|
107
|
-
// Get project name from arguments
|
|
108
|
-
const args = process.argv.slice(2);
|
|
109
|
-
const projectName = args[0] || 'my-backtest-project';
|
|
110
|
-
|
|
111
|
-
const projectPath = path.resolve(process.cwd(), projectName);
|
|
112
|
-
const srcTemplatePath = path.resolve(__dirname, '..', 'src');
|
|
113
|
-
const templateDir = path.resolve(__dirname, '..', 'template');
|
|
114
|
-
|
|
115
|
-
// Template data for Mustache
|
|
116
|
-
const templateData = {
|
|
117
|
-
PROJECT_NAME: projectName,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
// Check if directory exists and is not empty
|
|
122
|
-
{
|
|
123
|
-
const isEmpty = await isDirEmpty(projectPath);
|
|
124
|
-
if (!isEmpty) {
|
|
125
|
-
log.error(`Directory ${projectName} already exists and is not empty.`);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
{
|
|
131
|
-
log.info(`Creating a new Backtest Kit project in ${pc.bold(projectPath)}`);
|
|
132
|
-
console.log();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Create project directory
|
|
136
|
-
{
|
|
137
|
-
await fs.mkdir(projectPath, { recursive: true });
|
|
138
|
-
log.success('Created project directory');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Copy source template files using glob
|
|
142
|
-
{
|
|
143
|
-
log.info('Copying template files...');
|
|
144
|
-
await copyFiles(srcTemplatePath, path.join(projectPath, 'src'));
|
|
145
|
-
log.success('Copied template files');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Create package.json from template
|
|
149
|
-
{
|
|
150
|
-
log.info('Creating package.json...');
|
|
151
|
-
const packageJsonContent = await renderTemplate(
|
|
152
|
-
path.join(templateDir, 'package.mustache'),
|
|
153
|
-
templateData
|
|
154
|
-
);
|
|
155
|
-
await fs.writeFile(
|
|
156
|
-
path.join(projectPath, 'package.json'),
|
|
157
|
-
packageJsonContent,
|
|
158
|
-
'utf-8'
|
|
159
|
-
);
|
|
160
|
-
log.success('Created package.json');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Create .env files from template
|
|
164
|
-
{
|
|
165
|
-
log.info('Creating .env template...');
|
|
166
|
-
const envContent = await renderTemplate(
|
|
167
|
-
path.join(templateDir, 'env.mustache'),
|
|
168
|
-
templateData
|
|
169
|
-
);
|
|
170
|
-
await fs.writeFile(
|
|
171
|
-
path.join(projectPath, '.env.example'),
|
|
172
|
-
envContent,
|
|
173
|
-
'utf-8'
|
|
174
|
-
);
|
|
175
|
-
await fs.writeFile(
|
|
176
|
-
path.join(projectPath, '.env'),
|
|
177
|
-
envContent,
|
|
178
|
-
'utf-8'
|
|
179
|
-
);
|
|
180
|
-
log.success('Created .env files');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Create .gitignore from template
|
|
184
|
-
{
|
|
185
|
-
log.info('Creating .gitignore...');
|
|
186
|
-
const gitignoreContent = await renderTemplate(
|
|
187
|
-
path.join(templateDir, 'gitignore.mustache'),
|
|
188
|
-
templateData
|
|
189
|
-
);
|
|
190
|
-
await fs.writeFile(
|
|
191
|
-
path.join(projectPath, '.gitignore'),
|
|
192
|
-
gitignoreContent,
|
|
193
|
-
'utf-8'
|
|
194
|
-
);
|
|
195
|
-
log.success('Created .gitignore');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Create README.md from template
|
|
199
|
-
{
|
|
200
|
-
log.info('Creating README.md...');
|
|
201
|
-
const readmeContent = await renderTemplate(
|
|
202
|
-
path.join(templateDir, 'README.mustache'),
|
|
203
|
-
templateData
|
|
204
|
-
);
|
|
205
|
-
await fs.writeFile(
|
|
206
|
-
path.join(projectPath, 'README.md'),
|
|
207
|
-
readmeContent,
|
|
208
|
-
'utf-8'
|
|
209
|
-
);
|
|
210
|
-
log.success('Created README.md');
|
|
211
|
-
console.log();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Install dependencies
|
|
215
|
-
{
|
|
216
|
-
await runNpmInstall(projectPath);
|
|
217
|
-
console.log();
|
|
218
|
-
log.success('Installation complete!');
|
|
219
|
-
console.log();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Display success message with instructions
|
|
223
|
-
{
|
|
224
|
-
console.log(`${pc.bold('Success!')} Created ${pc.cyan(projectName)} at ${pc.bold(projectPath)}`);
|
|
225
|
-
console.log();
|
|
226
|
-
console.log('Inside that directory, you can run several commands:');
|
|
227
|
-
console.log();
|
|
228
|
-
console.log(` ${pc.cyan('npm start')}`);
|
|
229
|
-
console.log(' Starts the trading bot.');
|
|
230
|
-
console.log();
|
|
231
|
-
console.log('We suggest that you begin by typing:');
|
|
232
|
-
console.log();
|
|
233
|
-
console.log(` ${pc.cyan(`cd ${projectName}`)}`);
|
|
234
|
-
console.log(` ${pc.cyan('npm start')}`);
|
|
235
|
-
console.log();
|
|
236
|
-
console.log(`${pc.yellow('Don\'t forget to configure your API keys in .env file!')}`);
|
|
237
|
-
console.log();
|
|
238
|
-
console.log('Happy trading! 🚀');
|
|
239
|
-
console.log();
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
} catch (error) {
|
|
243
|
-
log.error('Failed to create project:');
|
|
244
|
-
console.error(error);
|
|
245
|
-
process.exit(1);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Run the script
|
|
250
|
-
main().catch(console.error);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { spawn } from 'child_process';
|
|
7
|
+
import pc from 'picocolors';
|
|
8
|
+
import { glob } from 'glob';
|
|
9
|
+
import Mustache from 'mustache';
|
|
10
|
+
import logSymbols from 'log-symbols';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
|
|
15
|
+
const log = {
|
|
16
|
+
info: (msg) => console.log(`${pc.cyan(logSymbols.info)} ${msg}`),
|
|
17
|
+
success: (msg) => console.log(`${pc.green(logSymbols.success)} ${msg}`),
|
|
18
|
+
error: (msg) => console.log(`${pc.red(logSymbols.error)} ${msg}`),
|
|
19
|
+
warn: (msg) => console.log(`${pc.yellow(logSymbols.warning)} ${msg}`),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Copy files using glob patterns
|
|
24
|
+
*/
|
|
25
|
+
async function copyFiles(srcDir, destDir, pattern = '**/*') {
|
|
26
|
+
await fs.mkdir(destDir, { recursive: true });
|
|
27
|
+
|
|
28
|
+
const files = await glob(pattern, {
|
|
29
|
+
cwd: srcDir,
|
|
30
|
+
nodir: true,
|
|
31
|
+
dot: true,
|
|
32
|
+
absolute: false,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
const srcPath = path.join(srcDir, file);
|
|
37
|
+
const destPath = path.join(destDir, file);
|
|
38
|
+
|
|
39
|
+
// Create destination directory if needed
|
|
40
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
41
|
+
|
|
42
|
+
// Copy file
|
|
43
|
+
await fs.copyFile(srcPath, destPath);
|
|
44
|
+
|
|
45
|
+
// Log copied file
|
|
46
|
+
console.log(` ${pc.dim('→')} ${file}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check if directory exists and is empty
|
|
52
|
+
*/
|
|
53
|
+
async function isDirEmpty(dirPath) {
|
|
54
|
+
try {
|
|
55
|
+
const files = await fs.readdir(dirPath);
|
|
56
|
+
return files.length === 0;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error.code === 'ENOENT') {
|
|
59
|
+
return true; // Directory doesn't exist, treat as empty
|
|
60
|
+
}
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Run npm install
|
|
67
|
+
*/
|
|
68
|
+
function runNpmInstall(projectPath) {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
log.info('Installing dependencies...');
|
|
71
|
+
|
|
72
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
73
|
+
const install = spawn(npm, ['install'], {
|
|
74
|
+
cwd: projectPath,
|
|
75
|
+
stdio: 'inherit',
|
|
76
|
+
shell: true,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
install.on('close', (code) => {
|
|
80
|
+
if (code !== 0) {
|
|
81
|
+
reject(new Error(`npm install exited with code ${code}`));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
resolve();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
install.on('error', reject);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Load and render template file
|
|
93
|
+
*/
|
|
94
|
+
async function renderTemplate(templatePath, data) {
|
|
95
|
+
const template = await fs.readFile(templatePath, 'utf-8');
|
|
96
|
+
return Mustache.render(template, data);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Main function
|
|
101
|
+
*/
|
|
102
|
+
async function main() {
|
|
103
|
+
console.log();
|
|
104
|
+
console.log(`${pc.bold(pc.blue('🧿 Backtest Kit'))}`);
|
|
105
|
+
console.log();
|
|
106
|
+
|
|
107
|
+
// Get project name from arguments
|
|
108
|
+
const args = process.argv.slice(2);
|
|
109
|
+
const projectName = args[0] || 'my-backtest-project';
|
|
110
|
+
|
|
111
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
112
|
+
const srcTemplatePath = path.resolve(__dirname, '..', 'src');
|
|
113
|
+
const templateDir = path.resolve(__dirname, '..', 'template');
|
|
114
|
+
|
|
115
|
+
// Template data for Mustache
|
|
116
|
+
const templateData = {
|
|
117
|
+
PROJECT_NAME: projectName,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
// Check if directory exists and is not empty
|
|
122
|
+
{
|
|
123
|
+
const isEmpty = await isDirEmpty(projectPath);
|
|
124
|
+
if (!isEmpty) {
|
|
125
|
+
log.error(`Directory ${projectName} already exists and is not empty.`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
{
|
|
131
|
+
log.info(`Creating a new Backtest Kit project in ${pc.bold(projectPath)}`);
|
|
132
|
+
console.log();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Create project directory
|
|
136
|
+
{
|
|
137
|
+
await fs.mkdir(projectPath, { recursive: true });
|
|
138
|
+
log.success('Created project directory');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Copy source template files using glob
|
|
142
|
+
{
|
|
143
|
+
log.info('Copying template files...');
|
|
144
|
+
await copyFiles(srcTemplatePath, path.join(projectPath, 'src'));
|
|
145
|
+
log.success('Copied template files');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Create package.json from template
|
|
149
|
+
{
|
|
150
|
+
log.info('Creating package.json...');
|
|
151
|
+
const packageJsonContent = await renderTemplate(
|
|
152
|
+
path.join(templateDir, 'package.mustache'),
|
|
153
|
+
templateData
|
|
154
|
+
);
|
|
155
|
+
await fs.writeFile(
|
|
156
|
+
path.join(projectPath, 'package.json'),
|
|
157
|
+
packageJsonContent,
|
|
158
|
+
'utf-8'
|
|
159
|
+
);
|
|
160
|
+
log.success('Created package.json');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Create .env files from template
|
|
164
|
+
{
|
|
165
|
+
log.info('Creating .env template...');
|
|
166
|
+
const envContent = await renderTemplate(
|
|
167
|
+
path.join(templateDir, 'env.mustache'),
|
|
168
|
+
templateData
|
|
169
|
+
);
|
|
170
|
+
await fs.writeFile(
|
|
171
|
+
path.join(projectPath, '.env.example'),
|
|
172
|
+
envContent,
|
|
173
|
+
'utf-8'
|
|
174
|
+
);
|
|
175
|
+
await fs.writeFile(
|
|
176
|
+
path.join(projectPath, '.env'),
|
|
177
|
+
envContent,
|
|
178
|
+
'utf-8'
|
|
179
|
+
);
|
|
180
|
+
log.success('Created .env files');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Create .gitignore from template
|
|
184
|
+
{
|
|
185
|
+
log.info('Creating .gitignore...');
|
|
186
|
+
const gitignoreContent = await renderTemplate(
|
|
187
|
+
path.join(templateDir, 'gitignore.mustache'),
|
|
188
|
+
templateData
|
|
189
|
+
);
|
|
190
|
+
await fs.writeFile(
|
|
191
|
+
path.join(projectPath, '.gitignore'),
|
|
192
|
+
gitignoreContent,
|
|
193
|
+
'utf-8'
|
|
194
|
+
);
|
|
195
|
+
log.success('Created .gitignore');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Create README.md from template
|
|
199
|
+
{
|
|
200
|
+
log.info('Creating README.md...');
|
|
201
|
+
const readmeContent = await renderTemplate(
|
|
202
|
+
path.join(templateDir, 'README.mustache'),
|
|
203
|
+
templateData
|
|
204
|
+
);
|
|
205
|
+
await fs.writeFile(
|
|
206
|
+
path.join(projectPath, 'README.md'),
|
|
207
|
+
readmeContent,
|
|
208
|
+
'utf-8'
|
|
209
|
+
);
|
|
210
|
+
log.success('Created README.md');
|
|
211
|
+
console.log();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Install dependencies
|
|
215
|
+
{
|
|
216
|
+
await runNpmInstall(projectPath);
|
|
217
|
+
console.log();
|
|
218
|
+
log.success('Installation complete!');
|
|
219
|
+
console.log();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Display success message with instructions
|
|
223
|
+
{
|
|
224
|
+
console.log(`${pc.bold('Success!')} Created ${pc.cyan(projectName)} at ${pc.bold(projectPath)}`);
|
|
225
|
+
console.log();
|
|
226
|
+
console.log('Inside that directory, you can run several commands:');
|
|
227
|
+
console.log();
|
|
228
|
+
console.log(` ${pc.cyan('npm start')}`);
|
|
229
|
+
console.log(' Starts the trading bot.');
|
|
230
|
+
console.log();
|
|
231
|
+
console.log('We suggest that you begin by typing:');
|
|
232
|
+
console.log();
|
|
233
|
+
console.log(` ${pc.cyan(`cd ${projectName}`)}`);
|
|
234
|
+
console.log(` ${pc.cyan('npm start')}`);
|
|
235
|
+
console.log();
|
|
236
|
+
console.log(`${pc.yellow('Don\'t forget to configure your API keys in .env file!')}`);
|
|
237
|
+
console.log();
|
|
238
|
+
console.log('Happy trading! 🚀');
|
|
239
|
+
console.log();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
} catch (error) {
|
|
243
|
+
log.error('Failed to create project:');
|
|
244
|
+
console.error(error);
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Run the script
|
|
250
|
+
main().catch(console.error);
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"backtest-kit": "^1.
|
|
13
|
-
"@backtest-kit/signals": "^0.0.
|
|
14
|
-
"@backtest-kit/ollama": "^0.0.
|
|
12
|
+
"backtest-kit": "^1.12.1",
|
|
13
|
+
"@backtest-kit/signals": "^0.0.3",
|
|
14
|
+
"@backtest-kit/ollama": "^0.0.2",
|
|
15
15
|
"agent-swarm-kit": "^1.1.180",
|
|
16
16
|
"ccxt": "^4.4.41",
|
|
17
17
|
"uuid": "^11.0.3",
|