import { BaseStrategy } from './base.js'; export class DontDoubtBullStrategy extends BaseStrategy { constructor(config = {}) { super('dont-doubt-bull', { minYesPct: config.minYesPct || 30, maxYesPct: config.maxYesPct || 40, betSize: config.betSize || 2, cooldownMs: config.cooldownMs || 60000, ...config }); this.lastTradeTime = 0; this.lastTradeTicker = null; } evaluate(state) { if (!state || !this.enabled || !state.closeTime) return null; const now = Date.now(); if (now - this.lastTradeTime < this.config.cooldownMs) return null; if (state.ticker === this.lastTradeTicker) return null; // 15 minute market total. First 1-5 minutes means 10 to 14 mins left. const timeLeftMs = new Date(state.closeTime).getTime() - now; const minsLeft = timeLeftMs / 60000; if (minsLeft > 14 || minsLeft < 10) return null; // Outside our time window const { yesPct } = state; // Buy Yes if it's struggling early on if (yesPct >= this.config.minYesPct && yesPct <= this.config.maxYesPct) { const signal = { strategy: this.name, side: 'yes', price: yesPct, size: this.config.betSize, reason: `Early Bullish Dip: ${minsLeft.toFixed(1)}m left, Yes @ ${yesPct}ยข`, ticker: state.ticker }; this.lastTradeTime = now; this.lastTradeTicker = state.ticker; return signal; } return null; } }