From 7253d34983d686aa4ef643ec50af6ed0f6866892 Mon Sep 17 00:00:00 2001 From: nicolas Date: Thu, 28 May 2026 16:37:32 -0300 Subject: [PATCH] feat: make balance wait between live legs configurable, default off --- config.yaml.example | 1 + src/config.c | 3 +++ src/config.h | 1 + src/executor.c | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.yaml.example b/config.yaml.example index fc198da..4dda3b2 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -12,6 +12,7 @@ fused_engine: heartbeat_interval: 18.0 cooldown_seconds: 0.0 kcs_discount_active: false + balance_wait_enabled: false initial_capital: USDT: 5 USDC: 5 diff --git a/src/config.c b/src/config.c index c62c3c2..df4f43b 100644 --- a/src/config.c +++ b/src/config.c @@ -82,6 +82,8 @@ static void handle_value(parse_state_t *st, const char *val) { st->cfg->stats_interval_seconds = atof(val); } else if (strcmp(key, "concurrent_slots") == 0) { st->cfg->concurrent_slots = atoi(val); + } else if (strcmp(key, "balance_wait_enabled") == 0) { + st->cfg->balance_wait_enabled = (strcmp(val, "true") == 0 || strcmp(val, "yes") == 0); } } else if (strcmp(st->section, "executor") == 0) { return; @@ -127,6 +129,7 @@ int config_load(const char *path, config_t *cfg) { cfg->stats_interval_seconds = 60.0; cfg->concurrent_slots = 1; cfg->live_mode = false; + cfg->balance_wait_enabled = false; FILE *f = fopen(path, "r"); if (!f) { diff --git a/src/config.h b/src/config.h index 88f134a..46cb714 100644 --- a/src/config.h +++ b/src/config.h @@ -39,6 +39,7 @@ typedef struct { double stats_interval_seconds; /* period between stats log dumps */ int concurrent_slots; /* number of executor threads (1 = single-threaded) */ bool live_mode; /* live trading vs paper/simulation */ + bool balance_wait_enabled; /* wait for WS balance settlement between legs */ /* Capital allocation limits — each entry maps a currency ticker to a max * quote amount the fused engine may deploy for any one triangle signal. */ diff --git a/src/executor.c b/src/executor.c index 915fdce..48f246c 100644 --- a/src/executor.c +++ b/src/executor.c @@ -342,7 +342,7 @@ void executor_execute_triangle(executor_thread_t *et, fills[leg][3] = total_funds; /* ── Balance wait (live only): wait for KuCoin to settle before next leg ── */ - if (sig->live && leg < 2) { + if (sig->live && leg < 2 && et->cfg->balance_wait_enabled) { const char *pair = sl->symbol; const char *dash = strchr(pair, '-'); char out_ccy[16] = {0};