mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-16 21:41:02 +00:00
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
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;
|
|
}
|
|
}
|