self.localize_datetime¶
- lumibot.strategies.strategy.Strategy.localize_datetime(self, dt: datetime)
Returns a datetime localized to the data source’s timezone.
A naive time in the repeated hour when daylight saving time ends maps to the earlier of the two instants; one in the skipped spring hour moves forward.
- Parameters:
dt (datetime.datetime) – The datetime to localize.
- Returns:
The localized datetime.
- Return type:
datetime.datetime
Example
>>> # Will return a datetime localized to the data source's timezone >>> localize_datetime = self.localize_datetime(dt=datetime.datetime(2020, 1, 1)) >>> self.log_message(f"Localized datetime: {localize_datetime}")