mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-16 21:41:02 +00:00
Fix: Prevent bot from placing 100¢ trades with zero profit potential
This commit is contained in:
@@ -1,21 +1,12 @@
|
||||
import { BaseStrategy } from './base.js';
|
||||
|
||||
/**
|
||||
* Martingale Strategy
|
||||
*
|
||||
* Logic:
|
||||
* - If one side is ~70%+ (configurable), bet the opposite side.
|
||||
* - On loss, double the bet size (Martingale).
|
||||
* - On win, reset to base bet size.
|
||||
* - Max consecutive losses cap to prevent blowup.
|
||||
*/
|
||||
export class MartingaleStrategy extends BaseStrategy {
|
||||
constructor(config = {}) {
|
||||
super('martingale', {
|
||||
threshold: config.threshold || 70, // Trigger when one side >= this %
|
||||
baseBet: config.baseBet || 1, // Base bet in dollars
|
||||
maxDoublings: config.maxDoublings || 5, // Max consecutive losses before stopping
|
||||
cooldownMs: config.cooldownMs || 60000, // Min time between trades (1 min)
|
||||
threshold: config.threshold || 70,
|
||||
baseBet: config.baseBet || 1,
|
||||
maxDoublings: config.maxDoublings || 5,
|
||||
cooldownMs: config.cooldownMs || 60000,
|
||||
...config
|
||||
});
|
||||
|
||||
@@ -30,24 +21,17 @@ export class MartingaleStrategy extends BaseStrategy {
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
// Cooldown — don't spam trades
|
||||
if (now - this.lastTradeTime < this.config.cooldownMs) return null;
|
||||
|
||||
// Don't trade same ticker twice
|
||||
if (state.ticker === this.lastTradeTicker) return null;
|
||||
|
||||
// Check if Martingale limit reached
|
||||
if (this.consecutiveLosses >= this.config.maxDoublings) {
|
||||
return null; // Paused — too many consecutive losses
|
||||
}
|
||||
if (this.consecutiveLosses >= this.config.maxDoublings) return null;
|
||||
|
||||
const { yesPct, noPct } = state;
|
||||
const threshold = this.config.threshold;
|
||||
|
||||
let signal = null;
|
||||
|
||||
// If "Yes" is at 70%+, bet "No" (the underdog)
|
||||
if (yesPct >= threshold) {
|
||||
// Prevent buying useless contracts at >= 99¢ (which would result in $0 or 0.01¢ profit)
|
||||
if (yesPct >= threshold && noPct < 99) {
|
||||
signal = {
|
||||
strategy: this.name,
|
||||
side: 'no',
|
||||
@@ -57,8 +41,7 @@ export class MartingaleStrategy extends BaseStrategy {
|
||||
ticker: state.ticker
|
||||
};
|
||||
}
|
||||
// If "No" is at 70%+, bet "Yes" (the underdog)
|
||||
else if (noPct >= threshold) {
|
||||
else if (noPct >= threshold && yesPct < 99) {
|
||||
signal = {
|
||||
strategy: this.name,
|
||||
side: 'yes',
|
||||
|
||||
Reference in New Issue
Block a user