added Huobi HTX data provider

This commit is contained in:
Dobromir Popov
2025-08-10 02:23:22 +03:00
parent b17d53510a
commit 4ea2386d07
3 changed files with 357 additions and 1 deletions

View File

@ -58,6 +58,12 @@ logger = logging.getLogger(__name__)
# Reduce Werkzeug/Dash logging noise
logging.getLogger('werkzeug').setLevel(logging.WARNING)
# Type imports for linter clarity (not required at runtime)
try:
from core.data_models import BaseDataInput, OHLCVBar, COBData, PivotPoint # noqa: F401
except Exception:
pass
logging.getLogger('dash').setLevel(logging.WARNING)
logging.getLogger('dash.dash').setLevel(logging.WARNING)
@ -2416,6 +2422,50 @@ class CleanTradingDashboard:
# Mini 1-second chart (if available)
if has_mini_chart and ws_data_1s is not None:
# Overlay COB heatmap (up to 5 minutes) behind the 1s price line
try:
hm_seconds = 300 # 5 minutes
bucket_radius = 10 # ±10 buckets
# Prefer raw liquidity for visual; models can still use normalized features internally
times, prices, matrix, mids = self.data_provider.get_cob_heatmap_matrix(
symbol=symbol,
seconds=hm_seconds,
bucket_radius=bucket_radius,
metric='liquidity'
)
if times and prices and matrix:
# Align times to local tz-naive to match chart
try:
_local_tz = datetime.now().astimezone().tzinfo
except Exception:
_local_tz = None
x_vals = []
for t in times:
try:
if hasattr(t, 'tzinfo') and t.tzinfo is not None:
tt = t.astimezone(_local_tz) if _local_tz else t
tt = tt.replace(tzinfo=None)
else:
tt = t
x_vals.append(tt)
except Exception:
x_vals.append(t)
# Plot heatmap beneath the 1s price line
fig.add_trace(
go.Heatmap(
x=x_vals,
y=prices, # numeric prices to share axis with 1s line
z=matrix,
colorscale='Turbo',
showscale=False,
zsmooth='best',
opacity=0.8,
name='COB Liquidity'
),
row=2, col=1
)
except Exception as e:
logger.debug(f"COB heatmap overlay skipped: {e}")
# Align mini chart to local tz-naive
try:
if hasattr(ws_data_1s.index, 'tz') and ws_data_1s.index.tz is not None: