fix(live): ROT02/TSM01 scartano la barra 1d in formazione (forming-bar in _panel)

Code-review follow-up: i worker daily valutavano momentum/regime e bookavano il
return sulla candela 1d PARZIALE al primo poll dopo mezzanotte UTC, poi last_bar_ts
bloccava la rivalutazione a giorno chiuso (stessa classe del bug gia' fixato su
fade/TR01/Pairs). Fix in _panel (un punto solo -> ROT02 e TSM01 lo ereditano) via
src.live.bars.last_bar_is_forming. Replay honest invariato (dati storici: nessuna
barra in formazione). Test: 88/88 + parity drop forming daily bar.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal Pastro
2026-06-08 10:00:16 +00:00
parent 7f4378190e
commit f509f51543
2 changed files with 26 additions and 1 deletions
+16
View File
@@ -47,6 +47,22 @@ def test_rotation_warns_once_on_short_panel(tmp_path, monkeypatch):
assert w._panel_warned is False
def test_panel_drops_forming_daily_bar(tmp_path):
# serie 1d che termina ADESSO -> l'ultima riga e' la candela 1d in formazione
import time
from src.live.rotation_worker import _panel
n = 200
now = int(time.time() * 1000)
ts = now - 86_400_000 * np.arange(n - 1, -1, -1)
def mk(slope):
c = np.linspace(100, 100 + slope * n, n)
return pd.DataFrame({"timestamp": ts, "open": c, "high": c, "low": c,
"close": c, "volume": 1.0})
panel, cols = _panel({"BTC": mk(1.0), "AAA": mk(2.0)}, ["BTC", "AAA"])
assert len(panel) == n - 1 # barra in formazione scartata
assert int(panel["timestamp"].iloc[-1]) == int(ts[-2])
def test_rotation_no_warn_on_cold_start(tmp_path, monkeypatch):
calls = []
monkeypatch.setattr("src.live.telegram_notifier.notify_event",