self.get_datetime#

lumibot.strategies.strategy.Strategy.get_datetime(self, adjust_for_delay=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.

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