running prettier for cleanup

This commit is contained in:
Boki 2025-06-11 10:13:25 -04:00
parent fe7733aeb5
commit d85cd58acd
151 changed files with 29158 additions and 27966 deletions

View file

@ -1,54 +1,54 @@
/**
* Processing Service - Technical indicators and data processing
*/
import { getLogger } from '@stock-bot/logger';
import { loadEnvVariables } from '@stock-bot/config';
import { Hono } from 'hono';
import { serve } from '@hono/node-server';
// Load environment variables
loadEnvVariables();
const app = new Hono();
const logger = getLogger('processing-service');
const PORT = parseInt(process.env.PROCESSING_SERVICE_PORT || '3003');
// Health check endpoint
app.get('/health', (c) => {
return c.json({
service: 'processing-service',
status: 'healthy',
timestamp: new Date().toISOString()
});
});
// Technical indicators endpoint
app.post('/api/indicators', async (c) => {
const body = await c.req.json();
logger.info('Technical indicators request', { indicators: body.indicators });
// TODO: Implement technical indicators processing
return c.json({
message: 'Technical indicators endpoint - not implemented yet',
requestedIndicators: body.indicators
});
});
// Vectorized processing endpoint
app.post('/api/vectorized/process', async (c) => {
const body = await c.req.json();
logger.info('Vectorized processing request', { dataPoints: body.data?.length });
// TODO: Implement vectorized processing
return c.json({
message: 'Vectorized processing endpoint - not implemented yet'
});
});
// Start server
serve({
fetch: app.fetch,
port: PORT,
});
logger.info(`Processing Service started on port ${PORT}`);
/**
* Processing Service - Technical indicators and data processing
*/
import { serve } from '@hono/node-server';
import { Hono } from 'hono';
import { loadEnvVariables } from '@stock-bot/config';
import { getLogger } from '@stock-bot/logger';
// Load environment variables
loadEnvVariables();
const app = new Hono();
const logger = getLogger('processing-service');
const PORT = parseInt(process.env.PROCESSING_SERVICE_PORT || '3003');
// Health check endpoint
app.get('/health', c => {
return c.json({
service: 'processing-service',
status: 'healthy',
timestamp: new Date().toISOString(),
});
});
// Technical indicators endpoint
app.post('/api/indicators', async c => {
const body = await c.req.json();
logger.info('Technical indicators request', { indicators: body.indicators });
// TODO: Implement technical indicators processing
return c.json({
message: 'Technical indicators endpoint - not implemented yet',
requestedIndicators: body.indicators,
});
});
// Vectorized processing endpoint
app.post('/api/vectorized/process', async c => {
const body = await c.req.json();
logger.info('Vectorized processing request', { dataPoints: body.data?.length });
// TODO: Implement vectorized processing
return c.json({
message: 'Vectorized processing endpoint - not implemented yet',
});
});
// Start server
serve({
fetch: app.fetch,
port: PORT,
});
logger.info(`Processing Service started on port ${PORT}`);

View file

@ -1,82 +1,77 @@
/**
* Technical Indicators Service
* Leverages @stock-bot/utils for calculations
*/
import { getLogger } from '@stock-bot/logger';
import {
sma,
ema,
rsi,
macd
} from '@stock-bot/utils';
const logger = getLogger('indicators-service');
export interface IndicatorRequest {
symbol: string;
data: number[];
indicators: string[];
parameters?: Record<string, any>;
}
export interface IndicatorResult {
symbol: string;
timestamp: Date;
indicators: Record<string, number[]>;
}
export class IndicatorsService {
async calculateIndicators(request: IndicatorRequest): Promise<IndicatorResult> {
logger.info('Calculating indicators', {
symbol: request.symbol,
indicators: request.indicators,
dataPoints: request.data.length
});
const results: Record<string, number[]> = {};
for (const indicator of request.indicators) {
try {
switch (indicator.toLowerCase()) {
case 'sma':
const smaPeriod = request.parameters?.smaPeriod || 20;
results.sma = sma(request.data, smaPeriod);
break;
case 'ema':
const emaPeriod = request.parameters?.emaPeriod || 20;
results.ema = ema(request.data, emaPeriod);
break;
case 'rsi':
const rsiPeriod = request.parameters?.rsiPeriod || 14;
results.rsi = rsi(request.data, rsiPeriod);
break;
case 'macd':
const fast = request.parameters?.macdFast || 12;
const slow = request.parameters?.macdSlow || 26;
const signal = request.parameters?.macdSignal || 9;
results.macd = macd(request.data, fast, slow, signal).macd;
break;
case 'stochastic':
// TODO: Implement stochastic oscillator
logger.warn('Stochastic oscillator not implemented yet');
break;
default:
logger.warn('Unknown indicator requested', { indicator });
}
} catch (error) {
logger.error('Error calculating indicator', { indicator, error });
}
}
return {
symbol: request.symbol,
timestamp: new Date(),
indicators: results
};
}
}
/**
* Technical Indicators Service
* Leverages @stock-bot/utils for calculations
*/
import { getLogger } from '@stock-bot/logger';
import { ema, macd, rsi, sma } from '@stock-bot/utils';
const logger = getLogger('indicators-service');
export interface IndicatorRequest {
symbol: string;
data: number[];
indicators: string[];
parameters?: Record<string, any>;
}
export interface IndicatorResult {
symbol: string;
timestamp: Date;
indicators: Record<string, number[]>;
}
export class IndicatorsService {
async calculateIndicators(request: IndicatorRequest): Promise<IndicatorResult> {
logger.info('Calculating indicators', {
symbol: request.symbol,
indicators: request.indicators,
dataPoints: request.data.length,
});
const results: Record<string, number[]> = {};
for (const indicator of request.indicators) {
try {
switch (indicator.toLowerCase()) {
case 'sma':
const smaPeriod = request.parameters?.smaPeriod || 20;
results.sma = sma(request.data, smaPeriod);
break;
case 'ema':
const emaPeriod = request.parameters?.emaPeriod || 20;
results.ema = ema(request.data, emaPeriod);
break;
case 'rsi':
const rsiPeriod = request.parameters?.rsiPeriod || 14;
results.rsi = rsi(request.data, rsiPeriod);
break;
case 'macd':
const fast = request.parameters?.macdFast || 12;
const slow = request.parameters?.macdSlow || 26;
const signal = request.parameters?.macdSignal || 9;
results.macd = macd(request.data, fast, slow, signal).macd;
break;
case 'stochastic':
// TODO: Implement stochastic oscillator
logger.warn('Stochastic oscillator not implemented yet');
break;
default:
logger.warn('Unknown indicator requested', { indicator });
}
} catch (error) {
logger.error('Error calculating indicator', { indicator, error });
}
}
return {
symbol: request.symbol,
timestamp: new Date(),
indicators: results,
};
}
}