From 041f010a305f03d208e64d6860fc17f13b7596d1 Mon Sep 17 00:00:00 2001 From: k Date: Sat, 30 May 2026 03:07:43 +0800 Subject: [PATCH] fix(kol): count 'reduce' action in divergence detection (was silently dropped) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kol-v2 added the 'reduce' action (KOL partially trimming a long), but kol_divergence._POST_LONG/_POST_SHORT predate it, so any post whose ticker action was 'reduce' was skipped by the 'not in (_POST_LONG|_POST_SHORT)' guard — the divergence scan never saw it. That dropped a high-value case: a KOL publicly trimming/taking profit on an asset while their on-chain wallet is ADDING is exactly the talks-vs-trades mismatch this module exists to surface. 'reduce' is a short-leaning stance, so it now joins _POST_SHORT: reduce + chain adding → divergence (long) reduce + chain reducing → alignment (short) 72 tests pass. Co-Authored-By: Claude Sonnet 4.6 --- app/services/kol_divergence.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/services/kol_divergence.py b/app/services/kol_divergence.py index 58ef040..5ce763a 100644 --- a/app/services/kol_divergence.py +++ b/app/services/kol_divergence.py @@ -14,9 +14,12 @@ Two outcomes: Logic: - post side → action ∈ {buy, bullish} = LONG intent - {sell, bearish} = SHORT intent - {mention} = skip (no clear view) + post side → action ∈ {buy, bullish} = LONG intent + {sell, bearish, reduce} = SHORT intent + {mention} = skip (no clear view) + (reduce = partial profit-take / trimming a long → a + risk-reducing, short-leaning stance. Counting it lets us + catch "publicly trimming BTC but wallet is adding" divergence.) chain side → change_type ∈ {new_position, increased} = LONG action {decreased, closed} = SHORT action @@ -54,8 +57,11 @@ WINDOW_DAYS = 7 MIN_USD_CHANGE = 10_000 # Post actions that map to a directional view (skip 'mention') +# 'reduce' (kol-v2: partial profit-take / trimming a long) is a short-leaning +# stance — include it so a "trimming publicly while accumulating on-chain" +# mismatch is caught instead of silently dropped. _POST_LONG = {"buy", "bullish"} -_POST_SHORT = {"sell", "bearish"} +_POST_SHORT = {"sell", "bearish", "reduce"} # On-chain actions that map to a direction _CHAIN_LONG = {"new_position", "increased"}