> ## Documentation Index
> Fetch the complete documentation index at: https://takeprofit.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Package indie.schedule

Schedule package that contains classes for working with schedules.

***

## Variables

**1. Constants**

[Navigate to const\_ALL\_DAYS](#const_ALL_DAYS)

ALL\_DAYS

list\[indie.schedule.week\_day]

List of `week_day`'s from `week_day.MONDAY` to `week_day.SUNDAY`.

[Navigate to const\_WEEKEND](#const_WEEKEND)

WEEKEND

list\[indie.schedule.week\_day]

List of `week_day`'s from `week_day.SATURDAY` to `week_day.SUNDAY`.

[Navigate to const\_WORKDAYS](#const_WORKDAYS)

WORKDAYS

list\[indie.schedule.week\_day]

List of `week_day`'s from `week_day.MONDAY` to `week_day.FRIDAY`.

***

## Types

### `Schedule`

*type*

Data type that manages a collection of scheduling rules, allowing for specific times and exceptions to be defined.

**1. Methods**

[Navigate to method\_Schedule\_init](#method_Schedule_init)

**init**

(rules, except\_once, except\_yearly, timezone) -> None

Class constructor (initializer for the data type).

**parameters info**

rules

list\[indie.schedule.ScheduleRule]

required

List of ScheduleRule instances that define the active scheduling rules.

except\_once

list\[datetime.datetime]

default:
\[]

List of dates that are excluded from the schedule only once.

except\_yearly

list\[datetime.datetime]

default:
\[]

List of dates that are excluded from the schedule every year.

timezone

str

default:
"UTC"

Timezone for schedule.

[Navigate to method\_Schedule\_is\_empty](#method_Schedule_is_empty)

is\_empty

() -> bool

Checks if the rules list in Schedule is empty. Returns `True` if list of rules is empty; otherwise, returns `False`.

[Navigate to method\_Schedule\_contains](#method_Schedule_contains)

**contains**

(t) -> bool

Checks whether a given timestamp falls within the defined schedule. Returns `True` if the timestamp falls within the schedule's active periods, otherwise returns `False`.

**parameters info**

t

float

required

Timestamp to check in defined schedule.

**contains**

(d) -> bool

Checks whether a given timestamp falls within the defined schedule. Returns `True` if the timestamp falls within the schedule's active periods, otherwise returns `False`.

**parameters info**

d

datetime.datetime

required

Datetime to check in defined schedule.

[Navigate to method\_Schedule\_is\_same\_period](#method_Schedule_is_same_period)

is\_same\_period

(timestamp1, timestamp2) -> bool

Determines whether two timestamps fall within the same schedule period on the same day. Returns `True` if both timestamps fall within the same period of the schedule, even if they are in different calendar days. False if the timestamps belong to different periods within the schedule.

**parameters info**

timestamp1

float

required

First timestamp to check.

timestamp2

float

required

Second timestamp to check.

> [!NOTE]
>
> This method checks if two timestamps, which may belong to different calendar days, are part of the same schedule period. It handles cases where a schedule spans across two consecutive days (e.g., a trading schedule that extends past midnight) and ensures both timestamps belong to the same logical period within the schedule.

> [!NOTE]
>
> See also: [`TradingSession`](https://takeprofit.com/docs/indie/Library-reference/package-indie#class_TradingSession)[`ScheduleRule`](https://takeprofit.com/docs/indie/Library-reference/package-indie-schedule#class_ScheduleRule)

***

### `ScheduleRule`

*type*

Data type to represent a rule for a schedule, specifying the start and end times, along with the weekdays when the rule is active.

**1. Methods**

[Navigate to method\_ScheduleRule\_init](#method_ScheduleRule_init)

**init**

(start, end, days) -> None

Class constructor (initializer for the data type).

**parameters info**

start

datetime.time

required

Start time of the rule.

end

datetime.time

required

End time of the rule.

days

list\[indie.schedule.week\_day]

default:
indie.schedule.ALL\_DAYS

List of weekdays when the rule is active.

```py Example theme={null}
# this rule applies from 9:00 AM to 6:30 PM (6:30 is not included) on weekdays (Monday through Friday).
rule = ScheduleRule(start=time(hour=9), end=time(hour=18, minute=30), days=WORKDAYS)
# this overnight_rule applies from 8:15 PM to 7:30 AM on weekdays (Monday through Friday).
overnight_rule = ScheduleRule(start=time(hour=20, minute=15), end=time(hour=7, minute=30), days=WORKDAYS)
```

> [!NOTE]
>
> For rules that span overnight (e.g., from 10:00 PM to 6:00 AM), the end time should be on the day listed in days, while the start time is understood to be on the previous day. This allows the rule to cover activities that occur late in the evening and extend into the early hours of the next day.

> [!NOTE]
>
> See also: [`Schedule`](https://takeprofit.com/docs/indie/Library-reference/package-indie-schedule#class_Schedule)[`TradingSession`](https://takeprofit.com/docs/indie/Library-reference/package-indie#class_TradingSession)

***

## Enums

### `week_day`

*enum*

Enum-like class with constants for days of week.

**1. Static fields**

[Navigate to const\_week\_day\_MONDAY](#const_week_day_MONDAY)

MONDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

[Navigate to const\_week\_day\_TUESDAY](#const_week_day_TUESDAY)

TUESDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

[Navigate to const\_week\_day\_WEDNESDAY](#const_week_day_WEDNESDAY)

WEDNESDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

[Navigate to const\_week\_day\_THURSDAY](#const_week_day_THURSDAY)

THURSDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

[Navigate to const\_week\_day\_FRIDAY](#const_week_day_FRIDAY)

FRIDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

[Navigate to const\_week\_day\_SATURDAY](#const_week_day_SATURDAY)

SATURDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

[Navigate to const\_week\_day\_SUNDAY](#const_week_day_SUNDAY)

SUNDAY

indie.schedule.week\_day

Built-in constants that represent days of week.

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.