From 996e7ff002922b811bbda1cb174a25c0d8d4206f Mon Sep 17 00:00:00 2001 From: jamsturg Date: Sat, 12 Jul 2025 17:14:22 +1000 Subject: [PATCH] Fix Cython compilation error in LimitOrder age methods - Changed return type from long long to double for c_age() and c_age_til() methods - Updated variable declarations to use double instead of long long for age_seconds - Fixed return value in c_age_til() to return -1.0 instead of -1 for consistency - Updated age() and age_til() public methods to cast double results to int This resolves the Cython compilation error: 'Cannot convert 'double' to Python object unless type is correctly specified' The underlying calculation already returns a double value (division by 1e6), so the type declarations now match the actual return type. --- hummingbot/core/data_type/limit_order.pxd | 4 ++-- hummingbot/core/data_type/limit_order.pyx | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hummingbot/core/data_type/limit_order.pxd b/hummingbot/core/data_type/limit_order.pxd index cfb9ed17f89..6e992d64737 100644 --- a/hummingbot/core/data_type/limit_order.pxd +++ b/hummingbot/core/data_type/limit_order.pxd @@ -6,8 +6,8 @@ from .LimitOrder cimport LimitOrder as CPPLimitOrder cdef class LimitOrder: cdef: CPPLimitOrder _cpp_limit_order - cdef long long c_age(self) - cdef long long c_age_til(self, long long start_timestamp) + cdef double c_age(self) + cdef double c_age_til(self, long long start_timestamp) cdef LimitOrder c_create_limit_order_from_cpp_limit_order(const CPPLimitOrder cpp_limit_order) diff --git a/hummingbot/core/data_type/limit_order.pyx b/hummingbot/core/data_type/limit_order.pyx index ecda2408c2f..73b3736cb8f 100644 --- a/hummingbot/core/data_type/limit_order.pyx +++ b/hummingbot/core/data_type/limit_order.pyx @@ -39,7 +39,7 @@ cdef class LimitOrder: list data = [] str order_id_txt, type_txt, spread_txt, age_txt, hang_txt double price, quantity - long long age_seconds + double age_seconds long long now_timestamp = int(time.time() * 1e6) if end_time_order_age == 0 else end_time_order_age sells.extend(buys) for order in sells: @@ -145,7 +145,7 @@ cdef class LimitOrder: str retval = cpp_position.decode("utf8") return PositionAction(retval) - cdef long long c_age_til(self, long long end_timestamp): + cdef double c_age_til(self, long long end_timestamp): """ Calculates and returns age of the order since it was created til end_timestamp in seconds :param end_timestamp: The end timestamp @@ -159,19 +159,19 @@ cdef class LimitOrder: if 0 < start_timestamp < end_timestamp: return int(end_timestamp - start_timestamp) / 1e6 else: - return -1 + return -1.0 - cdef long long c_age(self): + cdef double c_age(self): """ Calculates and returns age of the order since it was created til now. """ return self.c_age_til(int(time.time() * 1e6)) def age(self) -> int: - return self.c_age() + return int(self.c_age()) def age_til(self, start_timestamp: int) -> int: - return self.c_age_til(start_timestamp) + return int(self.c_age_til(start_timestamp)) def order_type(self) -> OrderType: return OrderType.LIMIT