mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-17 05:51:02 +00:00
Feat: Add Momentum Rider strategy
This commit is contained in:
56
lib/strategies/momentum-rider.js
Normal file
56
lib/strategies/momentum-rider.js
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user