fix(quant): eliminate all synthetic market/timeseries data, use 100% real exchange bars, and report 'No data available' when absent (v2.0.23)
This commit is contained in:
1 parent
9716a0ab61
commit
922f485388
27 files changed
+24021
-17509
No files matched your search
+172
-87
@@ -1,5 +1,5 @@
|
||||
// /workspace/hyperstitionstudio-core/site/quant/quant-app.js
|
||||
// Interactive Quantitative Finance & Memetic Gematria Time-Series Workbench (v2.0.22)
|
||||
// Interactive Quantitative Finance & Memetic Gematria Time-Series Workbench (v2.0.23)
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
@@ -27,12 +27,21 @@
|
||||
|
||||
let activeSpotlight = null;
|
||||
|
||||
function findLatestAvailableDateIdx(sym) {
|
||||
const inst = DATA.instruments.find((x) => x.symbol === sym) || DATA.instruments[0];
|
||||
if (!inst || !inst.bars) return DATA.dates_utc.length - 1;
|
||||
for (let i = inst.bars.length - 1; i >= 0; i--) {
|
||||
if (inst.bars[i].data_available) return i;
|
||||
}
|
||||
return DATA.dates_utc.length - 1;
|
||||
}
|
||||
|
||||
const state = {
|
||||
guildFilter: "ALL",
|
||||
selectedSymbol: "NVDA",
|
||||
selectedLens: DATA.default_lens || "fund_manager",
|
||||
metricMode: "spoken_aq", // "spoken_aq" | "close_usd" | "change_bps" | "digit_aq"
|
||||
selectedDateIdx: DATA.dates_utc.length - 1,
|
||||
selectedDateIdx: findLatestAvailableDateIdx("NVDA"),
|
||||
};
|
||||
|
||||
const guilds = ["ALL", "S1", "S2", "S3", "S4", "S5", "S6"];
|
||||
@@ -184,65 +193,95 @@
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Top Pane: Selected Metric Trajectory
|
||||
// Top Pane: Selected Metric Trajectory (strictly over real available bars; never synthesized or interpolated)
|
||||
const vals = bars.map((b) => {
|
||||
if (!b || !b.data_available || b.close_usd === null || b.close_usd === undefined) return null;
|
||||
if (state.metricMode === "close_usd") return Number(b.close_usd);
|
||||
if (state.metricMode === "change_bps") return Number(b.change_bps);
|
||||
if (state.metricMode === "digit_aq") return Number(b.close_digit_aq);
|
||||
return Number(b.close_spoken_ing_aq);
|
||||
if (state.metricMode === "change_bps") return b.change_bps !== null && b.change_bps !== undefined ? Number(b.change_bps) : null;
|
||||
if (state.metricMode === "digit_aq") return b.close_digit_aq !== null && b.close_digit_aq !== undefined ? Number(b.close_digit_aq) : null;
|
||||
return b.close_spoken_ing_aq !== null && b.close_spoken_ing_aq !== undefined ? Number(b.close_spoken_ing_aq) : null;
|
||||
});
|
||||
const minV = Math.min.apply(null, vals);
|
||||
const maxV = Math.max.apply(null, vals);
|
||||
const spanV = Math.max(1e-3, maxV - minV);
|
||||
const validVals = vals.filter((v) => v !== null && !Number.isNaN(v));
|
||||
|
||||
function yTop(v) {
|
||||
return topY1 - ((v - minV) / spanV) * (topY1 - topY0 - 14) - 6;
|
||||
}
|
||||
if (!inst.data_available || validVals.length === 0) {
|
||||
ctx.fillStyle = "rgba(15, 23, 42, 0.94)";
|
||||
ctx.fillRect(padL + 40, topY0 + 36, plotW - 80, 92);
|
||||
ctx.strokeStyle = "#f5c630";
|
||||
ctx.strokeRect(padL + 40, topY0 + 36, plotW - 80, 92);
|
||||
ctx.fillStyle = "#f5c630";
|
||||
ctx.font = "bold 13px monospace";
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText("NO MARKET DATA AVAILABLE FOR " + inst.symbol, padL + plotW / 2, topY0 + 74);
|
||||
ctx.fillStyle = "#94a3b8";
|
||||
ctx.font = "11px monospace";
|
||||
ctx.fillText(inst.status || "No public exchange feed available (0 synthetic bars generated).", padL + plotW / 2, topY0 + 98);
|
||||
ctx.textAlign = "left";
|
||||
} else {
|
||||
const minV = Math.min.apply(null, validVals);
|
||||
const maxV = Math.max.apply(null, validVals);
|
||||
const spanV = Math.max(1e-3, maxV - minV);
|
||||
|
||||
// Draw entity AQ horizontal reference line if within range
|
||||
const refAq = inst.entity_ing_aq;
|
||||
if (refAq >= minV && refAq <= maxV) {
|
||||
const ry = yTop(refAq);
|
||||
ctx.strokeStyle = "rgba(255, 77, 77, 0.45)";
|
||||
ctx.setLineDash([4, 4]);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(padL, ry);
|
||||
ctx.lineTo(W - padR, ry);
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([]);
|
||||
ctx.fillStyle = "#ff4d4d";
|
||||
ctx.font = "10px monospace";
|
||||
ctx.fillText(inst.entity_ing + "=" + refAq, padL + 6, ry - 4);
|
||||
}
|
||||
|
||||
// Plot curve
|
||||
ctx.strokeStyle = "#22d3ee";
|
||||
ctx.lineWidth = 2.2;
|
||||
ctx.beginPath();
|
||||
vals.forEach((v, idx) => {
|
||||
const px = xAt(idx);
|
||||
const py = yTop(v);
|
||||
if (idx === 0) ctx.moveTo(px, py);
|
||||
else ctx.lineTo(px, py);
|
||||
});
|
||||
ctx.stroke();
|
||||
|
||||
// Lock beacon markers on Top Pane
|
||||
bars.forEach((b, idx) => {
|
||||
const px = xAt(idx);
|
||||
const py = yTop(vals[idx]);
|
||||
if (b.scope1_locks && b.scope1_locks.length > 0) {
|
||||
ctx.fillStyle = "#f5c630";
|
||||
ctx.beginPath();
|
||||
ctx.arc(px, py, 5.2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
} else if (b.scope2_ring_coordinates && b.scope2_ring_coordinates.length > 0) {
|
||||
ctx.fillStyle = "#22d3ee";
|
||||
ctx.beginPath();
|
||||
ctx.arc(px, py, 3.8, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
function yTop(v) {
|
||||
return topY1 - ((v - minV) / spanV) * (topY1 - topY0 - 14) - 6;
|
||||
}
|
||||
});
|
||||
|
||||
// Draw entity AQ horizontal reference line if within range
|
||||
const refAq = inst.entity_ing_aq;
|
||||
if (refAq >= minV && refAq <= maxV) {
|
||||
const ry = yTop(refAq);
|
||||
ctx.strokeStyle = "rgba(255, 77, 77, 0.45)";
|
||||
ctx.setLineDash([4, 4]);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(padL, ry);
|
||||
ctx.lineTo(W - padR, ry);
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([]);
|
||||
ctx.fillStyle = "#ff4d4d";
|
||||
ctx.font = "10px monospace";
|
||||
ctx.fillText(inst.entity_ing + "=" + refAq, padL + 6, ry - 4);
|
||||
}
|
||||
|
||||
// Plot curve across available trading days
|
||||
ctx.strokeStyle = "#22d3ee";
|
||||
ctx.lineWidth = 2.2;
|
||||
ctx.beginPath();
|
||||
let started = false;
|
||||
vals.forEach((v, idx) => {
|
||||
if (v === null || Number.isNaN(v)) return;
|
||||
const px = xAt(idx);
|
||||
const py = yTop(v);
|
||||
if (!started) {
|
||||
ctx.moveTo(px, py);
|
||||
started = true;
|
||||
} else {
|
||||
ctx.lineTo(px, py);
|
||||
}
|
||||
});
|
||||
ctx.stroke();
|
||||
|
||||
// Lock beacon markers on Top Pane
|
||||
bars.forEach((b, idx) => {
|
||||
if (vals[idx] === null || Number.isNaN(vals[idx])) return;
|
||||
const px = xAt(idx);
|
||||
const py = yTop(vals[idx]);
|
||||
if (b.scope1_locks && b.scope1_locks.length > 0) {
|
||||
ctx.fillStyle = "#f5c630";
|
||||
ctx.beginPath();
|
||||
ctx.arc(px, py, 5.2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
} else if (b.scope2_ring_coordinates && b.scope2_ring_coordinates.length > 0) {
|
||||
ctx.fillStyle = "#22d3ee";
|
||||
ctx.beginPath();
|
||||
ctx.arc(px, py, 3.8, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
});
|
||||
|
||||
ctx.fillStyle = "#94a3b8";
|
||||
ctx.font = "10px monospace";
|
||||
ctx.fillText(maxV.toFixed(1), 6, topY0 + 8);
|
||||
ctx.fillText(minV.toFixed(1), 6, topY1 - 4);
|
||||
}
|
||||
|
||||
// Middle Pane: 00:00 GMT News Wire Equation Counts + Co-Presence Diamonds
|
||||
const wireTotals = DATA.daily_wire_series.map((d) => Number(d.equation_counts.total || 0));
|
||||
@@ -257,21 +296,22 @@
|
||||
});
|
||||
|
||||
// Bottom Pane: 20-Day Volume Ratio & Regime Color Strip
|
||||
const vols = bars.map((b) => Number(b.volume_ratio_20d));
|
||||
const maxVol = Math.max(2.6, Math.max.apply(null, vols));
|
||||
const vols = bars.map((b) => (b && b.data_available && b.volume_ratio_20d !== null && b.volume_ratio_20d !== undefined) ? Number(b.volume_ratio_20d) : null);
|
||||
const validVols = vols.filter((v) => v !== null && v > 0);
|
||||
const maxVol = validVols.length > 0 ? Math.max(2.6, Math.max.apply(null, validVols)) : 2.6;
|
||||
vols.forEach((vr, idx) => {
|
||||
if (vr === null) return;
|
||||
const px = xAt(idx);
|
||||
const bh = (vr / maxVol) * (botY1 - botY0 - 8);
|
||||
const b = bars[idx];
|
||||
ctx.fillStyle = b.change_pct <= -5.0 || vr >= 2.5 ? "#ff4d4d" : (vr < 0.45 ? "#f5c630" : "#38bdf8");
|
||||
const chgP = b.change_pct !== null && b.change_pct !== undefined ? Number(b.change_pct) : 0.0;
|
||||
ctx.fillStyle = chgP <= -5.0 || vr >= 2.5 ? "#ff4d4d" : (vr < 0.45 ? "#f5c630" : "#38bdf8");
|
||||
ctx.fillRect(px - barW / 2, botY1 - bh, barW, bh);
|
||||
});
|
||||
|
||||
// Axis labels
|
||||
ctx.fillStyle = "#94a3b8";
|
||||
ctx.font = "10px monospace";
|
||||
ctx.fillText(maxV.toFixed(1), 6, topY0 + 8);
|
||||
ctx.fillText(minV.toFixed(1), 6, topY1 - 4);
|
||||
ctx.fillText("Wire Eq", 6, midY0 + 12);
|
||||
ctx.fillText("Vol20d", 6, botY0 + 12);
|
||||
|
||||
@@ -329,11 +369,14 @@
|
||||
html += "</th>";
|
||||
inst.bars.forEach((b, dIdx) => {
|
||||
let cls = "hm-cell hm-none";
|
||||
if (b.scope1_locks && b.scope1_locks.length > 0) cls = "hm-cell hm-scope1";
|
||||
if (!b.data_available) cls = "hm-cell hm-nodata";
|
||||
else if (b.scope1_locks && b.scope1_locks.length > 0) cls = "hm-cell hm-scope1";
|
||||
else if (b.scope2_ring_coordinates && b.scope2_ring_coordinates.length > 0) cls = "hm-cell hm-scope2";
|
||||
if (b.co_present_in_news_wire) cls += " hm-wire";
|
||||
if (inst.symbol === state.selectedSymbol && dIdx === state.selectedDateIdx) cls += " hm-selected";
|
||||
const tip = inst.symbol + " (" + b.date_utc + "): $" + b.close_usd + " (" + b.change_bps + " bps) | Spoken AQ=" + b.close_spoken_ing_aq;
|
||||
const tip = !b.data_available
|
||||
? (inst.symbol + " (" + b.date_utc + "): No data available")
|
||||
: (inst.symbol + " (" + b.date_utc + "): $" + b.close_usd + " (" + (b.change_bps !== null ? b.change_bps + " bps" : "No bps data") + ") | Spoken AQ=" + b.close_spoken_ing_aq);
|
||||
html += "<td><span class='" + cls + "' data-sym='" + inst.symbol + "' data-didx='" + dIdx + "' title='" + tip + "'></span></td>";
|
||||
});
|
||||
html += "</tr>";
|
||||
@@ -366,17 +409,38 @@
|
||||
"PANEL 3: " + inst.symbol + " (" + inst.entity_eng + " \u2192 " + inst.entity_ing + "=" + inst.entity_ing_aq + ") @ " + dt;
|
||||
|
||||
const metricsGrid = document.getElementById("dateMetricsGrid");
|
||||
const lockSummary = (bar.scope1_locks || []).concat((bar.scope2_ring_coordinates || []).map((c) => "Ring " + c)).join(", ") || "None";
|
||||
metricsGrid.innerHTML = [
|
||||
{ l: "Close USD (Change)", v: "$" + bar.close_usd + " (" + (bar.change_bps >= 0 ? "+" : "") + bar.change_bps + " bps)" },
|
||||
{ l: "Spoken Close (Gen 1 AQ)", v: bar.close_spoken_ing + " (" + bar.close_spoken_ing_aq + ")" },
|
||||
{ l: "Scaled Cap (Gen 1 AQ)", v: bar.market_cap_str + " (" + bar.scaled_cap_spoken_ing_aq + ")" },
|
||||
{ l: "BPS Spoken AQ / Vol20d", v: bar.bps_spoken_ing_aq + " / " + bar.volume_ratio_20d + "x" },
|
||||
{ l: "Active Contingent Locks", v: lockSummary },
|
||||
{ l: "00:00 GMT Wire Co-Present", v: bar.co_present_in_news_wire ? "YES (Scope 3 Lock)" : "No" },
|
||||
]
|
||||
.map((m) => "<div class='stat-box'><div class='stat-label'>" + m.l + "</div><div class='stat-val'>" + m.v + "</div></div>")
|
||||
.join("");
|
||||
if (!bar.data_available || bar.close_usd === null || bar.close_usd === undefined) {
|
||||
metricsGrid.innerHTML = [
|
||||
{ l: "Close USD (Change)", v: "No data available" },
|
||||
{ l: "Spoken Close (Gen 1 AQ)", v: "No data available" },
|
||||
{ l: "Scaled Cap (Gen 1 AQ)", v: "No data available" },
|
||||
{ l: "BPS Spoken AQ / Vol20d", v: "No data available" },
|
||||
{ l: "Active Contingent Locks", v: "No data available" },
|
||||
{ l: "00:00 GMT Wire Co-Present", v: bar.co_present_in_news_wire ? "YES (Scope 3 Lock)" : "No" },
|
||||
]
|
||||
.map((m) => "<div class='stat-box'><div class='stat-label'>" + m.l + "</div><div class='stat-val' style='color:var(--text-muted);'>" + m.v + "</div></div>")
|
||||
.join("");
|
||||
} else {
|
||||
const lockSummary = (bar.scope1_locks || []).concat((bar.scope2_ring_coordinates || []).map((c) => "Ring " + c)).join(", ") || "None";
|
||||
const chgStr = bar.change_bps !== null && bar.change_bps !== undefined
|
||||
? (" (" + (bar.change_bps >= 0 ? "+" : "") + bar.change_bps + " bps)")
|
||||
: " (No prior day data)";
|
||||
const capDisp = (bar.market_cap_str && bar.market_cap_str !== "No data available" && bar.scaled_cap_spoken_ing_aq !== null)
|
||||
? (bar.market_cap_str + " (" + bar.scaled_cap_spoken_ing_aq + ")")
|
||||
: "No data available";
|
||||
const bpsDisp = bar.bps_spoken_ing_aq !== null && bar.bps_spoken_ing_aq !== undefined ? String(bar.bps_spoken_ing_aq) : "No data available";
|
||||
const volDisp = bar.volume_ratio_20d !== null && bar.volume_ratio_20d !== undefined ? (bar.volume_ratio_20d + "x") : "No data available";
|
||||
metricsGrid.innerHTML = [
|
||||
{ l: "Close USD (Change)", v: "$" + bar.close_usd + chgStr },
|
||||
{ l: "Spoken Close (Gen 1 AQ)", v: bar.close_spoken_ing + " (" + bar.close_spoken_ing_aq + ")" },
|
||||
{ l: "Scaled Cap (Gen 1 AQ)", v: capDisp },
|
||||
{ l: "BPS Spoken AQ / Vol20d", v: bpsDisp + " / " + volDisp },
|
||||
{ l: "Active Contingent Locks", v: lockSummary },
|
||||
{ l: "00:00 GMT Wire Co-Present", v: bar.co_present_in_news_wire ? "YES (Scope 3 Lock)" : "No" },
|
||||
]
|
||||
.map((m) => "<div class='stat-box'><div class='stat-label'>" + m.l + "</div><div class='stat-val'>" + m.v + "</div></div>")
|
||||
.join("");
|
||||
}
|
||||
|
||||
// Render Active Lens Projection Card (LENS_REGISTRY)
|
||||
const lensCard = document.getElementById("lensProjectionCard");
|
||||
@@ -384,17 +448,28 @@
|
||||
let rowsHtml = "";
|
||||
Object.keys(proj.labeled_timeseries || {}).forEach((k) => {
|
||||
const val = proj.labeled_timeseries[k];
|
||||
const disp = typeof val === "object" ? JSON.stringify(val) : String(val);
|
||||
let disp = "No data available";
|
||||
if (val !== null && val !== undefined) {
|
||||
if (typeof val === "object") {
|
||||
const nonNull = Object.values(val).some((x) => x !== null && x !== undefined);
|
||||
disp = nonNull ? JSON.stringify(val) : "No data available";
|
||||
} else {
|
||||
disp = String(val);
|
||||
}
|
||||
}
|
||||
rowsHtml += "<div style='display:flex;justify-content:space-between;font-size:0.69rem;border-bottom:1px solid #162032;padding:0.18rem 0;'>" +
|
||||
"<span style='color:var(--text-muted);'>" + k + ":</span><span style='color:var(--text-main);font-weight:600;'>" + disp + "</span></div>";
|
||||
});
|
||||
const archDisp = (proj.qualitative_profile && proj.qualitative_profile.archetype) || "No data available";
|
||||
const regDisp = (proj.qualitative_profile && proj.qualitative_profile.regime_specialization) || "No data available";
|
||||
const sparkDisp = inst.timeseries_moments.ts_sparkline_30d || "No data available";
|
||||
lensCard.innerHTML =
|
||||
"<div style='display:flex;justify-content:space-between;align-items:center;margin-bottom:0.4rem;'>" +
|
||||
"<span style='font-size:0.76rem;font-weight:700;color:var(--gold);'>Lens: " + proj.lens_title + "</span>" +
|
||||
"<span style='font-size:0.7rem;color:var(--cyan);'>" + proj.tier_classification + "</span></div>" +
|
||||
"<div style='font-size:0.71rem;color:var(--emerald);margin-bottom:0.4rem;'>" +
|
||||
"Archetype: " + proj.qualitative_profile.archetype + " • " + proj.qualitative_profile.regime_specialization +
|
||||
" • 30d: " + inst.timeseries_moments.ts_sparkline_30d + "</div>" +
|
||||
"Archetype: " + archDisp + " • " + regDisp +
|
||||
" • 30d: " + sparkDisp + "</div>" +
|
||||
rowsHtml;
|
||||
}
|
||||
|
||||
@@ -484,22 +559,32 @@
|
||||
const container = document.getElementById("lagBarsContainer");
|
||||
let html = "";
|
||||
for (let tau = -5; tau <= 5; tau++) {
|
||||
const r = Number(curve[String(tau)] || 0);
|
||||
const hPct = Math.max(6, Math.round(Math.abs(r) * 85));
|
||||
const color = tau === optLag ? "var(--gold)" : (r >= 0 ? "var(--cyan)" : "var(--rose)");
|
||||
html +=
|
||||
"<div class='lag-col' title='Lag tau=" + tau + "d: r=" + r.toFixed(3) + "'>" +
|
||||
"<div style='font-size:0.62rem;color:var(--text-main);'>" + r.toFixed(2) + "</div>" +
|
||||
"<div class='lag-bar' style='height:" + hPct + "px;background:" + color + ";'></div>" +
|
||||
"<div class='lag-lbl'>τ=" + (tau >= 0 ? "+" + tau : tau) + "d</div></div>";
|
||||
const rawR = curve[String(tau)];
|
||||
if (rawR === null || rawR === undefined) {
|
||||
html +=
|
||||
"<div class='lag-col' title='Lag tau=" + tau + "d: No data available'>" +
|
||||
"<div style='font-size:0.62rem;color:var(--text-muted);'>N/A</div>" +
|
||||
"<div class='lag-bar' style='height:4px;background:#334155;'></div>" +
|
||||
"<div class='lag-lbl'>τ=" + (tau >= 0 ? "+" + tau : tau) + "d</div></div>";
|
||||
} else {
|
||||
const r = Number(rawR);
|
||||
const hPct = Math.max(6, Math.round(Math.abs(r) * 85));
|
||||
const color = tau === optLag ? "var(--gold)" : (r >= 0 ? "var(--cyan)" : "var(--rose)");
|
||||
html +=
|
||||
"<div class='lag-col' title='Lag tau=" + tau + "d: r=" + r.toFixed(3) + "'>" +
|
||||
"<div style='font-size:0.62rem;color:var(--text-main);'>" + r.toFixed(2) + "</div>" +
|
||||
"<div class='lag-bar' style='height:" + hPct + "px;background:" + color + ";'></div>" +
|
||||
"<div class='lag-lbl'>τ=" + (tau >= 0 ? "+" + tau : tau) + "d</div></div>";
|
||||
}
|
||||
}
|
||||
container.innerHTML = html;
|
||||
|
||||
const pGate = DATA.periodicity_gate || {};
|
||||
const optLagDisp = optLag !== null && optLag !== undefined ? ((optLag >= 0 ? "+" + optLag : optLag) + "d") : "No data available";
|
||||
document.getElementById("periodicityAuditFooter").textContent =
|
||||
"Periodicity Gate Enforced: " + pGate.dated_news_dossiers_ingested + " dated 00:00 UTC news dossiers + 30 daily 21:30 UTC closing-bell bars (" +
|
||||
pGate.non_periodic_records_ingested + " non-periodic/static records ingested) | Optimal Lag tau* = " +
|
||||
(optLag >= 0 ? "+" + optLag : optLag) + "d | CIDv1: " + (DATA.ipld_dag_json_cidv1 && DATA.ipld_dag_json_cidv1["/"]);
|
||||
"Periodicity Gate Enforced: " + pGate.dated_news_dossiers_ingested + " dated 00:00 UTC news dossiers + real exchange closing-bell bars (" +
|
||||
pGate.non_periodic_records_ingested + " non-periodic/static records ingested; missing bars = null / No data available) | Optimal Lag tau* = " +
|
||||
optLagDisp + " | CIDv1: " + (DATA.ipld_dag_json_cidv1 && DATA.ipld_dag_json_cidv1["/"]);
|
||||
}
|
||||
|
||||
function renderAll() {
|
||||
|
||||
Reference in new issue
Block a user