Skip to content

FutureExchange

QuantConnect.Securities.Future.FutureExchange

FutureExchange(exchange_hours: SecurityExchangeHours)

Bases: SecurityExchange

Future exchange class - information and helper tools for future exchange properties

Initializes a new instance of the FutureExchange class using the specified exchange hours to determine open/close times

Parameters:

Name Type Description Default
exchange_hours SecurityExchangeHours

Contains the weekly exchange schedule plus holidays

required

trading_days_per_year

trading_days_per_year: int

Number of trading days per year for this security, 252.

hours

Gets the SecurityExchangeHours for this exchange

time_zone

time_zone: Any

Gets the time zone for this exchange

local_time

local_time: datetime

Time from the most recent data

exchange_open

exchange_open: bool

Boolean property for quickly testing if the exchange is open.

closing_soon

closing_soon: bool

Boolean property for quickly testing if the exchange is 10 minutes away from closing.

date_is_open

date_is_open(
    date_to_check: Union[datetime, date],
    extended_market_hours: bool = False,
) -> bool

Check if the date is open.

Parameters:

Name Type Description Default
date_to_check Union[datetime, date]

Date to check

required
extended_market_hours bool

True to consider days with extended market hours only as open

False

Returns:

Type Description
bool

Return true if the exchange is open for this date.

date_time_is_open

date_time_is_open(date_time: Union[datetime, date]) -> bool

Check if this DateTime is open.

Parameters:

Name Type Description Default
date_time Union[datetime, date]

DateTime to check

required

Returns:

Type Description
bool

Boolean true if the market is open.

is_closing_soon

is_closing_soon(minutes_to_close: int) -> bool

Determines if the exchange is going to close in the next provided minutes

Parameters:

Name Type Description Default
minutes_to_close int

Minutes to close to check

required

Returns:

Type Description
bool

Returns true if the exchange is going to close in the next provided minutes.

is_open_during_bar

is_open_during_bar(
    bar_start_time: Union[datetime, date],
    bar_end_time: Union[datetime, date],
    is_extended_market_hours: bool,
) -> bool

Determines if the exchange was open at any time between start and stop

set_local_date_time_frontier_provider

set_local_date_time_frontier_provider(
    time_provider: LocalTimeKeeper,
) -> None

Set the current datetime in terms of the exchange's local time zone

Parameters:

Name Type Description Default
time_provider LocalTimeKeeper

Most recent data tick

required

set_market_hours

set_market_hours(
    market_hours_segments: List[MarketHoursSegment],
    *days: Union[DayOfWeek, Iterable[DayOfWeek]]
) -> None

Sets the regular market hours for the specified days If no days are specified then all days will be updated.

Parameters:

Name Type Description Default
market_hours_segments List[MarketHoursSegment]

Specifies each segment of the market hours, such as premarket/market/postmark

required
days Union[DayOfWeek, Iterable[DayOfWeek]]

The days of the week to set these times for

()