* Run 'sparkd tests' outside of the CLI::App framework (delegate to 'catch', which has a solid cli). This fixes a bug which prevented callers from specifying test tags (in the form of '[<tag>]'), as the CLI::App's parse method removes square brackets from cli options. * Bind cli options to instance members of their subcommand's CLI::App derived class. This seems to fix a bug which caused the [static instance] binding source to be destructed twice. * Add help text for several subcommands
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#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 <condition_variable>
|
|
#include <future>
|
|
#include <google/protobuf/text_format.h>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
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<Position> 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
|