Merge remote-tracking branch 'origin/prod'
This commit is contained in:
commit
ab5fca73f6
11 files changed
+152
-32
No files matched your search
@@ -114,7 +114,7 @@ namespace bts.spark {
|
||||
(var security, var spec) = get_security(neworder.Def.SecurityKey);
|
||||
//
|
||||
// description
|
||||
var mod_desc = modified_description(oldorder, neworder, spec.Value);
|
||||
var mod_desc = modified_description(oldorder, neworder, spec);
|
||||
if (!string.IsNullOrEmpty(mod_desc)) {
|
||||
log_status(ActivityLogCategory.modify, security, mod_desc);
|
||||
}
|
||||
|
||||
@@ -820,19 +820,49 @@ void AdminServiceUtils::delete_user (bts::api::admin::AdminData& admin_data,
|
||||
////////////////////////////////////////////
|
||||
bool AdminServiceUtils::_sort_security_scopes (const bts::api::admin::SecurityScope& a,
|
||||
const bts::api::admin::SecurityScope& b){
|
||||
if (has_id(a.security_id()))
|
||||
return true;
|
||||
// for both the sec and product scope sorting, the more
|
||||
// qualified arg is sent to the top (vs wildcard). the
|
||||
// order of qualification is sec_id, symbol, type, exchange.
|
||||
// if both a and b are equally qualified, it is a
|
||||
// a dont-care case (in terms of sec/prod res) and
|
||||
// ascending orderring is used
|
||||
if (has_id(a.security_id())){
|
||||
if (has_id(b.security_id()))
|
||||
return a.security_id() < b.security_id();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
if (has_id(b.security_id()))
|
||||
return false;
|
||||
if (a.security_symbol() != "*")
|
||||
return true;
|
||||
return false;
|
||||
// symbol
|
||||
if (is_symbol_set(a.security_symbol())){
|
||||
if (is_symbol_set(b.security_symbol()))
|
||||
return a.security_symbol() < b.security_symbol();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
if (is_symbol_set(b.security_symbol()))
|
||||
return false;
|
||||
// sec type
|
||||
if (a.security_type() != b.security_type())
|
||||
return a.security_type() < b.security_type();
|
||||
return a.exchange() < b.exchange();
|
||||
}
|
||||
bool AdminServiceUtils::_sort_product_scopes (const bts::api::admin::ProductScope& a,
|
||||
const bts::api::admin::ProductScope&){
|
||||
if (a.security_symbol() != "*")
|
||||
return true;
|
||||
return false;
|
||||
const bts::api::admin::ProductScope& b){
|
||||
// symbol
|
||||
if (is_symbol_set(a.security_symbol())){
|
||||
if (is_symbol_set(b.security_symbol()))
|
||||
return a.security_symbol() < b.security_symbol();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
if (is_symbol_set(b.security_symbol()))
|
||||
return false;
|
||||
// sec type
|
||||
if (a.security_type() != b.security_type())
|
||||
return a.security_type() < b.security_type();
|
||||
return a.exchange() < b.exchange();
|
||||
}
|
||||
void AdminServiceUtils::sort_limits (bts::api::admin::BTSAccount& account){
|
||||
std::sort (account.mutable_security_position_limits()->begin(),
|
||||
@@ -1025,4 +1055,7 @@ void AdminServiceUtils::bootstrap_data (bts::api::admin::AdminData& data){
|
||||
acct_a1_clip_size->set_clip_size(100);
|
||||
}
|
||||
bool AdminServiceUtils::has_id (uint32_t id){return id>0;}
|
||||
bool AdminServiceUtils::is_symbol_set (const std::string& symbol){
|
||||
return symbol !="*";
|
||||
}
|
||||
}}
|
||||
@@ -240,6 +240,7 @@ public:
|
||||
// misc//////// ////////////////////////////
|
||||
////////////////////////////////////////////
|
||||
static bool has_id (uint32_t id);
|
||||
static bool is_symbol_set (const std::string& symbol);
|
||||
static void bootstrap_data (bts::api::admin::AdminData& data);
|
||||
};
|
||||
}}
|
||||
@@ -193,10 +193,18 @@ void QBConnection::handle_msg(msgs::QBMsg *msgs)
|
||||
me->intro=op.intro();
|
||||
me->my_id = NodeID(me->intro.node_id());
|
||||
|
||||
if (!me->router.add_neighbour(me->my_id,shared_from_this())) {
|
||||
close_connection("Node is already connected");
|
||||
if (me->router.is_neighbour(me->my_id)) {
|
||||
LOG(QBus,Warn, "Refusing connection from {} to {} reason: {} is already connected" ,
|
||||
me->my_desc , me->remote_desc , me->my_id.value());
|
||||
if (me->socket.is_open())
|
||||
me->socket.close();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
LOG(QBus,Warn, "Accepted connection from {} to {}. {} is now connected." ,
|
||||
me->my_desc , me->remote_desc , me->my_id.value());
|
||||
me->router.add_neighbour(me->my_id,shared_from_this());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -184,6 +184,11 @@ void Router::remove_neighbour(NodeID const&removed_neighbour_id)
|
||||
me->neighbours.erase(removed_neighbour_id);
|
||||
}
|
||||
|
||||
bool Router::is_neighbour(NodeID const&neighbour_id) const
|
||||
{
|
||||
return me->neighbours.find(neighbour_id) != me->neighbours.end();
|
||||
}
|
||||
|
||||
void Router::advertise(NodeID const& sender,TableID const&tid,Advertisement const&ad)
|
||||
{
|
||||
LOG(QBus,Diag, "{} received advertisement from nid: {} tid: {} ad topic: {}",
|
||||
|
||||
@@ -15,7 +15,8 @@ public:
|
||||
NodeID id() const ;
|
||||
bool add_neighbour (NodeID const& neighbour_id, INodePtr const& neighbour);
|
||||
void remove_neighbour (NodeID const& neighbour_id);
|
||||
|
||||
bool is_neighbour(NodeID const&neighbour_id) const;
|
||||
|
||||
// from INode
|
||||
void advertise(NodeID const& sender,TableID const&id,Advertisement const&adv) override;
|
||||
void unadvertise(NodeID const& sender,TableID const&tid) override;
|
||||
|
||||
@@ -217,11 +217,22 @@ namespace http {
|
||||
con->set_body(read_file(path.string()));
|
||||
con->set_status(websocketpp::http::status_code::ok);
|
||||
}
|
||||
|
||||
void return_bts_installer(connection_ptr& con) {
|
||||
std::string installer_bits = read_file(_www+"/bts_installer.exe");
|
||||
const std::string installer_config = _www+"install_config.json";
|
||||
if (boost::filesystem::is_regular_file(installer_config)) {
|
||||
installer_bits += read_file(installer_config);
|
||||
auto conf = read_file(installer_config);
|
||||
std::string needle = "$HOST";
|
||||
std::size_t pos;
|
||||
do {
|
||||
pos = conf.find(needle,0);
|
||||
if (pos != std::string::npos) {
|
||||
auto host = con->get_uri()->get_host();
|
||||
conf.replace(pos, needle.size(), host);
|
||||
}
|
||||
} while(pos != std::string::npos);
|
||||
installer_bits += conf;
|
||||
}
|
||||
con->set_body(installer_bits);
|
||||
con->set_status(websocketpp::http::status_code::ok);
|
||||
|
||||
@@ -127,17 +127,6 @@ std::string store_path (std::string base_path,
|
||||
return result.string ();
|
||||
}
|
||||
|
||||
void create_current_simlink (std::string const &path)
|
||||
{
|
||||
auto sym_link_path = boost::filesystem::path (path);
|
||||
sym_link_path /= "..";
|
||||
sym_link_path /= "current";
|
||||
if (boost::filesystem::exists (sym_link_path))
|
||||
boost::filesystem::remove (sym_link_path);
|
||||
|
||||
boost::filesystem::create_symlink (boost::filesystem::path (path),sym_link_path);
|
||||
}
|
||||
|
||||
std::map<uint32_t,InMsgBuffer>
|
||||
load_replay (config::JetFIX::Connection const &cfg,std::string const&path, uint32_t max_sn)
|
||||
{
|
||||
@@ -227,8 +216,6 @@ FIXFileStore::FIXFileStore (config::JetFIX::Connection const&cfg,std::string bas
|
||||
}
|
||||
}
|
||||
me->fix_store.open (fix_log_p,std::ofstream::app);
|
||||
|
||||
create_current_simlink (path);
|
||||
me->writer_thread = std::thread (std::bind (&FIXFileStore::write,this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,10 +133,11 @@ private:
|
||||
void _transform_to_END(std::string* m = nullptr);
|
||||
// swtches to the state passed in the arg
|
||||
void _switch_state (ISpreaderStateWorker* new_state);
|
||||
// this means on_init_new has been called and we have the
|
||||
// the structure built
|
||||
// misc ////////////////////
|
||||
////////////////////////////
|
||||
// this means on_init_new or on_init_recovered
|
||||
// has been called and we have the bookkeeping
|
||||
// data built
|
||||
bool _inited () const {
|
||||
return _bookkeeping_data_ptr != nullptr;
|
||||
}
|
||||
|
||||
+9
-3
@@ -40,13 +40,19 @@ void SpreaderStartStateWorker::on_init_recovered(const bts::api::orderman::Order
|
||||
const SpreaderPreActivationOrderServices& spreader_pao_services)
|
||||
{
|
||||
bts_assert(!_spreader->_inited());
|
||||
// we are not handling this yet, so lets send it directly to END
|
||||
// we are not handling recovery, so if order is not in a terminal state,
|
||||
// instead of carrying on from where we left, we go directly to the end state
|
||||
// and mark the order cancelled. if its already in a terminal state we
|
||||
// just go to end and not do anything
|
||||
bts::api::orderman::OrderRecord order_record_copy = order_record;
|
||||
if (!SpreaderUtils::order_in_terminal_state(order_record_copy.mutable_state()->status()))
|
||||
order_record_copy.mutable_state()->set_status(bts::api::orderman::OrderStatus::ORDER_STATUS_CANCELED);
|
||||
_spreader->_bookkeeping_data_ptr = std::make_unique<SpreaderBookkeepingData>(*_spreader,
|
||||
order_record,
|
||||
order_record_copy,
|
||||
spreader_pao_services,
|
||||
std::vector<LegPropertyData>());
|
||||
LOG(OrderMan, Warn, "SpreaderStartStateWorker.on_init_recovered key: {} , going to END", _spreader->key().value());
|
||||
std::string msg = "Recovered spreader orders and not supported";
|
||||
std::string msg = "Recovered spreader orders (from last session) are cancelled";
|
||||
_spreader->_transform_to_END (&msg);
|
||||
}
|
||||
void SpreaderStartStateWorker::on_activate(Price price, Quantity quantity, SpreaderOrderServices& order_services){
|
||||
|
||||
@@ -268,4 +268,71 @@ TEST_CASE ("Bootstrapping", "[admin_service]")
|
||||
REQUIRE(account.connections().exchange_connection_names_size()==2);
|
||||
}
|
||||
}
|
||||
TEST_CASE("Sorting Limit","[admin_service]"){
|
||||
bts::api::admin::AdminData admin_data;
|
||||
bts::api::admin::AdminServiceCreateAccountResult account_result;
|
||||
auto account = AdminServiceUtils::create_account(admin_data,
|
||||
0,
|
||||
std::string("A"),
|
||||
std::string("description"),
|
||||
true,
|
||||
account_result);
|
||||
auto l1 = account->mutable_security_clip_limits()->add_limit();
|
||||
l1->mutable_security()->set_exchange(api::Venue::VENUE_GLBX);
|
||||
l1->mutable_security()->set_security_type(api::SecurityType::SECURITYTYPE_FUTURE);
|
||||
l1->mutable_security()->set_security_symbol("*");
|
||||
l1->mutable_security()->set_security_id(0);
|
||||
l1->set_clip_size(100);
|
||||
auto l2 = account->mutable_security_clip_limits()->add_limit();
|
||||
l2->mutable_security()->set_exchange(api::Venue::VENUE_GLBX);
|
||||
l2->mutable_security()->set_security_type(api::SecurityType::SECURITYTYPE_FUTURE);
|
||||
l2->mutable_security()->set_security_symbol("SI");
|
||||
l2->mutable_security()->set_security_id(0);
|
||||
l2->set_clip_size(101);
|
||||
auto l3 = account->mutable_security_clip_limits()->add_limit();
|
||||
l3->mutable_security()->set_exchange(api::Venue::VENUE_GLBX);
|
||||
l3->mutable_security()->set_security_type(api::SecurityType::SECURITYTYPE_FUTURE);
|
||||
l3->mutable_security()->set_security_symbol("CL");
|
||||
l3->mutable_security()->set_security_id(0);
|
||||
l3->set_clip_size(102);
|
||||
auto l4 = account->mutable_security_clip_limits()->add_limit();
|
||||
l4->mutable_security()->set_exchange(api::Venue::VENUE_GLBX);
|
||||
l4->mutable_security()->set_security_type(api::SecurityType::SECURITYTYPE_FUTURE);
|
||||
l4->mutable_security()->set_security_symbol("ZC");
|
||||
l4->mutable_security()->set_security_id(10);
|
||||
l4->set_clip_size(103);
|
||||
auto l5 = account->mutable_security_clip_limits()->add_limit();
|
||||
l5->mutable_security()->set_exchange(api::Venue::VENUE_GLBX);
|
||||
l5->mutable_security()->set_security_type(api::SecurityType::SECURITYTYPE_FUTURE);
|
||||
l5->mutable_security()->set_security_symbol("ZN");
|
||||
l5->mutable_security()->set_security_id(5);
|
||||
l5->set_clip_size(104);
|
||||
auto l6 = account->mutable_security_clip_limits()->add_limit();
|
||||
l6->mutable_security()->set_exchange(api::Venue::VENUE_GLBX);
|
||||
l6->mutable_security()->set_security_type(api::SecurityType::SECURITYTYPE_SPREAD);
|
||||
l6->mutable_security()->set_security_symbol("SI");
|
||||
l6->mutable_security()->set_security_id(0);
|
||||
l6->set_clip_size(105);
|
||||
// tests
|
||||
auto sorted_admin_data = AdminServiceUtils::sort_limits(admin_data);
|
||||
const auto& r_account = sorted_admin_data.accounts(0);
|
||||
const auto& r_l1 = r_account.security_clip_limits().limit(0);
|
||||
REQUIRE(r_l1.security().security_id()==5);
|
||||
REQUIRE(r_l1.clip_size()==104);
|
||||
const auto& r_l2 = r_account.security_clip_limits().limit(1);
|
||||
REQUIRE(r_l2.security().security_id()==10);
|
||||
REQUIRE(r_l2.clip_size()==103);
|
||||
const auto& r_l3 = r_account.security_clip_limits().limit(2);
|
||||
REQUIRE(r_l3.security().security_symbol()=="CL");
|
||||
REQUIRE(r_l3.clip_size()==102);
|
||||
const auto& r_l4 = r_account.security_clip_limits().limit(3);
|
||||
REQUIRE(r_l4.security().security_symbol()=="SI");
|
||||
REQUIRE(r_l4.clip_size()==101);
|
||||
const auto& r_l5 = r_account.security_clip_limits().limit(4);
|
||||
REQUIRE(r_l5.security().security_symbol()=="SI");
|
||||
REQUIRE(r_l5.clip_size()==105);
|
||||
const auto& r_l6 = r_account.security_clip_limits().limit(5);
|
||||
REQUIRE(r_l6.security().security_symbol()=="*");
|
||||
REQUIRE(r_l6.clip_size()==100);
|
||||
}
|
||||
}}
|
||||
Reference in new issue
Block a user