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.
Windows specific notes:
* Get rid of unnecessary script vs_filters.cmake
* Define WebsocketConnectionGateway directly in cs (instead of proto)
- The proto would no longer be in the include path passed to protoc.
Moving it to c# because there wasn't a compelling reason for it to
be a proto in the first place.
* Set spark output prefix to "lib" on windows
- So we get "libspark.dll" instead of "spark.dll", which conflicts
with the csharp lib, "Spark.dll".
* Copy libspark.dll to net8.0 & net8.0-windows in a single cmake build
target
fix build: Copy libspark to both dirs net8.0, net8.0-windows
64 lines
1.6 KiB
C++
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
|