work on engine
This commit is contained in:
parent
a1e5a21847
commit
cbe8f0282c
12 changed files with 694 additions and 16 deletions
32
apps/stock/orchestrator/examples/test-engine-import.ts
Normal file
32
apps/stock/orchestrator/examples/test-engine-import.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bun
|
||||
|
||||
// Test importing the @stock-bot/engine package
|
||||
import * as engine from '@stock-bot/engine';
|
||||
|
||||
console.log('Successfully imported @stock-bot/engine');
|
||||
console.log('Available exports:', Object.keys(engine));
|
||||
|
||||
// Test creating some basic objects if they're available
|
||||
try {
|
||||
if (engine.createBacktestEngine) {
|
||||
console.log('✓ createBacktestEngine is available');
|
||||
}
|
||||
|
||||
if (engine.createIndicator) {
|
||||
console.log('✓ createIndicator is available');
|
||||
}
|
||||
|
||||
if (engine.createRiskManager) {
|
||||
console.log('✓ createRiskManager is available');
|
||||
}
|
||||
|
||||
// List all available functions
|
||||
console.log('\nAll available functions:');
|
||||
for (const [key, value] of Object.entries(engine)) {
|
||||
if (typeof value === 'function') {
|
||||
console.log(` - ${key}()`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error testing engine exports:', error);
|
||||
}
|
||||
|
|
@ -11,9 +11,11 @@
|
|||
"test": "bun test",
|
||||
"test:indicators": "bun test tests/indicators.test.ts",
|
||||
"example:indicators": "bun run examples/indicator-usage.ts",
|
||||
"build:rust": "cd ../core && cargo build --release && napi build --platform --release"
|
||||
"test:engine": "bun run examples/test-engine-import.ts",
|
||||
"build:rust": "cd ../engine && cargo build --release && napi build --platform --release"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/engine": "*",
|
||||
"@stock-bot/cache": "*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/di": "*",
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ export class BacktestEngine extends EventEmitter {
|
|||
this.reset();
|
||||
this.isRunning = true;
|
||||
this.initialCapital = validatedConfig.initialCapital;
|
||||
this.commission = validatedConfig.commission || 0.001;
|
||||
this.slippage = validatedConfig.slippage || 0.0001;
|
||||
this.commission = validatedConfig.commission ?? 0.001;
|
||||
this.slippage = validatedConfig.slippage ?? 0.0001;
|
||||
|
||||
// Recreate performance analyzer with correct initial capital
|
||||
this.performanceAnalyzer = new PerformanceAnalyzer(this.initialCapital);
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ export class RustBacktestAdapter extends EventEmitter {
|
|||
startDate: config.startDate,
|
||||
endDate: config.endDate,
|
||||
initialCapital: config.initialCapital,
|
||||
commission: config.commission || 0.001,
|
||||
slippage: config.slippage || 0.0001,
|
||||
commission: config.commission ?? 0.001,
|
||||
slippage: config.slippage ?? 0.0001,
|
||||
dataFrequency: config.dataFrequency || '1d',
|
||||
};
|
||||
|
||||
|
|
@ -134,8 +134,8 @@ export class RustBacktestAdapter extends EventEmitter {
|
|||
startDate: config.startDate,
|
||||
endDate: config.endDate,
|
||||
initialCapital: config.initialCapital,
|
||||
commission: config.commission || 0.001,
|
||||
slippage: config.slippage || 0.0001,
|
||||
commission: config.commission ?? 0.001,
|
||||
slippage: config.slippage ?? 0.0001,
|
||||
dataFrequency: config.dataFrequency || '1d',
|
||||
},
|
||||
metrics: this.getEmptyMetrics(),
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ export class RustBacktestEngine {
|
|||
startDate: config.startDate,
|
||||
endDate: config.endDate,
|
||||
initialCapital: config.initialCapital,
|
||||
commission: config.commission || 0.001,
|
||||
slippage: config.slippage || 0.0001,
|
||||
commission: config.commission ?? 0.001,
|
||||
slippage: config.slippage ?? 0.0001,
|
||||
dataFrequency: config.dataFrequency || '1d',
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,12 @@
|
|||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
"rootDir": "./src",
|
||||
"paths": {
|
||||
"@stock-bot/engine": ["../engine/index"],
|
||||
"@stock-bot/engine/*": ["../engine/*"]
|
||||
},
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue