Securities

Exchange

Introduction

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

Properties

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

Hours

To get the exchange hours, use the Exchange.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 IsOpen method.

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

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

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

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

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

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

var marketOpenTime = securityExchangeHours.GetNextMarketOpen(Time, extendedMarket: false);
market_open_time = security_exchange_hours.GetNextMarketOpen(self.Time, extendedMarket=False)

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

var marketCloseTime = securityExchangeHours.GetNextMarketClose(Time, extendedMarket: false);
market_close_time = security_exchange_hours.GetNextMarketClose(self.Time, extendedMarket=False)

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

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

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

var day = securityExchangeHours.GetNextTradingDay(Time);
day = security_exchange_hours.GetNextTradingDay(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 extendedMarketHours argument when you create the security subscription.

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

You only receive extended market hours data if you create the subscription with an intraday resolution. If you create the subscription with daily resolution, the daily 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: