feat: Add Binance USDS Futures execution
This commit is contained in:
1 parent
25439b094a
commit
1b232aa610
71 files changed
+3913
-66
No files matched your search
@@ -13,6 +13,7 @@
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/md/MDClient.h"
|
||||
#include "lib/md/MDConsumer.h"
|
||||
#include "lib/md/UserSymbol.h"
|
||||
#include "lib/mercury/actors/Timer.h"
|
||||
#include "lib/mercury/executor/Executor.h"
|
||||
#include "lib/metrics/metrics.h"
|
||||
@@ -24,16 +25,23 @@
|
||||
#include "lib/orderman/actors/SecuritySrc.h"
|
||||
#include "lib/orderman/actors/ServiceBridge.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderManager.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderServicesData.h"
|
||||
#include "lib/orderman/actors/order_manager/order_gateway_definition.h"
|
||||
#include "lib/orderman/events/ExchangePositionEvent.h"
|
||||
#include "lib/orderman/events/OrderOpResultEvent.h"
|
||||
#include "lib/orderman/gateways/execution_gateway_provider.h"
|
||||
#include "lib/orderman/gateways/i_execution_gateway_provider.h"
|
||||
#include "lib/orderman/order_factory/DynamicOrderRegistry.h"
|
||||
#include "lib/orderman/orderman_utils/ExchangeOpenOrders.h"
|
||||
#include "lib/orderman/orders/Order.h"
|
||||
#include "lib/os/spark_data_directory.h"
|
||||
#include "lib/plugin/SparkServices.h"
|
||||
#include "lib/plugin/plugin.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
#include "lib/utils/type_name.h"
|
||||
#include "lib_binance_execution/binance_execution/execution_gateway_provider.h"
|
||||
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@@ -43,6 +51,8 @@
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
using std::unique_ptr;
|
||||
using std::vector;
|
||||
|
||||
struct ActorThread {
|
||||
ActorThread(
|
||||
@@ -126,10 +136,13 @@ struct OrderServiceServer::PImpl {
|
||||
const Exchange_open_ordersStatefulPublisher &open_orders_publisher,
|
||||
md::MDClient &mdc,
|
||||
DynamicOrderRegistry const &d,
|
||||
std::vector<std::unique_ptr<IExecutionGatewayProvider>>
|
||||
gateway_providers,
|
||||
metrics::MetricsContainer &stats,
|
||||
trace::PerfLog &log)
|
||||
: context(ctx), service_bridge(), service_ready(false), known_orders(),
|
||||
known_fills(), publish_orders(), publish_fills(),
|
||||
: context(ctx), service_bridge(),
|
||||
gateway_providers(std::move(gateway_providers)), service_ready(false),
|
||||
known_orders(), known_fills(), publish_orders(), publish_fills(),
|
||||
exchange_pos_publisher(exchange_pos_publisher),
|
||||
open_orders_publisher(open_orders_publisher),
|
||||
admin_service(ctx.locate<api::admin::AdminService>()),
|
||||
@@ -137,11 +150,15 @@ struct OrderServiceServer::PImpl {
|
||||
margin_service(ctx.locate<api::position::MarginService>()),
|
||||
md_consumer(mdc.current_consumer()), stats(stats),
|
||||
dyn_order_registry(d), log(log), in_flight_order_ops(),
|
||||
current_req_op_id(0) {}
|
||||
current_req_op_id(0) {
|
||||
LOG(OrderMan, Info, "OrderServiceServer ctr. n_gateway_providers: {}",
|
||||
this->gateway_providers.size());
|
||||
}
|
||||
|
||||
bts::api::ServiceContext &context;
|
||||
ServiceBridge *service_bridge;
|
||||
|
||||
std::vector<std::unique_ptr<IExecutionGatewayProvider>> gateway_providers;
|
||||
std::vector<std::unique_ptr<ActorThread>> actor_threads;
|
||||
|
||||
std::atomic<bool> service_ready;
|
||||
@@ -169,6 +186,7 @@ OrderServiceServer::OrderServiceServer(
|
||||
bts::api::ServiceContext &ctx,
|
||||
md::MDClient &mdc,
|
||||
DynamicOrderRegistry const &d,
|
||||
std::vector<std::unique_ptr<IExecutionGatewayProvider>> gateway_providers,
|
||||
metrics::MetricsContainer &stats,
|
||||
trace::PerfLog &log,
|
||||
md::TradeSummarySignalDispatcher &tssd)
|
||||
@@ -179,6 +197,7 @@ OrderServiceServer::OrderServiceServer(
|
||||
make_exchange_open_orders_stateful_publisher(),
|
||||
mdc,
|
||||
d,
|
||||
std::move(gateway_providers),
|
||||
stats,
|
||||
log)) {
|
||||
LOG(md, Info, "OrderServiceServer cons t_id: {} t_name: {}",
|
||||
@@ -209,7 +228,10 @@ OrderServiceServer::OrderServiceServer(
|
||||
bts_assert_msg(
|
||||
thread, "Could not find a configured thread for OrderManager. See "
|
||||
"the OrdermanCfg key");
|
||||
thread->executor.spawn<OrderManager>(d, me->log, mdc.oracle());
|
||||
{
|
||||
thread->executor.spawn<OrderManager>(
|
||||
d, me->log, mdc.oracle(), std::move(me->gateway_providers));
|
||||
}
|
||||
|
||||
// Timer
|
||||
thread = find_thread_for_actor("Timer", me->actor_threads);
|
||||
@@ -404,7 +426,6 @@ void OrderServiceServer::create_order(
|
||||
void OrderServiceServer::cancel_order(
|
||||
const api::orderman::Cancel &cancel,
|
||||
const api::Response<api::orderman::Response> &r) {
|
||||
|
||||
if (!me->service_ready) {
|
||||
api::orderman::Response response;
|
||||
response.set_order_key(cancel.order_key());
|
||||
@@ -435,7 +456,6 @@ void OrderServiceServer::update_order(
|
||||
void OrderServiceServer::detach_order(
|
||||
const api::orderman::Detach &detach,
|
||||
const api::Response<api::orderman::Response> &r) {
|
||||
|
||||
if (!me->service_ready) {
|
||||
api::orderman::Response response;
|
||||
response.set_order_key(detach.order_key());
|
||||
|
||||
Reference in new issue
Block a user