#include "Span.h" #include "server/sparkd/position/MarginServiceCore.h" #include "server/sparkd/position/Position.h" #include "server/sparkd/position/PositionAggregator.h" #include "lib/orderman/orderman_utils/orderman_common.h" #include "lib/api/public/ServiceContext.h" #include "lib/api/services/AuthService.client.pb.h" #include "lib/config/config.h" #include "lib/domain_model/Security.pb.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/helper_macros.h" #include #include #include #include #include #include #include using namespace bts::position; using namespace bts::api::position; namespace bts::cmds { static void execute() { srand(time(NULL)); auto &disp = utils::Dispatcher::current(); MarginServiceCore core(disp); auto acct = std::string("ACC A"); Position p; p.security_desc = "ESU9"; p.account = acct; p.position = Quantity(rand() % 100); p.side = api::SIDE_BUY; std::vector pos; pos.push_back(p); p.position = Quantity(rand() % 200); p.side = api::SIDE_SELL; pos.push_back(p); // core.set_verbose_debugging(true); core.compute_margin(acct, pos, [](const api::position::MarginResult &m) { std::string str; google::protobuf::TextFormat::PrintToString(m, &str); std::cout << std::endl << str << std::endl << std::endl; }); std::cout << "Waiting for margin results, press any key to exit" << std::endl; disp.run(); } Span::Span() : CLI::App("Test CME CORE Span integration", "span") { callback(execute); } } // namespace bts::cmds