def build_econometric_validation_html(dm_results, var_results, psr_results=None, dsr_results=None, pt_results=None, lb_results=None):
validation_html = ""
if dm_results or var_results or psr_results or dsr_results:
val_rows = ""
if dm_results:
dm_pass = dm_results.get('significant', False) and dm_results.get('winner') not in ['Naive Mean', 'Model 2']
dm_col = "#3fb950" if dm_pass else "#e3b341"
if dm_pass:
dm_diag = "Model successfully outperforms a naive historical baseline with statistical significance."
elif not dm_results.get('significant', False):
dm_diag = "Model fails to statistically distinguish itself from a simple historical average."
else:
dm_diag = "Model underperforms the naive historical baseline."
val_rows += (
f'
'
f'Predictive Alpha (DM Test) ⓘ
'
f'
{"PASS" if dm_pass else "INCONCLUSIVE"}
'
f'
p = {dm_results.get("p_value", 1.0):.4f}
'
f'
{dm_diag}
'
)
if var_results:
var_pass = var_results.get('overall_pass', False)
var_col = "#3fb950" if var_pass else "#f85149"
uc_p = var_results.get('unconditional_coverage', {}).get('p_value', 0.0)
ind_p = var_results.get('independence', {}).get('p_value', 0.0)
diag_text = var_results.get('diagnostic', '')
val_rows += (
f''
f'Tail Risk Validity (VaR) ⓘ
'
f'
{"PASS" if var_pass else "FAIL"}
'
f'
Coverage p = {uc_p:.4f} | Independence p = {ind_p:.4f}
'
+ (f'
{diag_text}
' if diag_text and not var_pass else '')
+ '
'
)
if psr_results:
psr_pass = psr_results.get('p_value', 1.0) < 0.05
psr_col = "#3fb950" if psr_pass else "#e3b341"
if psr_pass:
psr_diag = "Sharpe ratio is statistically robust even after accounting for non-normal skew and fat tails."
else:
psr_diag = "Sharpe ratio is not statistically significant; outperformance may be driven by extreme outliers or luck."
val_rows += (
f''
f'Probabilistic Sharpe (PSR) ⓘ
'
f'
{"PASS" if psr_pass else "INCONCLUSIVE"}
'
f'
p = {psr_results.get("p_value", 1.0):.4f} (Obs: {psr_results.get("observed_sharpe", 0.0):.2f})
'
f'
{psr_diag}
'
)
if dsr_results:
dsr_pass = dsr_results.get('p_value', 1.0) < 0.05
dsr_col = "#3fb950" if dsr_pass else "#e3b341"
if dsr_pass:
dsr_diag = "Strategy is robust against overfitting and multiple testing bias (data mining)."
else:
dsr_diag = "Cannot rule out multiple testing bias; strategy might be overfitted to historical data."
val_rows += (
f''
f'Deflated Sharpe (DSR) ⓘ
'
f'
{"PASS" if dsr_pass else "INCONCLUSIVE"}
'
f'
p = {dsr_results.get("p_value", 1.0):.4f}
'
f'
{dsr_diag}
'
)
if pt_results:
pt_pass = pt_results.get('significant', False)
pt_col = "#3fb950" if pt_pass else "#e3b341"
val_rows += (
f''
f'Directional Accuracy (PT Test) ⓘ
'
f'
{"PASS" if pt_pass else "INCONCLUSIVE"}
'
f'
p = {pt_results.get("p_value", 1.0):.4f}
'
)
if lb_results:
lb_pass = not lb_results.get('significant', True) # Null hypothesis is NO autocorrelation. We want p > 0.05
lb_col = "#3fb950" if lb_pass else "#e3b341"
val_rows += (
f''
f'GARCH Autocorrelation (Ljung-Box) ⓘ
'
f'
{"PASS" if lb_pass else "FAIL"}
'
f'
p = {lb_results.get("p_value", 0.0):.4f}
'
)
verdicts = []
if dm_results:
if dm_results.get('significant', False) and dm_results.get('winner') not in ['Naive Mean', 'Model 2']:
verdicts.append("Your model statistically outperforms the naive historical baseline at 95% confidence.")
else:
verdicts.append("The model does not show statistically significant outperformance over a naive historical mean.")
if var_results:
if var_results.get('overall_pass', False):
verdicts.append("Tail risk metrics (VaR) hold up well against real-world volatility clustering.")
else:
verdicts.append("VaR breaches cluster significantly; consider widening your rebalance frequency or reducing risk limits.")
if psr_results and psr_results.get('p_value', 1.0) < 0.05:
verdicts.append("The Sharpe ratio is robust even under non-normal return distributions.")
verdict_html = ""
if verdicts:
verdict_html = (
f''
f'Diagnostic Verdict: {" ".join(verdicts)}'
f'
'
)
validation_html = (
'Advanced Econometric Validation
'
f'{verdict_html}'
f'{val_rows}
'
)
return validation_html