More refactoring of orderman.

This commit is contained in:
Pedro Pinto committed 2018-02-06 17:56:39 -05:00
1 parent 551ac20aaf
commit 560e54075c
50 files changed
+144 -220

No files matched your search

+1 -1
View File
@@ -1 +1 @@
set(sources ;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/TestOrderman.cpp;dspark/mirage.cpp;dspark/mirage/routing/Router.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/Market.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/store_tests.cpp;main.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;mercury/actors/Actor.cpp;mercury/broker/AsyncEventBroker.cpp;mercury/broker/CoreEventBroker.cpp;mercury/broker/IEventBroker.cpp;mercury/events/TimerEvent.cpp;mercury/mercury_utils/Executor.cpp;mercury/mercury_utils/IPollableActor.cpp;mercury/mercury_utils/mercury_common.cpp;mercury/synopsis/SynopsisBuilder.cpp;mercury/topics/ITopic.cpp;orderman/spreader_orders/SpreaderOrder.cpp;orderman/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/tests/spreader_tests.cpp;orderman/utils/orderman_utils.cpp;orderman2/actors/AsyncFactory.cpp;orderman2/actors/ExecutionGateway.cpp;orderman2/actors/FillStore.cpp;orderman2/actors/OrderStore.cpp;orderman2/actors/SecuritySrc.cpp;orderman2/actors/ServiceBridge.cpp;orderman2/actors/order_manager/OrderBuilder.cpp;orderman2/actors/order_manager/OrderManager.cpp;orderman2/events/CancelRejectEvent.cpp;orderman2/events/NewExecutionReportEvent.cpp;orderman2/order_factory/OrderFactory.cpp;orderman2/orderman2_utils/fix_order_codec.cpp;orderman2/orders/IcebergOrder.cpp;orderman2/orders/NativeOrder.cpp;orderman2/orders/Order.cpp;orderman2/server/OrderServiceServer2.cpp;orderman2/tests/fat_wrapper_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/tests/PositionTests.cpp;risk_limits/AccountRiskLimiter.cpp;risk_limits/IRiskLimitObserver.cpp;risk_limits/OperatorRiskLimiter.cpp;risk_limits/RiskLimitManager.cpp;risk_limits/RiskLimiter.cpp;risk_limits/SymbolKey.cpp;risk_limits/tests/RiskLimitsTests.cpp;securities/SecurityDB.cpp;spreader/SingleFillHedger.cpp;spreader/SingleLegQuoter.cpp;spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;testing/catch_test_runner.cpp;tracing/bts_trace_c.c;user/AccountServiceServer.cpp;user/UserServiceServer.cpp;user/tests/UserAndAccountTests.cpp)
set(sources ;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/TestOrderman.cpp;dspark/mirage.cpp;dspark/mirage/routing/Router.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/Market.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/store_tests.cpp;main.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;mercury/actors/Actor.cpp;mercury/broker/AsyncEventBroker.cpp;mercury/broker/CoreEventBroker.cpp;mercury/broker/IEventBroker.cpp;mercury/events/TimerEvent.cpp;mercury/mercury_utils/Executor.cpp;mercury/mercury_utils/IPollableActor.cpp;mercury/mercury_utils/mercury_common.cpp;mercury/synopsis/SynopsisBuilder.cpp;mercury/topics/ITopic.cpp;orderman/spreader_orders/SpreaderOrder.cpp;orderman/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/tests/spreader_tests.cpp;orderman2/actors/AsyncFactory.cpp;orderman2/actors/ExecutionGateway.cpp;orderman2/actors/FillStore.cpp;orderman2/actors/OrderStore.cpp;orderman2/actors/SecuritySrc.cpp;orderman2/actors/ServiceBridge.cpp;orderman2/actors/order_manager/OrderBuilder.cpp;orderman2/actors/order_manager/OrderManager.cpp;orderman2/events/CancelRejectEvent.cpp;orderman2/events/NewExecutionReportEvent.cpp;orderman2/order_factory/OrderFactory.cpp;orderman2/orderman2_utils/fix_order_codec.cpp;orderman2/orders/IcebergOrder.cpp;orderman2/orders/NativeOrder.cpp;orderman2/orders/Order.cpp;orderman2/server/OrderServiceServer2.cpp;orderman2/tests/fat_wrapper_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/tests/PositionTests.cpp;risk_limits/AccountRiskLimiter.cpp;risk_limits/IRiskLimitObserver.cpp;risk_limits/OperatorRiskLimiter.cpp;risk_limits/RiskLimitManager.cpp;risk_limits/RiskLimiter.cpp;risk_limits/SymbolKey.cpp;risk_limits/tests/RiskLimitsTests.cpp;securities/SecurityDB.cpp;spreader/SingleFillHedger.cpp;spreader/SingleLegQuoter.cpp;spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;testing/catch_test_runner.cpp;tracing/bts_trace_c.c;user/AccountServiceServer.cpp;user/UserServiceServer.cpp;user/tests/UserAndAccountTests.cpp)
@@ -10,7 +10,7 @@
#include "lib/utils/TimeStamp.h"
#include "lib/utils/datetime.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include <thread>
#include <atomic>
@@ -46,9 +46,9 @@ struct CoreGateway::EventData
ts (src.ts)
{}
EventData () : handler (), out_msgs (),in_msg (), cid(orderman::NullTickToTradeCorID),ts () {}
EventData () : handler (), out_msgs (),in_msg (), cid(orderman2::NullTickToTradeCorID),ts () {}
EventData (Handler handler) : handler (handler), out_msgs (),in_msg (),cid(), ts () {}
EventData (Handler handler,orderman::TickToTradeCorID cid, OutFIXPtr const &out_msgs) :
EventData (Handler handler,orderman2::TickToTradeCorID cid, OutFIXPtr const &out_msgs) :
handler (handler),
out_msgs (out_msgs),
in_msg (),
@@ -59,14 +59,14 @@ struct CoreGateway::EventData
EventData (Handler handler,InMsgBuffer const&in_msg) :
handler (handler), out_msgs (),
in_msg (in_msg),
cid(orderman::NullTickToTradeCorID),
cid(orderman2::NullTickToTradeCorID),
ts ()
{}
EventData (Handler handler,std::shared_ptr<std::string> const&ts)
: handler (handler),
out_msgs (),in_msg (),
cid(orderman::NullTickToTradeCorID),
cid(orderman2::NullTickToTradeCorID),
ts (ts)
{}
@@ -92,7 +92,7 @@ struct CoreGateway::EventData
Handler handler;
OutFIXPtr out_msgs;
InMsgBuffer in_msg;
orderman::TickToTradeCorID cid;
orderman2::TickToTradeCorID cid;
std::shared_ptr<std::string> ts;
};
@@ -158,7 +158,7 @@ CoreGateway::~CoreGateway ()
me->timer_thread.join ();
}
void CoreGateway::send (orderman::TickToTradeCorID cid, OutFIXPtr const &fix)
void CoreGateway::send (orderman2::TickToTradeCorID cid, OutFIXPtr const &fix)
{
LOG(Latency,Info,"CoreGateway_send {} {}", cid, utils::TimeStamp::now().to_uint64());
me->event_queue.enqueue (EventData (&CoreGateway::sync_send,cid,fix));
@@ -5,7 +5,7 @@
#include "server/sparkd/jetfix/gateway/ICoreGatewayEventSink.h"
#include "server/sparkd/jetfix/common/OutFIXPtr.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/config/protos/jetfix.pb.h"
@@ -30,7 +30,7 @@ public:
~CoreGateway();
void start ();
void stop ();
void send (orderman::TickToTradeCorID cid, OutFIXPtr const &msgs);
void send (orderman2::TickToTradeCorID cid, OutFIXPtr const &msgs);
void dispatch_events ();
private:
@@ -7,7 +7,7 @@
#include "server/sparkd/jetfix/connection/SocketConnection.h"
#include "server/sparkd/jetfix/store/FIXFileStore.h"
#include "lib/utils/meta_programming.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/config/protos/jetfix.pb.h"
@@ -44,7 +44,7 @@ public:
void start () {_core.start ();}
void stop () {_core.stop ();}
void send (orderman::TickToTradeCorID cid, OutFIXPtr const &msgs) {_core.send (cid,msgs);}
void send (orderman2::TickToTradeCorID cid, OutFIXPtr const &msgs) {_core.send (cid,msgs);}
void dispatch_events () {_core.dispatch_events ();}
std::function<void()> &on_ready () {return _on_ready;}
+3 -3
View File
@@ -113,7 +113,7 @@ void Session::start ()
internal_send (make_logon (me->cfg));
}
void Session::send (orderman::TickToTradeCorID cid, OutFIXPtr const&msgs)
void Session::send (orderman2::TickToTradeCorID cid, OutFIXPtr const&msgs)
{
switch (me->state)
{
@@ -526,9 +526,9 @@ void Session::buffer_or_deliver (InMsgBuffer const&msg)
}
}
void Session::internal_send (OutFIXPtr const&msgs) {internal_send(orderman::NullTickToTradeCorID,msgs);}
void Session::internal_send (OutFIXPtr const&msgs) {internal_send(orderman2::NullTickToTradeCorID,msgs);}
void Session::internal_send (orderman::TickToTradeCorID cid, OutFIXPtr const&msgs)
void Session::internal_send (orderman2::TickToTradeCorID cid, OutFIXPtr const&msgs)
{
IConnection::WriteVec data_vec;
bts_assert (msgs->fix.size () < IConnection::MaxWriteVecSz);
+3 -3
View File
@@ -7,7 +7,7 @@
#include "server/sparkd/jetfix/common/JetFIXError.h"
#include "lib/utils/datetime.h"
#include "server/sparkd/jetfix/common/OutFIXPtr.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/config/protos/jetfix.pb.h"
@@ -31,7 +31,7 @@ public:
~Session();
void start ();
void send (orderman::TickToTradeCorID cid, OutFIXPtr const&);
void send (orderman2::TickToTradeCorID cid, OutFIXPtr const&);
void receive (InMsgBuffer const&);
void shutdown ();
void time (std::shared_ptr<std::string> const&time_str);
@@ -55,7 +55,7 @@ private:
void buffer (InMsgBuffer const &msg);
void buffer_or_deliver (InMsgBuffer const&msg);
void internal_send (orderman::TickToTradeCorID cid, OutFIXPtr const&);
void internal_send (orderman2::TickToTradeCorID cid, OutFIXPtr const&);
void internal_send (OutFIXPtr const&);
void logout (JetFIXError::Code reason);
void logout (JetFIXError::Code reason,std::string const &extra_info);
@@ -2,7 +2,7 @@
#include "lib/utils/bts_chrono.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/sparkproto/SparkProtos.pb.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/spreader/SpreaderLegData.h" // fix this (not needed, all the headers can be fwd ref's)
#include "server/sparkd/orderman/spreader_orders/spreader_states/SpreaderState.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
@@ -5,7 +5,6 @@
#include "server/sparkd/securities/SecurityDB.h"
#include "lib/domain_model/Security.h"
#include "lib/utils/bts_assert.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman/spreader_orders/SpreaderOrder.h"
#include "server/sparkd/spreader/SpreaderLegData.h"
#include "lib/utils/datetime.h"
@@ -297,7 +296,7 @@ void fire_book_update (double* prices, uint16_t* sizes, api::Side side, size_t l
bts::orderman2::Book book;
fill_book (book, prices, sizes, side);
sm.set_book (book, leg_index);
quoter.on_book (bts::orderman::NullTickToTradeCorID, leg_index, book);
quoter.on_book (bts::orderman2::NullTickToTradeCorID, leg_index, book);
}
void verify_leg_data (SpreaderLegData& l, bts::orderman2::OrderKey, size_t leg_index, uint32_t sec_key, uint32_t exp_yr, uint32_t exp_m, uint32_t exp_day, const std::string& symbol, double leg_mult, double price_mult, api::Side side)
{
@@ -343,7 +342,7 @@ void fire_book_update_hedger (double* prices, uint16_t* sizes, api::Side side, S
{
bts::orderman2::Book book;
fill_book (book, prices, sizes, side);
hedger.on_book (bts::orderman::NullTickToTradeCorID, book);
hedger.on_book (bts::orderman2::NullTickToTradeCorID, book);
}
void verify_complete_hedger_state (const SingleFillHedger& hedger, HedgerState state, Price target_price, Quantity target_quantity, Quantity aggregated_filled_quantity,
Price out_price, Quantity, Quantity remaining_to_fill)
@@ -1,6 +0,0 @@
#include "orderman_utils.h"
namespace bts {
namespace orderman {
}}
@@ -1,68 +0,0 @@
#pragma once
#include <cstdint>
#include <string>
#include <array>
#include <cstring>
#include "lib/utils/ValueWrapper.h"
#include "lib/domain_model/common.h"
#include "lib/utils/bts_assert.h"
namespace bts {
namespace api {class Security;}
namespace orderman {
using OrderKey = utils::ValueWrapper<struct OrderKeyTag,uint32_t>;
using FIXSessionName = utils::ValueWrapper<struct FIXSessionNameTag,std::string>;
using GatewayName = utils::ValueWrapper<struct GatewayNameTag,std::string>;
using OperatorID = utils::ValueWrapper<struct OperatorIDTag,std::array<char,18>>;
using ExchangeOrderID = utils::ValueWrapper<struct ExchangeOrderIDTag,std::array<char,17>>;
using OrderTimeStamp = utils::ValueWrapper<struct OrderTimeStampTag,std::array<char, sizeof("20121204-14:44:02.000")-1>> ;
using SecurityPtr = const api::Security *;
using AccountName = utils::ValueWrapper<struct AccountNameTag,std::array<char,12>>;
using ExchangeFillID = utils::ValueWrapper<struct ExchangeFillIDTag,std::array<char,40>>;
using TickToTradeCorID = uint16_t;
const uint16_t NullTickToTradeCorID = 0;
template <size_t N> void to_array(std::string const&str,std::array<char,N>*out )
{
auto &result = *out;
bts_assert(str.size() <= N);
memset(&result[0],' ', N);
memcpy(&result[0],str.data(),str.size());
}
template <size_t N> void to_str(std::array<char,N> const&in ,std::string *out)
{
auto &result = *out;
result.resize(N);
memcpy(&result[0],in.data(),N);
}
template <class T>
T to(std::string const&str)
{
T result;
to_array(str,&result.value());
return result;
}
template <class T>
inline std::string to_str (T const&t)
{
std::string result;
to_str(t.value(),&result);
return result;
}
template <size_t N>
std::pair<const char*,size_t> to_trim_str(std::array<char,N> const&in)
{
for (auto i = (size_t) 0; i < N; i++)
if (in[i] == ' ')
return std::make_pair (&in[0],i);
return std::make_pair (&in[0],N);
}
}}
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts
{
@@ -12,7 +12,7 @@ IMarginObserver
{
public:
virtual ~IMarginObserver();
virtual void on_margin_change(const orderman::AccountName&, const MarginResult&) = 0;
virtual void on_margin_change(const orderman2::AccountName&, const MarginResult&) = 0;
};
}
}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts
{
@@ -11,7 +11,7 @@ class IPositionObserver
{
public:
virtual ~IPositionObserver();
virtual void on_position_change(const orderman::AccountName&, SecurityKey, double quantity, double avg_price) = 0;
virtual void on_position_change(const orderman2::AccountName&, SecurityKey, double quantity, double avg_price) = 0;
};
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/domain_model/Security.pb.h"
namespace bts
@@ -38,7 +38,7 @@ namespace bts
namespace position
{
using MarginMap = boost::container::flat_map<orderman::AccountName, MarginResult>;
using MarginMap = boost::container::flat_map<orderman2::AccountName, MarginResult>;
struct MarginServiceCore::PImpl
{
securities::SecurityDB& db;
@@ -377,13 +377,13 @@ MarginServiceCore::MarginServiceCore(securities::SecurityDB& db, IMarginObserver
MarginServiceCore::~MarginServiceCore() {}
bool MarginServiceCore::pump(const orderman::AccountName& acct)
bool MarginServiceCore::pump(const orderman2::AccountName& acct)
{
MarginResult result;
return compute_margin(acct, result);
}
bool MarginServiceCore::compute_margin(const orderman::AccountName& acct, MarginResult& result)
bool MarginServiceCore::compute_margin(const orderman2::AccountName& acct, MarginResult& result)
{
auto now = bts::datetime::now();
auto diff = bts::datetime::ptime_diff_in_ms(now, me->last_update);
@@ -400,12 +400,12 @@ bool MarginServiceCore::compute_margin(const orderman::AccountName& acct, Margin
}
}
bool MarginServiceCore::query_margin_webapi(const orderman::AccountName& acct, MarginResult& margin)
bool MarginServiceCore::query_margin_webapi(const orderman2::AccountName& acct, MarginResult& margin)
{
std::vector<Position> pos;
me->position_service.query_all_positions(acct, pos);
utils::Uuid guid;
bool succ = me->compute_margin(orderman::to_str(acct), guid.to_text_string(), pos, margin);
bool succ = me->compute_margin(orderman2::to_str(acct), guid.to_text_string(), pos, margin);
if(me->observer)
me->observer->on_margin_change(acct, margin);
me->last_results.insert_or_assign(acct, margin);
@@ -426,7 +426,7 @@ void MarginServiceCore::set_verbose_debugging(bool verb)
me->verbose = verb;
}
bool MarginServiceCore::get_last_valid_result(const orderman::AccountName& acct, MarginResult& result)
bool MarginServiceCore::get_last_valid_result(const orderman2::AccountName& acct, MarginResult& result)
{
auto it = me->last_valid_results.find(acct);
if(it != me->last_valid_results.end())
@@ -437,7 +437,7 @@ bool MarginServiceCore::get_last_valid_result(const orderman::AccountName& acct,
return false;
}
bool MarginServiceCore::get_last_result(const orderman::AccountName& acct, MarginResult& result)
bool MarginServiceCore::get_last_result(const orderman2::AccountName& acct, MarginResult& result)
{
auto it = me->last_results.find(acct);
if(it != me->last_results.end())
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/position/Position.h"
#include "lib/domain_model/Security.pb.h"
@@ -21,16 +21,16 @@ public:
~MarginServiceCore();
//Call as much as you want; it will update IMarginObserver at most once every 30s
bool pump(const orderman::AccountName&);
bool pump(const orderman2::AccountName&);
//Call as much as you want; it will query the webapi at most once every 30s
bool compute_margin(const orderman::AccountName&, MarginResult&);
bool compute_margin(const orderman2::AccountName&, MarginResult&);
private:
friend class PositionTests;
bool get_last_valid_result(const orderman::AccountName&, MarginResult&);
bool get_last_result(const orderman::AccountName&, MarginResult&);
bool get_last_valid_result(const orderman2::AccountName&, MarginResult&);
bool get_last_result(const orderman2::AccountName&, MarginResult&);
//This is a blocking call to a WebAPI. Very Slow.
bool query_margin_webapi(const orderman::AccountName&, MarginResult&);
bool query_margin_webapi(const orderman2::AccountName&, MarginResult&);
//This is a blocking call to a WebAPI. Very Slow.
bool query_margin_webapi(const std::vector<Position>&, MarginResult&);
void set_verbose_debugging(bool);
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/domain_model/Security.pb.h"
namespace bts
@@ -9,7 +9,7 @@ namespace position
{
struct Position
{
orderman::AccountName account;
orderman2::AccountName account;
const api::Security* security;
Quantity position;
api::Side side;
@@ -2,7 +2,7 @@
#include "Position.h"
#include "IPositionObserver.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/securities/SecurityDB.h"
#include "lib/utils/bts_assert.h"
@@ -23,12 +23,12 @@ template <typename T> int sgn(T val) {
class BookEntry
{
public:
orderman::AccountName account;
orderman2::AccountName account;
SecurityKey security_key;
double position;
double avg_price;
public:
BookEntry(const orderman::AccountName& acc, SecurityKey k) :
BookEntry(const orderman2::AccountName& acc, SecurityKey k) :
account(acc), security_key(k), position(0.0), avg_price(0.0)
{
}
@@ -49,14 +49,14 @@ public:
struct PositionServiceCore::PImpl
{
typedef std::pair<orderman::AccountName, SecurityKey> KeyType;
typedef std::pair<orderman2::AccountName, SecurityKey> KeyType;
boost::container::flat_map<KeyType, std::shared_ptr<BookEntry>> book;
IPositionObserver* observer;
PImpl(IPositionObserver* obs) : book(), observer(obs)
{
}
BookEntry& find_entry(const orderman::AccountName& account, SecurityKey skey)
BookEntry& find_entry(const orderman2::AccountName& account, SecurityKey skey)
{
KeyType key(account, skey);
auto& entry = book[key];
@@ -65,7 +65,7 @@ struct PositionServiceCore::PImpl
return *entry;
}
void book_raw_fill(const orderman::AccountName& account, SecurityKey sec,
void book_raw_fill(const orderman2::AccountName& account, SecurityKey sec,
double last_size, double last_price, api::Side side)
{
auto& entry = find_entry(account, sec);
@@ -82,7 +82,7 @@ PositionServiceCore::PositionServiceCore(securities::SecurityDB& db, IPositionOb
PositionServiceCore::~PositionServiceCore() {}
bool PositionServiceCore::query_position(const orderman::AccountName& account, SecurityKey seckey, Position& result)
bool PositionServiceCore::query_position(const orderman2::AccountName& account, SecurityKey seckey, Position& result)
{
auto& entry = me->find_entry(account, seckey);
auto sec = _db.resolve(entry.security_key);
@@ -99,7 +99,7 @@ bool PositionServiceCore::query_position(const orderman::AccountName& account, S
return false;
}
void PositionServiceCore::query_all_positions(const orderman::AccountName& account, std::vector<Position>& result)
void PositionServiceCore::query_all_positions(const orderman2::AccountName& account, std::vector<Position>& result)
{
result.reserve(me->book.size());
for(auto& entry : me->book)
@@ -123,7 +123,7 @@ void PositionServiceCore::query_all_positions(const orderman::AccountName& accou
void PositionServiceCore::consume_raw_fill(const std::string& account, uint32_t security_key,
double last_size, double last_price, api::Side side)
{
orderman::AccountName acc = orderman::to<orderman::AccountName>(account);
orderman2::AccountName acc = orderman2::to<orderman2::AccountName>(account);
SecurityKey skey(security_key);
auto sec = _db.resolve(skey);
if(sec->Contract_case() == api::Security::ContractCase::kSpread)
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/utils/bts_no_copy.h"
@@ -20,8 +20,8 @@ public:
PositionServiceCore(securities::SecurityDB&, IPositionObserver* obs = nullptr);
~PositionServiceCore();
bool query_position(const orderman::AccountName&, SecurityKey, Position&);
void query_all_positions(const orderman::AccountName&, std::vector<Position>&);
bool query_position(const orderman2::AccountName&, SecurityKey, Position&);
void query_all_positions(const orderman2::AccountName&, std::vector<Position>&);
private:
void consume_raw_fill(const std::string& account, uint32_t security_key,
@@ -6,7 +6,7 @@
#include "../MarginResult.h"
#include "../IMarginObserver.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/securities/SecurityDB.h"
#include "server/sparkd/user/AccountServiceServer.h"
#include "server/sparkd/user/UserServiceServer.h"
@@ -55,7 +55,7 @@ TEST_CASE ("Margin API", "[margin]")
if(i.second->has_future() && i.second->symbol() == "ES")
p.security = i.second;
}
auto acct = orderman::to<orderman::AccountName>("TAG1");
auto acct = orderman2::to<orderman2::AccountName>("TAG1");
p.account = acct;
p.avg_price = Price(2500.0);
p.position = Quantity(1);
@@ -15,7 +15,7 @@
#include <vector>
#include <utility>
using namespace bts::orderman;
using namespace bts::orderman2;
namespace bts
{
@@ -78,7 +78,7 @@ const SymbolKey& AccountRiskLimiter::symbol_key()
return me->shared_data.position_info.symbol;
}
void AccountRiskLimiter::allowed_operators(std::vector<orderman::OperatorID>& opers)
void AccountRiskLimiter::allowed_operators(std::vector<orderman2::OperatorID>& opers)
{
for(const auto& i : me->operator_map)
opers.push_back(i.first);
@@ -136,4 +136,4 @@ RiskLimitManager& AccountRiskLimiter::manager()
}
}
}
}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/risk_limits/SymbolKey.h"
#include "server/sparkd/position/MarginResult.h"
#include "lib/api/services/AccountService.pb.h"
@@ -20,8 +20,8 @@ class SharedLimiterData
{
BTS_NO_COPY(SharedLimiterData);
public:
SharedLimiterData(const orderman::AccountName&, const SymbolKey&);
orderman::AccountName account_name;
SharedLimiterData(const orderman2::AccountName&, const SymbolKey&);
orderman2::AccountName account_name;
api::account::Account account_info;
struct PositionInfo { SymbolKey symbol;
uint32_t long_position; uint32_t short_position;
@@ -35,13 +35,13 @@ class AccountRiskLimiter
{
BTS_NO_COPY(AccountRiskLimiter);
public:
AccountRiskLimiter(RiskLimitManager&, const orderman::AccountName&, const SymbolKey&);
AccountRiskLimiter(RiskLimitManager&, const orderman2::AccountName&, const SymbolKey&);
~AccountRiskLimiter();
RiskLimiter& find_limiter(const orderman::OperatorID&, orderman::OrderKey);
const orderman::AccountName& account_key();
RiskLimiter& find_limiter(const orderman2::OperatorID&, orderman2::OrderKey);
const orderman2::AccountName& account_key();
const SymbolKey& symbol_key();
void allowed_operators(std::vector<orderman::OperatorID>&);
void allowed_operators(std::vector<orderman2::OperatorID>&);
protected:
friend class RiskLimitManager;
@@ -18,7 +18,7 @@
#include <vector>
#include <utility>
using namespace bts::orderman;
using namespace bts::orderman2;
namespace bts
{
@@ -28,11 +28,11 @@ namespace risklimits
struct OperatorRiskLimiter::PImpl
{
AccountRiskLimiter& account;
orderman::OperatorID operator_id;
orderman2::OperatorID operator_id;
bool operator_can_trade;
boost::container::flat_map<OrderKey, std::shared_ptr<RiskLimiter>> limiter_map;
PImpl(AccountRiskLimiter& sh, const orderman::OperatorID& opid) :
PImpl(AccountRiskLimiter& sh, const orderman2::OperatorID& opid) :
account(sh),
operator_id(opid),
operator_can_trade(false),
@@ -51,13 +51,13 @@ struct OperatorRiskLimiter::PImpl
}
};
OperatorRiskLimiter::OperatorRiskLimiter(AccountRiskLimiter& sh, const orderman::OperatorID& opid)
OperatorRiskLimiter::OperatorRiskLimiter(AccountRiskLimiter& sh, const orderman2::OperatorID& opid)
: me(new PImpl(sh, opid))
{
}
OperatorRiskLimiter::~OperatorRiskLimiter() {}
RiskLimiter& OperatorRiskLimiter::find_limiter(orderman::OrderKey key)
RiskLimiter& OperatorRiskLimiter::find_limiter(orderman2::OrderKey key)
{
auto& lim = me->limiter_map[key];
if(!lim)
@@ -65,7 +65,7 @@ RiskLimiter& OperatorRiskLimiter::find_limiter(orderman::OrderKey key)
return *lim;
}
const orderman::OperatorID& OperatorRiskLimiter::operator_key()
const orderman2::OperatorID& OperatorRiskLimiter::operator_key()
{
return me->operator_id;
}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/utils/bts_no_copy.h"
@@ -20,11 +20,11 @@ class OperatorRiskLimiter
{
BTS_NO_COPY(OperatorRiskLimiter);
public:
OperatorRiskLimiter(AccountRiskLimiter&, const orderman::OperatorID&);
OperatorRiskLimiter(AccountRiskLimiter&, const orderman2::OperatorID&);
~OperatorRiskLimiter();
RiskLimiter& find_limiter(orderman::OrderKey);
const orderman::OperatorID& operator_key();
RiskLimiter& find_limiter(orderman2::OrderKey);
const orderman2::OperatorID& operator_key();
bool operator_can_trade();
protected:
@@ -15,7 +15,7 @@
#include <boost/container/flat_map.hpp>
#include <utility>
using namespace bts::orderman;
using namespace bts::orderman2;
namespace bts
{
@@ -109,7 +109,7 @@ RiskLimiter& RiskLimitManager::find_limiter(const AccountName& acctname, const O
return sym.find_limiter(opid, key);
}
void RiskLimitManager::on_margin_update(const orderman::AccountName& account, const position::MarginResult& margin)
void RiskLimitManager::on_margin_update(const orderman2::AccountName& account, const position::MarginResult& margin)
{
for(const auto& i : me->limiter_map)
if(i.first.first == account)
@@ -5,9 +5,10 @@
#include <vector>
#include "lib/utils/bts_no_copy.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "RiskLimitState.h"
namespace bts
{
namespace api
@@ -37,13 +38,13 @@ public:
~RiskLimitManager();
void initialize(const std::vector<api::account::Account>&, const std::vector<api::user::User>&);
RiskLimiter& find_limiter(const orderman::AccountName&, const orderman::OperatorID&,
const api::Security&, orderman::OrderKey);
void on_margin_update(const orderman::AccountName&, const position::MarginResult&);
RiskLimiter& find_limiter(const orderman2::AccountName&, const orderman2::OperatorID&,
const api::Security&, orderman2::OrderKey);
void on_margin_update(const orderman2::AccountName&, const position::MarginResult&);
IRiskLimitObserver* observer();
protected:
friend class RiskLimitsTests;
AccountRiskLimiter& find_shared_limiter(const orderman::AccountName&, const api::Security&);
AccountRiskLimiter& find_shared_limiter(const orderman2::AccountName&, const api::Security&);
void all_shared_limiters(std::vector<std::shared_ptr<AccountRiskLimiter>>& shared_limiters);
private:
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts
{
@@ -8,8 +8,8 @@ namespace risklimits
{
struct RiskLimitState
{
orderman::AccountName account_name;
orderman::OperatorID operator_id;
orderman2::AccountName account_name;
orderman2::OperatorID operator_id;
bool limits_ok;
};
}
@@ -12,7 +12,7 @@
#include <fmt/format.h>
using namespace bts::orderman;
using namespace bts::orderman2;
namespace bts
{
@@ -24,11 +24,11 @@ struct RiskLimiter::PImpl
OperatorRiskLimiter& _operator;
SharedLimiterData& shared;
orderman::OrderKey key;
orderman2::OrderKey key;
Quantity remaining_quantity;
Quantity filled_quantity;
PImpl(OperatorRiskLimiter& oplim, orderman::OrderKey ok) :
PImpl(OperatorRiskLimiter& oplim, orderman2::OrderKey ok) :
_operator(oplim),
shared(oplim.account_limiter().shared_data()),
key(ok),
@@ -93,7 +93,7 @@ struct RiskLimiter::PImpl
}
};
RiskLimiter::RiskLimiter(OperatorRiskLimiter& sh, orderman::OrderKey key)
RiskLimiter::RiskLimiter(OperatorRiskLimiter& sh, orderman2::OrderKey key)
: me(new PImpl(sh, key))
{
}
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/utils/bts_no_copy.h"
@@ -20,7 +20,7 @@ class RiskLimiter
BTS_NO_COPY(RiskLimiter);
public:
struct RiskLimitResult { bool success; std::string message; };
RiskLimiter(OperatorRiskLimiter&, orderman::OrderKey);
RiskLimiter(OperatorRiskLimiter&, orderman2::OrderKey);
~RiskLimiter();
RiskLimitResult check(Quantity, api::Side) const;
@@ -7,8 +7,7 @@
#include "../IRiskLimitObserver.h"
#include "../SymbolKey.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/user/AccountServiceServer.h"
#include "server/sparkd/user/UserServiceServer.h"
@@ -23,7 +22,7 @@
#include <memory>
#include <stdlib.h>
using namespace bts::orderman;
using namespace bts::orderman2;
namespace bts
{
@@ -221,14 +220,14 @@ TEST_CASE ("RiskLimits Limits", "[risklimits]")
for(auto i : limiters)
{
std::vector<orderman::OperatorID> operators;
std::vector<orderman2::OperatorID> operators;
i->allowed_operators(operators);
const api::account::RiskLimit& limits = RiskLimitsTests::risk_limit(*i.get());
SharedLimiterData& data = RiskLimitsTests::shared_data(*i.get());
api::Security sec = api::Security::default_instance();
setup_security(sec, data.position_info.symbol);
OrderKey key(0);
RiskLimiter& lim = _manager.find_limiter(to<orderman::AccountName>(data.account_info.tag1()), operators[0], sec, key);
RiskLimiter& lim = _manager.find_limiter(to<orderman2::AccountName>(data.account_info.tag1()), operators[0], sec, key);
auto res = lim.check(Quantity(rand() % limits.max_order_size()), api::SIDE_BUY);
REQUIRE(res.success);
res = lim.check(Quantity(rand() % limits.max_order_size()), api::SIDE_SELL);
@@ -282,7 +281,7 @@ TEST_CASE ("RiskLimits Limits", "[risklimits]")
int lim_count = 0;
SharedLimiterData* data = nullptr;
api::account::RiskLimit limits;
std::vector<orderman::OperatorID> operators;
std::vector<orderman2::OperatorID> operators;
for(auto ii : limiters)
{
ii->allowed_operators(operators);
@@ -308,9 +307,9 @@ TEST_CASE ("RiskLimits Limits", "[risklimits]")
auto maxorder = limits.max_order_size();
OrderKey key1(0);
RiskLimiter& lim1 = manager.find_limiter(to<orderman::AccountName>(data->account_info.tag1()), operators[0], sec, key1);
RiskLimiter& lim1 = manager.find_limiter(to<orderman2::AccountName>(data->account_info.tag1()), operators[0], sec, key1);
OrderKey key2(1);
RiskLimiter& lim2 = manager.find_limiter(to<orderman::AccountName>(data->account_info.tag1()), operators[1], sec, key2);
RiskLimiter& lim2 = manager.find_limiter(to<orderman2::AccountName>(data->account_info.tag1()), operators[1], sec, key2);
lim1.on_order_state(side, Quantity(maxpos), Quantity(maxpos));
auto r1 = lim1.check(Quantity(maxorder), side);
REQUIRE(!r1.success);
@@ -334,7 +333,7 @@ TEST_CASE ("RiskLimits Limits", "[risklimits]")
int lim_count = 0;
for(auto ii : limiters)
{
std::vector<orderman::OperatorID> operators;
std::vector<orderman2::OperatorID> operators;
ii->allowed_operators(operators);
lim_count++;
@@ -362,7 +361,7 @@ TEST_CASE ("RiskLimits Limits", "[risklimits]")
int iters = 2;
for(int i = 0; i < iters; i++)
{
RiskLimiter& lim = observed_manager.find_limiter(to<orderman::AccountName>(data.account_info.tag1()), operators[0], sec, key);
RiskLimiter& lim = observed_manager.find_limiter(to<orderman2::AccountName>(data.account_info.tag1()), operators[0], sec, key);
SharedLimiterData& shared2 = RiskLimitsTests::shared_data(lim);
auto limsym = shared2.position_info.symbol.first;
auto limtype = shared2.position_info.symbol.second;
+1 -1
View File
@@ -5,7 +5,7 @@
#include "lib/utils/bts_assert.h"
#include "lib/domain_model/Security.h"
#include "lib/logging/logging.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/persistence/SqliteStore.h"
#include "lib/utils/bts_chrono.h"
@@ -1,7 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts {
namespace orderman {
@@ -3,7 +3,7 @@
#include <memory>
#include <boost/container/flat_map.hpp>
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/spreader/hedger/HedgePriceQuantityState.h"
#include "server/sparkd/spreader/hedger/hedger_states/HedgerStartStateWorker.h"
#include "server/sparkd/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.h"
@@ -4,7 +4,7 @@
#include "SpreaderUtils.h"
#include "LegPropertyData.h"
#include "SpreaderChildOrderState.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts {
namespace orderman {
@@ -203,4 +203,4 @@ void SingleLegQuoter::_switch_state (IQuoterStateWorker* new_state)
_worker = new_state;
_worker->on_transition();
}
}}
}}
@@ -6,7 +6,6 @@
#include "lib/sparkproto/SparkProtos.pb.h"
#include "QuoteLegPriceQuantityState.h"
#include "LegPropertyData.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterStartStateWorker.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.h"
@@ -1,7 +1,8 @@
#pragma once
#include <memory>
#include <boost/container/flat_map.hpp>
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "SpreaderLegData.h"
#include "lib/api/services/OrderService2.pb.h"
#include "server/sparkd/orderman2/actors/order_manager/OrderBuilder.h"
@@ -116,4 +117,4 @@ public:
_quantity = quantity;
}
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/api/services/OrderService2.pb.h"
#include "server/sparkd/orderman2/events/OrderStateUpdateEvent.h"
#include "SpreaderUtils.h"
@@ -1,5 +1,5 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/api/services/OrderService2.pb.h"
namespace bts{
@@ -1,6 +1,5 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/hedger/hedger_states/HedgerState.h"
@@ -35,4 +34,4 @@ public:
// time update from the infrastructure
virtual void on_time(const TimeStamp&) = 0;
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
@@ -38,4 +38,4 @@ public:
// the price or quantity does not change
virtual void update_spreader_order (Price price, Quantity quantity) = 0;
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts {
namespace orderman {
@@ -29,4 +29,4 @@ public:
quoter_leg_quantity = new_quoter_leg_quantity;
}
};
}}
}}
@@ -38,4 +38,4 @@ void QuoterEndStateWorker::on_other_leg_quoter_fill (size_t, Quantity)
{}
void QuoterEndStateWorker::update_spreader_order (Price, Quantity)
{}
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -29,4 +29,4 @@ public:
void on_other_leg_quoter_fill (size_t leg_id, Quantity fill_quantity) override;
void update_spreader_order (Price price, Quantity quantity) override;
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -31,4 +31,4 @@ public:
private:
void _on_price_quantity_set(Price, Quantity);
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -29,4 +29,4 @@ public:
void on_other_leg_quoter_fill (size_t leg_id, Quantity fill_quantity) override;
void update_spreader_order (Price price, Quantity quantity) override;
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -31,4 +31,4 @@ public:
void on_other_leg_quoter_fill (size_t leg_id, Quantity fill_quantity) override;
void update_spreader_order (Price price, Quantity quantity) override;
};
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -34,4 +34,4 @@ private:
// the order if so
void _analyze_and_act ();
};
}}
}}
@@ -36,14 +36,14 @@ void QuoterWaitingForSizeStateWorker::on_time(const TimeStamp&)
void QuoterWaitingForSizeStateWorker::on_other_leg_quoter_fill (size_t leg_index, Quantity filled_quantity)
{
_quoter->_incorporate_other_leg_fill (leg_index, filled_quantity);
_longpath_analyze_and_act (bts::orderman::NullTickToTradeCorID);
_longpath_analyze_and_act (orderman2::NullTickToTradeCorID);
}
void QuoterWaitingForSizeStateWorker::update_spreader_order (Price price, Quantity quantity)
{
_quoter->_price_quantity_state.update_target_price_quantity (price, quantity);
_longpath_analyze_and_act (bts::orderman::NullTickToTradeCorID);
_longpath_analyze_and_act (orderman2::NullTickToTradeCorID);
}
void QuoterWaitingForSizeStateWorker::_longpath_analyze_and_act (bts::orderman::TickToTradeCorID)
void QuoterWaitingForSizeStateWorker::_longpath_analyze_and_act (orderman2::TickToTradeCorID)
{
if (_quoter->_price_quantity_state.target_reached())
{
@@ -67,4 +67,4 @@ void QuoterWaitingForSizeStateWorker::_longpath_analyze_and_act (bts::orderman::
}
}
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -33,6 +33,6 @@ private:
// checks to see if target has reached and goes to end
// if it has. otherwise computes the price, qty and if
// its valid, places an order goes to waiting_for_first_ack
void _longpath_analyze_and_act (bts::orderman::TickToTradeCorID corid);
void _longpath_analyze_and_act (bts::orderman2::TickToTradeCorID corid);
};
}}
}}
@@ -3,6 +3,7 @@
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/SingleLegQuoter.h"
#include "server/sparkd/spreader/ISpreaderManager.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
namespace bts{
namespace orderman{
@@ -22,7 +23,7 @@ void QuoterWorkingStateWorker::on_order_update (const SpreaderChildOrderState& u
_quoter->_transform_to_END ();
}
else
_longpath_analyze_and_act (bts::orderman::NullTickToTradeCorID);
_longpath_analyze_and_act (orderman2::NullTickToTradeCorID);
}
void QuoterWorkingStateWorker::on_book (bts::orderman2::TickToTradeCorID corid, size_t,
const bts::orderman2::Book&)
@@ -43,12 +44,12 @@ void QuoterWorkingStateWorker::on_time(const TimeStamp&)
void QuoterWorkingStateWorker::on_other_leg_quoter_fill (size_t leg_index, Quantity filled_quantity)
{
_quoter->_incorporate_other_leg_fill (leg_index, filled_quantity);
_longpath_analyze_and_act (bts::orderman::NullTickToTradeCorID);
_longpath_analyze_and_act (orderman2::NullTickToTradeCorID);
}
void QuoterWorkingStateWorker::update_spreader_order (Price price, Quantity quantity)
{
_quoter->_price_quantity_state.update_target_price_quantity (price, quantity);
_longpath_analyze_and_act (bts::orderman::NullTickToTradeCorID);
_longpath_analyze_and_act (orderman2::NullTickToTradeCorID);
}
void QuoterWorkingStateWorker::_longpath_analyze_and_act (bts::orderman2::TickToTradeCorID corid)
{
@@ -91,10 +92,10 @@ void QuoterWorkingStateWorker::_longpath_analyze_and_act (bts::orderman2::TickTo
}
}
}
void QuoterWorkingStateWorker::_modify_order (TickToTradeCorID, Price price, Quantity quantity)
void QuoterWorkingStateWorker::_modify_order (orderman2::TickToTradeCorID , Price price, Quantity quantity)
{
_quoter->_price_quantity_state.update_out_price_quantity(price, quantity);
_quoter->_commit_drivers ();
_quoter->_modify_order(price, quantity);
}
}}
}}
@@ -1,6 +1,6 @@
#pragma once
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
#include "lib/utils/bts_chrono.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/quoter/IQuoterStateWorker.h"
@@ -33,7 +33,7 @@ private:
// i. if target reached => cxl order and go to waiting_for_cancel_ack_final
// ii. if computed_qty = 0 => cxl order and go to waiting_for_cancel_ack_continue
// iii. if reprice (ie qty changed or price changed beyond the threshold) => requote
void _longpath_analyze_and_act (bts::orderman::TickToTradeCorID);
void _modify_order (TickToTradeCorID cid, Price price, Quantity quantity);
void _longpath_analyze_and_act (orderman2::TickToTradeCorID);
void _modify_order (orderman2::TickToTradeCorID cid, Price price, Quantity quantity);
};
}}
}}