adsense verification, remove latest sales table, add new search mechanic (weight, synonyms), fix low volatility (NaN%)

This commit is contained in:
Zach Harding
2026-04-01 17:43:47 -04:00
parent c61cafecdc
commit 17465b13c1
4 changed files with 67 additions and 14 deletions

View File

@@ -88,13 +88,22 @@ for (const row of historyRows) {
function computeVolatility(prices: number[]): { label: string; monthlyVol: number } {
if (prices.length < 2) return { label: '—', monthlyVol: 0 };
const returns: number[] = [];
for (let i = 1; i < prices.length; i++) {
returns.push(Math.log(prices[i] / prices[i - 1]));
const ratio = prices[i] / prices[i - 1];
if (!isFinite(ratio) || ratio <= 0) continue; // skip bad ratios
returns.push(Math.log(ratio));
}
if (returns.length < 2) return { label: '—', monthlyVol: 0 }; // ← key fix
const mean = returns.reduce((a, b) => a + b, 0) / returns.length;
const variance = returns.reduce((sum, r) => sum + (r - mean) ** 2, 0) / (returns.length - 1);
const monthlyVol = Math.sqrt(variance) * Math.sqrt(30);
if (!isFinite(monthlyVol)) return { label: '—', monthlyVol: 0 }; // safety net
const label = monthlyVol >= 0.30 ? 'High'
: monthlyVol >= 0.15 ? 'Medium'
: 'Low';
@@ -310,7 +319,7 @@ const altSearchUrl = (card: any) => {
<!-- Table only — chart is outside the tab panes -->
<div class="w-100">
<div class="alert alert-dark rounded p-2 mb-0 table-responsive">
<div class="alert alert-dark rounded p-2 mb-0 table-responsive d-none">
<h6>Latest Verified Sales</h6>
<table class="table table-sm mb-0">
<caption class="small">Filtered to remove mismatched language variants</caption>
@@ -382,4 +391,4 @@ const altSearchUrl = (card: any) => {
</div>
</div>
</div>
</div>
</div>