INNER CODE UNIT · JavaScript
CVD_HISTORY_LEN
dearvn/tradovate-trading-bot · agents/order-flow/index.js:37
const CVD_HISTORY_LEN = 60; // one entry per second for linreg
const CVD_UPDATE_INTERVAL_MS = 1_000;
// ── DST-aware Eastern Time helpers ────────────────────────────────────────────
function nthSundayUTC(year, month, n) {
// month: 0-indexed JS month
const d = new Date(Date.UTC(year, month, 1));
const day = d.getUTCDay(); // 0=Sun
d.setUTCDate(1 + ((7 - day) % 7) + (n - 1) * 7);
return d;
}
function etOffsetHours(now) {
const y = now.getUTCFullYear();
// EDT: 2nd Sunday March 02:00 → 4th Sunday November 02:00
const dstStart = nthSundayUTC(y, 2, 2); // March (month 2)
dstStart.setUTCHours(7); // 02:00 ET = 07:00 UTC