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}`);