mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-16 21:41:02 +00:00
Feat: Split paper/live tracking, orderbook pricing
This commit is contained in:
@@ -5,32 +5,36 @@ export class MomentumRiderStrategy extends BaseStrategy {
|
||||
super('momentum-rider', {
|
||||
triggerPct: config.triggerPct || 75,
|
||||
betSize: config.betSize || 2,
|
||||
cooldownMs: config.cooldownMs || 60000,
|
||||
slippage: config.slippage || 3,
|
||||
cooldownMs: config.cooldownMs || 20000,
|
||||
...config
|
||||
});
|
||||
|
||||
this.lastTradeTime = 0;
|
||||
this.lastTradeTicker = null;
|
||||
|
||||
this._lastTrade = {
|
||||
paper: { time: 0, ticker: null },
|
||||
live: { time: 0, ticker: null }
|
||||
};
|
||||
}
|
||||
|
||||
evaluate(state) {
|
||||
evaluate(state, caller = 'paper') {
|
||||
if (!state || !this.enabled) return null;
|
||||
|
||||
const track = this._lastTrade[caller] || this._lastTrade.paper;
|
||||
const now = Date.now();
|
||||
if (now - this.lastTradeTime < this.config.cooldownMs) return null;
|
||||
if (state.ticker === this.lastTradeTicker) return null;
|
||||
if (now - track.time < this.config.cooldownMs) return null;
|
||||
if (state.ticker === track.ticker) 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,
|
||||
maxPrice: Math.min(yesPct + this.config.slippage, 95),
|
||||
size: this.config.betSize,
|
||||
reason: `Riding Momentum! Yes is at ${yesPct}%`,
|
||||
ticker: state.ticker
|
||||
@@ -40,6 +44,7 @@ export class MomentumRiderStrategy extends BaseStrategy {
|
||||
strategy: this.name,
|
||||
side: 'no',
|
||||
price: noPct,
|
||||
maxPrice: Math.min(noPct + this.config.slippage, 95),
|
||||
size: this.config.betSize,
|
||||
reason: `Riding Momentum! No is at ${noPct}%`,
|
||||
ticker: state.ticker
|
||||
@@ -47,8 +52,8 @@ export class MomentumRiderStrategy extends BaseStrategy {
|
||||
}
|
||||
|
||||
if (signal) {
|
||||
this.lastTradeTime = now;
|
||||
this.lastTradeTicker = state.ticker;
|
||||
track.time = now;
|
||||
track.ticker = state.ticker;
|
||||
}
|
||||
|
||||
return signal;
|
||||
|
||||
Reference in New Issue
Block a user