first refactor
This commit is contained in:
parent
1f5dac28c7
commit
588f666943
84 changed files with 996 additions and 1062 deletions
|
|
@ -12,6 +12,7 @@
|
|||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/services": "workspace:*",
|
||||
"@stock-bot/cache": "*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/stock-config": "*",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
import { IB_CONFIG } from '../shared/config';
|
||||
import { fetchSession } from './fetch-session.action';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
// Import handlers explicitly for bundling (ensures they're included in the build)
|
||||
// These imports trigger the decorator metadata to be set
|
||||
import { CeoHandler } from './ceo/ceo.handler';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import type { CacheProvider } from '@stock-bot/cache';
|
||||
import type { Logger } from '@stock-bot/types';
|
||||
import type { Logger } from '@stock-bot/services';
|
||||
import { QM_SESSION_IDS, SESSION_CONFIG } from './config';
|
||||
import type { QMSession } from './types';
|
||||
|
||||
|
|
@ -379,4 +379,4 @@ export class QMSessionManagerRedis {
|
|||
|
||||
this.logger?.info('Migration completed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import type { CacheProvider } from '@stock-bot/cache';
|
||||
import type { Logger } from '@stock-bot/types';
|
||||
import type { Logger } from '@stock-bot/services';
|
||||
import { QMSessionManager } from './session-manager';
|
||||
import { QMSessionManagerRedis } from './session-manager-redis';
|
||||
import type { QMSession } from './types';
|
||||
|
|
@ -125,4 +125,4 @@ export class SessionManagerWrapper {
|
|||
}
|
||||
throw new Error('Migration only available for Redis implementation');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import type { CacheProvider } from '@stock-bot/cache';
|
||||
import type { Logger } from '@stock-bot/types';
|
||||
import type { Logger } from '@stock-bot/services';
|
||||
import { QM_SESSION_IDS, SESSION_CONFIG } from './config';
|
||||
import type { CachedSession, QMSession } from './types';
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export function createMarketDataRoutes(container: IServiceContainer) {
|
|||
|
||||
try {
|
||||
// Queue job for live data using Yahoo provider
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ status: 'error', message: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ export function createMarketDataRoutes(container: IServiceContainer) {
|
|||
const toDate = to ? new Date(to) : new Date(); // Now
|
||||
|
||||
// Queue job for historical data using Yahoo provider
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ status: 'error', message: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ export function createMarketDataRoutes(container: IServiceContainer) {
|
|||
useBatching,
|
||||
});
|
||||
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ status: 'error', message: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export function createQueueRoutes(container: IServiceContainer) {
|
|||
// Queue status endpoint
|
||||
queue.get('/status', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ status: 'error', message: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Base class for operation providers
|
||||
*/
|
||||
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/types';
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/services';
|
||||
import type {
|
||||
OperationConfig,
|
||||
OperationUpdate,
|
||||
|
|
@ -170,4 +170,4 @@ export abstract class BaseOperationProvider {
|
|||
}))
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Central registry for managing operations across multiple providers
|
||||
*/
|
||||
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/types';
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/services';
|
||||
import { BaseOperationProvider } from './BaseOperationProvider';
|
||||
import { OperationTracker } from './OperationTracker';
|
||||
import type {
|
||||
|
|
@ -330,4 +330,4 @@ export class OperationRegistry {
|
|||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* General operation tracker that works with any provider
|
||||
*/
|
||||
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/types';
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/services';
|
||||
import type { BaseOperationProvider } from './BaseOperationProvider';
|
||||
import type {
|
||||
BulkOperationUpdate,
|
||||
|
|
@ -781,4 +781,4 @@ export class OperationTracker {
|
|||
getProviderInfo() {
|
||||
return this.provider.getProviderConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Types for the general operation management system
|
||||
*/
|
||||
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/types';
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/services';
|
||||
|
||||
/**
|
||||
* Configuration for a single operation
|
||||
|
|
@ -184,4 +184,4 @@ export interface SymbolWithOperations {
|
|||
export interface OperationComponentOptions {
|
||||
mongodb: MongoDBClient;
|
||||
logger: Logger;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Defines required services for data ingestion handlers
|
||||
*/
|
||||
|
||||
import type { ServiceTypes } from '@stock-bot/types';
|
||||
import type { ServiceTypes } from '@stock-bot/services';
|
||||
|
||||
/**
|
||||
* Services required by data ingestion handlers
|
||||
|
|
@ -22,4 +22,4 @@ export type DataIngestionServices = ServiceTypes & {
|
|||
postgres: ServiceTypes['postgres'];
|
||||
questdb: ServiceTypes['questdb'];
|
||||
globalCache: ServiceTypes['globalCache'];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach } from 'bun:test';
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/types';
|
||||
import type { Logger, MongoDBClient } from '@stock-bot/services';
|
||||
import {
|
||||
BaseOperationProvider,
|
||||
OperationRegistry,
|
||||
|
|
@ -193,4 +193,4 @@ describe('Operation Management System', () => {
|
|||
expect(stats.totalSymbols).toBe(100);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.app.json",
|
||||
"compilerOptions": { "rootDir": "./src", "outDir": "./dist" },
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
|
||||
"references": [
|
||||
{ "path": "../../../libs/core/types" },
|
||||
{ "path": "../../../libs/core/config" },
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/services": "workspace:*",
|
||||
"@stock-bot/cache": "*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/stock-config": "*",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { BaseHandler, Handler, Operation, ScheduledOperation } from '@stock-bot/handlers';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
import { clearPostgreSQLData } from './operations/clear-postgresql-data.operations';
|
||||
import { getSyncStatus } from './operations/enhanced-sync-status.operations';
|
||||
import { getExchangeStats } from './operations/exchange-stats.operations';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
import type { JobPayload } from '../../../types/job-payloads';
|
||||
|
||||
const logger = getLogger('sync-qm-exchanges');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
// Import handlers directly
|
||||
import { ExchangesHandler } from './exchanges/exchanges.handler';
|
||||
import { SymbolsHandler } from './symbols/symbols.handler';
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
enhancedSync.post('/exchanges/all', async c => {
|
||||
try {
|
||||
const clearFirst = c.req.query('clear') === 'true';
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-all-exchanges', {
|
||||
const job = await exchangesQueue.add('sync-all-exchanges', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-all-exchanges',
|
||||
payload: { clearFirst },
|
||||
|
|
@ -36,14 +36,14 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
|
||||
enhancedSync.post('/provider-mappings/qm', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-qm-provider-mappings', {
|
||||
const job = await exchangesQueue.add('sync-qm-provider-mappings', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-qm-provider-mappings',
|
||||
payload: {},
|
||||
|
|
@ -65,14 +65,14 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
|
||||
enhancedSync.post('/provider-mappings/ib', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-ib-exchanges', {
|
||||
const job = await exchangesQueue.add('sync-ib-exchanges', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-ib-exchanges',
|
||||
payload: {},
|
||||
|
|
@ -94,14 +94,14 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
|
||||
enhancedSync.get('/status', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
|
||||
const job = await symbolsQueue.addJob('sync-status', {
|
||||
const job = await symbolsQueue.add('sync-status', {
|
||||
handler: 'symbols',
|
||||
operation: 'sync-status',
|
||||
payload: {},
|
||||
|
|
@ -120,14 +120,14 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
enhancedSync.post('/clear/postgresql', async c => {
|
||||
try {
|
||||
const dataType = c.req.query('type') as 'exchanges' | 'provider_mappings' | 'all';
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('clear-postgresql-data', {
|
||||
const job = await exchangesQueue.add('clear-postgresql-data', {
|
||||
handler: 'exchanges',
|
||||
operation: 'clear-postgresql-data',
|
||||
payload: { dataType: dataType || 'all' },
|
||||
|
|
|
|||
|
|
@ -10,21 +10,21 @@ export function createStatsRoutes(container: IServiceContainer) {
|
|||
// Statistics endpoints
|
||||
stats.get('/exchanges', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('get-exchange-stats', {
|
||||
const job = await exchangesQueue.add('get-exchange-stats', {
|
||||
handler: 'exchanges',
|
||||
operation: 'get-exchange-stats',
|
||||
payload: {},
|
||||
});
|
||||
|
||||
// Wait for job to complete and return result
|
||||
const result = await job.waitUntilFinished();
|
||||
const result = await exchangesQueue.waitForJob(job);
|
||||
return c.json(result);
|
||||
} catch (error) {
|
||||
logger.error('Failed to get exchange stats', { error });
|
||||
|
|
@ -34,21 +34,21 @@ export function createStatsRoutes(container: IServiceContainer) {
|
|||
|
||||
stats.get('/provider-mappings', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('get-provider-mapping-stats', {
|
||||
const job = await exchangesQueue.add('get-provider-mapping-stats', {
|
||||
handler: 'exchanges',
|
||||
operation: 'get-provider-mapping-stats',
|
||||
payload: {},
|
||||
});
|
||||
|
||||
// Wait for job to complete and return result
|
||||
const result = await job.waitUntilFinished();
|
||||
const result = await exchangesQueue.waitForJob(job);
|
||||
return c.json(result);
|
||||
} catch (error) {
|
||||
logger.error('Failed to get provider mapping stats', { error });
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
// Manual sync trigger endpoints
|
||||
sync.post('/symbols', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
|
||||
const job = await symbolsQueue.addJob('sync-qm-symbols', {
|
||||
const job = await symbolsQueue.add('sync-qm-symbols', {
|
||||
handler: 'symbols',
|
||||
operation: 'sync-qm-symbols',
|
||||
payload: {},
|
||||
|
|
@ -35,14 +35,14 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
|
||||
sync.post('/exchanges', async c => {
|
||||
try {
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-qm-exchanges', {
|
||||
const job = await exchangesQueue.add('sync-qm-exchanges', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-qm-exchanges',
|
||||
payload: {},
|
||||
|
|
@ -61,14 +61,14 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
sync.post('/symbols/:provider', async c => {
|
||||
try {
|
||||
const provider = c.req.param('provider');
|
||||
const queueManager = container.queue;
|
||||
const queueManager = container.queueManager;
|
||||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
|
||||
const job = await symbolsQueue.addJob('sync-symbols-from-provider', {
|
||||
const job = await symbolsQueue.add('sync-symbols-from-provider', {
|
||||
handler: 'symbols',
|
||||
operation: 'sync-symbols-from-provider',
|
||||
payload: { provider },
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.app.json",
|
||||
"compilerOptions": { "rootDir": "./src", "outDir": "./dist" },
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
|
||||
"references": [
|
||||
{ "path": "../../../libs/core/types" },
|
||||
{ "path": "../../../libs/core/config" },
|
||||
|
|
|
|||
10
apps/stock/engine/index.cjs
Normal file
10
apps/stock/engine/index.cjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
const { join } = require('node:path');
|
||||
|
||||
const nativeBinding = require(join(__dirname, 'dist', 'engine.node'));
|
||||
|
||||
module.exports = {
|
||||
...nativeBinding,
|
||||
IncrementalSMA: nativeBinding.IncrementalSma,
|
||||
IncrementalEMA: nativeBinding.IncrementalEma,
|
||||
IncrementalRSI: nativeBinding.IncrementalRsi,
|
||||
};
|
||||
9
apps/stock/engine/index.d.ts
vendored
Normal file
9
apps/stock/engine/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export * from './dist/index';
|
||||
export {
|
||||
IncrementalSma as IncrementalSMA,
|
||||
IncrementalEma as IncrementalEMA,
|
||||
IncrementalRsi as IncrementalRSI,
|
||||
} from './dist/index';
|
||||
|
||||
declare const nativeBinding: typeof import('./dist/index');
|
||||
export default nativeBinding;
|
||||
|
|
@ -1,36 +1,40 @@
|
|||
// ESM wrapper for the native module
|
||||
import { createRequire } from 'module';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const nativeBinding = require(join(__dirname, 'index.node'));
|
||||
|
||||
export const {
|
||||
TradingEngine,
|
||||
BacktestEngine,
|
||||
TechnicalIndicators,
|
||||
IncrementalSMA,
|
||||
IncrementalEMA,
|
||||
IncrementalRSI,
|
||||
RiskAnalyzer,
|
||||
OrderbookAnalyzer,
|
||||
MarketData,
|
||||
MarketUpdate,
|
||||
Order,
|
||||
Fill,
|
||||
Position,
|
||||
RiskLimits,
|
||||
RiskMetrics,
|
||||
ExecutionResult,
|
||||
OrderBookLevel,
|
||||
OrderBookSnapshot,
|
||||
MarketMicrostructure,
|
||||
PositionUpdate,
|
||||
RiskCheckResult
|
||||
} = nativeBinding;
|
||||
|
||||
export default nativeBinding;
|
||||
// ESM wrapper for the native module
|
||||
import { createRequire } from 'module';
|
||||
import { dirname, join } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const nativeBinding = require(join(__dirname, 'dist', 'engine.node'));
|
||||
|
||||
export const {
|
||||
TradingEngine,
|
||||
BacktestEngine,
|
||||
TechnicalIndicators,
|
||||
IncrementalSma,
|
||||
IncrementalEma,
|
||||
IncrementalRsi,
|
||||
RiskAnalyzer,
|
||||
OrderbookAnalyzer,
|
||||
MarketData,
|
||||
MarketUpdate,
|
||||
Order,
|
||||
Fill,
|
||||
Position,
|
||||
RiskLimits,
|
||||
RiskMetrics,
|
||||
ExecutionResult,
|
||||
OrderBookLevel,
|
||||
OrderBookSnapshot,
|
||||
MarketMicrostructure,
|
||||
PositionUpdate,
|
||||
RiskCheckResult,
|
||||
} = nativeBinding;
|
||||
|
||||
export const IncrementalSMA = IncrementalSma;
|
||||
export const IncrementalEMA = IncrementalEma;
|
||||
export const IncrementalRSI = IncrementalRsi;
|
||||
|
||||
export default nativeBinding;
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@
|
|||
"types": "index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js",
|
||||
"types": "./index.d.ts"
|
||||
"require": "./index.cjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"index.mjs",
|
||||
"index.node"
|
||||
"index.cjs",
|
||||
"dist"
|
||||
],
|
||||
"napi": {
|
||||
"name": "engine",
|
||||
|
|
@ -30,14 +30,14 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics",
|
||||
"build": "napi build dist --dts index.d.ts --no-dts-header",
|
||||
"build:debug": "npm run build --",
|
||||
"build:release": "npm run build -- --release",
|
||||
"build:napi": "napi build --platform --release",
|
||||
"build:napi": "bun run build --release",
|
||||
"test": "cargo test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^2.16.3",
|
||||
"cargo-cp-artifact": "^0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,48 @@
|
|||
{
|
||||
"name": "@stock-bot/orchestrator",
|
||||
"version": "0.1.0",
|
||||
"description": "Trading system orchestrator - coordinates between Rust core, data feeds, and analytics",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "bun --watch src/index.ts",
|
||||
"build": "bun build src/index.ts --outdir dist --target node",
|
||||
"start": "bun dist/index.js",
|
||||
"test": "bun test",
|
||||
"test:indicators": "bun test tests/indicators.test.ts",
|
||||
"example:indicators": "bun run examples/indicator-usage.ts",
|
||||
"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": "*",
|
||||
"@stock-bot/logger": "*",
|
||||
"@stock-bot/questdb": "*",
|
||||
"@stock-bot/queue": "*",
|
||||
"@stock-bot/shutdown": "*",
|
||||
"@stock-bot/stock-config": "*",
|
||||
"@stock-bot/utils": "*",
|
||||
"hono": "^4.0.0",
|
||||
"socket.io": "^4.7.2",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"zod": "^3.22.0",
|
||||
"uuid": "^9.0.0",
|
||||
"axios": "^1.6.0",
|
||||
"simple-statistics": "^7.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "@stock-bot/orchestrator",
|
||||
"version": "0.1.0",
|
||||
"description": "Trading system orchestrator - coordinates between Rust core, data feeds, and analytics",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "bun --watch src/index.ts",
|
||||
"build": "bun build src/index.ts --outdir dist --target node --external @stock-bot/engine --external @tensorflow/tfjs-node",
|
||||
"start": "bun dist/index.js",
|
||||
"test": "bun test",
|
||||
"test:indicators": "bun test tests/indicators.test.ts",
|
||||
"example:indicators": "bun run examples/indicator-usage.ts",
|
||||
"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": "*",
|
||||
"@stock-bot/logger": "*",
|
||||
"@stock-bot/questdb": "*",
|
||||
"@stock-bot/queue": "*",
|
||||
"@stock-bot/shutdown": "*",
|
||||
"@stock-bot/stock-config": "*",
|
||||
"@stock-bot/utils": "*",
|
||||
"hono": "^4.0.0",
|
||||
"socket.io": "^4.7.2",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"zod": "^3.22.0",
|
||||
"uuid": "^9.0.0",
|
||||
"axios": "^1.6.0",
|
||||
"simple-statistics": "^7.8.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tensorflow/tfjs-node": "^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@tensorflow/tfjs-node": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"lib": ["ESNext"],
|
||||
"moduleResolution": "bundler",
|
||||
"moduleDetection": "force",
|
||||
"allowImportingTsExtensions": true,
|
||||
"strict": true,
|
||||
"downlevelIteration": true,
|
||||
"skipLibCheck": true,
|
||||
"jsx": "preserve",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowJs": true,
|
||||
"types": ["bun-types"],
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"noEmit": true,
|
||||
"composite": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"paths": {
|
||||
"@stock-bot/engine": ["../engine/index"],
|
||||
"@stock-bot/engine/*": ["../engine/*"]
|
||||
},
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"lib": ["ESNext"],
|
||||
"moduleResolution": "bundler",
|
||||
"moduleDetection": "force",
|
||||
"allowImportingTsExtensions": true,
|
||||
"strict": true,
|
||||
"downlevelIteration": true,
|
||||
"skipLibCheck": true,
|
||||
"jsx": "preserve",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowJs": true,
|
||||
"types": ["bun-types"],
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"noEmit": true,
|
||||
"composite": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"paths": {
|
||||
"@stock-bot/engine": ["../engine/index"],
|
||||
"@stock-bot/engine/*": ["../engine/*"]
|
||||
},
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,5 +69,5 @@
|
|||
"node": ">=18.0.0",
|
||||
"bun": ">=1.1.0"
|
||||
},
|
||||
"packageManager": "bun@1.1.12"
|
||||
"packageManager": "bun@1.2.17"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stock-bot/queue": "workspace:*",
|
||||
"@stock-bot/services": "workspace:*",
|
||||
"@stock-bot/config": "*",
|
||||
"@stock-bot/stock-config": "*",
|
||||
"@stock-bot/logger": "*",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
import { Hono } from 'hono';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
import { createExchangeService } from '../services/exchange.service';
|
||||
import { createSuccessResponse, handleError } from '../utils/error-handler';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
import {
|
||||
CreateExchangeRequest,
|
||||
CreateProviderMappingRequest,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { getFullQueueName } from '@stock-bot/queue';
|
||||
|
||||
const logger = getLogger('pipeline-service');
|
||||
|
||||
|
|
@ -30,13 +31,13 @@ export class PipelineService {
|
|||
*/
|
||||
async syncQMSymbols(): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
const job = await symbolsQueue.addJob('sync-qm-symbols', {
|
||||
const symbolsQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'symbols'));
|
||||
const job = await symbolsQueue.add('sync-qm-symbols', {
|
||||
handler: 'symbols',
|
||||
operation: 'sync-qm-symbols',
|
||||
payload: {},
|
||||
|
|
@ -58,13 +59,13 @@ export class PipelineService {
|
|||
*/
|
||||
async syncQMExchanges(): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('sync-qm-exchanges', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('sync-qm-exchanges', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-qm-exchanges',
|
||||
payload: {},
|
||||
|
|
@ -86,13 +87,13 @@ export class PipelineService {
|
|||
*/
|
||||
async syncProviderSymbols(provider: string): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
const job = await symbolsQueue.addJob('sync-symbols-from-provider', {
|
||||
const symbolsQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'symbols'));
|
||||
const job = await symbolsQueue.add('sync-symbols-from-provider', {
|
||||
handler: 'symbols',
|
||||
operation: 'sync-symbols-from-provider',
|
||||
payload: { provider },
|
||||
|
|
@ -118,13 +119,13 @@ export class PipelineService {
|
|||
*/
|
||||
async syncAllExchanges(clearFirst: boolean = false): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('sync-all-exchanges', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('sync-all-exchanges', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-all-exchanges',
|
||||
payload: { clearFirst },
|
||||
|
|
@ -150,13 +151,13 @@ export class PipelineService {
|
|||
*/
|
||||
async syncQMProviderMappings(): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('sync-qm-provider-mappings', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('sync-qm-provider-mappings', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-qm-provider-mappings',
|
||||
payload: {},
|
||||
|
|
@ -182,13 +183,13 @@ export class PipelineService {
|
|||
*/
|
||||
async syncIBExchanges(): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('sync-ib-exchanges', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('sync-ib-exchanges', {
|
||||
handler: 'exchanges',
|
||||
operation: 'sync-ib-exchanges',
|
||||
payload: {},
|
||||
|
|
@ -214,13 +215,13 @@ export class PipelineService {
|
|||
*/
|
||||
async getSyncStatus(): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
const job = await symbolsQueue.addJob('sync-status', {
|
||||
const symbolsQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'symbols'));
|
||||
const job = await symbolsQueue.add('sync-status', {
|
||||
handler: 'symbols',
|
||||
operation: 'sync-status',
|
||||
payload: {},
|
||||
|
|
@ -248,13 +249,13 @@ export class PipelineService {
|
|||
dataType: 'exchanges' | 'provider_mappings' | 'all' = 'all'
|
||||
): Promise<PipelineJobResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('clear-postgresql-data', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('clear-postgresql-data', {
|
||||
handler: 'exchanges',
|
||||
operation: 'clear-postgresql-data',
|
||||
payload: { dataType },
|
||||
|
|
@ -280,20 +281,20 @@ export class PipelineService {
|
|||
*/
|
||||
async getExchangeStats(): Promise<PipelineStatsResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('get-exchange-stats', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('get-exchange-stats', {
|
||||
handler: 'exchanges',
|
||||
operation: 'get-exchange-stats',
|
||||
payload: {},
|
||||
});
|
||||
|
||||
// Wait for job to complete and return result
|
||||
const result = await job.waitUntilFinished();
|
||||
const result = await exchangesQueue.waitForJob(job);
|
||||
return { success: true, data: result };
|
||||
} catch (error) {
|
||||
logger.error('Failed to get exchange stats', { error });
|
||||
|
|
@ -309,20 +310,20 @@ export class PipelineService {
|
|||
*/
|
||||
async getProviderMappingStats(): Promise<PipelineStatsResult> {
|
||||
try {
|
||||
const queueManager = this.container.queue;
|
||||
const queueManager = this.container.queueManager;
|
||||
if (!queueManager) {
|
||||
return { success: false, error: 'Queue manager not available' };
|
||||
}
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
const job = await exchangesQueue.addJob('get-provider-mapping-stats', {
|
||||
const exchangesQueue = queueManager.getQueue(getFullQueueName('data-pipeline', 'exchanges'));
|
||||
const job = await exchangesQueue.add('get-provider-mapping-stats', {
|
||||
handler: 'exchanges',
|
||||
operation: 'get-provider-mapping-stats',
|
||||
payload: {},
|
||||
});
|
||||
|
||||
// Wait for job to complete and return result
|
||||
const result = await job.waitUntilFinished();
|
||||
const result = await exchangesQueue.waitForJob(job);
|
||||
return { success: true, data: result };
|
||||
} catch (error) {
|
||||
logger.error('Failed to get provider mapping stats', { error });
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Defines required services for web API handlers
|
||||
*/
|
||||
|
||||
import type { ServiceTypes } from '@stock-bot/types';
|
||||
import type { ServiceTypes } from '@stock-bot/services';
|
||||
|
||||
/**
|
||||
* Services required by web API handlers
|
||||
|
|
@ -22,4 +22,4 @@ export type WebApiServices = ServiceTypes & {
|
|||
proxy: ServiceTypes['proxy'];
|
||||
questdb: ServiceTypes['questdb'];
|
||||
globalCache: ServiceTypes['globalCache'];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.app.json",
|
||||
"compilerOptions": { "rootDir": "./src", "outDir": "./dist" },
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
|
||||
"references": [
|
||||
{ "path": "../../../libs/core/types" },
|
||||
{ "path": "../../../libs/core/config" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue