mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-16 21:41:02 +00:00
Feat: Add Bull Dip Buyer strategy
This commit is contained in:
44
lib/strategies/bull-dip-buyer.js
Normal file
44
lib/strategies/bull-dip-buyer.js
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user