fix(live): parita' worker multi-asset — TR01 fee x leva, forming-bar su TR01/Pairs, WARN panel corto
Punti 2-4 dell'improvement-sweep 2026-06-06 (fix di parita', nessun cambio di strategia): - TR01 (basket_trend_worker): fee per flip = POS * LEV * fee_rt/2 come il reference honest_improve2._tr_basket_daily:150 (mancava il fattore leva -> fee sotto-caricate 2x, bias ottimistico che gonfiava total_capital al ribilancio). - TR01: crossover EMA e booking del return valutati SOLO su barre 4h COMPLETE (la riga -1 e' la candela in corso finche' non e' trascorsa la sua durata) — lezione EXIT-16; evidenza live: flip SOL 0->1->0 in 59min nella stessa finestra 4h. - PairsWorker: entry ED exit valutati sul close di barra COMPLETA, come il backtest pairs_research (close settled). Stesso pattern bar_ms di strategy_worker.tick. - TSM01/ROT02: il silent return su panel inner-join troncato sotto il lookback ora emette WARN log + Telegram PANEL_SHORT (helper _warn_panel_short condiviso), gated su "era gia' operativo" (no falsi positivi al cold-start), una notifica per episodio. Test: 72/72 verdi (7 nuovi: forming-bar TR01/pairs + controllo positivo, fee con leva, PANEL_SHORT warn/dedup/cold-start). Replay parity: validate_worker_pairs ESATTO (ETH/BTC e BTC/LTC == backtest); validate_honest_workers invariato (TR01 -44% vs ref +42% IDENTICO pre/post fix: e' la divergenza di convenzione capitale-unico vs media-equity gia' documentata, da rivisitare a parte). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ Stato persistente (resume al restart) e log come StrategyWorker.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
@@ -178,6 +179,14 @@ class PairsWorker:
|
||||
m = df_a[["timestamp", "close"]].rename(columns={"close": "ca"}).merge(
|
||||
df_b[["timestamp", "close"]].rename(columns={"close": "cb"}), on="timestamp", how="inner"
|
||||
).sort_values("timestamp").reset_index(drop=True)
|
||||
# Scarta la barra IN FORMAZIONE (la riga -1 e' la candela in corso finche'
|
||||
# non e' trascorsa la sua durata): entry ED exit valutati SOLO sul close di
|
||||
# barra COMPLETA, come il backtest (pairs_research: close settled) —
|
||||
# lezione EXIT-16 (strategy_worker.tick).
|
||||
ts_arr = m["timestamp"].values.astype("int64")
|
||||
bar_ms = int(np.median(np.diff(ts_arr[-50:]))) if len(ts_arr) > 1 else 0
|
||||
if bar_ms and int(time.time() * 1000) < int(ts_arr[-1]) + bar_ms:
|
||||
m = m.iloc[:-1]
|
||||
if len(m) < self.n + 2:
|
||||
return
|
||||
ca, cb = m["ca"].values, m["cb"].values
|
||||
|
||||
Reference in New Issue
Block a user