SniperGold_ML/ml/probe_density.py

36 lines
1.5 KiB
Python
Raw Permalink Normal View History

# -*- coding: utf-8 -*-
"""Analisis densitas bar XAUUSD M15 (feed HFM) — untuk keputusan label & konsistensi."""
import os
import numpy as np
import datetime as dt
BASE = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
"..", "..", "..", "Files", "AlgoForge", "Data"))
z = np.load(os.path.join(BASE, "XAUUSD_M15.npz"))
t = z["time"].astype(np.int64)
print("n =", len(t))
days = t // 86400
uniq, cnt = np.unique(days, return_counts=True)
print("hari dengan data:", len(uniq), "| span hari:", days[-1] - days[0] + 1)
print("bars/hari: mean=%.1f median=%d p10=%d p90=%d max=%d"
% (cnt.mean(), np.median(cnt), np.percentile(cnt, 10), np.percentile(cnt, 90), cnt.max()))
for label, lo, hi in [("2008", 2008, 2009), ("2015", 2015, 2016), ("2024", 2024, 2025)]:
lo_ts = dt.datetime(lo, 1, 1).timestamp()
hi_ts = dt.datetime(hi, 1, 1).timestamp()
sl = (t >= lo_ts) & (t < hi_ts)
tt = t[sl]
if len(tt) == 0:
print(label, "n=0")
continue
hrs = (tt % 86400) // 3600
u, c = np.unique(hrs, return_counts=True)
top = u[np.argsort(-c)][:8]
print(label, "n=", len(tt), "jam terbanyak(UTC):", sorted(int(x) for x in top))
d = np.diff(t)
big = d[d > 3 * 3600]
print("gap >3jam:", len(big), "| max gap:", big.max() // 3600, "jam")
print("gap 3-6 jam (indikasi break harian):", int(np.sum((d > 3 * 3600) & (d <= 6 * 3600))))
print("gap 6-48 jam (malam/libur):", int(np.sum((d > 6 * 3600) & (d <= 2 * 86400))))