import { BaseStrategy } from './base.js'; export class MomentumRiderStrategy extends BaseStrategy { constructor(config = {}) { super('momentum-rider', { triggerPct: config.triggerPct || 75, betSize: config.betSize || 2, cooldownMs: config.cooldownMs || 60000, ...config }); this.lastTradeTime = 0; this.lastTradeTicker = null; } evaluate(state) { if (!state || !this.enabled) return null; const now = Date.now(); if (now - this.lastTradeTime < this.config.cooldownMs) return null; if (state.ticker === this.lastTradeTicker) return null; const { yesPct, noPct } = state; const trigger = this.config.triggerPct; let signal = null; // Buy the favorite! if (yesPct >= trigger && yesPct < 99) { signal = { strategy: this.name, side: 'yes', price: yesPct, size: this.config.betSize, reason: `Riding Momentum! Yes is at ${yesPct}%`, ticker: state.ticker }; } else if (noPct >= trigger && noPct < 99) { signal = { strategy: this.name, side: 'no', price: noPct, size: this.config.betSize, reason: `Riding Momentum! No is at ${noPct}%`, ticker: state.ticker }; } if (signal) { this.lastTradeTime = now; this.lastTradeTicker = state.ticker; } return signal; } }