INNER CODE UNIT · TypeScript
absChange
alexanderwanyoike/the0 · example-bots/typescript-price-alerts/main.ts:227
const absChange = Math.abs(priceData.change_pct);
if (absChange >= threshold) {
state.lastAlertTime = now;
const direction = priceData.change_pct > 0 ? "spike" : "drop";
const severity =
absChange >= threshold * 2
? "high"
: absChange >= threshold * 1.5
? "medium"
: "low";
return {
symbol,
type: `price_${direction}`,
change_pct: Math.round(priceData.change_pct * 100) / 100,
message: `${symbol} ${direction} of ${absChange.toFixed(2)}%`,