From 3cfcc9a0eec121838470dc929ffa7a0c441d6d3c Mon Sep 17 00:00:00 2001 From: George Hill Date: Fri, 25 Oct 2024 14:55:29 +0100 Subject: [PATCH] quote and bar to_capsule --- nautilus_trader/model/data.pxd | 5 +++++ nautilus_trader/model/data.pyx | 10 ++++++++++ 2 files changed, 15 insertions(+) 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 a108fc3be6d7..883315e78226 100644 --- a/nautilus_trader/model/data.pyx +++ b/nautilus_trader/model/data.pyx @@ -1451,6 +1451,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: """ @@ -4166,6 +4171,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): """