self.get_datetime

lumibot.strategies.strategy.Strategy.get_datetime(self, adjust_for_delay: bool = False)

Returns the current datetime according to the data source. In a backtest this will be the current bar’s datetime. In live trading this will be the current datetime on the exchange.

Parameters:

adjust_for_delay (bool) – If True, will adjust the datetime for any delay in the data source.

Returns:

The current datetime.

Return type:

datetime.datetime

Example

>>> # Will return the current datetime
>>> datetime = self.get_datetime()
>>> self.log_message(f"The current datetime is {datetime}")