self.get_datetime#

strategies.strategy.Strategy.get_datetime(self)#

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