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', {
|
super('momentum-rider', {
|
||||||
triggerPct: config.triggerPct || 75,
|
triggerPct: config.triggerPct || 75,
|
||||||
betSize: config.betSize || 2,
|
betSize: config.betSize || 2,
|
||||||
cooldownMs: config.cooldownMs || 60000,
|
slippage: config.slippage || 3,
|
||||||
|
cooldownMs: config.cooldownMs || 20000,
|
||||||
...config
|
...config
|
||||||
});
|
});
|
||||||
|
|
||||||
this.lastTradeTime = 0;
|
this._lastTrade = {
|
||||||
this.lastTradeTicker = null;
|
paper: { time: 0, ticker: null },
|
||||||
|
live: { time: 0, ticker: null }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate(state) {
|
evaluate(state, caller = 'paper') {
|
||||||
if (!state || !this.enabled) return null;
|
if (!state || !this.enabled) return null;
|
||||||
|
|
||||||
|
const track = this._lastTrade[caller] || this._lastTrade.paper;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (now - this.lastTradeTime < this.config.cooldownMs) return null;
|
if (now - track.time < this.config.cooldownMs) return null;
|
||||||
if (state.ticker === this.lastTradeTicker) return null;
|
if (state.ticker === track.ticker) return null;
|
||||||
|
|
||||||
const { yesPct, noPct } = state;
|
const { yesPct, noPct } = state;
|
||||||
const trigger = this.config.triggerPct;
|
const trigger = this.config.triggerPct;
|
||||||
|
|
||||||
let signal = null;
|
let signal = null;
|
||||||
|
|
||||||
// Buy the favorite!
|
|
||||||
if (yesPct >= trigger && yesPct < 99) {
|
if (yesPct >= trigger && yesPct < 99) {
|
||||||
signal = {
|
signal = {
|
||||||
strategy: this.name,
|
strategy: this.name,
|
||||||
side: 'yes',
|
side: 'yes',
|
||||||
price: yesPct,
|
price: yesPct,
|
||||||
|
maxPrice: Math.min(yesPct + this.config.slippage, 95),
|
||||||
size: this.config.betSize,
|
size: this.config.betSize,
|
||||||
reason: `Riding Momentum! Yes is at ${yesPct}%`,
|
reason: `Riding Momentum! Yes is at ${yesPct}%`,
|
||||||
ticker: state.ticker
|
ticker: state.ticker
|
||||||
@@ -40,6 +44,7 @@ export class MomentumRiderStrategy extends BaseStrategy {
|
|||||||
strategy: this.name,
|
strategy: this.name,
|
||||||
side: 'no',
|
side: 'no',
|
||||||
price: noPct,
|
price: noPct,
|
||||||
|
maxPrice: Math.min(noPct + this.config.slippage, 95),
|
||||||
size: this.config.betSize,
|
size: this.config.betSize,
|
||||||
reason: `Riding Momentum! No is at ${noPct}%`,
|
reason: `Riding Momentum! No is at ${noPct}%`,
|
||||||
ticker: state.ticker
|
ticker: state.ticker
|
||||||
@@ -47,8 +52,8 @@ export class MomentumRiderStrategy extends BaseStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (signal) {
|
if (signal) {
|
||||||
this.lastTradeTime = now;
|
track.time = now;
|
||||||
this.lastTradeTicker = state.ticker;
|
track.ticker = state.ticker;
|
||||||
}
|
}
|
||||||
|
|
||||||
return signal;
|
return signal;
|
||||||
|
|||||||
Reference in New Issue
Block a user