mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-17 14:01:02 +00:00
Feat: support YES+NO late momentum
This commit is contained in:
@@ -4,8 +4,8 @@ import { BaseStrategy } from './base.js';
|
|||||||
* Late Momentum Strategy
|
* Late Momentum Strategy
|
||||||
*
|
*
|
||||||
* Rules:
|
* Rules:
|
||||||
* - Only buys YES momentum
|
* - Buys momentum on YES or NO
|
||||||
* - Requires YES price >= triggerPct (default 75)
|
* - Requires side price >= triggerPct (default 75)
|
||||||
* - Only allowed after first 5 minutes of market lifecycle
|
* - Only allowed after first 5 minutes of market lifecycle
|
||||||
* - Default window: elapsed minute 5 through 15
|
* - Default window: elapsed minute 5 through 15
|
||||||
*/
|
*/
|
||||||
@@ -44,20 +44,32 @@ export class LateMomentumStrategy extends BaseStrategy {
|
|||||||
const elapsedMin = (this.config.marketDurationMin * 60000 - timeLeftMs) / 60000;
|
const elapsedMin = (this.config.marketDurationMin * 60000 - timeLeftMs) / 60000;
|
||||||
if (!Number.isFinite(elapsedMin)) return null;
|
if (!Number.isFinite(elapsedMin)) return null;
|
||||||
|
|
||||||
// Skip first 5 minutes; trade only in configured late window.
|
// Skip first minutes; trade only in configured late window.
|
||||||
if (elapsedMin < this.config.minElapsedMin || elapsedMin > this.config.maxElapsedMin) return null;
|
if (elapsedMin < this.config.minElapsedMin || elapsedMin > this.config.maxElapsedMin) return null;
|
||||||
|
|
||||||
const yesPct = Number(state.yesPct);
|
const yesPct = Number(state.yesPct);
|
||||||
if (!Number.isFinite(yesPct)) return null;
|
const noPct = Number(state.noPct);
|
||||||
|
if (!Number.isFinite(yesPct) || !Number.isFinite(noPct)) return null;
|
||||||
|
|
||||||
|
const trigger = this.config.triggerPct;
|
||||||
|
const candidates = [];
|
||||||
|
|
||||||
|
if (yesPct >= trigger && yesPct < 99) candidates.push({ side: 'yes', pct: yesPct });
|
||||||
|
if (noPct >= trigger && noPct < 99) candidates.push({ side: 'no', pct: noPct });
|
||||||
|
|
||||||
|
if (!candidates.length) return null;
|
||||||
|
|
||||||
|
// Prefer the stronger momentum side if both qualify.
|
||||||
|
candidates.sort((a, b) => b.pct - a.pct);
|
||||||
|
const pick = candidates[0];
|
||||||
|
|
||||||
if (yesPct >= this.config.triggerPct && yesPct < 99) {
|
|
||||||
const signal = {
|
const signal = {
|
||||||
strategy: this.name,
|
strategy: this.name,
|
||||||
side: 'yes',
|
side: pick.side,
|
||||||
price: yesPct,
|
price: pick.pct,
|
||||||
maxPrice: Math.min(yesPct + this.config.slippage, 95),
|
maxPrice: Math.min(pick.pct + this.config.slippage, 95),
|
||||||
size: this.config.betSize,
|
size: this.config.betSize,
|
||||||
reason: `Late momentum: t+${elapsedMin.toFixed(1)}m, YES @ ${yesPct}¢`,
|
reason: `Late momentum: t+${elapsedMin.toFixed(1)}m, ${pick.side.toUpperCase()} @ ${pick.pct}¢`,
|
||||||
ticker: state.ticker
|
ticker: state.ticker
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +77,4 @@ export class LateMomentumStrategy extends BaseStrategy {
|
|||||||
track.ticker = state.ticker;
|
track.ticker = state.ticker;
|
||||||
return signal;
|
return signal;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user