self.localize_datetime#

lumibot.strategies.strategy.Strategy.localize_datetime(self, dt: datetime)#

Returns a datetime localized to the data source’s timezone.

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}")