Skip to content

Conversation

@jamsturg
Copy link

Description

This PR fixes a Cython compilation error in the LimitOrder class that was preventing successful compilation of the project.

Problem

The Cython compiler was failing with the error: Cannot convert 'double' to Python object unless type is correctly specified

This occurred in the c_age() and c_age_til() methods of the LimitOrder class, where the return type was declared as long long but the actual calculation returned a double value due to the division by 1e6.

Solution

  • Changed the return type from long long to double for both c_age() and c_age_til() methods in the .pxd file
  • Updated the local variable age_seconds declaration from long long to double in the .pyx file
  • Fixed the return value in c_age_til() to return -1.0 instead of -1 for type consistency
  • Updated the public age() and age_til() methods to cast the double results to int before returning

Files Changed

  • hummingbot/core/data_type/limit_order.pxd
  • hummingbot/core/data_type/limit_order.pyx

Testing

The fix resolves the Cython compilation error while maintaining backward compatibility. The public interface continues to return integers as expected, but the internal calculations now properly handle the floating-point arithmetic.

Request for Review

Please review this fix for the Cython compilation issue. The changes are minimal and focused on correcting the type declarations to match the actual return types from the calculations.

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant