Skip to content

MarketHoursSegment

QuantConnect.Securities.MarketHoursSegment

MarketHoursSegment(
    state: MarketHoursState,
    start: timedelta,
    end: timedelta,
)

Bases: Object

Represents the state of an exchange during a specified time range

Initializes a new instance of the MarketHoursSegment class

Parameters:

Name Type Description Default
state MarketHoursState

The state of the market during the specified times

required
start timedelta

The start time of the segment

required
end timedelta

The end time of the segment

required

start

start: timedelta

Gets the start time for this segment

end

end: timedelta

Gets the end time for this segment

state

Gets the market hours state for this segment

closed_all_day

closed_all_day() -> MarketHoursSegment

Gets a new market hours segment representing being open all day

contains

contains(time: timedelta) -> bool

Determines whether or not the specified time is contained within this segment

Parameters:

Name Type Description Default
time timedelta

The time to check

required

Returns:

Type Description
bool

True if this segment contains the specified time, false otherwise.

get_market_hours_segments

get_market_hours_segments(
    extended_market_open: timedelta,
    market_open: timedelta,
    market_close: timedelta,
    extended_market_close: timedelta,
) -> List[MarketHoursSegment]

Creates the market hours segments for the specified market open/close times

Parameters:

Name Type Description Default
extended_market_open timedelta

The extended market open time. If no pre market, set to market open

required
market_open timedelta

The regular market open time

required
market_close timedelta

The regular market close time

required
extended_market_close timedelta

The extended market close time. If no post market, set to market close

required

Returns:

Type Description
List[MarketHoursSegment]

An array of MarketHoursSegment representing the specified market open/close times.

open_all_day

open_all_day() -> MarketHoursSegment

Gets a new market hours segment representing being open all day

overlaps

overlaps(start: timedelta, end: timedelta) -> bool

Determines whether or not the specified time range overlaps with this segment

Parameters:

Name Type Description Default
start timedelta

The start of the range

required
end timedelta

The end of the range

required

Returns:

Type Description
bool

True if the specified range overlaps this time segment, false otherwise.

to_string

to_string() -> str

Returns a string that represents the current object.

Returns:

Type Description
str

A string that represents the current object.