()
| 4 | |
| 5 | |
| 6 | def 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 | |
| 32 | if __name__ == "__main__": |
no test coverage detected