Securities

Exchange

Introduction

The Exchange property of a Security object contains information about the exchange that lists the security.

Properties

The Exchangeexchange property of a Security object returns an SecurityExchange object, which has the following attributes:

Hours

To get the exchange hours, use the Exchange.Hoursexchange.hours property on a Security object.

var securityExchangeHours = Securities["SPY"].Exchange.Hours;
security_exchange_hours = self.securities["SPY"].exchange.hours

The preceding code snippet returns a SecurityExchangeHours object, which has the following attributes:

To check if the exchange is open at a specific time, call the IsOpenis_open method.

// Check if the exchange is open at a specific time
var isOpenNow = securityExchangeHours.IsOpen(Time, extendedMarketHours: false);

// Check if the exchange is open at any point in time over a specific interval
var isOpen = securityExchangeHours.IsOpen(Time, Time.AddDays(1), extendedMarketHours: false);
# Check if the exchange is open at a specific time
is_open_now = security_exchange_hours.is_open(self.time, extended_market_hours=False)

# Check if the exchange is open at any point in time over a specific interval
is_open = security_exchange_hours.is_open(self.time, self.time + timedelta(days=1), extended_market_hours=False)

To check if the exchange is open on a specific date, call the IsDateOpenis_date_open method.

var isOpen = securityExchangeHours.IsDateOpen(Time);
is_open = security_exchange_hours.is_date_open(self.time)

To get the next market open time, call the GetNextMarketOpenget_next_market_open method.

var marketOpenTime = securityExchangeHours.GetNextMarketOpen(Time, extendedMarketHours: false);
market_open_time = security_exchange_hours.get_next_market_open(self.time, extended_market_hours=False)

To get the next market close time, call the GetNextMarketCloseget_next_market_close method.

var marketCloseTime = securityExchangeHours.GetNextMarketClose(Time, extendedMarketHours: false);
market_close_time = security_exchange_hours.get_next_market_close(self.time, extended_market_hours=False)

To get the previous trading day, call the GetPreviousTradingDayget_previous_trading_day method.

var day = securityExchangeHours.GetPreviousTradingDay(Time);
day = security_exchange_hours.get_previous_trading_day(self.time)

To get the next trading day, call the GetNextTradingDayget_next_trading_day method.

var day = securityExchangeHours.GetNextTradingDay(Time);
day = security_exchange_hours.get_next_trading_day(self.time)

Extended Market Hours

By default, your security subscriptions only cover regular trading hours. To subscribe to pre and post-market trading hours for a specific asset, enable the extendedMarketHoursextended_market_hours argument when you create the security subscription.

AddEquity("SPY", extendedMarketHours: true);
self.add_equity("SPY", extended_market_hours=True)

You only receive extended market hours data if you create the subscription with minute, second, or tick resolution. If you create the subscription with daily or hourly resolution, the bars only reflect the regular trading hours.

24 Hour Markets

The Crypto market trades 24/7, but other asset classes only trade during part of the week. Each market has an official trading schedule, but it can be impacted by daylight savings, holidays, and trading halts.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: