| 39 | }; |
| 40 | |
| 41 | int main(int argc, char** argv) |
| 42 | { |
| 43 | MySender sender; |
| 44 | |
| 45 | // Enable logging |
| 46 | sender.logging(true); |
| 47 | |
| 48 | // Create and send a new order |
| 49 | proto::OrderMessage order({ proto::Order({ 1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0 }) }); |
| 50 | sender.send(order); |
| 51 | |
| 52 | // Create and send a new balance wallet |
| 53 | proto::BalanceMessage balance({ proto::Balance({ "USD", 1000.0 }) }); |
| 54 | sender.send(balance); |
| 55 | |
| 56 | // Create and send a new account with some orders |
| 57 | proto::AccountMessage account({ proto::Account({ 1, "Test", proto::State::good, { "USD", 1000.0 }, std::make_optional<proto::Balance>({ "EUR", 100.0 }), {} }) }); |
| 58 | account.body.orders.emplace_back(1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0); |
| 59 | account.body.orders.emplace_back(2, "EURUSD", proto::OrderSide::sell, proto::OrderType::limit, 1.0, 100.0); |
| 60 | account.body.orders.emplace_back(3, "EURUSD", proto::OrderSide::buy, proto::OrderType::stop, 1.5, 10.0); |
| 61 | sender.send(account); |
| 62 | |
| 63 | MyReceiver receiver; |
| 64 | |
| 65 | // Enable logging |
| 66 | receiver.logging(true); |
| 67 | |
| 68 | // Receive all data from the sender |
| 69 | receiver.receive(sender.buffer().data(), sender.buffer().size()); |
| 70 | |
| 71 | return 0; |
| 72 | } |