Esempio n. 1
0
    def timeReceived(self, tzinfo=UTC):
        """Get the time when the message was received by the SDK.

        Args:
            tzinfo (~datetime.tzinfo): Timezone info

        Returns:
            datetime.datetime or datetime.date or datetime.time: Time when the
            message was received by the SDK.

        Raises:
            ValueError: If this information was not recorded for this message.
                See :meth:`SessionOptions.recordSubscriptionDataReceiveTimes`
                for information on configuring this recording.

        The resulting datetime will be represented using the specified
        ``tzinfo`` value, and will be measured using a high-resolution clock
        internal to the SDK.
        """
        err_code, time_point = internals.blpapi_Message_timeReceived(
            self.__handle)
        if err_code != 0:
            raise ValueError("Message has no timestamp")
        original = internals.blpapi_HighPrecisionDatetime_fromTimePoint_wrapper(
            time_point)

        native = _DatetimeUtil.convertToNative(original)
        return native.astimezone(tzinfo)
Esempio n. 2
0
 def timeReceived(self, tzinfo=UTC):
     """Return the time when the message was received by the SDK. This
     method will throw 'ValueError' if this information was not recorded for
     this message; see 'SessionOptions.recordSubscriptionDataReceiveTimes'
     for information on configuring this recording. The resulting datetime
     will be represented using the specified 'tzinfo' value, and will be
     measured using a high-resolution clock internal to the SDK; see
     'highresclock' for more information on this clock."""
     original = internals.blpapi_Message_timeReceived_wrapper(self.__handle)
     native = _DatetimeUtil.convertToNative(original)
     return native.astimezone(tzinfo)
Esempio n. 3
0
def now(tzinfo=UTC):
    """Return the current time using the same clock as is used to measure the
    'timeReceived' value on incoming messages; note that this is *not*
    necessarily the same clock as is accessed by calls to 'datetime.now'. The
    resulting datetime will be represented using the specified 'tzinfo'.
    """
    err_code, time_point = internals.blpapi_HighResolutionClock_now()
    if err_code != 0:
        raise RuntimeError("High resolution clock error")
    original = internals.blpapi_HighPrecisionDatetime_fromTimePoint_wrapper(
        time_point)
    native = _DatetimeUtil.convertToNative(original)
    return native.astimezone(tzinfo)