Appearance
Calendar & Time
Market Time
python
market_time = client.get_market_time()Returns: MarketTime dataclass
python
MarketTime(
eastern_time='2026-01-26T11:11:00.793328-05:00',
is_weekday=True,
is_market_hours=True,
market_open='2026-01-26T09:30:00-05:00',
market_close='2026-01-26T16:00:00-05:00'
)| Field | Type | Description |
|---|---|---|
eastern_time | str | Current time in ET (ISO format) |
is_weekday | bool | True if Mon-Fri |
is_market_hours | bool | True if 9:30-16:00 ET |
market_open | str | Today's open time |
market_close | str | Today's close time |
Quick Checks
python
is_open = client.is_market_open() # Returns boolEastern Time
python
from datetime import time
et = client.get_eastern_time() # Returns datetime in US/EasternTrade Window
python
# Check if current time is within 10:00-15:00 ET
if client.is_within_trade_window(time(10, 0), time(15, 0)):
# Place ordersEnd of Day
python
if client.is_eod(): # Default: 15:30 ET
# Exit positionsCustom EOD time:
python
if client.is_eod(time(14, 0)): # 2:00 PM ETTrading Calendar
python
calendar = client.get_trading_calendar(days=30)Returns: Dict with holidays and early closes.
Next Open/Close
python
next_open = client.get_next_market_open("NYSE")
next_close = client.get_next_market_close("NYSE")Count Trading Days
python
days = client.count_trading_days("2026-01-01", "2026-03-31")Returns: int — number of trading days in the range.
Usage Patterns
Gate Trading on Market Hours
python
if not client.is_market_open():
print("Market closed, skipping trade")
returnTime-Based Strategy Logic
python
et = client.get_eastern_time()
# Exit-only mode after 1:00 PM ET
if et.hour >= 13:
print("Exit-only mode")Safe Order Wrapper
python
def safe_order(client, symbol, qty, price):
if not client.is_market_open():
raise Exception("Market is closed")
return client.buy_limit(symbol, qty, price)