예제 #1
0
    def _adjust_ib_time_to_local(self, timestamp_ib) -> datetime.datetime:

        if getattr(timestamp_ib, "tz_localize", None) is None:
            # daily, nothing to do
            return timestamp_ib

        # IB timestamp already includes tz
        timestamp_ib_with_tz = timestamp_ib
        local_timestamp_ib_with_tz = timestamp_ib_with_tz.astimezone(tz.tzlocal())
        local_timestamp_ib = strip_timezone_fromdatetime(local_timestamp_ib_with_tz)

        return local_timestamp_ib
예제 #2
0
    def adjust_ib_time_to_local(self, timestamp_ib):

        if getattr(timestamp_ib, "tz_localize", None) is None:
            # daily, nothing to do
            return timestamp_ib

        timestamp_ib_with_tz = self.add_tz_to_ib_time(timestamp_ib)
        local_timestamp_ib_with_tz = timestamp_ib_with_tz.astimezone(
            tz.tzlocal())
        local_timestamp_ib = strip_timezone_fromdatetime(
            local_timestamp_ib_with_tz)

        return local_timestamp_ib
예제 #3
0
    def get_broker_time_local_tz(self) -> datetime.datetime:
        ib_time = self.ib.reqCurrentTime()
        local_ib_time_with_tz = ib_time.astimezone(tz.tzlocal())
        local_ib_time = strip_timezone_fromdatetime(local_ib_time_with_tz)

        return local_ib_time