Feat: support YES+NO late momentum

This commit is contained in:
2026-03-16 18:43:02 -07:00
parent 0301b8a0ae
commit fa5303d9dc

View File

@@ -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,28 +44,37 @@ 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;
if (yesPct >= this.config.triggerPct && yesPct < 99) { const trigger = this.config.triggerPct;
const signal = { const candidates = [];
strategy: this.name,
side: 'yes',
price: yesPct,
maxPrice: Math.min(yesPct + this.config.slippage, 95),
size: this.config.betSize,
reason: `Late momentum: t+${elapsedMin.toFixed(1)}m, YES @ ${yesPct}¢`,
ticker: state.ticker
};
track.time = now; if (yesPct >= trigger && yesPct < 99) candidates.push({ side: 'yes', pct: yesPct });
track.ticker = state.ticker; if (noPct >= trigger && noPct < 99) candidates.push({ side: 'no', pct: noPct });
return signal;
}
return null; 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];
const signal = {
strategy: this.name,
side: pick.side,
price: pick.pct,
maxPrice: Math.min(pick.pct + this.config.slippage, 95),
size: this.config.betSize,
reason: `Late momentum: t+${elapsedMin.toFixed(1)}m, ${pick.side.toUpperCase()} @ ${pick.pct}¢`,
ticker: state.ticker
};
track.time = now;
track.ticker = state.ticker;
return signal;
} }
} }