Files
Adriano 212427ffa1 feat(analysis): 3 strategie oneste validate OOS multi-crypto (DIP/TR/ROT)
Ricerca onesta post-squeeze su 8 crypto (2018-2026), engine fee-aware con
ingresso eseguibile a close[i], uscita TP/SL intrabar, OOS held-out, sweep fee.

Lezione madre: shortare cripto perde OOS sistematicamente (campione net-bull)
-> tutte le strategie robuste sono long-biased.

Tre meccanismi distinti e complementari:
- DIP01  dip-buy z-score reversion (long-only, 1h)  robusto BTC/ETH/SOL
- TR01   EMA 20/100 trend-following (long-only, 4h) robusto su 5/8 asset
- ROT01  rotazione cross-sectional momentum sul paniere (1d) OOS +44%, param-insensitive

Engine e validazione: scripts/analysis/honest_lab.py + honest_final.py
(+ honest_candidates/diag/diag2/trend/rotation). Diario in docs/diary/.

Onesto sull'obiettivo: €50/giorno su €1000 in pochi mesi non e' raggiungibile a
rischio sano (~1825%/anno); edge reali 30-60% OOS pluriennale. Via realistica:
portafoglio delle 3, leva moderata, crescita composta.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-28 23:28:00 +02:00

51 lines
1.8 KiB
Python

"""TR01 — EMA Trend Following (long-only), timeframe 4h.
Cavalca i trend rialzisti, si mette in cash nei downtrend. Niente short
(shortare cripto perde OOS nel campione 2018-2026). Complementare a DIP01:
DIP01 guadagna nei regimi di reversione, TR01 nei regimi di trend.
Logica:
1. EMA fast (20) e EMA slow (100) sul close
2. LONG quando EMA_fast > EMA_slow (uptrend), altrimenti CASH
3. posizione continua, decisione a close[i] (no look-ahead);
fee solo sui cambi di stato (poche operazioni = fee non letali)
Validazione (netto, fee 0.10% RT, leva 3x, pos 15%, OOS = ultimo 30%):
robusto FULL+OOS su 5/8 asset: BNB(+14), BTC(+27), DOGE(+53), SOL(+7), XRP(+29) OOS.
ETH ~flat, ADA/LTC negativi OOS -> preferire BNB/BTC/DOGE/SOL/XRP.
Dettagli in scripts/analysis/honest_final.py / honest_trend.py.
"""
from __future__ import annotations
import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(PROJECT_ROOT))
from scripts.analysis.honest_trend import ( # noqa: E402
simulate_position, ema_dual_signal, oos as trend_oos,
)
from scripts.analysis.honest_lab import get_df
ASSETS = ["BNB", "BTC", "DOGE", "SOL", "XRP"]
FAST, SLOW, TF = 20, 100, "4h"
def run():
print("=" * 90)
print(f" TR01 EMA TREND {FAST}/{SLOW} long-only | {TF} | netto fee 0.10% RT leva 3x pos 15%")
print("=" * 90)
print(f" {'Asset':<6s}{'Flip':>6s}{'FULL%':>9s}{'OOS%':>9s}{'DD%':>6s}{'Exp%':>6s}{'AnniPos':>9s}")
for a in ASSETS:
df = get_df(a, TF)
sig = ema_dual_signal(df, FAST, SLOW, long_only=True)
f = simulate_position(sig, df)
o = trend_oos(sig, df)
print(f" {a:<6s}{f['flips']:>6d}{f['ret']:>+9.0f}{o['ret']:>+9.0f}"
f"{f['dd']:>6.0f}{f['exposure']:>6.0f}{str(f['pos_years'])+'/'+str(f['n_years']):>9s}")
if __name__ == "__main__":
run()