From 5cba4ef17544ffc442ad264bdc3c22b3a200e924 Mon Sep 17 00:00:00 2001 From: Senofy <63175905+Senofy@users.noreply.github.com> Date: Mon, 9 Mar 2026 14:24:37 -0500 Subject: [PATCH] =?UTF-8?q?Block=20new=20trades=20during=203=E2=80=935=20P?= =?UTF-8?q?M=20Central=20no-trade=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isInNoTradeWindow() checks the current hour in America/Chicago (handles CST/CDT automatically) and returns true from 15:00–16:59. runTrade() returns early if the window is active, blocking all entries regardless of whether the scheduler is running or a manual trade is triggered. Co-Authored-By: Claude Sonnet 4.6 --- lib/auto-trade.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/auto-trade.ts b/lib/auto-trade.ts index d4e13bc..c963958 100644 --- a/lib/auto-trade.ts +++ b/lib/auto-trade.ts @@ -48,9 +48,28 @@ function mapFirmConfig(firm: FirmWithAccounts): FirmConfig { +// ── helpers ─────────────────────────────────────────────────────────────────── + +/** Returns true during the 3:00 PM – 4:59 PM Central no-trade window. */ +function isInNoTradeWindow(): boolean { + const hour = parseInt( + new Intl.DateTimeFormat('en-US', { + hour: 'numeric', + hour12: false, + timeZone: 'America/Chicago', + }).format(new Date()), + 10 + ); + return hour >= 15 && hour < 17; +} + // ── core trade logic ────────────────────────────────────────────────────────── export async function runTrade(action: 'Buy' | 'Sell', symbol: string) { + if (isInNoTradeWindow()) { + console.log('[auto-trade] no-trade window active (3–5 PM Central) — skipping'); + return []; + } const pointValue = POINT_VALUES[symbol]; if (!pointValue) throw new Error(`Unknown symbol: ${symbol}`);