INNER CODE UNIT · Python
from_bytes
baileydanseglio/thetadata-python · thetadata/client.py:175
def from_bytes(self, data: bytes):
"""Deserializes a trade."""
view = memoryview(data)
parse_int = lambda d: int.from_bytes(d, "big")
mult = _pt_to_price_mul[parse_int(view[36:40])]
self.ms_of_day = parse_int(view[0:4])
self.bid_size = parse_int(view[4:8])
self.bid_exchange = Exchange.from_code(parse_int(view[8:12]))
self.bid_price = round(parse_int(view[12:16]) * mult, 4)
self.bid_condition = QuoteCondition.from_code(parse_int(view[16:20]))
self.ask_size = parse_int(view[20:24])
self.ask_exchange = Exchange.from_code(parse_int(view[24:28]))
self.ask_price = round(parse_int(view[28:32]) * mult, 4)
self.ask_condition = QuoteCondition.from_code(parse_int(view[32:36]))
date_raw = str(parse_int(view[40:44]))
self.date = date(year=int(date_raw[0:4]), month=int(date_raw[4:6]), day=int(date_raw[6:8]))
def copy_from(self, other_quote):