diff --git a/nautilus_trader/model/data.pxd b/nautilus_trader/model/data.pxd index 4b1561f31b13..061fef40d9d5 100644 --- a/nautilus_trader/model/data.pxd +++ b/nautilus_trader/model/data.pxd @@ -200,6 +200,8 @@ cdef class Bar(Data): cpdef bint is_single_price(self) + cdef inline object to_capsule_c(self) + cdef class BookOrder: cdef BookOrder_t _mem @@ -406,6 +408,8 @@ cdef class QuoteTick(Data): cpdef Price extract_price(self, PriceType price_type) cpdef Quantity extract_size(self, PriceType price_type) + cdef inline object to_capsule_c(self) + cdef class TradeTick(Data): cdef TradeTick_t _mem @@ -458,3 +462,4 @@ cdef class TradeTick(Data): @staticmethod cdef TradeTick from_mem_c(TradeTick_t mem) + \ No newline at end of file diff --git a/nautilus_trader/model/data.pyx b/nautilus_trader/model/data.pyx index ec420e9657c0..54a676886a78 100644 --- a/nautilus_trader/model/data.pyx +++ b/nautilus_trader/model/data.pyx @@ -1450,6 +1450,11 @@ cdef class Bar(Data): """ return self._mem.open.raw == self._mem.high.raw == self._mem.low.raw == self._mem.close.raw + def to_capsule(self): + return self.to_capsule_c() + + cdef inline object to_capsule_c(self): + return PyCapsule_New(&self._mem, NULL, NULL) cdef class DataType: """ @@ -4165,6 +4170,11 @@ cdef class QuoteTick(Data): else: raise ValueError(f"Cannot extract with PriceType {price_type_to_str(price_type)}") + def to_capsule(self): + return self.to_capsule_c() + + cdef inline object to_capsule_c(self): + return PyCapsule_New(&self._mem, NULL, NULL) cdef class TradeTick(Data): """