import { BaseStrategy } from './base.js'; export class BullDipBuyer extends BaseStrategy { constructor(config = {}) { super('bull-dip-buyer', { maxYesPrice: config.maxYesPrice || 45, // Buy the dip when Yes is cheap minYesPrice: config.minYesPrice || 15, // Avoid completely dead markets betSize: config.betSize || 1, // Changed to $1 per Master's orders! 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 } = state; // Only buy YES when it dips into our target buy zone if (yesPct <= this.config.maxYesPrice && yesPct >= this.config.minYesPrice) { const signal = { strategy: this.name, side: 'yes', price: yesPct, size: this.config.betSize, reason: `Bullish dip buy: Yes dropped to ${yesPct}ยข`, ticker: state.ticker }; this.lastTradeTime = now; this.lastTradeTicker = state.ticker; return signal; } return null; } }