deephaven.calendar

This module provides a collection of business calendars and convenient calendar functions.

class BusinessCalendar(name=None)[source]

Bases: deephaven.calendar.Calendar

A business calendar.

business_days_in_range(start, end)[source]

Returns the business days between the specified start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

Returns

a list of dates

Return type

List[str]

Raises

DHError

business_schedule(date)[source]

Returns the specified day’s business schedule.

Parameters

date (str) – the date str, format must be “yyyy-MM-dd”

Return type

BusinessSchedule

Returns

a BusinessSchedule instance

Raises

DHError

property current_day

The current day.

day_of_week(date)

The day of week for the given date.

Parameters

date (str) – the date of interest

Return type

DayOfWeek

Returns

str

Raises

DHError

days_in_range(start, end)

Returns the days between the specified start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

Returns

a list of dates

Return type

List[str]

Raises

DHError

property default_business_periods

The default business periods for the business days. Returns a list of strings with a comma separating open and close times.

property is_business_day

If today is a business day.

is_last_business_day_of_month(date)[source]

Returns if the specified date is the last business day of the month.

Parameters

date (str) – the date

Return type

bool

Returns

bool

Raises

DHError

is_last_business_day_of_week(date)[source]

Returns if the specified date is the last business day of the week.

Parameters

date (str) – the date

Return type

bool

Returns

bool

Raises

DHError

j_object_type

alias of io.deephaven.time.calendar.BusinessCalendar

next_business_day(date)[source]

Gets the business day after the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

next_day(date)

Gets the day after the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

next_non_business_day(date)[source]

Gets the non-business day after the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

non_business_days_in_range(start, end)[source]

Returns the non-business days between the specified start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

Returns

a list of dates

Return type

List[str]

Raises

DHError

number_of_business_days(start, end, end_inclusive=False)[source]

Returns the number of business days between the start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

  • end_inclusive (bool) – whether to include the end date, default is False

Return type

int

Returns

int

Raises

DHError

number_of_days(start, end, end_inclusive=False)

Returns the number of days between the start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

  • end_inclusive (bool) – whether to include the end date, default is False

Return type

int

Returns

int

Raises

DHError

number_of_non_business_days(start, end, end_inclusive=False)[source]

Returns the number of non-business days between the start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

  • end_inclusive (bool) – whether to include the end date, default is False

Return type

int

Returns

int

Raises

DHError

previous_business_day(date)[source]

Gets the business day prior to the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

previous_day(date)

Gets the day prior to the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

previous_non_business_day(date)[source]

Gets the non-business day prior to the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

property standard_business_day_length

The length of a standard business day in nanoseconds.

property time_zone

Returns the timezone of the calendar.

class BusinessPeriod(j_business_period)[source]

Bases: deephaven._wrapper.JObjectWrapper

A period of business time during a business day.

property end_time

The end of the period.

j_object_type

alias of io.deephaven.time.calendar.BusinessPeriod

property length

The length of the period in nanoseconds.

property start_time

The start of the period.

class BusinessSchedule(j_business_schedule)[source]

Bases: deephaven._wrapper.JObjectWrapper

A business schedule defines a single business day.

property business_periods

The business periods of the day.

Returns

List[BusinessPeriod]

business_time_elapsed(time)[source]

Returns the amount of business time in nanoseconds that has elapsed on the given day by the specified time.

Parameters

time (DateTime) – the time during the day

Return type

int

Returns

int

property end_of_day

The end of the business day.

is_business_day()[source]

Whether it is a business day.

Return type

bool

Returns

bool

is_business_time(time)[source]

Whether the specified time is a business time for the day.

Parameters

time (DateTime) – the time during the day

Return type

bool

Returns

bool

j_object_type

alias of io.deephaven.time.calendar.BusinessSchedule

property start_of_day

The start of the business day.

class Calendar[source]

Bases: deephaven._wrapper.JObjectWrapper

property current_day

The current day.

day_of_week(date)[source]

The day of week for the given date.

Parameters

date (str) – the date of interest

Return type

DayOfWeek

Returns

str

Raises

DHError

days_in_range(start, end)[source]

Returns the days between the specified start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

Returns

a list of dates

Return type

List[str]

Raises

DHError

j_object_type

alias of io.deephaven.time.calendar.Calendar

next_day(date)[source]

Gets the day after the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

number_of_days(start, end, end_inclusive=False)[source]

Returns the number of days between the start and end dates.

Parameters
  • start (str) – the start day of the range

  • end (str) – the end day of the range

  • end_inclusive (bool) – whether to include the end date, default is False

Return type

int

Returns

int

Raises

DHError

previous_day(date)[source]

Gets the day prior to the given date.

Parameters

date (str) – the date of interest

Return type

str

Returns

str

Raises

DHError

property time_zone

Returns the timezone of the calendar.

class DayOfWeek(value)[source]

Bases: enum.Enum

A Enum that defines the days of a week.

calendar_names()[source]

Returns the names of all available calendars.

Return type

List[str]

Returns

a list of names of all available calendars

Raises

DHError

default_calendar_name()[source]

Returns the default calendar name which is set by the ‘Calendar.default’ property in the configuration file that the Deephaven server is started with.

Returns

the default business calendar name

Raises

DHError