Merge branch 'prod' of bitbucket.org:bluetradesys/spark
This commit is contained in:
commit
bd63c0798e
6 files changed
+91
-12
No files matched your search
@@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using static bts.api.Security;
|
||||
|
||||
namespace bts.api {
|
||||
struct FutureLeg {
|
||||
public readonly Venue exchange;
|
||||
public readonly string symbol;
|
||||
public readonly string symbol, exchange_desc;
|
||||
public readonly FutureContractImmutable future;
|
||||
public readonly int quantity;
|
||||
|
||||
public FutureLeg(Venue exchange, string symbol, FutureContractImmutable future, int quantity) {
|
||||
public FutureLeg(Venue exchange, string symbol, string exchange_desc, FutureContractImmutable future, int quantity) {
|
||||
this.exchange = exchange;
|
||||
this.symbol = symbol;
|
||||
this.exchange_desc = exchange_desc;
|
||||
this.future = future;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
@@ -32,12 +32,14 @@ namespace bts.api {
|
||||
return string.Join("", _format_future_legs(future_legs));
|
||||
}
|
||||
|
||||
public static string format_future(string symbol, FutureContractImmutable future) =>
|
||||
$"{symbol}{DateFormatter.Format(future.ExpirationYear, future.ExpirationMonth, future.ExpirationDay, DateFormat.MonthCodeLastDigitYear)}";
|
||||
public static string format_future(string symbol, string exch_desc, FutureContractImmutable future) =>
|
||||
string.IsNullOrEmpty(exch_desc) ?
|
||||
$"{symbol}{DateFormatter.Format(future.ExpirationYear, future.ExpirationMonth, future.ExpirationDay, DateFormat.MonthCodeLastDigitYear)}" :
|
||||
exch_desc;
|
||||
|
||||
static string _format(SecurityImmutable security) {
|
||||
switch (security.ContractCase) {
|
||||
case ContractOneofCase.Future: return format_future(security.Symbol, security.Future);
|
||||
case ContractOneofCase.Future: return format_future(security.Symbol, security.glbx_desc(), security.Future);
|
||||
case ContractOneofCase.Spread:
|
||||
if (security.HasGlbx) {
|
||||
// In case we ever bring it back, pretty printed spread names can be found here:
|
||||
@@ -61,7 +63,7 @@ namespace bts.api {
|
||||
}
|
||||
|
||||
static string _get_first_leg_name(FutureLeg fl) {
|
||||
string sym_exp_name = format_future(fl.symbol, fl.future);
|
||||
string sym_exp_name = format_future(fl.symbol, fl.exchange_desc, fl.future);
|
||||
switch (fl.quantity) {
|
||||
case 1: return sym_exp_name;
|
||||
case -1: return $"-{sym_exp_name}";
|
||||
@@ -70,7 +72,7 @@ namespace bts.api {
|
||||
}
|
||||
|
||||
static string _get_subsequent_leg_name(FutureLeg fl) {
|
||||
string sym_exp_name = format_future(fl.symbol, fl.future);
|
||||
string sym_exp_name = format_future(fl.symbol, fl.exchange_desc, fl.future);
|
||||
switch (fl.quantity) {
|
||||
case 1: return $"+{sym_exp_name}";
|
||||
case -1: return $"-{sym_exp_name}";
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace bts.api {
|
||||
foreach (var l in legs) {
|
||||
switch (l.Security.ContractCase) {
|
||||
case ContractOneofCase.Future:
|
||||
yield return new FutureLeg(l.Security.Exchange, l.Security.Symbol, l.Security.Future, qty * l.SignedQuantity());
|
||||
yield return new FutureLeg(l.Security.Exchange, l.Security.Symbol, l.Security.glbx_desc(), l.Security.Future, qty * l.SignedQuantity());
|
||||
break;
|
||||
case ContractOneofCase.Spread:
|
||||
foreach (var fl in _get_flat_future_legs(l.Security.Spread.Legs, qty * l.SignedQuantity()))
|
||||
@@ -56,6 +56,9 @@ namespace bts.api {
|
||||
|
||||
public static string DisplayExchange(this SecurityImmutable security) =>
|
||||
security.ContractCase == ContractOneofCase.Synthetic ? $"[{string.Join(",", get_flat_future_legs(security).Select(flt => flt.exchange.ToString()).Distinct().OrderBy(e => e))}]" : security.Exchange.ToString();
|
||||
|
||||
public static string glbx_desc(this SecurityImmutable security) =>
|
||||
security.HasGlbx ? security.Glbx.SecurityDesc ?? string.Empty : string.Empty;
|
||||
#endregion
|
||||
|
||||
public static class Comparer {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "Web.h"
|
||||
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/quickbus_cfg.pb.h"
|
||||
#include "lib/config/protos/Ports.pb.h"
|
||||
#include "lib/quickbus/quickbus.h"
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
|
||||
#include "server/sparkd/metrics/metrics.h"
|
||||
#include "server/sparkd/metrics/system_metrics.h"
|
||||
#include "server/sparkd/http/WebServer.h"
|
||||
#include "lib/md/relay/QueryServer.h"
|
||||
#include "lib/md/SyntheticSecurityService.h"
|
||||
#include "server/sparkd/user/AdminServiceServer.h"
|
||||
#include "server/sparkd/user/UserServiceServer.h"
|
||||
#include "server/sparkd/md/run_md.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
int Web::execute(const std::vector<std::string>& args) {
|
||||
config::QuickbusNodeCfg qb_cfg;
|
||||
auto& ports = config::get<config::Ports>();
|
||||
qb_cfg.set_my_port(ports.qbus_port());
|
||||
qbus::Quickbus quickbus(qb_cfg);
|
||||
api::ServiceContext sc(&quickbus);
|
||||
|
||||
metrics::MetricsContainer stats;
|
||||
metrics::publish_system_metrics(stats);
|
||||
http::SparkWebServer webserver(sc, stats, ports.config_port());
|
||||
|
||||
user::UserServiceServer login_server(sc);
|
||||
if (std::find(args.begin(), args.end(), "-md") != args.end()) {
|
||||
md::run_market_datapublishers();
|
||||
}
|
||||
|
||||
std::shared_ptr<api::ISyntheticSecurityService> synthetic_service =
|
||||
std::make_shared<api::synthetic::SyntheticSecurityService>(sc);
|
||||
md::QueryServerPtr md_query_server(
|
||||
md::run_query_server(sc, synthetic_service, stats));
|
||||
|
||||
admin::AdminServiceServer admin_service(sc);
|
||||
|
||||
|
||||
|
||||
std::this_thread::sleep_until(
|
||||
std::chrono::time_point<std::chrono::system_clock>::max());
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string Web::help() { return "\t run only the services required for the web admin. This cannot be run concurrently with 'sparkd run'\n\tAdd -md to start market data too."; }
|
||||
|
||||
}}//namespace
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ICmd.h"
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
class Web : public ICmd
|
||||
{
|
||||
public:
|
||||
int execute(std::vector<std::string> const &args);
|
||||
std::string help ();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "server/sparkd/cmds/AutoCert.h"
|
||||
#include "server/sparkd/cmds/QuickTest.h"
|
||||
#include "server/sparkd/cmds/Span.h"
|
||||
#include "server/sparkd/cmds/Web.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
using namespace bts;
|
||||
@@ -33,6 +34,7 @@ int main(int argc, char **argv) {
|
||||
REGISTER(QuickTest);
|
||||
REGISTER(AutoCert);
|
||||
REGISTER(Span);
|
||||
REGISTER(Web);
|
||||
END_CMD;
|
||||
|
||||
utils::finit_spark_lib();
|
||||
|
||||
@@ -303,8 +303,7 @@ void NativeOrder::on_activate(Price p, Quantity q,
|
||||
AccountID(me->definition.account_id()));
|
||||
if (!lqr.ok) {
|
||||
LOG(OrderMan, Warn, "Unauthorized order attempted. User: {} on "
|
||||
"Account: {}. Msg: {} Order: {} "
|
||||
"Dropping order {}",
|
||||
"Account: {}. Msg: {} Order: {}. Dropping order",
|
||||
me->definition.user(), me->definition.account(), lqr.error_msg,
|
||||
key().value());
|
||||
|
||||
|
||||
Reference in new issue
Block a user