| 11 | #include <iostream> |
| 12 | |
| 13 | int main(int argc, char** argv) |
| 14 | { |
| 15 | // Create a new account with some orders |
| 16 | proto::Account account = { 1, "Test", proto::State::good, { "USD", 1000.0 }, std::make_optional<proto::Balance>({ "EUR", 100.0 }), {} }; |
| 17 | account.orders.emplace_back(1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0); |
| 18 | account.orders.emplace_back(2, "EURUSD", proto::OrderSide::sell, proto::OrderType::limit, 1.0, 100.0); |
| 19 | account.orders.emplace_back(3, "EURUSD", proto::OrderSide::buy, proto::OrderType::stop, 1.5, 10.0); |
| 20 | |
| 21 | // Serialize the account to the FBE stream |
| 22 | FBE::proto::AccountFinalModel writer; |
| 23 | writer.serialize(account); |
| 24 | assert(writer.verify()); |
| 25 | |
| 26 | // Show the serialized FBE size |
| 27 | std::cout << "FBE final size: " << writer.buffer().size() << std::endl; |
| 28 | |
| 29 | // Deserialize the account from the FBE stream |
| 30 | FBE::proto::AccountFinalModel reader; |
| 31 | reader.attach(writer.buffer()); |
| 32 | assert(reader.verify()); |
| 33 | reader.deserialize(account); |
| 34 | |
| 35 | // Show account content |
| 36 | std::cout << std::endl; |
| 37 | std::cout << account; |
| 38 | |
| 39 | return 0; |
| 40 | } |
nothing calls this directly
no test coverage detected