MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / Order

Class Order

projects/Python/proto/protoex.py:395–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393
394@functools.total_ordering
395class Order(object):
396 __slots__ = "id", "symbol", "side", "type", "price", "volume", "tp", "sl",
397
398 def __init__(self, id=0, symbol="", side=None, type=None, price=float(0.0), volume=float(0.0), tp=float(10.0), sl=float(-10.0)):
399 if side is None:
400 side = OrderSide()
401 if type is None:
402 type = OrderType()
403 self.id = id
404 self.symbol = symbol
405 self.side = side
406 self.type = type
407 self.price = price
408 self.volume = volume
409 self.tp = tp
410 self.sl = sl
411
412 # Struct shallow copy
413 def copy(self, other):
414 self.id = other.id
415 self.symbol = other.symbol
416 self.side = other.side
417 self.type = other.type
418 self.price = other.price
419 self.volume = other.volume
420 self.tp = other.tp
421 self.sl = other.sl
422 return self
423
424 # Struct deep clone
425 def clone(self):
426 # Serialize the struct to the FBE stream
427 writer = OrderModel(fbe.WriteBuffer())
428 writer.serialize(self)
429
430 # Deserialize the struct from the FBE stream
431 reader = OrderModel(fbe.ReadBuffer())
432 reader.attach_buffer(writer.buffer)
433 return reader.deserialize()[0]
434
435 def __eq__(self, other):
436 if not isinstance(self, other.__class__):
437 return NotImplemented
438 if not self.id == other.id:
439 return False
440 return True
441
442 def __lt__(self, other):
443 if not isinstance(self, other.__class__):
444 return NotImplemented
445 if self.id < other.id:
446 return True
447 if self.id == other.id:
448 return False
449 return False
450
451 @property
452 def __key__(self):

Callers 7

__from_json__Method · 0.70
getMethod · 0.70
deserializeMethod · 0.70
getMethod · 0.70
deserializeMethod · 0.70
__init__Method · 0.70
get_fieldsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected