This commit is contained in:
Boki 2025-06-11 10:35:15 -04:00
parent 8955544593
commit 9d38f9a7b6
91 changed files with 2224 additions and 1400 deletions

View file

@ -1,33 +1,34 @@
{
"name": "@stock-bot/strategy-service",
"version": "1.0.0",
"description": "Combined strategy execution and multi-mode backtesting service",
"main": "dist/index.js",
"type": "module",
"scripts": {
"devvvvv": "bun --watch src/index.ts",
"build": "bun build src/index.ts --outdir dist --target node",
"start": "bun dist/index.js",
"test": "bun test", "clean": "rm -rf dist",
"backtest": "bun src/cli/index.ts",
"optimize": "bun src/cli/index.ts optimize",
"cli": "bun src/cli/index.ts"
},
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/logger": "*",
"@stock-bot/types": "*",
"@stock-bot/utils": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/strategy-engine": "*",
"@stock-bot/vector-engine": "*",
"@stock-bot/data-frame": "*",
"@stock-bot/questdb-client": "*",
"hono": "^4.0.0",
"commander": "^11.0.0"
},
"devDependencies": {
"@types/node": "^20.0.0",
"typescript": "^5.0.0"
}
}
{
"name": "@stock-bot/strategy-service",
"version": "1.0.0",
"description": "Combined strategy execution and multi-mode backtesting service",
"main": "dist/index.js",
"type": "module",
"scripts": {
"devvvvv": "bun --watch src/index.ts",
"build": "bun build src/index.ts --outdir dist --target node",
"start": "bun dist/index.js",
"test": "bun test",
"clean": "rm -rf dist",
"backtest": "bun src/cli/index.ts",
"optimize": "bun src/cli/index.ts optimize",
"cli": "bun src/cli/index.ts"
},
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/logger": "*",
"@stock-bot/types": "*",
"@stock-bot/utils": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/strategy-engine": "*",
"@stock-bot/vector-engine": "*",
"@stock-bot/data-frame": "*",
"@stock-bot/questdb-client": "*",
"hono": "^4.0.0",
"commander": "^11.0.0"
},
"devDependencies": {
"@types/node": "^20.0.0",
"typescript": "^5.0.0"
}
}

View file

@ -1,4 +1,3 @@
import { create } from 'domain';
import { DataFrame } from '@stock-bot/data-frame';
import { EventBus } from '@stock-bot/event-bus';
import { getLogger } from '@stock-bot/logger';
@ -198,7 +197,7 @@ export class HybridMode extends ExecutionMode {
private overrideIndicatorCalculations(eventMode: EventMode): void {
// Override the event mode's indicator calculations to use pre-computed values
// This is a simplified approach - in production you'd want a more sophisticated interface
const originalCalculateIndicators = (eventMode as any).calculateIndicators;
const _originalCalculateIndicators = (eventMode as any).calculateIndicators;
(eventMode as any).calculateIndicators = (symbol: string, index: number) => {
const indicators: Record<string, number> = {};

View file

@ -19,7 +19,7 @@ export class LiveMode extends ExecutionMode {
return new Date(); // Real time
}
async getMarketData(symbol: string): Promise<MarketData> {
async getMarketData(_symbol: string): Promise<MarketData> {
// TODO: Get live market data
throw new Error('Live market data fetching not implemented yet');
}

View file

@ -82,7 +82,7 @@ async function runBacktest(options: CLIBacktestConfig): Promise<void> {
// Subscribe to progress updates
eventBus.subscribe('backtest.update', message => {
const { backtestId, progress, ...data } = message.data;
const { backtestId: _backtestId, progress, ...data } = message.data;
console.log(`Progress: ${progress}%`, data);
});
@ -172,7 +172,7 @@ async function saveResults(result: any, outputPath: string): Promise<void> {
}
function convertTradesToCSV(trades: any[]): string {
if (trades.length === 0) return 'No trades executed\n';
if (trades.length === 0) {return 'No trades executed\n';}
const headers = Object.keys(trades[0]).join(',');
const rows = trades.map(trade =>
@ -259,7 +259,7 @@ program
const strategies = options.strategies.split(',').map((s: string) => s.trim());
console.log(`Comparing strategies: ${strategies.join(', ')}`);
const results: any[] = [];
const _results: any[] = [];
for (const strategy of strategies) {
console.log(`\nRunning ${strategy}...`);

View file

@ -4,7 +4,7 @@
*/
import { getLogger } from '@stock-bot/logger';
const logger = getLogger('execution-mode');
const _logger = getLogger('execution-mode');
export interface Order {
id: string;
@ -55,7 +55,7 @@ export enum BacktestMode {
}
export class ModeFactory {
static create(mode: BacktestMode, config?: any): ExecutionMode {
static create(mode: BacktestMode, _config?: any): ExecutionMode {
switch (mode) {
case BacktestMode.LIVE:
// TODO: Import and create LiveMode

View file

@ -1,18 +1,26 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts", "**/test/**", "**/tests/**", "**/__tests__/**"],
"references": [
{ "path": "../../libs/types" },
{ "path": "../../libs/config" },
{ "path": "../../libs/logger" },
{ "path": "../../libs/utils" },
{ "path": "../../libs/strategy-engine" },
{ "path": "../../libs/event-bus" },
{ "path": "../../libs/shutdown" }
]
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": [
"node_modules",
"dist",
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**",
"**/tests/**",
"**/__tests__/**"
],
"references": [
{ "path": "../../libs/types" },
{ "path": "../../libs/config" },
{ "path": "../../libs/logger" },
{ "path": "../../libs/utils" },
{ "path": "../../libs/strategy-engine" },
{ "path": "../../libs/event-bus" },
{ "path": "../../libs/shutdown" }
]
}