Release v2.10.0: Implement progressive scale-ready UI navigation for growing datasets across /quant/, /graph/, /learn/, /engineering/, and /math/
This commit is contained in:
1 parent
f0aaae680f
commit
e788f357ff
36 files changed
+402
-176
No files matched your search
+143
-20
@@ -1,5 +1,5 @@
|
||||
// /workspace/hyperstitionstudio-core/site/quant/quant-app.js
|
||||
// Interactive Quantitative Finance & Memetic Gematria Time-Series Workbench (v2.9.0)
|
||||
// Interactive Quantitative Finance & Memetic Gematria Time-Series Workbench (v2.10.0)
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
@@ -243,9 +243,21 @@
|
||||
selectedLens: DATA.default_lens || "fund_manager",
|
||||
metricMode: "spoken_aq", // "spoken_aq" | "close_usd" | "change_bps" | "digit_aq"
|
||||
selectedDateIdx: findLatestAvailableDateIdx("NVDA"),
|
||||
timeWindowDays: 30, // 30 | 90 | 180 | 0 (ALL)
|
||||
tickerSearchQuery: "",
|
||||
heatmapPage: 0,
|
||||
heatmapPageSize: 25,
|
||||
heatmapShowAll: false,
|
||||
wireTapeQuery: "",
|
||||
};
|
||||
|
||||
const guilds = ["ALL", "S1", "S2", "S3", "S4", "S5", "S6", "DOSE_D3"];
|
||||
const timeWindows = [
|
||||
{ days: 30, label: "30D" },
|
||||
{ days: 90, label: "90D" },
|
||||
{ days: 180, label: "180D" },
|
||||
{ days: 0, label: "ALL" },
|
||||
];
|
||||
const modes = [
|
||||
{ id: "spoken_aq", label: "Spoken AQ (Gen 1)" },
|
||||
{ id: "close_usd", label: "Close Price (USD)" },
|
||||
@@ -254,26 +266,50 @@
|
||||
];
|
||||
|
||||
const elGuildPills = document.getElementById("guildFilterPills");
|
||||
const elTickerQuickFilter = document.getElementById("tickerQuickFilter");
|
||||
const elTickerSelect = document.getElementById("tickerSelect");
|
||||
const elLensSelect = document.getElementById("lensSelect");
|
||||
const elModePills = document.getElementById("metricModePills");
|
||||
const elTimeWindowPills = document.getElementById("timeWindowPills");
|
||||
const elWireTapeFilter = document.getElementById("wireTapeFilterInput");
|
||||
const elDateBadge = document.getElementById("activeDateBadge");
|
||||
const elTvBtn = document.getElementById("openTradingViewBtn");
|
||||
const elPanel3TvBtn = document.getElementById("panel3TvBtn");
|
||||
const canvas = document.getElementById("tsCanvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
function getActiveDateRange() {
|
||||
const total = DATA.dates_utc.length;
|
||||
if (!state.timeWindowDays || state.timeWindowDays <= 0 || state.timeWindowDays >= total) {
|
||||
return { startIdx: 0, endIdx: total };
|
||||
}
|
||||
return { startIdx: Math.max(0, total - state.timeWindowDays), endIdx: total };
|
||||
}
|
||||
|
||||
function instrumentHasDoseD3(inst) {
|
||||
return (inst.bars || []).some((b) => b.data_available && Number(b.confluence_dose || 0) >= 3);
|
||||
}
|
||||
|
||||
function getFilteredInstruments() {
|
||||
if (state.guildFilter === "ALL") return DATA.instruments;
|
||||
let base = DATA.instruments;
|
||||
if (state.guildFilter === "DOSE_D3") {
|
||||
const d3 = DATA.instruments.filter(instrumentHasDoseD3);
|
||||
return d3.length ? d3 : DATA.instruments;
|
||||
base = d3.length ? d3 : DATA.instruments;
|
||||
} else if (state.guildFilter !== "ALL") {
|
||||
base = DATA.instruments.filter((inst) => inst.guilds.indexOf(state.guildFilter) !== -1);
|
||||
}
|
||||
return DATA.instruments.filter((inst) => inst.guilds.indexOf(state.guildFilter) !== -1);
|
||||
const q = (state.tickerSearchQuery || "").trim().toLowerCase();
|
||||
if (!q) return base;
|
||||
const matched = base.filter((inst) => {
|
||||
return (
|
||||
String(inst.symbol || "").toLowerCase().includes(q) ||
|
||||
String(inst.entity_eng || "").toLowerCase().includes(q) ||
|
||||
String(inst.entity_ing || "").toLowerCase().includes(q) ||
|
||||
String(inst.entity_ing_aq || "") === q ||
|
||||
String(inst.entity_eng_aq || "") === q
|
||||
);
|
||||
});
|
||||
return matched.length ? matched : base;
|
||||
}
|
||||
|
||||
function getSelectedInstrument() {
|
||||
@@ -358,14 +394,54 @@
|
||||
elModePills.appendChild(btn);
|
||||
});
|
||||
|
||||
// Sliding Temporal Window Pills (Strategy 1A: 30D | 90D | 180D | ALL)
|
||||
if (elTimeWindowPills) {
|
||||
elTimeWindowPills.innerHTML = "";
|
||||
timeWindows.forEach((tw) => {
|
||||
const btn = document.createElement("button");
|
||||
btn.className = "pill" + (state.timeWindowDays === tw.days ? " active" : "");
|
||||
btn.textContent = tw.label;
|
||||
btn.onclick = function () {
|
||||
state.timeWindowDays = tw.days;
|
||||
const rng = getActiveDateRange();
|
||||
if (state.selectedDateIdx < rng.startIdx) state.selectedDateIdx = rng.endIdx - 1;
|
||||
renderAll();
|
||||
};
|
||||
elTimeWindowPills.appendChild(btn);
|
||||
});
|
||||
}
|
||||
|
||||
elDateBadge.textContent = DATA.dates_utc[state.selectedDateIdx];
|
||||
updateTradingViewLinks();
|
||||
}
|
||||
|
||||
if (elTickerQuickFilter) {
|
||||
elTickerQuickFilter.addEventListener("input", function () {
|
||||
state.tickerSearchQuery = elTickerQuickFilter.value || "";
|
||||
state.heatmapPage = 0;
|
||||
const list = getFilteredInstruments();
|
||||
if (list.length && !list.some((x) => x.symbol === state.selectedSymbol)) {
|
||||
state.selectedSymbol = list[0].symbol;
|
||||
}
|
||||
renderAll();
|
||||
});
|
||||
}
|
||||
|
||||
if (elWireTapeFilter) {
|
||||
elWireTapeFilter.addEventListener("input", function () {
|
||||
state.wireTapeQuery = elWireTapeFilter.value || "";
|
||||
renderInspectorAndLens();
|
||||
});
|
||||
}
|
||||
|
||||
function drawCanvas() {
|
||||
const inst = getSelectedInstrument();
|
||||
const bars = inst.bars;
|
||||
const rng = getActiveDateRange();
|
||||
const bars = inst.bars.slice(rng.startIdx, rng.endIdx);
|
||||
const datesSlice = DATA.dates_utc.slice(rng.startIdx, rng.endIdx);
|
||||
const wireSlice = DATA.daily_wire_series.slice(rng.startIdx, rng.endIdx);
|
||||
const N = bars.length;
|
||||
const localSelIdx = Math.max(0, Math.min(N - 1, state.selectedDateIdx - rng.startIdx));
|
||||
const W = canvas.width;
|
||||
const H = canvas.height;
|
||||
ctx.clearRect(0, 0, W, H);
|
||||
@@ -384,7 +460,7 @@
|
||||
}
|
||||
|
||||
// Selected date vertical crosshair
|
||||
const selX = xAt(state.selectedDateIdx);
|
||||
const selX = xAt(localSelIdx);
|
||||
ctx.strokeStyle = "rgba(245, 198, 48, 0.45)";
|
||||
ctx.lineWidth = 1.5;
|
||||
ctx.beginPath();
|
||||
@@ -493,14 +569,14 @@
|
||||
}
|
||||
|
||||
// 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));
|
||||
const wireTotals = wireSlice.map((d) => Number(d.equation_counts.total || 0));
|
||||
const maxW = Math.max(10, Math.max.apply(null, wireTotals));
|
||||
const barW = Math.max(6, Math.floor(plotW / N) - 5);
|
||||
const barW = Math.max(2, Math.floor(plotW / Math.max(1, N)) - 3);
|
||||
|
||||
wireTotals.forEach((wt, idx) => {
|
||||
const px = xAt(idx);
|
||||
const bh = (wt / maxW) * (midY1 - midY0 - 14);
|
||||
ctx.fillStyle = bars[idx].co_present_in_news_wire ? "#34d399" : "#a78bfa";
|
||||
ctx.fillStyle = bars[idx] && bars[idx].co_present_in_news_wire ? "#34d399" : "#a78bfa";
|
||||
ctx.fillRect(px - barW / 2, midY1 - bh, barW, bh);
|
||||
});
|
||||
|
||||
@@ -524,9 +600,10 @@
|
||||
ctx.fillText("Wire Eq", 6, midY0 + 12);
|
||||
ctx.fillText("Vol20d", 6, botY0 + 12);
|
||||
|
||||
// Date ticks along bottom
|
||||
for (let i = 0; i < N; i += 4) {
|
||||
ctx.fillText(DATA.dates_utc[i].slice(5), xAt(i) - 14, H - 4);
|
||||
// Date ticks along bottom (adaptive step so labels never overlap as N grows)
|
||||
const tickStep = Math.max(4, Math.ceil(N / 8));
|
||||
for (let i = 0; i < N; i += tickStep) {
|
||||
ctx.fillText(datesSlice[i].slice(5), xAt(i) - 14, H - 4);
|
||||
}
|
||||
|
||||
// Optional Tutorial Spotlight Ring & Callout Banner on Canvas
|
||||
@@ -562,21 +639,32 @@
|
||||
|
||||
function renderHeatmap() {
|
||||
const tbl = document.getElementById("heatmapTable");
|
||||
const pagBar = document.getElementById("heatmapPaginationBar");
|
||||
const filtered = getFilteredInstruments();
|
||||
const rng = getActiveDateRange();
|
||||
const totalRows = filtered.length;
|
||||
const pageSize = state.heatmapShowAll ? Math.max(1, totalRows) : state.heatmapPageSize;
|
||||
const totalPages = Math.max(1, Math.ceil(totalRows / pageSize));
|
||||
if (state.heatmapPage >= totalPages) state.heatmapPage = totalPages - 1;
|
||||
const rowStart = state.heatmapShowAll ? 0 : state.heatmapPage * pageSize;
|
||||
const pageSlice = filtered.slice(rowStart, rowStart + pageSize);
|
||||
|
||||
let html = "<thead><tr><th class='sym-col'>Ticker (TV)</th>";
|
||||
DATA.dates_utc.forEach((dt, idx) => {
|
||||
for (let idx = rng.startIdx; idx < rng.endIdx; idx++) {
|
||||
const dt = DATA.dates_utc[idx];
|
||||
const selStyle = idx === state.selectedDateIdx ? "color:var(--gold);font-weight:700;" : "color:var(--text-muted);";
|
||||
html += "<th style='" + selStyle + "'>" + dt.slice(8) + "</th>";
|
||||
});
|
||||
}
|
||||
html += "</tr></thead><tbody>";
|
||||
|
||||
filtered.forEach((inst) => {
|
||||
pageSlice.forEach((inst) => {
|
||||
const rowSel = inst.symbol === state.selectedSymbol ? "background:rgba(34,211,238,0.12);" : "";
|
||||
html += "<tr style='" + rowSel + "'><th class='sym-col'>";
|
||||
html += "<span style='cursor:pointer;color:var(--text-main);' data-sym='" + inst.symbol + "' class='hm-sym-pick'>" + inst.symbol + "</span> ";
|
||||
html += "<a href='" + inst.tradingview_url + "' target='_blank' rel='noopener noreferrer' style='color:var(--gold);text-decoration:none;' title='Open " + inst.tradingview_symbol + " on TradingView'>\u2197</a>";
|
||||
html += "</th>";
|
||||
inst.bars.forEach((b, dIdx) => {
|
||||
for (let dIdx = rng.startIdx; dIdx < rng.endIdx; dIdx++) {
|
||||
const b = inst.bars[dIdx];
|
||||
let cls = "hm-cell hm-none";
|
||||
if (!b.data_available) cls = "hm-cell hm-nodata";
|
||||
else if (b.scope1_locks && b.scope1_locks.length > 0) cls = "hm-cell hm-scope1";
|
||||
@@ -587,12 +675,35 @@
|
||||
? (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>";
|
||||
});
|
||||
html += "</tbody>";
|
||||
tbl.innerHTML = html;
|
||||
|
||||
if (pagBar) {
|
||||
if (totalRows <= state.heatmapPageSize) {
|
||||
pagBar.style.display = "none";
|
||||
pagBar.innerHTML = "";
|
||||
} else {
|
||||
pagBar.style.display = "flex";
|
||||
pagBar.innerHTML =
|
||||
"<span style='color:var(--text-muted);'>Showing " + (rowStart + 1) + "–" + Math.min(totalRows, rowStart + pageSize) + " of " + totalRows + " tickers</span>" +
|
||||
"<div style='display:flex;gap:0.4rem;'>" +
|
||||
"<button type='button' class='pill' id='hmPrevPageBtn'>← Prev</button>" +
|
||||
"<span style='padding:0.2rem 0.4rem;color:var(--gold);'>Page " + (state.heatmapPage + 1) + "/" + totalPages + "</span>" +
|
||||
"<button type='button' class='pill' id='hmNextPageBtn'>Next →</button>" +
|
||||
"<button type='button' class='pill' id='hmToggleAllBtn'>" + (state.heatmapShowAll ? "Paginate (25/p)" : "Show All (" + totalRows + ")") + "</button>" +
|
||||
"</div>";
|
||||
const pBtn = document.getElementById("hmPrevPageBtn");
|
||||
const nBtn = document.getElementById("hmNextPageBtn");
|
||||
const aBtn = document.getElementById("hmToggleAllBtn");
|
||||
if (pBtn) pBtn.onclick = function () { state.heatmapPage = Math.max(0, state.heatmapPage - 1); renderHeatmap(); };
|
||||
if (nBtn) nBtn.onclick = function () { state.heatmapPage = Math.min(totalPages - 1, state.heatmapPage + 1); renderHeatmap(); };
|
||||
if (aBtn) aBtn.onclick = function () { state.heatmapShowAll = !state.heatmapShowAll; state.heatmapPage = 0; renderHeatmap(); };
|
||||
}
|
||||
}
|
||||
|
||||
tbl.querySelectorAll(".hm-cell").forEach((cell) => {
|
||||
cell.addEventListener("click", function () {
|
||||
state.selectedSymbol = cell.getAttribute("data-sym");
|
||||
@@ -725,7 +836,17 @@
|
||||
hdrEl.innerHTML =
|
||||
"Dated 00:00 GMT Wire Dossier (<a href='" + resolveUrl(wireDay.archive_route) + "' target='_blank' style='color:var(--cyan);'>" +
|
||||
wireDay.dossier_file + "</a> • " + wireDay.equation_counts.total + " Verified Equations):";
|
||||
tapeEl.innerHTML = (wireDay.sample_equations || [])
|
||||
const wq = (state.wireTapeQuery || "").trim().toLowerCase();
|
||||
const rawEqs = wireDay.sample_equations || [];
|
||||
const filteredEqs = !wq ? rawEqs : rawEqs.filter((eq) => {
|
||||
return (
|
||||
String(eq.ing || "").toLowerCase().includes(wq) ||
|
||||
String(eq.eng || "").toLowerCase().includes(wq) ||
|
||||
String(eq.target || "") === wq ||
|
||||
String(eq.breakdown || "").toLowerCase().includes(wq)
|
||||
);
|
||||
});
|
||||
tapeEl.innerHTML = filteredEqs
|
||||
.map(
|
||||
(eq) => {
|
||||
const dLink = resolveUrl(eq.dossier_deep_link || wireDay.archive_route);
|
||||
@@ -935,8 +1056,10 @@
|
||||
const relX = ((ev.clientX - rect.left) / rect.width) * canvas.width;
|
||||
const padL = 62, padR = 28;
|
||||
const ratio = (relX - padL) / (canvas.width - padL - padR);
|
||||
const idx = Math.round(ratio * (DATA.dates_utc.length - 1));
|
||||
state.selectedDateIdx = Math.max(0, Math.min(DATA.dates_utc.length - 1, idx));
|
||||
const rng = getActiveDateRange();
|
||||
const span = Math.max(1, rng.endIdx - rng.startIdx - 1);
|
||||
const idx = rng.startIdx + Math.round(ratio * span);
|
||||
state.selectedDateIdx = Math.max(rng.startIdx, Math.min(rng.endIdx - 1, idx));
|
||||
renderAll();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user