/** * Base strategy class. All strategies extend this. * * Strategies receive market state updates and emit trade signals. * Signals are { side: 'yes'|'no', price: number, size: number, reason: string } */ export class BaseStrategy { constructor(name, config = {}) { this.name = name; this.config = config; this.enabled = true; this.mode = 'paper'; // 'paper' | 'live' } /** * Called on every market state update. * Return a signal object or null. */ evaluate(marketState) { throw new Error(`${this.name}: evaluate() not implemented`); } /** * Called when a market settles. Useful for strategies that * need to know outcomes (like Martingale). */ onSettlement(result, tradeHistory) { // Override in subclass if needed } toJSON() { return { name: this.name, enabled: this.enabled, mode: this.mode, config: this.config }; } }