Merge remote-tracking branch 'origin/spark_crypto.dev' into spark_crypto.websocket-api.linux
This commit is contained in:
1 parent
a7e89b075b
commit
c31d9d6c72
33 files changed
+447
-89
No files matched your search
@@ -114,22 +114,6 @@ else()
|
||||
|
||||
endif()
|
||||
|
||||
# flags
|
||||
set(
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-pedantic \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wno-missing-braces \
|
||||
-Wno-ignored-qualifiers \
|
||||
--std=c++17 -fdiagnostics-color")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -DNDEBUG -O3")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
|
||||
|
||||
# subdirs
|
||||
if (BUILD_SPARKD)
|
||||
add_subdirectory(src/server/sparkd)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace mbts.analytics {
|
||||
|
||||
public VolSurfaceMDUnit(NativePriceSize bid, NativePriceSize ask,
|
||||
double mark_price)
|
||||
: this(bid.price, bid.size, ask.price, ask.size, mark_price) {
|
||||
: this(bid.price, bid.size_f, ask.price, ask.size_f, mark_price) {
|
||||
}
|
||||
|
||||
public bool is_two_sided() { return bid_size != 0 && ask_size != 0; }
|
||||
|
||||
@@ -3,13 +3,14 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mbts.ui.converters {
|
||||
class DictionaryLookupConverter : IMultiValueConverter {
|
||||
[ThreadStatic]
|
||||
static Dictionary<Type, Lookup> _type_impls_backing;
|
||||
static Dictionary<Type, Lookup> _type_impls => _type_impls_backing ??= new();
|
||||
Dictionary<Type, Lookup> _type_impls_backing;
|
||||
Dictionary<Type, Lookup> _type_impls =>
|
||||
Interlocked.CompareExchange(ref _type_impls_backing, new(), null);
|
||||
|
||||
delegate bool Lookup(object source, object key, out object result);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
|
||||
// Compare bids
|
||||
if (direct.int_price == implied.int_price) {
|
||||
bid[x] = new NativePriceSize(direct.int_price, direct.size, implied.size);
|
||||
bid[x] = new NativePriceSize(direct.int_price, direct.size_f, implied.size_f);
|
||||
dbid_idx++;
|
||||
ibid_idx++;
|
||||
}
|
||||
@@ -185,7 +185,7 @@
|
||||
|
||||
// Compare asks
|
||||
if (direct.int_price == implied.int_price) {
|
||||
ask[x] = new NativePriceSize(direct.int_price, direct.size, implied.size);
|
||||
ask[x] = new NativePriceSize(direct.int_price, direct.size_f, implied.size_f);
|
||||
dask_idx++;
|
||||
iask_idx++;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace mbts.co2 {
|
||||
|
||||
|
||||
public override string ToString() =>
|
||||
$"{price} {size} ({implied_size})";
|
||||
$"{price} {size_f} ({implied_size})";
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is NativePriceSize p ? Equals(p) : base.Equals(obj);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace bts.api {
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
public static class SecurityExtensions {
|
||||
public static Security.ContractOneofCase contract_case(this SecurityType type) =>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>8981</NoWarn>
|
||||
<Version>$(major).$(minor).$(patch)</Version>
|
||||
<Version Condition="'$(version)'=='..'">0.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -79,6 +79,40 @@ Misc:
|
||||
To search for a publisher for an event search for make_stream<Event_Name>, for
|
||||
example make_stream<OrderStateUpdateEvent>()
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
market data
|
||||
--------------------------------------------------------------------------
|
||||
adding exchanges:
|
||||
the following places need to accommodate exchanges
|
||||
managed:
|
||||
- SecurityExtensions: public static string security_desc(this SecurityImmutable security) ..
|
||||
- SecurityExtensions: public static Venue to_venue(this domain.Venue api_venue) ..
|
||||
- SecurityExtensions: public static domain.Venue to_api_venue(this Venue venue) ..
|
||||
C++
|
||||
- AdminServiceUtils.cpp, 6 switch statements should compilation error
|
||||
- Symbols.proto in Symbols
|
||||
- Symbols.conf exchange section in SymbolLists and Symbols
|
||||
- Security.proto, 3 places
|
||||
- PlatformLoader.cpp, in get_system_md_symbols(), could be concverted into switch
|
||||
- FixedSecurity.cpp, exchange_id(..) and convert_security(..) both switch
|
||||
- QueryServer set_mic, switch
|
||||
- VenueOption name(..) switch
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
adding security type
|
||||
---------------------------------------------------------------------------
|
||||
modified: src/lib/api/service_helpers/AdminServiceUtils.cpp
|
||||
modified: src/lib/domain_model/Security.cpp
|
||||
modified: src/lib/domain_model/Security.proto
|
||||
modified: src/lib/md/MDConsumer.cpp
|
||||
modified: src/lib/md/PlatformLoader.cpp
|
||||
modified: src/lib/md/SecurityMapper.cpp
|
||||
modified: src/lib/md/Shm/FixedSecurity.cpp
|
||||
modified: src/lib/md/Shm/FixedSecurity.h
|
||||
modified: src/lib/md/ccApi/CCMain.cpp
|
||||
modified: src/lib/md/ccApi/CCMarketDataListener.cpp
|
||||
modified: src/lib/md/relay/RelayClient.cpp
|
||||
modified: src/lib/orderman/limiter/Limiter.cpp
|
||||
|
||||
ALGO:
|
||||
----
|
||||
|
||||
@@ -10,7 +10,6 @@ import "lib/api/md/DeribitMarketDataConfig.proto";
|
||||
|
||||
|
||||
option csharp_namespace = "bts.api.md";
|
||||
option cc_enable_arenas = true;
|
||||
|
||||
package bts.api.md;
|
||||
|
||||
@@ -22,5 +21,4 @@ message MarketDataConfig {
|
||||
repeated DeribitMarketDataConfig deribit = 5;
|
||||
repeated MarketDataRecordingConfig recording = 500;
|
||||
repeated MarketDataReplayConfig replay = 510;
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ SymbolList {
|
||||
# symbol: "ES"
|
||||
# symbol: "FYT"
|
||||
# symbol: "FOB"
|
||||
# symbol: "GC"
|
||||
symbol: "GC"
|
||||
# symbol: "GE"
|
||||
# symbol: "HE"
|
||||
# symbol: "HG"
|
||||
@@ -37,7 +37,7 @@ SymbolList {
|
||||
# symbol: "NUB"
|
||||
# symbol: "RB"
|
||||
# symbol: "RBT"
|
||||
# symbol: "SI"
|
||||
symbol: "SI"
|
||||
# symbol: "SOM"
|
||||
# symbol: "SR1"
|
||||
# symbol: "SR3"
|
||||
@@ -84,6 +84,11 @@ SymbolLists
|
||||
key: "DERIBIT"
|
||||
symbol: @SymbolList.symbol
|
||||
}
|
||||
list
|
||||
{
|
||||
key: "FTX"
|
||||
symbol: @SymbolList.symbol
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,5 +146,10 @@ Symbols {
|
||||
option: @SymbolLists.list[DERIBIT].symbol
|
||||
spread: @SymbolLists.list[DERIBIT].symbol
|
||||
}
|
||||
ftx {
|
||||
future: @SymbolLists.list[FTX].symbol
|
||||
option: @SymbolLists.list[FTX].symbol
|
||||
spread: @SymbolLists.list[FTX].symbol
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
#include "lib/core/TimeStamp.h"
|
||||
#include "lib/domain/DomainSecurityUtils.h"
|
||||
#include "lib/domain/SpreadSecurity.h"
|
||||
#include <cstdio>
|
||||
#ifdef SPARK_ENABLE_CCAPI
|
||||
#include "CCMarketDataListener.h"
|
||||
#include "lib/api/domain/Currency.pb.h"
|
||||
@@ -10,6 +6,7 @@
|
||||
#include "lib/core/TimeStamp.h"
|
||||
#include "lib/domain/AggressorSide.h"
|
||||
#include "lib/domain/Book.h"
|
||||
#include "lib/domain/DomainSecurityUtils.h"
|
||||
#include "lib/domain/FutureSecurity.h"
|
||||
#include "lib/domain/OptionSecurity.h"
|
||||
#include "lib/domain/Price.h"
|
||||
@@ -42,6 +39,7 @@
|
||||
#include "lib/utils/bts_fatal.h"
|
||||
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <cstdio>
|
||||
#include <google/protobuf/timestamp.pb.h>
|
||||
#include <google/protobuf/util/time_util.h>
|
||||
#include <sstream>
|
||||
@@ -429,15 +427,5 @@ void CCMarketDataListener::_copy_security_common(
|
||||
to.low_tick = to.high_tick = from.security_common.min_price_increment;
|
||||
}
|
||||
|
||||
uint64_t CCMarketDataListener::_generate_security_key(
|
||||
const bts::domain::Security &sec) {
|
||||
auto logical_key = get_logical_key(sec);
|
||||
// if (me->use_given_sec_key)
|
||||
// return sec.security_common.id.value();
|
||||
auto rv = me->id_gen.get_id(me->cc_name_prefix, logical_key, true);
|
||||
bts_assert(rv.has_value());
|
||||
return rv.value();
|
||||
}
|
||||
|
||||
} // namespace bts::md
|
||||
#endif
|
||||
@@ -67,10 +67,10 @@ struct TEASecData {
|
||||
|
||||
double eps = 0.0000001;
|
||||
|
||||
static bool eq(double d1, double d2) { return std::abs(d1 - d2) < eps; }
|
||||
static bool tea_eq(double d1, double d2) { return std::abs(d1 - d2) < eps; }
|
||||
|
||||
static bool greater_then_eq(double d1, double d2) {
|
||||
return eq(d1, d2) || d2 > d1;
|
||||
return tea_eq(d1, d2) || d2 > d1;
|
||||
}
|
||||
|
||||
// Returns the number of shots that are within the Shots Window
|
||||
@@ -245,7 +245,7 @@ void TaskingEyeAlgo::on_child_change(
|
||||
me->accum_qty += state.last_fills.full_value();
|
||||
}
|
||||
}
|
||||
if (!eq(me->accum_qty, pre_accum_qty)) {
|
||||
if (!tea_eq(me->accum_qty, pre_accum_qty)) {
|
||||
bts::Quantity accum_qty_qty = bts::Quantity::create_new(me->accum_qty);
|
||||
LOG(OrderMan, Info,
|
||||
"TaskingEyeAlgo::on_child_change order_key: {} qty: {} price: {}",
|
||||
@@ -379,7 +379,7 @@ bool TaskingEyeAlgo::_in_shooting_zone(
|
||||
TEASecData const &sec_data = it->second;
|
||||
const md::PriceSize &driver_bid = sec_data.driver_book.bid().at(0);
|
||||
const md::PriceSize &driver_ask = sec_data.driver_book.ask().at(0);
|
||||
if (eq(driver_bid.size(), 0) || eq(driver_ask.size(), 0))
|
||||
if (tea_eq(driver_bid.size(), 0) || tea_eq(driver_ask.size(), 0))
|
||||
return false;
|
||||
// finding weighted mean (TODO change it to mark price later)
|
||||
double driver = (driver_bid.price() * driver_bid.size() +
|
||||
|
||||
@@ -63,7 +63,7 @@ class QHOOrderManager {
|
||||
_orders.reserve(_n_eff_orders);
|
||||
_show_qty = show_qty;
|
||||
for (uint16_t i = 0; i < _n_eff_orders; i++)
|
||||
_orders.emplace_back(key, true, side, true, nullptr);
|
||||
_orders.emplace_back(nullptr, key, true, side, true, nullptr);
|
||||
_target_price = price;
|
||||
_target_qty = qty;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/tracing/bts_trace.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/helper_macros.h"
|
||||
|
||||
namespace bts {
|
||||
@@ -64,6 +65,8 @@ OrderOpResult SpreaderOrder::on_activate(
|
||||
Price price, Quantity quantity, OrderServices &services) {
|
||||
if (!_active)
|
||||
return OrderOpResult{api::orderman::ORDER_ERROR_OP_NOT_SUPPORTED};
|
||||
quantity =
|
||||
_bookkeeping_data().fqty_helper().in_transform_spreader_qty(quantity);
|
||||
SpreaderOrderServices spreader_order_services(&services);
|
||||
_on_activate(price, quantity, spreader_order_services);
|
||||
// the reason why this is immediatly reported (vs in the timer
|
||||
@@ -76,6 +79,8 @@ OrderOpResult SpreaderOrder::on_activate(
|
||||
OrderOpResult SpreaderOrder::on_update(Price price, Quantity quantity) {
|
||||
if (!_active)
|
||||
return OrderOpResult{api::orderman::ORDER_ERROR_OP_NOT_SUPPORTED};
|
||||
quantity =
|
||||
_bookkeeping_data().fqty_helper().in_transform_spreader_qty(quantity);
|
||||
LOG(OrderMan, Info, "SpreaderOrder.on_update key:{} price:{} quantity:{}",
|
||||
key().value(), price.value(), quantity.value());
|
||||
_state_worker->on_update(price, quantity);
|
||||
@@ -147,7 +152,9 @@ void SpreaderOrder::_on_book_update(const BookUpdateEvent &book_event) {
|
||||
return;
|
||||
auto scoped = _order_services->log_scope(
|
||||
"SpreaderOrder::_on_book_update", key().value());
|
||||
_state_worker->on_book(book_event.book);
|
||||
const Book &book =
|
||||
_bookkeeping_data().fqty_helper().in_transform_book(book_event.book);
|
||||
_state_worker->on_book(book);
|
||||
}
|
||||
void SpreaderOrder::_on_settlement_update(
|
||||
const SettlementUpdateEvent &settlement_event) {
|
||||
@@ -190,7 +197,13 @@ void SpreaderOrder::_keep_hedging_path_hot() {
|
||||
}
|
||||
|
||||
void SpreaderOrder::_on_child_order_update(
|
||||
const OrderStateUpdateEvent &ord_ev) {
|
||||
const OrderStateUpdateEvent &ord_ev_arg) {
|
||||
SpreaderLegData *leg =
|
||||
_bookkeeping_data().find_leg_from_orderkey(ord_ev_arg.key);
|
||||
bts_assert(leg != nullptr);
|
||||
const OrderStateUpdateEvent &ord_ev =
|
||||
_bookkeeping_data().fqty_helper().in_transform_order_event(
|
||||
leg->leg_property_data().leg_security_key(), ord_ev_arg);
|
||||
_perf_ts = utils::TimeStamp::now();
|
||||
auto start = _perf_ts;
|
||||
bool order_acked = SpreaderUtils::order_acknowledged(ord_ev.status);
|
||||
@@ -304,6 +317,8 @@ void SpreaderOrder::_on_activate(
|
||||
Price price, Quantity quantity, SpreaderOrderServices &order_services) {
|
||||
bts_assert(_inited());
|
||||
bts_assert(!_activated());
|
||||
quantity =
|
||||
_bookkeeping_data().fqty_helper().in_transform_spreader_qty(quantity);
|
||||
LOG(OrderMan, Info, "SpreaderOrder.on_activate key:{} price:{} quantity:{}",
|
||||
key().value(), price.value(), quantity.value());
|
||||
_order_services = new SpreaderOrderServices(order_services);
|
||||
@@ -471,7 +486,10 @@ void SpreaderOrder::_comp_and_report_state() {
|
||||
"price:{} qty:{} filled:{} avg_price:{}",
|
||||
key(), status, reported_state.price(), reported_state.quantity(),
|
||||
reported_state.filled_quantity(), reported_state.avg_price());
|
||||
_order_services->report_state(reported_state);
|
||||
const auto &rerported_state_adj =
|
||||
_bookkeeping_data().fqty_helper().out_transform_order_state(
|
||||
reported_state);
|
||||
_order_services->report_state(rerported_state_adj);
|
||||
}
|
||||
}
|
||||
bts::api::orderman::OrderStatus SpreaderOrder::_get_order_status() const {
|
||||
|
||||
@@ -146,6 +146,28 @@ class SpreaderOrder : public Order, public ISpreaderManager {
|
||||
inline bool in_cache_warming_cycle() const override {
|
||||
return _cw_helper.in_cache_warming_cycle;
|
||||
}
|
||||
void place_order(
|
||||
ChildOrder &child_order,
|
||||
Price price,
|
||||
Quantity quantity,
|
||||
SecurityKey sec_key,
|
||||
bool) override {
|
||||
auto qty_adjusted =
|
||||
_bookkeeping_data().fqty_helper().out_transform_leg_order_qty(
|
||||
sec_key, quantity);
|
||||
child_order.activate(price, qty_adjusted);
|
||||
}
|
||||
void update_order(
|
||||
ChildOrder &child_order,
|
||||
Price price,
|
||||
Quantity quantity,
|
||||
SecurityKey sec_key,
|
||||
bool) override {
|
||||
auto qty_adjusted =
|
||||
_bookkeeping_data().fqty_helper().out_transform_leg_order_qty(
|
||||
sec_key, quantity);
|
||||
child_order.update(price, qty_adjusted);
|
||||
}
|
||||
|
||||
private:
|
||||
// events from orders system ////////////////////
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
#include "lib/domain_model/SecurityKey.h"
|
||||
#include "lib/domain_model/common.h"
|
||||
#include "lib/orderman/ChildOrder.h"
|
||||
#include "lib/orderman/orderman_utils/Book.h"
|
||||
#include "lib/orderman/orders/book_algos/PricerOrder.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
@@ -37,6 +40,22 @@ class ISpreaderManager {
|
||||
// (however do as much as they can to keep the instruction
|
||||
// cache warm)
|
||||
virtual bool in_cache_warming_cycle() const = 0;
|
||||
// orders are placed through the ISpreaderManager. Eventhough ChildOrder has
|
||||
// the facility to do that directly, we want to control all order activity
|
||||
// through one central place
|
||||
virtual void place_order(
|
||||
ChildOrder &child_order,
|
||||
Price price,
|
||||
Quantity qty,
|
||||
SecurityKey sec_key,
|
||||
bool is_quoting) = 0;
|
||||
// just like order placement above
|
||||
virtual void update_order(
|
||||
ChildOrder &child_order,
|
||||
Price price,
|
||||
Quantity qty,
|
||||
SecurityKey sec_key,
|
||||
bool is_quoting) = 0;
|
||||
virtual ~ISpreaderManager() {}
|
||||
};
|
||||
} // namespace orderman
|
||||
|
||||
@@ -10,10 +10,11 @@ LegPropertyData::LegPropertyData(
|
||||
const bts::api::ContractLeg &leg_contract,
|
||||
const bts::spark::LegSpreaderParams &leg_params,
|
||||
api::Side trading_side,
|
||||
bts::api::SyntheticContract::PriceCalc price_calc)
|
||||
bts::api::SyntheticContract::PriceCalc price_calc,
|
||||
double qty_tick_size)
|
||||
: _leg_index(leg_index), _leg_contract(leg_contract),
|
||||
_leg_params(leg_params), _trading_side(trading_side),
|
||||
_price_calc(price_calc) {
|
||||
_price_calc(price_calc), _qty_tick_size(qty_tick_size) {
|
||||
LOG(OrderMan, Info,
|
||||
"LegPropertyData.cons leg_idx: "
|
||||
"{} sec_key: {} side: {}",
|
||||
|
||||
@@ -18,6 +18,7 @@ class LegPropertyData {
|
||||
const bts::spark::LegSpreaderParams _leg_params;
|
||||
const api::Side _trading_side;
|
||||
const bts::api::SyntheticContract::PriceCalc _price_calc;
|
||||
const double _qty_tick_size = 1.0;
|
||||
|
||||
public:
|
||||
LegPropertyData(
|
||||
@@ -26,7 +27,8 @@ class LegPropertyData {
|
||||
const bts::spark::LegSpreaderParams &leg_params,
|
||||
api::Side trading_side,
|
||||
bts::api::SyntheticContract::PriceCalc price_calc =
|
||||
bts::api::SyntheticContract::PRICECALC_STANDARD);
|
||||
bts::api::SyntheticContract::PRICECALC_STANDARD,
|
||||
double qty_tick_size = 1.0);
|
||||
size_t leg_index() const { return _leg_index; }
|
||||
const bts::api::ContractLeg &leg_contract() const { return _leg_contract; }
|
||||
const bts::spark::LegSpreaderParams &leg_params() const {
|
||||
@@ -47,6 +49,7 @@ class LegPropertyData {
|
||||
double tick_size() const {
|
||||
return _leg_contract.security().contract_spec().low_tick();
|
||||
}
|
||||
double qty_tick_size() const { return _qty_tick_size; }
|
||||
bool is_active_quoting() const { return _leg_params.is_active_quoting(); }
|
||||
bool is_net_change() const {
|
||||
return _price_calc == bts::api::SyntheticContract::PRICECALC_NET_CHANGE;
|
||||
@@ -64,6 +67,9 @@ class LegPropertyData {
|
||||
uint32_t n_queue_holder_orders() const {
|
||||
return _leg_params.quote_params().n_queue_holder_orders();
|
||||
}
|
||||
const bts::api::ContractLeg& leg () const{
|
||||
return _leg_contract;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace orderman
|
||||
|
||||
@@ -16,6 +16,7 @@ SingleFillHedger::SingleFillHedger(
|
||||
: _is_permenantly_cancelled(false), _spreader(spreader_manager),
|
||||
_leg_property_data(leg_property_data),
|
||||
_child_order_state(
|
||||
&spreader_manager,
|
||||
leg_property_data.leg_security_key(),
|
||||
is_live,
|
||||
leg_property_data.trading_side(),
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "SpreaderBookkeepingData.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderFractionalQtyHelper.h"
|
||||
#include "lib/os/os.h"
|
||||
|
||||
namespace bts {
|
||||
@@ -22,14 +24,15 @@ SpreaderBookkeepingData::SpreaderBookkeepingData(
|
||||
order_def.custom_def()
|
||||
.spreader()
|
||||
.execution_strategy()
|
||||
.hedge_pricing()) {
|
||||
.hedge_pricing()),
|
||||
_fqty_helper(spreader_order_key, legs) {
|
||||
LOG(OrderMan, Info,
|
||||
"SpreaderBookkeepingData.cons started "
|
||||
"key: {} n_legs: {}",
|
||||
spreader_order_key.value(), _n_legs);
|
||||
_leg_data.reserve(_n_legs);
|
||||
size_t i = 0;
|
||||
for (const auto &leg_property_data : legs) {
|
||||
for (const auto &leg_property_data : _fqty_helper.legs()) {
|
||||
_leg_data.emplace_back(
|
||||
spreader_pao_services, spreader_order_key, _n_legs, spreader_manager,
|
||||
quoter_ord_defs[i], hedger_ord_defs[i], leg_property_data);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
#include "lib/orderman/OrderBuilder.h"
|
||||
#include "lib/orderman/orders/PreActivationOrderServices.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderFractionalQtyHelper.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h"
|
||||
@@ -38,6 +39,7 @@ class SpreaderBookkeepingData {
|
||||
Price _effective_price;
|
||||
Quantity _quantity;
|
||||
NLegsHedgeRecompData _hedge_recomp_data;
|
||||
SpreaderFractionalQtyHelper _fqty_helper;
|
||||
|
||||
private:
|
||||
size_t _calc_n_quoting_legs(const std::vector<LegPropertyData> &legs);
|
||||
@@ -94,8 +96,8 @@ class SpreaderBookkeepingData {
|
||||
return _leg_data[index];
|
||||
}
|
||||
// finds the quoter that has the arg order key
|
||||
SpreaderLegData *
|
||||
find_leg_from_quoter_orderkey(bts::orderman::OrderKey order_key) {
|
||||
SpreaderLegData *find_leg_from_quoter_orderkey(
|
||||
bts::orderman::OrderKey order_key) {
|
||||
for (SpreaderLegData &leg : _leg_data)
|
||||
if (leg.leg_property_data().is_active_quoting())
|
||||
if (leg.key() == order_key)
|
||||
@@ -103,8 +105,8 @@ class SpreaderBookkeepingData {
|
||||
return nullptr;
|
||||
}
|
||||
// finds the hedger that has the arg order key
|
||||
SingleFillHedger *
|
||||
find_hedger_from_orderkey(bts::orderman::OrderKey order_key) {
|
||||
SingleFillHedger *find_hedger_from_orderkey(
|
||||
bts::orderman::OrderKey order_key) {
|
||||
for (SpreaderLegData &leg : _leg_data) {
|
||||
SingleFillHedger *rv = leg.find_hedger_from_orderkey(order_key);
|
||||
if (rv != nullptr)
|
||||
@@ -112,6 +114,18 @@ class SpreaderBookkeepingData {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
SpreaderLegData *find_leg_from_orderkey(bts::orderman::OrderKey order_key) {
|
||||
for (SpreaderLegData &leg : _leg_data)
|
||||
if (leg.leg_property_data().is_active_quoting())
|
||||
if (leg.key() == order_key)
|
||||
return ⋚
|
||||
for (SpreaderLegData &leg : _leg_data) {
|
||||
SingleFillHedger *rv = leg.find_hedger_from_orderkey(order_key);
|
||||
if (rv != nullptr)
|
||||
return ⋚
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
// creates a new hedger for a given leg index,
|
||||
// adds it to appropriate place in _hedgers,
|
||||
// and returns a ref to it
|
||||
@@ -130,8 +144,8 @@ class SpreaderBookkeepingData {
|
||||
void update_order(Price input_price, Quantity quantity) {
|
||||
update_order(input_price, input_price, quantity);
|
||||
}
|
||||
void
|
||||
update_order(Price input_price, Price effective_price, Quantity quantity) {
|
||||
void update_order(
|
||||
Price input_price, Price effective_price, Quantity quantity) {
|
||||
_input_price = input_price;
|
||||
_effective_price = effective_price;
|
||||
_quantity = quantity;
|
||||
@@ -142,6 +156,7 @@ class SpreaderBookkeepingData {
|
||||
return !os::is_nan(_effective_price.value());
|
||||
}
|
||||
size_t n_quoting_legs() const { return _n_quoting_legs; }
|
||||
SpreaderFractionalQtyHelper &fqty_helper() { return _fqty_helper; }
|
||||
};
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -4,8 +4,10 @@ namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
SpreaderChildOrderState::SpreaderChildOrderState(SpreaderChildOrderState &&src)
|
||||
: _is_live(src._is_live), _alt_order_gwy(std::move(src._alt_order_gwy)),
|
||||
_sec_key(src._sec_key), _is_quoting(src._is_quoting), _side(src._side),
|
||||
: _is_live(src._is_live),
|
||||
_spreader_manager(std::move(src._spreader_manager)),
|
||||
_alt_order_gwy(std::move(src._alt_order_gwy)), _sec_key(src._sec_key),
|
||||
_is_quoting(src._is_quoting), _side(src._side),
|
||||
_test_only_order_key(src._test_only_order_key),
|
||||
_n_place_orders(src._n_place_orders),
|
||||
_n_cancel_orders(src._n_cancel_orders),
|
||||
@@ -20,15 +22,16 @@ SpreaderChildOrderState::SpreaderChildOrderState(SpreaderChildOrderState &&src)
|
||||
_order_place_time(src._order_place_time) {}
|
||||
|
||||
SpreaderChildOrderState::SpreaderChildOrderState(
|
||||
ISpreaderManager *spreader_manager,
|
||||
SecurityKey sec_key,
|
||||
bool,
|
||||
api::Side side,
|
||||
bool is_quoting,
|
||||
IAlternateOrderGateway *alt_order_gwy)
|
||||
: _is_live(alt_order_gwy == nullptr), _alt_order_gwy(alt_order_gwy),
|
||||
_sec_key(sec_key), _is_quoting(is_quoting), _side(side),
|
||||
_test_only_order_key(
|
||||
(uint32_t)bts::Timer::now().time_since_epoch().count()),
|
||||
: _is_live(alt_order_gwy == nullptr), _spreader_manager(spreader_manager),
|
||||
_alt_order_gwy(alt_order_gwy), _sec_key(sec_key), _is_quoting(is_quoting),
|
||||
_side(side), _test_only_order_key(
|
||||
(uint32_t)bts::Timer::now().time_since_epoch().count()),
|
||||
_base_price(0), _base_quantity(0) {
|
||||
ChildOrder &empty_order = _empty_order();
|
||||
re_init(empty_order);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
#include "lib/orderman/events/OrderStateUpdateEvent.h"
|
||||
#include "lib/orderman/orderman_utils/orderman_common.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/ISpreaderManager.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
@@ -17,6 +18,7 @@ class SpreaderChildOrderState {
|
||||
//_is_live is false for unit tests which enables
|
||||
// this to work without the actual order infrastructure
|
||||
const bool _is_live;
|
||||
ISpreaderManager *const _spreader_manager;
|
||||
IAlternateOrderGateway *const _alt_order_gwy;
|
||||
const SecurityKey _sec_key;
|
||||
const bool _is_quoting;
|
||||
@@ -60,6 +62,7 @@ class SpreaderChildOrderState {
|
||||
// 1. SpreaderLegData, when making the quoting order
|
||||
// 2. SingleFillHedger when constructing the hedging order
|
||||
SpreaderChildOrderState(
|
||||
ISpreaderManager *spreader_manager,
|
||||
SecurityKey sec_key,
|
||||
bool is_live,
|
||||
api::Side side,
|
||||
@@ -155,9 +158,13 @@ class SpreaderChildOrderState {
|
||||
_order_place_time = curr_time;
|
||||
bts_assert(_n_place_orders == 0);
|
||||
_n_place_orders++;
|
||||
if (_is_live)
|
||||
_child_order.activate(price, quantity);
|
||||
else if (_alt_order_gwy != nullptr)
|
||||
if (_is_live) {
|
||||
if (_spreader_manager != nullptr)
|
||||
_spreader_manager->place_order(
|
||||
_child_order, price, quantity, _sec_key, _is_quoting);
|
||||
else
|
||||
_child_order.activate(price, quantity);
|
||||
} else if (_alt_order_gwy != nullptr)
|
||||
_alt_order_gwy->place_order(
|
||||
_sec_key, _test_only_order_key, _side, price, quantity);
|
||||
LOG(OrderMan, Info,
|
||||
@@ -173,9 +180,14 @@ class SpreaderChildOrderState {
|
||||
_out_price = price;
|
||||
_out_quantity = quantity;
|
||||
_n_modify_orders++;
|
||||
if (_is_live)
|
||||
_child_order.update(price, quantity);
|
||||
else if (_alt_order_gwy != nullptr)
|
||||
if (_is_live) {
|
||||
if (_spreader_manager != nullptr) {
|
||||
_spreader_manager->update_order(
|
||||
_child_order, price, quantity, _sec_key, _is_quoting);
|
||||
} else {
|
||||
_child_order.update(price, quantity);
|
||||
}
|
||||
} else if (_alt_order_gwy != nullptr)
|
||||
_alt_order_gwy->modify_order(_test_only_order_key, price, quantity);
|
||||
LOG(OrderMan, Info,
|
||||
"SpreaderChildOrderState::modify_order "
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
#include "SpreaderFractionalQtyHelper.h"
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "lib/domain_model/SecurityKey.h"
|
||||
#include "lib/domain_model/common.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/md/PriceSize.h"
|
||||
#include "lib/orderman/events/BookUpdateEvent.h"
|
||||
#include "lib/orderman/events/OrderStateUpdateEvent.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <utility>
|
||||
|
||||
namespace bts::orderman {
|
||||
|
||||
// TODO: get it from config
|
||||
double get_qty_tick(const api::Security &sec) {
|
||||
// only Deribit options have fractional qtys
|
||||
if (sec.has_deribit()) {
|
||||
if (sec.has_option()) {
|
||||
if (sec.symbol() == "BTC") {
|
||||
return 0.1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
double get_leg_qty_mult(const api::Security &sec) {
|
||||
double tick_size = get_qty_tick(sec);
|
||||
return 1.0 / tick_size;
|
||||
}
|
||||
|
||||
struct SFQHLegData {
|
||||
const SecurityKey key;
|
||||
const double qty_mult;
|
||||
const bool passthrough = true;
|
||||
SFQHLegData(SecurityKey key, double qty_mult)
|
||||
: key(key), qty_mult(qty_mult),
|
||||
passthrough(Quantity::equal_d(qty_mult, 1.0)) {}
|
||||
};
|
||||
|
||||
SFQHLegData const *find_sec(
|
||||
SecurityKey key, const std::vector<SFQHLegData> &leg_vec) {
|
||||
for (const auto &p : leg_vec) {
|
||||
if (p.key == key)
|
||||
return &p;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpreaderFractionalQtyHelper ::PImpl {
|
||||
Book op_book = {};
|
||||
std::vector<LegPropertyData> leg_pds;
|
||||
std::vector<SFQHLegData> leg_mults;
|
||||
OrderStateUpdateEvent op_ord = {};
|
||||
bool passthrough = false;
|
||||
PImpl() {}
|
||||
};
|
||||
|
||||
// std::vector<LegPropertyData> SpreaderFractionalQtyHelper::transform_legs(
|
||||
// const std::vector<LegPropertyData> &lpd_vec) {
|
||||
// std::vector<LegPropertyData> rv = {};
|
||||
// for (const auto &lpd : lpd_vec) {
|
||||
// double leg_tick_size = get_qty_tick(lpd.security());
|
||||
// double leg_mult = get_leg_qty_mult(lpd.security());
|
||||
// bts::api::ContractLeg leg_adj = lpd.leg_contract();
|
||||
// leg_adj.set_quantity(lpd.size_multiplier() * leg_mult);
|
||||
// rv.emplace_back(
|
||||
// lpd.leg_index(), leg_adj, lpd.leg_params(), lpd.trading_side(),
|
||||
// api::SyntheticContract::PriceCalc::
|
||||
// SyntheticContract_PriceCalc_PRICECALC_STANDARD,
|
||||
// leg_tick_size);
|
||||
// }
|
||||
// return rv;
|
||||
// }
|
||||
|
||||
SpreaderFractionalQtyHelper::SpreaderFractionalQtyHelper(
|
||||
OrderKey spreader_ord_key, const std::vector<LegPropertyData> &lpd_vec)
|
||||
: me(new PImpl()) {
|
||||
for (const auto &lpd : lpd_vec) {
|
||||
double leg_tick_sz = get_qty_tick(lpd.security());
|
||||
double leg_mult = get_leg_qty_mult(lpd.security());
|
||||
bts::api::ContractLeg leg_adj = lpd.leg_contract();
|
||||
leg_adj.set_quantity(lpd.size_multiplier() * leg_mult);
|
||||
me->leg_pds.emplace_back(
|
||||
lpd.leg_index(), leg_adj, lpd.leg_params(), lpd.trading_side(),
|
||||
api::SyntheticContract::PriceCalc::
|
||||
SyntheticContract_PriceCalc_PRICECALC_STANDARD,
|
||||
leg_tick_sz);
|
||||
me->leg_mults.push_back({SecurityKey(lpd.security().id()), leg_mult});
|
||||
}
|
||||
me->passthrough = true;
|
||||
size_t i = 0;
|
||||
for (const auto &lm : me->leg_mults) {
|
||||
me->passthrough &= lm.passthrough;
|
||||
const auto &lpd = me->leg_pds.at(i++);
|
||||
LOG(OrderMan, Info,
|
||||
"SpreaderFractionalQtyHelper::SpreaderFractionalQtyHelper key: {} "
|
||||
"leg_sec: {} "
|
||||
"mult: {} passthrough: {} leg_contract: {} params: {}",
|
||||
spreader_ord_key.value(), lm.key.value(), lm.qty_mult, lm.passthrough,
|
||||
utils::pb::to_string(lpd.leg()),
|
||||
utils::pb::to_string(lpd.leg_params()));
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<LegPropertyData> &SpreaderFractionalQtyHelper::legs() const {
|
||||
return me->leg_pds;
|
||||
}
|
||||
|
||||
const Book &SpreaderFractionalQtyHelper::in_transform_book(const Book &bk) {
|
||||
if (me->passthrough)
|
||||
return bk;
|
||||
SFQHLegData const *lp = find_sec(bk.security_key(), me->leg_mults);
|
||||
bts_assert(lp != nullptr);
|
||||
if (lp->passthrough)
|
||||
return bk;
|
||||
me->op_book = bk;
|
||||
double qm = lp->qty_mult;
|
||||
for (auto &ps : me->op_book.bid()) {
|
||||
ps = bts::md::PriceSize(ps.int_price(), ps.size() * qm);
|
||||
}
|
||||
for (auto &ps : me->op_book.ask()) {
|
||||
ps = bts::md::PriceSize(ps.int_price(), ps.size() * qm);
|
||||
}
|
||||
// mult by leg_mult
|
||||
return me->op_book;
|
||||
}
|
||||
|
||||
const OrderStateUpdateEvent &
|
||||
SpreaderFractionalQtyHelper::in_transform_order_event(
|
||||
SecurityKey sec_key, const OrderStateUpdateEvent &ev) {
|
||||
auto log_ev = [](auto sec_key, const auto &ev, const auto &rv_ev) {
|
||||
LOG(OrderMan, Info,
|
||||
"SpreaderFractionalQtyHelper::in_transform_order_event sec_key: {} "
|
||||
"ev.qty: {} ev.filled_qty: {} rv.qty: {} rv.filled_qty: {}",
|
||||
sec_key.value(), ev.quantity, ev.filled_quantity, rv_ev.quantity,
|
||||
rv_ev.filled_quantity);
|
||||
};
|
||||
if (me->passthrough) {
|
||||
log_ev(sec_key, ev, ev);
|
||||
return ev;
|
||||
}
|
||||
SFQHLegData const *lp = find_sec(sec_key, me->leg_mults);
|
||||
bts_assert(lp != nullptr);
|
||||
if (lp->passthrough) {
|
||||
log_ev(sec_key, ev, ev);
|
||||
return ev;
|
||||
}
|
||||
me->op_ord = ev;
|
||||
double qmult = lp->qty_mult;
|
||||
me->op_ord.quantity *= qmult;
|
||||
me->op_ord.filled_quantity *= qmult;
|
||||
me->op_ord.filled_at_attach_time_quantity *= qmult;
|
||||
log_ev(sec_key, ev, me->op_ord);
|
||||
return me->op_ord;
|
||||
}
|
||||
|
||||
Quantity SpreaderFractionalQtyHelper::in_transform_spreader_qty(
|
||||
Quantity qty) const {
|
||||
if (me->passthrough)
|
||||
return qty;
|
||||
return qty;
|
||||
}
|
||||
|
||||
Quantity SpreaderFractionalQtyHelper::out_transform_leg_order_qty(
|
||||
SecurityKey sec_key, Quantity qty) const {
|
||||
auto tr = [&]() {
|
||||
if (me->passthrough)
|
||||
return qty;
|
||||
SFQHLegData const *lp = find_sec(sec_key, me->leg_mults);
|
||||
bts_assert(lp != nullptr);
|
||||
if (lp->passthrough)
|
||||
return qty;
|
||||
return Quantity::create_new(qty.full_value() / lp->qty_mult);
|
||||
};
|
||||
auto rv_qty = tr();
|
||||
LOG(OrderMan, Info,
|
||||
"SpreaderFractionalQtyHelper::out_transform_leg_order_qty qty: {} "
|
||||
"rv_qty: {}",
|
||||
qty.full_value(), rv_qty.full_value());
|
||||
return rv_qty;
|
||||
}
|
||||
|
||||
const bts::api::orderman::OrderState &
|
||||
SpreaderFractionalQtyHelper::out_transform_order_state(
|
||||
bts::api::orderman::OrderState &ord_st) {
|
||||
if (me->passthrough)
|
||||
return ord_st;
|
||||
return ord_st;
|
||||
}
|
||||
|
||||
} // namespace bts::orderman
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/domain_model/common.h"
|
||||
#include "lib/orderman/orderman_utils/orderman_common.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderLegData.h"
|
||||
|
||||
namespace bts::api::orderman {
|
||||
class OrderState;
|
||||
}
|
||||
|
||||
namespace bts::orderman {
|
||||
class Book;
|
||||
class OrderStateUpdateEvent;
|
||||
class SpreaderFractionalQtyHelper {
|
||||
public:
|
||||
// static std::vector<LegPropertyData> transform_legs(
|
||||
// const std::vector<LegPropertyData> &lpd_vec);
|
||||
SpreaderFractionalQtyHelper(
|
||||
OrderKey spreader_ord_key, const std::vector<LegPropertyData> &legs);
|
||||
const std::vector<LegPropertyData> &legs() const;
|
||||
const Book &in_transform_book(const Book &book);
|
||||
const OrderStateUpdateEvent &in_transform_order_event(
|
||||
SecurityKey sec_key, const OrderStateUpdateEvent &);
|
||||
Quantity in_transform_spreader_qty(Quantity qty) const;
|
||||
Quantity out_transform_leg_order_qty(SecurityKey key, Quantity qty) const;
|
||||
const bts::api::orderman::OrderState &out_transform_order_state(
|
||||
bts::api::orderman::OrderState &);
|
||||
|
||||
private:
|
||||
struct PImpl;
|
||||
PImpl *me;
|
||||
};
|
||||
} // namespace bts::orderman
|
||||
@@ -49,6 +49,7 @@ class SpreaderLegData {
|
||||
_leg_property_data(leg_property_data),
|
||||
_quoter_child_order_state(
|
||||
_is_quoting ? new SpreaderChildOrderState(
|
||||
&spreader_manager,
|
||||
_leg_property_data.leg_security_key(),
|
||||
services.is_live(),
|
||||
leg_property_data.trading_side(),
|
||||
@@ -172,8 +173,8 @@ class SpreaderLegData {
|
||||
SingleFillHedger &get_hedger_test_only(size_t index) {
|
||||
return _hedger_manager.test_only_get_hedger_at(index);
|
||||
}
|
||||
SingleFillHedger &
|
||||
add_new_hedger(bts::Price hedge_price, bts::Quantity hedge_quantity) {
|
||||
SingleFillHedger &add_new_hedger(
|
||||
bts::Price hedge_price, bts::Quantity hedge_quantity) {
|
||||
SingleFillHedger &rv = _hedger_manager.get_hedger();
|
||||
rv.init_hedger(hedge_price, hedge_quantity);
|
||||
return rv;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "lib/md/IMarketDataListener.h"
|
||||
#include "lib/io/websocket/WebsocketClient.h"
|
||||
#include "lib/md/IMarketDataListener.h"
|
||||
#include "lib/orderman/orders/spreader_orders/tests/tests_common.h"
|
||||
#include "lib/utils/helper_macros.h"
|
||||
#include <boost/container/flat_set.hpp>
|
||||
@@ -25,7 +25,7 @@ TEST_CASE("quoter price quantity state", "[spreader]") {
|
||||
create_leg_property_data(leg_1, 0, 1.0, true, 2.0);
|
||||
AltOrderGatewayForTest alt_order_gateway;
|
||||
SpreaderChildOrderState order(
|
||||
leg_prop_data_1.leg_security_key(), false,
|
||||
nullptr, leg_prop_data_1.leg_security_key(), false,
|
||||
leg_prop_data_1.trading_side(), true, &alt_order_gateway);
|
||||
QuoteLegPriceQuantityState s(Price(-1.0), Quantity(200), order);
|
||||
REQUIRE(s.target_spread_price() == Price(-1.0));
|
||||
@@ -99,7 +99,7 @@ TEST_CASE("quoter price quantity state", "[spreader]") {
|
||||
REQUIRE(s.out_quantity() == Quantity(123));
|
||||
SECTION("test cycle_back") {
|
||||
SpreaderChildOrderState order_2(
|
||||
leg_prop_data_1.leg_security_key(), false,
|
||||
nullptr, leg_prop_data_1.leg_security_key(), false,
|
||||
leg_prop_data_1.trading_side(), true, &alt_order_gateway);
|
||||
QuoteLegPriceQuantityState s(Price(-1.0), Quantity(200), order_2);
|
||||
REQUIRE(s.target_spread_price() == Price(-1.0));
|
||||
|
||||
@@ -108,6 +108,11 @@ class SpreaderManagerForTest : public ISpreaderManager {
|
||||
return &_alt_order_gateway;
|
||||
}
|
||||
bool in_cache_warming_cycle() const override { return false; }
|
||||
|
||||
void place_order(ChildOrder &, Price, Quantity, SecurityKey, bool) override {
|
||||
}
|
||||
void update_order(
|
||||
ChildOrder &, Price, Quantity, SecurityKey, bool) override {}
|
||||
};
|
||||
/**********************************************************************/
|
||||
/***************************orders ************************************/
|
||||
@@ -368,8 +373,10 @@ void fill_book(
|
||||
bts::orderman::BookSide &bidside = book.side(api::Side::SIDE_BUY);
|
||||
bts::orderman::BookSide &askside = book.side(api::Side::SIDE_SELL);
|
||||
for (size_t i = 0; i < book.n_levels(); i++) {
|
||||
bidside[i] = bts::md::PriceSize_from_double<6>(bid_prices[i], bid_sizes[i]);
|
||||
askside[i] = bts::md::PriceSize_from_double<6>(ask_prices[i], ask_sizes[i]);
|
||||
bidside[i] =
|
||||
bts::md::PriceSize_from_double<6>(bid_prices[i], bid_sizes[i]);
|
||||
askside[i] =
|
||||
bts::md::PriceSize_from_double<6>(ask_prices[i], ask_sizes[i]);
|
||||
}
|
||||
}
|
||||
bts::orderman::Book get_book(
|
||||
|
||||
@@ -150,9 +150,9 @@ void Run::run(
|
||||
bts_assert(_md_thread == std::nullopt);
|
||||
|
||||
// start a thread for the md
|
||||
// _md_thread =
|
||||
// std::optional(bts::threading::make_thread("MDPublisher", impl));
|
||||
bool is_run_emumba = false;
|
||||
_md_thread =
|
||||
std::optional(bts::threading::make_thread("MDPublisher", impl));
|
||||
bool is_run_emumba = true;
|
||||
if (is_run_emumba) {
|
||||
threading::make_thread("Emumba", []() { run_emumba(); }).detach();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "EmumbaMain.h"
|
||||
|
||||
#include "EMTradingSession.h"
|
||||
#include "EmMDListener.h"
|
||||
#include "EmumbaSecurityIndex.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/system_config.pb.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/md/MDProducer.h"
|
||||
#include "lib/md/SecurityDB.h"
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "lib/utils/proto_helper.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
#include "server/sparkd/cmds/crypto/DeribitDemoConfiguration.h"
|
||||
#include <emumba-deribit-connector/deribit_listener.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <emumba-deribit-connector/deribit_listener.h>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
@@ -30,6 +30,9 @@ using namespace bts::orderman;
|
||||
|
||||
namespace bts::md {
|
||||
|
||||
using bts::config::SystemConfig;
|
||||
using Path = boost::filesystem::path;
|
||||
|
||||
struct EmumbaMain::PImpl {
|
||||
EmumbaSecurityIndex sec_index;
|
||||
SecurityIDRecorder recorder;
|
||||
@@ -46,8 +49,9 @@ struct EmumbaMain::PImpl {
|
||||
}}),
|
||||
producer(bts::co2::PLATFORM_SIM, recorder),
|
||||
listener(sec_index, producer) {
|
||||
const auto config_path =
|
||||
os::app_data_path("conf/deribit_demo_config.json");
|
||||
|
||||
const auto config_path = Path{config::get<SystemConfig>().config_path()} /
|
||||
"deribit_demo_config.json";
|
||||
std::optional<bts::cmds::DeribitDemoConfiguration> conf =
|
||||
bts::cmds::DeribitDemoConfiguration::read_file(config_path.string());
|
||||
// log
|
||||
|
||||
@@ -393,7 +393,7 @@ def build(
|
||||
build_cmd_steps.append(f'cd {Path(t.path).parent}')
|
||||
build_cmd_steps.append('dotnet publish -c Release -r win-x64 --sc')
|
||||
build_cmd_steps.append(
|
||||
f'copy {bins.joinpath("libspark.dll")} {bins.joinpath("publish")}')
|
||||
f'copy {bins.joinpath("libspark.dll")} {bins.joinpath("win-x64", "publish")}')
|
||||
|
||||
build_cmd = ' && '.join(build_cmd_steps)
|
||||
proc_results.append(subprocess.run(build_cmd))
|
||||
|
||||
@@ -42,7 +42,7 @@ class SparkPaths:
|
||||
|
||||
@staticmethod
|
||||
def client_bins(build_root=_default_build(), configuration='Release'):
|
||||
return build_root.joinpath(configuration, 'bin', 'net6.0-windows', 'win-x64')
|
||||
return build_root.joinpath(configuration, 'bin', 'net6.0-windows')
|
||||
|
||||
@staticmethod
|
||||
def client_sln():
|
||||
|
||||
@@ -41,7 +41,7 @@ def _main():
|
||||
configuration='release',
|
||||
restore=True,
|
||||
build_dir=output_dir,
|
||||
targets=['publish'],
|
||||
targets=['libspark', 'publish'],
|
||||
verbosity=args.verbosity)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user