Files
spark/src/app_sparkd/sparkd/cmds/Span.cpp
T
John Colvin 5356b0694b refactor: Organize libspark proj w/ stuttering include
This new structure provides several benefits:

* Allows us to install multiple CMake projects in the same destination
  dir (without include path conflicts).
  - This makes shipping the trading algo sdk a trivial excercise. Simply
    copy the lib and include dirs from the install dest. That's it!
* Puts us in a position to break up the monolithic libspark into smaller
  modules, which are easier to manage.
2024-10-12 18:37:13 +00:00

64 lines
1.6 KiB
C++

#include "Span.h"
#include "sparkd/position/MarginServiceCore.h"
#include "sparkd/position/Position.h"
#include "sparkd/position/PositionAggregator.h"
#include "spark/orderman/orderman_utils/orderman_common.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/api/services/AuthService.client.pb.h"
#include "spark/config/config.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/utils/Dispatcher.h"
#include "spark/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