mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-17 05:51:02 +00:00
Feat: Split paper/live tracking, orderbook pricing
This commit is contained in:
@@ -6,42 +6,46 @@ export class DontDoubtBullStrategy extends BaseStrategy {
|
|||||||
minYesPct: config.minYesPct || 30,
|
minYesPct: config.minYesPct || 30,
|
||||||
maxYesPct: config.maxYesPct || 40,
|
maxYesPct: config.maxYesPct || 40,
|
||||||
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 || !state.closeTime) return null;
|
if (!state || !this.enabled || !state.closeTime) 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;
|
||||||
|
|
||||||
// 15 minute market total. First 1-5 minutes means 10 to 14 mins left.
|
|
||||||
const timeLeftMs = new Date(state.closeTime).getTime() - now;
|
const timeLeftMs = new Date(state.closeTime).getTime() - now;
|
||||||
const minsLeft = timeLeftMs / 60000;
|
const minsLeft = timeLeftMs / 60000;
|
||||||
|
if (minsLeft > 14 || minsLeft < 10) return null;
|
||||||
if (minsLeft > 14 || minsLeft < 10) return null; // Outside our time window
|
|
||||||
|
|
||||||
const { yesPct } = state;
|
const { yesPct } = state;
|
||||||
|
|
||||||
// Buy Yes if it's struggling early on
|
|
||||||
if (yesPct >= this.config.minYesPct && yesPct <= this.config.maxYesPct) {
|
if (yesPct >= this.config.minYesPct && yesPct <= this.config.maxYesPct) {
|
||||||
|
const maxPrice = Math.min(yesPct + this.config.slippage, 95);
|
||||||
|
|
||||||
const signal = {
|
const signal = {
|
||||||
strategy: this.name,
|
strategy: this.name,
|
||||||
side: 'yes',
|
side: 'yes',
|
||||||
price: yesPct,
|
price: yesPct,
|
||||||
|
maxPrice,
|
||||||
size: this.config.betSize,
|
size: this.config.betSize,
|
||||||
reason: `Early Bullish Dip: ${minsLeft.toFixed(1)}m left, Yes @ ${yesPct}¢`,
|
reason: `Early Bullish Dip: ${minsLeft.toFixed(1)}m left, Yes @ ${yesPct}¢`,
|
||||||
ticker: state.ticker
|
ticker: state.ticker
|
||||||
};
|
};
|
||||||
|
|
||||||
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