From cffb156231ca708e4cdeae35f9f580f6959edd63 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Sun, 15 Mar 2026 20:44:07 -0700 Subject: [PATCH] Feat: Add Momentum Rider strategy --- lib/strategies/momentum-rider.js | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 lib/strategies/momentum-rider.js diff --git a/lib/strategies/momentum-rider.js b/lib/strategies/momentum-rider.js new file mode 100644 index 0000000..bf9c752 --- /dev/null +++ b/lib/strategies/momentum-rider.js @@ -0,0 +1,56 @@ +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; + } +}