Add granular logging across all source files
Introduce logger infrastructure and add structured logging to every layer: alpaca.ts (buy/sell/quote/clock), momentum-indicator.ts (evaluate flow), momentum-strategy.ts (poll loop), index.ts (startup/cycle), and trading.ts (market timing). Replace raw console.log calls with leveled logger. Update all tests with appropriate console spies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Alpaca } from "./alpaca";
|
||||
import { Indicator } from "./indicator";
|
||||
import { logger } from "./logger";
|
||||
import { wait } from "./trading";
|
||||
|
||||
export interface MomentumResult {
|
||||
@@ -29,15 +30,17 @@ export class MomentumIndicator implements Indicator<MomentumResult> {
|
||||
}
|
||||
|
||||
async evaluate(alpaca: Alpaca): Promise<MomentumResult> {
|
||||
logger.debug(`waiting ${this.config.settleDelay}ms for market to settle`);
|
||||
await wait(this.config.settleDelay);
|
||||
|
||||
const priceBefore = await alpaca.getLatestAsk(this.config.symbol);
|
||||
|
||||
logger.debug(`${this.config.symbol} priceBefore: ${priceBefore}`);
|
||||
|
||||
await wait(this.config.sampleDelay);
|
||||
|
||||
const priceAfter = await alpaca.getLatestAsk(this.config.symbol);
|
||||
|
||||
const direction = priceAfter >= priceBefore ? 'up' : 'down';
|
||||
logger.debug(`${this.config.symbol} priceAfter: ${priceAfter} → direction: ${direction}`);
|
||||
|
||||
return { direction, priceBefore, priceAfter };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user