Feat: Add Bull Dip Buyer strategy

This commit is contained in:
2026-03-15 20:43:40 -07:00
parent 1999377682
commit 4feed18ce0

View File

@@ -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;
}
}