diff --git a/lib/strategies/bull-dip-buyer.js b/lib/strategies/bull-dip-buyer.js new file mode 100644 index 0000000..72a5032 --- /dev/null +++ b/lib/strategies/bull-dip-buyer.js @@ -0,0 +1,44 @@ +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 || 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 } = 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; + } +}