diff --git a/lib/strategies/dont-doubt-bull.js b/lib/strategies/dont-doubt-bull.js index 0d3f646..077cfe0 100644 --- a/lib/strategies/dont-doubt-bull.js +++ b/lib/strategies/dont-doubt-bull.js @@ -6,42 +6,46 @@ export class DontDoubtBullStrategy extends BaseStrategy { minYesPct: config.minYesPct || 30, maxYesPct: config.maxYesPct || 40, betSize: config.betSize || 2, - cooldownMs: config.cooldownMs || 60000, + slippage: config.slippage || 3, + cooldownMs: config.cooldownMs || 20000, ...config }); - - this.lastTradeTime = 0; - this.lastTradeTicker = null; + + this._lastTrade = { + paper: { time: 0, ticker: null }, + live: { time: 0, ticker: null } + }; } - evaluate(state) { + evaluate(state, caller = 'paper') { if (!state || !this.enabled || !state.closeTime) return null; + const track = this._lastTrade[caller] || this._lastTrade.paper; const now = Date.now(); - if (now - this.lastTradeTime < this.config.cooldownMs) return null; - if (state.ticker === this.lastTradeTicker) return null; + if (now - track.time < this.config.cooldownMs) return null; + if (state.ticker === track.ticker) 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 + if (minsLeft > 14 || minsLeft < 10) return null; const { yesPct } = state; - // Buy Yes if it's struggling early on if (yesPct >= this.config.minYesPct && yesPct <= this.config.maxYesPct) { + const maxPrice = Math.min(yesPct + this.config.slippage, 95); + const signal = { strategy: this.name, side: 'yes', price: yesPct, + maxPrice, 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; + track.time = now; + track.ticker = state.ticker; return signal; }