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

Function main

projects/Python/examples/serialization.py:6–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def main():
7 # Create a new account with some orders
8 account = proto.Account(1, "Test", proto.State.good, proto.Balance("USD", 1000.0), proto.Balance("EUR", 100.0))
9 account.orders.append(proto.Order(1, "EURUSD", proto.OrderSide.buy, proto.OrderType.market, 1.23456, 1000.0))
10 account.orders.append(proto.Order(2, "EURUSD", proto.OrderSide.sell, proto.OrderType.limit, 1.0, 100.0))
11 account.orders.append(proto.Order(3, "EURUSD", proto.OrderSide.buy, proto.OrderType.stop, 1.5, 10.0))
12
13 # Serialize the account to the FBE stream
14 writer = proto.AccountModel(fbe.WriteBuffer())
15 writer.serialize(account)
16 assert writer.verify()
17
18 # Show the serialized FBE size
19 print("FBE size: {}".format(writer.buffer.size))
20
21 # Deserialize the account from the FBE stream
22 reader = proto.AccountModel(fbe.ReadBuffer())
23 reader.attach_buffer(writer.buffer)
24 assert reader.verify()
25 reader.deserialize(account)
26
27 # Show account content
28 print()
29 print(account)
30
31
32if __name__ == "__main__":

Callers 1

serialization.pyFile · 0.70

Calls 9

serializeMethod · 0.95
verifyMethod · 0.95
deserializeMethod · 0.95
AccountMethod · 0.45
BalanceMethod · 0.45
OrderMethod · 0.45
AccountModelMethod · 0.45
formatMethod · 0.45
attach_bufferMethod · 0.45

Tested by

no test coverage detected