TimeKeeper
QuantConnect.TimeKeeper
TimeKeeper(
utc_date_time: Union[datetime, date],
*time_zones: Union[DateTimeZone, Iterable[DateTimeZone]]
)
TimeKeeper(
utc_date_time: Union[datetime, date],
time_zones: List[DateTimeZone],
)
Bases: Object, ITimeKeeper
Provides a means of centralizing time for various time zones.
Initializes a new instance of the TimeKeeper class at the specified UTC time and for the specified time zones. Each time zone specified will cause the creation of a LocalTimeKeeper to handle conversions for that time zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_date_time
|
Union[datetime, date]
|
The initial time |
required |
time_zones
|
Union[DateTimeZone, Iterable[DateTimeZone]]
|
The time zones used to instantiate LocalTimeKeeper instances. |
()
|
utc_time
utc_time: datetime
Gets the current time in UTC
add_time_zone
add_time_zone(time_zone: Any) -> None
Adds the specified time zone to this time keeper
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_zone
|
Any
|
|
required |
get_local_time_keeper
get_local_time_keeper(time_zone: Any) -> LocalTimeKeeper
Gets the LocalTimeKeeper instance for the specified time zone
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_zone
|
Any
|
The time zone whose LocalTimeKeeper we seek |
required |
Returns:
| Type | Description |
|---|---|
LocalTimeKeeper
|
The LocalTimeKeeper instance for the specified time zone. |
get_time_in
get_time_in(time_zone: Any) -> datetime
Gets the local time in the specified time zone. If the specified DateTimeZone has not already been added, this will throw a KeyNotFoundException.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_zone
|
Any
|
The time zone to get local time for |
required |
Returns:
| Type | Description |
|---|---|
datetime
|
The local time in the specifed time zone. |
set_utc_date_time
set_utc_date_time(
utc_date_time: Union[datetime, date],
) -> None
Sets the current UTC time for this time keeper and the attached child LocalTimeKeeper instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_date_time
|
Union[datetime, date]
|
The current time in UTC |
required |