Block new trades during 3–5 PM Central no-trade window

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 <noreply@anthropic.com>
This commit is contained in:
Senofy
2026-03-09 14:24:37 -05:00
co-authored by Claude Sonnet 4.6
parent 1902322627
commit 5cba4ef175
+19
View File
@@ -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 (35 PM Central) — skipping');
return [];
}
const pointValue = POINT_VALUES[symbol];
if (!pointValue) throw new Error(`Unknown symbol: ${symbol}`);