more cobfixes
This commit is contained in:
@ -341,10 +341,31 @@ def save_inference_audit_image(base_data, model_name: str, symbol: str, out_root
|
||||
ax6 = fig.add_subplot(gs[1, 2])
|
||||
_plot_data_summary(ax6, base_data, symbol)
|
||||
|
||||
# COB data (bottom, spanning all columns)
|
||||
# COB data (bottom, spanning all columns) with optional heatmap overlay above it
|
||||
ax7 = fig.add_subplot(gs[2, :])
|
||||
_plot_cob_data(ax7, prices, bid_v, ask_v, imb, current_price, symbol)
|
||||
|
||||
# Optional: append a small heatmap figure to the side if available
|
||||
try:
|
||||
heat_times = getattr(base_data, 'cob_heatmap_times', [])
|
||||
heat_prices = getattr(base_data, 'cob_heatmap_prices', [])
|
||||
heat_vals = getattr(base_data, 'cob_heatmap_values', [])
|
||||
if heat_times and heat_prices and heat_vals:
|
||||
import numpy as np
|
||||
# Create an inset axes on ax7 for compact heatmap
|
||||
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
|
||||
inset_ax = inset_axes(ax7, width="25%", height="100%", loc='upper right', borderpad=1)
|
||||
z = np.array(heat_vals, dtype=float)
|
||||
if z.size > 0:
|
||||
col_max = np.maximum(z.max(axis=0), 1e-9)
|
||||
zn = (z / col_max).T
|
||||
inset_ax.imshow(zn, aspect='auto', origin='lower', cmap='turbo')
|
||||
inset_ax.set_title('COB Heatmap', fontsize=8)
|
||||
inset_ax.set_xticks([])
|
||||
inset_ax.set_yticks([])
|
||||
except Exception as _hm_ex:
|
||||
logger.debug(f"Audit heatmap overlay skipped: {_hm_ex}")
|
||||
|
||||
# Add overall title with model and timestamp info
|
||||
fig.suptitle(f"{model_name} - {safe_symbol} - {datetime.utcnow().strftime('%H:%M:%S')}",
|
||||
fontsize=14, fontweight='bold')
|
||||
|
Reference in New Issue
Block a user