mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-17 05:51: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';
|
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 {
|
export class MartingaleStrategy extends BaseStrategy {
|
||||||
constructor(config = {}) {
|
constructor(config = {}) {
|
||||||
super('martingale', {
|
super('martingale', {
|
||||||
threshold: config.threshold || 70, // Trigger when one side >= this %
|
threshold: config.threshold || 70,
|
||||||
baseBet: config.baseBet || 1, // Base bet in dollars
|
baseBet: config.baseBet || 1,
|
||||||
maxDoublings: config.maxDoublings || 5, // Max consecutive losses before stopping
|
maxDoublings: config.maxDoublings || 5,
|
||||||
cooldownMs: config.cooldownMs || 60000, // Min time between trades (1 min)
|
cooldownMs: config.cooldownMs || 60000,
|
||||||
...config
|
...config
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,24 +21,17 @@ export class MartingaleStrategy extends BaseStrategy {
|
|||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
// Cooldown — don't spam trades
|
|
||||||
if (now - this.lastTradeTime < this.config.cooldownMs) return null;
|
if (now - this.lastTradeTime < this.config.cooldownMs) return null;
|
||||||
|
|
||||||
// Don't trade same ticker twice
|
|
||||||
if (state.ticker === this.lastTradeTicker) return null;
|
if (state.ticker === this.lastTradeTicker) return null;
|
||||||
|
if (this.consecutiveLosses >= this.config.maxDoublings) return null;
|
||||||
// Check if Martingale limit reached
|
|
||||||
if (this.consecutiveLosses >= this.config.maxDoublings) {
|
|
||||||
return null; // Paused — too many consecutive losses
|
|
||||||
}
|
|
||||||
|
|
||||||
const { yesPct, noPct } = state;
|
const { yesPct, noPct } = state;
|
||||||
const threshold = this.config.threshold;
|
const threshold = this.config.threshold;
|
||||||
|
|
||||||
let signal = null;
|
let signal = null;
|
||||||
|
|
||||||
// If "Yes" is at 70%+, bet "No" (the underdog)
|
// Prevent buying useless contracts at >= 99¢ (which would result in $0 or 0.01¢ profit)
|
||||||
if (yesPct >= threshold) {
|
if (yesPct >= threshold && noPct < 99) {
|
||||||
signal = {
|
signal = {
|
||||||
strategy: this.name,
|
strategy: this.name,
|
||||||
side: 'no',
|
side: 'no',
|
||||||
@@ -57,8 +41,7 @@ export class MartingaleStrategy extends BaseStrategy {
|
|||||||
ticker: state.ticker
|
ticker: state.ticker
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// If "No" is at 70%+, bet "Yes" (the underdog)
|
else if (noPct >= threshold && yesPct < 99) {
|
||||||
else if (noPct >= threshold) {
|
|
||||||
signal = {
|
signal = {
|
||||||
strategy: this.name,
|
strategy: this.name,
|
||||||
side: 'yes',
|
side: 'yes',
|
||||||
|
|||||||
Reference in New Issue
Block a user