Top order support attach/detach and full update.
This commit is contained in:
1 parent
9413eb2206
commit
f5354776f1
8 files changed
+220
-22
No files matched your search
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServices.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/core/IOrderServices.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.Line truncated
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServices.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/core/IOrderServices.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.Line truncated
|
||||
@@ -29,19 +29,23 @@ inline api::Side other_side(api::Side side) {
|
||||
}
|
||||
}
|
||||
|
||||
inline double market_epislon() {
|
||||
return 1e-10;
|
||||
}
|
||||
|
||||
inline bool is_better(api::Side side, Price p1, Price p2) {
|
||||
switch (side) {
|
||||
case api::SIDE_BUY:
|
||||
return p1.value()>p2.value();
|
||||
return p1.value()-p2.value() > market_epislon();
|
||||
case api::SIDE_SELL:
|
||||
return p1.value()<p2.value();
|
||||
return p2.value()-p1.value() > market_epislon();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool is_same (Price p1, Price p2) {
|
||||
return std::abs(p1.value()-p2.value()) < 1e-10;
|
||||
return std::abs(p1.value()-p2.value()) < market_epislon();
|
||||
}
|
||||
|
||||
inline bool is_equal_or_better(api::Side side, Price p1, Price p2) {
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "lib/orderman/orders/TriggerOrder.h"
|
||||
#include "lib/orderman/orders/book_algos/CoverOrder.h"
|
||||
#include "lib/orderman/orders/book_algos/JoinOrder2.h"
|
||||
#include "lib/orderman/orders/book_algos/TopOrder2.h"
|
||||
#include "lib/orderman/orders/book_algos/LeanOrder.h"
|
||||
#include "lib/orderman/orders/book_algos/OffsetOrder.h"
|
||||
#include "lib/orderman/orders/book_algos/OCOOrder.h"
|
||||
#include "lib/orderman/orders/book_algos/PricerOrder.h"
|
||||
#include "lib/orderman/orders/book_algos/TopOrder.h"
|
||||
#include "lib/orderman/orders/spreader_orders/SpreaderOrder.h"
|
||||
|
||||
#include <limits>
|
||||
@@ -165,7 +165,7 @@ Order &OrderFactory::allocate(OrderKey k, OrderKey pk,
|
||||
order_ptr.reset(new orderman::JoinOrder2());
|
||||
break;
|
||||
case CustomOrderDefinition::kTop:
|
||||
order_ptr.reset(new orderman::TopOrder());
|
||||
order_ptr.reset(new orderman::TopOrder2());
|
||||
break;
|
||||
case CustomOrderDefinition::kTrigger:
|
||||
order_ptr.reset(new orderman::TriggerOrder());
|
||||
|
||||
@@ -81,7 +81,6 @@ void BookOrderBase::on_init_recovered(OrderRecord const &rec,
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
// these are illegal persisted states for this order type
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
@@ -134,11 +133,6 @@ OrderOpResult BookOrderBase::on_update(Update const &update) {
|
||||
case InternalStatus::WORKING: {
|
||||
auto r = do_on_update(update);
|
||||
if (r.ok()) {
|
||||
|
||||
// copy new price, size to our state
|
||||
state().set_price(update.price());
|
||||
state().set_quantity(update.quantity());
|
||||
|
||||
// Copy the new custom parameters if any
|
||||
if (update.has_custom()) {
|
||||
*me->definition.mutable_custom_def() = update.custom();
|
||||
@@ -568,15 +562,29 @@ void BookOrderBase::_transition(InternalStatus st) {
|
||||
check_invariants();
|
||||
}
|
||||
|
||||
api::orderman::OrderDefinition const &BookOrderBase::definition() {
|
||||
api::orderman::OrderDefinition const &BookOrderBase::definition() const {
|
||||
return me->definition;
|
||||
}
|
||||
|
||||
api::orderman::OrderState &BookOrderBase::state() { return me->state; }
|
||||
api::orderman::OrderState const &BookOrderBase::state() const { return me->state; }
|
||||
|
||||
Book const &BookOrderBase::last_book() { return me->last_book; }
|
||||
void BookOrderBase::cancel(std::string const&msg ) {
|
||||
bts_assert(me->internal_status == InternalStatus::WORKING);
|
||||
terminate(ORDER_STATUS_CANCELED,msg);
|
||||
report_and_return();
|
||||
}
|
||||
|
||||
Book const &BookOrderBase::book_at_inception() { return me->book_at_inception; }
|
||||
void BookOrderBase::detach(std::string const&msg) {
|
||||
bts_assert(me->internal_status == InternalStatus::WORKING);
|
||||
me->child = {};
|
||||
terminate(ORDER_STATUS_CANCELED,msg);
|
||||
report_and_return();
|
||||
}
|
||||
|
||||
Book const &BookOrderBase::last_book() const { return me->last_book; }
|
||||
|
||||
Book const &BookOrderBase::book_at_inception() const { return me->book_at_inception; }
|
||||
|
||||
void BookOrderBase::launch_child(api::orderman::OrderDefinition const&child_def) {
|
||||
bts_assert(me->internal_status == InternalStatus::WORKING);
|
||||
|
||||
@@ -35,13 +35,17 @@ class BookOrderBase : public Order {
|
||||
virtual void do_on_ready(bool is_attached) = 0;
|
||||
virtual OrderOpResult do_on_update(api::orderman::Update const &) = 0;
|
||||
|
||||
void cancel(std::string const&msg = "");
|
||||
void detach(std::string const&msg = "");
|
||||
void unsubscribe_from_book();
|
||||
api::orderman::OrderDefinition const &definition();
|
||||
api::orderman::OrderDefinition const &definition() const;
|
||||
api::orderman::OrderState &state();
|
||||
api::orderman::OrderState const &state() const;
|
||||
void launch_child(api::orderman::OrderDefinition const&child_def);
|
||||
void update_child(api::orderman::Update &);
|
||||
Book const&last_book();
|
||||
Book const&book_at_inception();
|
||||
Book const&last_book() const;
|
||||
Book const&book_at_inception() const;
|
||||
|
||||
private:
|
||||
enum class InternalStatus;
|
||||
struct PImpl;
|
||||
|
||||
@@ -47,9 +47,6 @@ void JoinOrder2::do_on_ready(bool is_attached) {
|
||||
|
||||
if (!is_attached) {
|
||||
auto const&def = definition();
|
||||
bts_assert(def.has_custom_def());
|
||||
bts_assert(def.custom_def().has_join());
|
||||
bts_assert(def.custom_def().join().has_child());
|
||||
api::orderman::OrderDefinition child_def = def;
|
||||
*child_def.mutable_custom_def() =
|
||||
definition().custom_def().join().child();
|
||||
@@ -101,7 +98,11 @@ OrderOpResult JoinOrder2::do_on_update(api::orderman::Update const &update) {
|
||||
return {ORDER_ERROR_INVALID_OP,
|
||||
"Update is not valid for this order type"};
|
||||
|
||||
// build child update
|
||||
// copy new price, size to our state
|
||||
state().set_price(update.price());
|
||||
state().set_quantity(update.quantity());
|
||||
|
||||
// Build child update
|
||||
Update child_update;
|
||||
child_update.set_price(update.price());
|
||||
child_update.set_quantity(update.quantity());
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
#include "TopOrder2.h"
|
||||
#include "lib/domain_model/Security.h"
|
||||
#include "lib/orderman/order_factory/IOrderFactory.h"
|
||||
#include "lib/orderman/orderman_utils/Book.h"
|
||||
#include "lib/orderman/orderman_utils/orderman_utils.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
using namespace api::orderman;
|
||||
|
||||
struct TopOrder2::PImpl {
|
||||
spark::QuantityMeasure top_threshold_measure;
|
||||
};
|
||||
|
||||
TopOrder2::TopOrder2() : me(new PImpl()) {}
|
||||
TopOrder2::~TopOrder2() {}
|
||||
|
||||
OrderOpResult TopOrder2::do_on_init_new() {
|
||||
auto &def = definition();
|
||||
bts_assert(def.has_custom_def());
|
||||
bts_assert(def.custom_def().has_top());
|
||||
|
||||
// validate the top part of the definition
|
||||
auto &top = def.custom_def().top();
|
||||
if (!top.has_child() &&
|
||||
OrderKey(def.attach_target_order_key()) == null_order_key()) {
|
||||
return OrderOpResult{
|
||||
ORDER_ERROR_INVALID_ORDER_DEFINITON,
|
||||
"Top order must have either a child order definition or an "
|
||||
"order to attach to"};
|
||||
}
|
||||
|
||||
me->top_threshold_measure = top.top_threshold();
|
||||
|
||||
// set the custom component of our state
|
||||
state().mutable_top();
|
||||
return OrderOpResult{};
|
||||
}
|
||||
|
||||
void TopOrder2::do_on_ready(bool is_attached) {
|
||||
|
||||
if (!is_attached) {
|
||||
|
||||
if (better_than_top()) {
|
||||
cancel("Order would become BBO on inception");
|
||||
return;
|
||||
}
|
||||
|
||||
if (at_top_of_book() && top_of_book_quantity() < min_quantity_at_top()) {
|
||||
cancel("Top of book is below threshold");
|
||||
return;
|
||||
}
|
||||
|
||||
auto const &def = definition();
|
||||
api::orderman::OrderDefinition child_def = def;
|
||||
*child_def.mutable_custom_def() = definition().custom_def().top().child();
|
||||
launch_child(child_def);
|
||||
return;
|
||||
}
|
||||
check_min_quantity();
|
||||
}
|
||||
|
||||
void TopOrder2::do_on_book(Book const &) { check_min_quantity(); }
|
||||
|
||||
void TopOrder2::check_min_quantity() {
|
||||
LOG(OrderMan, Diag, "Checking min quantity in top order {}", key().value());
|
||||
|
||||
if (better_than_top()) {
|
||||
LOG(OrderMan, Diag,
|
||||
"Top order {} became better than the top of the book, canceling",
|
||||
key().value());
|
||||
cancel("Order would become BBO");
|
||||
return;
|
||||
}
|
||||
|
||||
if (at_top_of_book()) {
|
||||
auto total_min_quantity =
|
||||
state().quantity() + min_quantity_at_top().value();
|
||||
LOG(OrderMan, Diag,
|
||||
"Top order {} is now at the top of the book, min quantity for book "
|
||||
"is: {}"
|
||||
" book quantity is: {}",
|
||||
key().value(), total_min_quantity, top_of_book_quantity().value());
|
||||
if (top_of_book_quantity() < Quantity(total_min_quantity)) {
|
||||
LOG(OrderMan, Diag,
|
||||
"Top order {} is canceling because min quantiy is not met",
|
||||
key().value());
|
||||
cancel("Top of book is below threshold");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OrderOpResult TopOrder2::do_on_update(api::orderman::Update const &update) {
|
||||
// validate update
|
||||
if (update.has_custom() && !update.custom().has_top())
|
||||
return {ORDER_ERROR_INVALID_OP,
|
||||
"Update is not valid for this order type"};
|
||||
|
||||
LOG(OrderMan, Diag, "Top order {} receiving update: {}", key().value(),
|
||||
utils::pb::to_string(update));
|
||||
|
||||
// Copy new price, size to our state
|
||||
state().set_price(update.price());
|
||||
state().set_quantity(update.quantity());
|
||||
|
||||
// Build child update
|
||||
Update child_update;
|
||||
child_update.set_price(update.price());
|
||||
child_update.set_quantity(update.quantity());
|
||||
if (update.has_custom()) {
|
||||
// process custom part of the udpate if any
|
||||
auto &top_update = update.custom().top();
|
||||
*child_update.mutable_custom() = top_update.child();
|
||||
me->top_threshold_measure = top_update.top_threshold();
|
||||
}
|
||||
update_child(child_update);
|
||||
check_min_quantity();
|
||||
return OrderOpResult();
|
||||
}
|
||||
|
||||
bool TopOrder2::at_top_of_book() const {
|
||||
auto my_side = definition().side();
|
||||
auto &my_side_psz = last_book().side(my_side)[0];
|
||||
|
||||
return securities::is_same(Price(state().price()),
|
||||
Price(my_side_psz.price()));
|
||||
}
|
||||
|
||||
bool TopOrder2::better_than_top() const {
|
||||
auto my_side = definition().side();
|
||||
auto &my_side_psz = last_book().side(my_side)[0];
|
||||
|
||||
return securities::is_better(my_side, Price(state().price()),
|
||||
Price(my_side_psz.price()));
|
||||
}
|
||||
|
||||
Quantity TopOrder2::top_of_book_quantity() const {
|
||||
auto my_side = definition().side();
|
||||
auto &my_side_psz = last_book().side(my_side)[0];
|
||||
return Quantity(my_side_psz.size());
|
||||
}
|
||||
|
||||
Quantity TopOrder2::min_quantity_at_top() const {
|
||||
return SpreaderUtils::_quantity_threshold(me->top_threshold_measure,
|
||||
Quantity(state().quantity()));
|
||||
}
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/orderman/orders/book_algos/BookOrderBase.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class TopOrder2 : public BookOrderBase {
|
||||
public:
|
||||
TopOrder2();
|
||||
~TopOrder2();
|
||||
|
||||
private:
|
||||
OrderOpResult do_on_init_new() override;
|
||||
void do_on_book(Book const &) override;
|
||||
void do_on_ready(bool is_attached) override;
|
||||
OrderOpResult do_on_update(api::orderman::Update const &) override;
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
bool at_top_of_book() const;
|
||||
bool better_than_top() const;
|
||||
Quantity top_of_book_quantity() const;
|
||||
Quantity min_quantity_at_top() const ;
|
||||
void check_min_quantity() ;
|
||||
};
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user