Skip to content

Commit

Permalink
quote and bar to_capsule
Browse files Browse the repository at this point in the history
  • Loading branch information
ghill2 committed Nov 24, 2024
1 parent 230b42f commit d73faed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nautilus_trader/model/data.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -458,3 +462,4 @@ cdef class TradeTick(Data):

@staticmethod
cdef TradeTick from_mem_c(TradeTick_t mem)

10 changes: 10 additions & 0 deletions nautilus_trader/model/data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit d73faed

Please sign in to comment.