Skip to content

[Migration] hummingbot.core.data_type.order_expiration_entry - Tier 3 Rust Migration #21

Description

@MementoRC

Module: hummingbot.core.data_type.order_expiration_entry

  • Tier: 3 – Rust Migration
  • Source Path: hummingbot/core/data_type/order_expiration_entry.pyx
  • C++ Source: hummingbot/core/cpp/OrderExpirationEntry.cpp, OrderExpirationEntry.h
  • Status: Migration candidate

API Surface

C++ Struct Fields (private)

Field Type Description
tradingPair std::string Trading pair identifier
orderId std::string Client order ID
timestamp double Order creation timestamp
expiration_timestamp double Order expiration timestamp

C++ Constructors

  • OrderExpirationEntry() — default constructor (all fields zeroed/empty)
  • OrderExpirationEntry(string tradingPair, string orderId, double timestamp, double expiration_timestamp) — parameterized constructor
  • OrderExpirationEntry(const OrderExpirationEntry &other) — copy constructor
  • OrderExpirationEntry &operator=(const OrderExpirationEntry &other) — copy assignment

C++ Methods

Method Return Type Description
getTradingPair() std::string Returns trading pair
getClientOrderID() std::string Returns client order ID
getTimestamp() double Returns creation timestamp
getExpirationTimestamp() double Returns expiration timestamp
operator< (friend) bool Ordering: by expiration_timestamp first, then orderId

Python-facing API (Cython wrapper)

class OrderExpirationEntry:
    def __init__(self,
                 trading_pair: str,
                 order_id: str,
                 timestamp: float,
                 expiration_ts: float): ...

    @property
    def trading_pair(self) -> str: ...

    @property
    def order_id(self) -> str: ...

    @property
    def timestamp(self) -> float: ...

    @property
    def expiration_timestamp(self) -> float: ...

    def __repr__(self) -> str: ...

    @classmethod
    def to_pandas(cls, order_expiration_entries: List[OrderExpirationEntry]) -> pd.DataFrame: ...

Cython internal helper (cdef, not public Python)

cdef OrderExpirationEntry c_create_order_expiration_from_cpp_order_expiration(
    const CPPOrderExpirationEntry cpp_order_expiration_entry
)

to_pandas DataFrame columns

["trading_pair", "order_id", "timestamp", "expiration", "expiration_time"]

Note: .pyx exposes expiration_timestamp as a property, but to_pandas uses columns named expiration and expiration_time — these reference fields expiration_entry.expiration and expiration_entry.expiration_time which do not exist on the public API (likely a latent bug in the original).

Rust Migration Rationale

This is the smallest self-contained C++ module in hummingbot — a single struct wrapping order expiration data. It has no dependencies on other C++ modules (unlike OrderBookEntry or LimitOrder). This makes it the ideal first migration target to validate the full Rust pipeline end-to-end:

  1. C++ struct → Rust struct with PyO3 bindings
  2. Python wrapper with fallback pattern
  3. Integration into hummingbot via rust_accelerators

Dependencies

  • None (self-contained C++ struct)
  • Used by: paper_trade_exchange.pxd (via cimport — type annotation only)

Migration Scope

  • Replace OrderExpirationEntry.cpp + .h with Rust PyO3 implementation
  • Replace order_expiration_entry.pyx with Python wrapper importing from rust_accelerators
  • Maintain identical Python-facing API
  • Implement __lt__ for ordering (expiration_timestamp first, then order_id) to match C++ operator<
  • Clarify/fix to_pandas column naming (expiration / expiration_time vs expiration_timestamp)

This issue was created to validate the cython-framework → rust-accelerators migration pipeline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions