refactor: Move TradingStatus enum to lib_domain
This commit is contained in:
1 parent
c35d7c90f6
commit
df750c4dd0
30 files changed
+142
-102
No files matched your search
@@ -53,7 +53,7 @@ The status callback is called when the market for this security opens, closes, o
|
||||
// Subscribe to security trading status
|
||||
void IAlgoServices::subscribe_status(SecurityKey);
|
||||
// You implement
|
||||
virtual void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
virtual void on_status(SecurityKey, domain::protobufs::TradingStatus) override;
|
||||
```
|
||||
|
||||
# Child Orders
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "EmMDListener.h"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/api/services/ShellDiagnosticService.server.pb.h"
|
||||
#include "spark/domain_model/Security.pb.h"
|
||||
#include "spark/logging/logging.h"
|
||||
@@ -59,6 +60,10 @@ using namespace bts::orderman;
|
||||
|
||||
namespace bts::md {
|
||||
|
||||
#define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
std::atomic<orderman::IEMOrderMuxer *> EmMDListener::_order_mux = nullptr;
|
||||
using MDArray = std::array<PriceSize, COCONUT_MAX_DEPTH>;
|
||||
using EMOrderKey = uint64_t;
|
||||
@@ -119,18 +124,18 @@ bts::api::SecurityType convert_securitytype(
|
||||
return api::SecurityType::SECURITYTYPE_UNSET;
|
||||
}
|
||||
|
||||
bts::co2::TradingStatus convert_trading_status(
|
||||
TradingStatus convert_trading_status(
|
||||
emumba::market_data::security_state::state state) {
|
||||
switch (state) {
|
||||
case emumba::market_data::security_state::state::open:
|
||||
return bts::co2::TradingStatus::TRADINGSTATUS_NORMAL;
|
||||
return TRADING_STATUS(NORMAL);
|
||||
case emumba::market_data::security_state::state::preopen:
|
||||
return bts::co2::TradingStatus::TRADINGSTATUS_PRE_OPEN;
|
||||
return TRADING_STATUS(PRE_OPEN);
|
||||
case emumba::market_data::security_state::state::closed:
|
||||
return bts::co2::TradingStatus::TRADINGSTATUS_CLOSED;
|
||||
return TRADING_STATUS(CLOSED);
|
||||
}
|
||||
bts_assert(false);
|
||||
return bts::co2::TradingStatus::TRADINGSTATUS_UNKNOWN;
|
||||
return TradingStatus::TRADINGSTATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
bts::co2::AggressorSide convert_trade_side(
|
||||
@@ -206,7 +211,7 @@ inline api::Venue extract_venue(const emumba::market_data::security &s) {
|
||||
return convert_venue(s.sec_common.exchange);
|
||||
}
|
||||
|
||||
bts::co2::TradingStatus extract_trading_status(
|
||||
TradingStatus extract_trading_status(
|
||||
emumba::market_data::security_state state) {
|
||||
return convert_trading_status(state.state_);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "MDP3Listener.h"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/config/protos/market_data.pb.h"
|
||||
#include "spark/md/protos/co2.pb.h"
|
||||
#include "spark/utils/datetime.h"
|
||||
@@ -11,6 +12,8 @@ using namespace bts::co2;
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
MDP3Listener::MDP3Listener(
|
||||
CMESecurityIndex &index,
|
||||
MDProducer &producer,
|
||||
@@ -285,7 +288,7 @@ void MDP3Listener::heartbeat() {
|
||||
// Called by MDP3Main::prepare_listener as part of pre-load. Also called by
|
||||
// MDP3Listener::onFuture, onOption and onSpread
|
||||
void MDP3Listener::add_security(
|
||||
const FixedSecurity &security, co2::TradingStatus status) {
|
||||
const FixedSecurity &security, TradingStatus status) {
|
||||
bts_assert(security.numeric_id != 0);
|
||||
// Set up the shared memory for this security
|
||||
auto handle = _producer.add_security(security);
|
||||
@@ -324,7 +327,7 @@ void MDP3Listener::update_all_status(CoconutSecurityStatus status) {
|
||||
}
|
||||
|
||||
void MDP3Listener::update_group_exchange_status(
|
||||
const onixs::StrRef &group, co2::TradingStatus status) {
|
||||
const onixs::StrRef &group, TradingStatus status) {
|
||||
_index.walk_security_list([=](SecurityData &data) {
|
||||
if (data.handle.security().alt_symbol() == group) {
|
||||
data.handle.update_exchange_status(utils::TimeStamp::now(), status);
|
||||
@@ -332,7 +335,7 @@ void MDP3Listener::update_group_exchange_status(
|
||||
});
|
||||
}
|
||||
void MDP3Listener::update_asset_exchange_status(
|
||||
const onixs::StrRef &asset, co2::TradingStatus status) {
|
||||
const onixs::StrRef &asset, TradingStatus status) {
|
||||
_index.walk_security_list([=](SecurityData &data) {
|
||||
if (data.handle.security().symbol() == asset) {
|
||||
data.handle.update_exchange_status(utils::TimeStamp::now(), status);
|
||||
|
||||
@@ -76,36 +76,38 @@ inline inc::UpdateAction mbo_update_action(onixs::UpdateAction::Enum a) {
|
||||
}
|
||||
}
|
||||
|
||||
inline co2::TradingStatus map_status(onixs::SecurityTradingStatus::Enum ts) {
|
||||
inline domain::protobufs::TradingStatus map_status(
|
||||
onixs::SecurityTradingStatus::Enum ts) {
|
||||
switch (ts) {
|
||||
case onixs::SecurityTradingStatus::TradingHalt:
|
||||
return co2::TRADINGSTATUS_HALTED;
|
||||
return domain::protobufs::TRADINGSTATUS_HALTED;
|
||||
case onixs::SecurityTradingStatus::Close:
|
||||
return co2::TRADINGSTATUS_CLOSED;
|
||||
return domain::protobufs::TRADINGSTATUS_CLOSED;
|
||||
case onixs::SecurityTradingStatus::NewPriceIndication:
|
||||
return co2::TRADINGSTATUS_PRICE_INDICATION;
|
||||
return domain::protobufs::TRADINGSTATUS_PRICE_INDICATION;
|
||||
case onixs::SecurityTradingStatus::ReadyToTrade:
|
||||
return co2::TRADINGSTATUS_NORMAL;
|
||||
return domain::protobufs::TRADINGSTATUS_NORMAL;
|
||||
case onixs::SecurityTradingStatus::NotAvailableForTrading:
|
||||
return co2::TRADINGSTATUS_NOT_AVAILABLE;
|
||||
return domain::protobufs::TRADINGSTATUS_NOT_AVAILABLE;
|
||||
case onixs::SecurityTradingStatus::UnknownorInvalid:
|
||||
return co2::TRADINGSTATUS_UNKNOWN;
|
||||
return domain::protobufs::TRADINGSTATUS_UNKNOWN;
|
||||
case onixs::SecurityTradingStatus::PreOpen:
|
||||
return co2::TRADINGSTATUS_PRE_OPEN;
|
||||
return domain::protobufs::TRADINGSTATUS_PRE_OPEN;
|
||||
case onixs::SecurityTradingStatus::PreCross:
|
||||
return co2::TRADINGSTATUS_PRE_CROSS;
|
||||
return domain::protobufs::TRADINGSTATUS_PRE_CROSS;
|
||||
case onixs::SecurityTradingStatus::Cross:
|
||||
return co2::TRADINGSTATUS_CROSS;
|
||||
return domain::protobufs::TRADINGSTATUS_CROSS;
|
||||
case onixs::SecurityTradingStatus::PostClose:
|
||||
return co2::TRADINGSTATUS_POST_CLOSE;
|
||||
return domain::protobufs::TRADINGSTATUS_POST_CLOSE;
|
||||
case onixs::SecurityTradingStatus::NoChange:
|
||||
return co2::TRADINGSTATUS_NO_CHANGE;
|
||||
return domain::protobufs::TRADINGSTATUS_NO_CHANGE;
|
||||
}
|
||||
return co2::TRADINGSTATUS_UNKNOWN;
|
||||
return domain::protobufs::TRADINGSTATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::optional<co2::TradingStatus> security_trading_status(const T &t) {
|
||||
std::optional<domain::protobufs::TradingStatus> security_trading_status(
|
||||
const T &t) {
|
||||
onixs::SecurityTradingStatus::Enum status;
|
||||
if (t.securityTradingStatus(status)) {
|
||||
return {map_status(status)};
|
||||
@@ -641,7 +643,8 @@ class MDP3Listener : public onixs::HandlerListener,
|
||||
void heartbeat();
|
||||
|
||||
// Add a new security to the index
|
||||
void add_security(const FixedSecurity &security, co2::TradingStatus);
|
||||
void add_security(
|
||||
const FixedSecurity &security, domain::protobufs::TradingStatus);
|
||||
|
||||
private:
|
||||
enum SecurityFilterAction { ADD, SKIP, DELETE };
|
||||
@@ -665,8 +668,10 @@ class MDP3Listener : public onixs::HandlerListener,
|
||||
}
|
||||
void flush_books();
|
||||
void update_all_status(co2::CoconutSecurityStatus status);
|
||||
void update_group_exchange_status(const onixs::StrRef &, co2::TradingStatus);
|
||||
void update_asset_exchange_status(const onixs::StrRef &, co2::TradingStatus);
|
||||
void update_group_exchange_status(
|
||||
const onixs::StrRef &, domain::protobufs::TradingStatus);
|
||||
void update_asset_exchange_status(
|
||||
const onixs::StrRef &, domain::protobufs::TradingStatus);
|
||||
|
||||
CMESecurityIndex &_index;
|
||||
MDProducer &_producer;
|
||||
@@ -756,7 +761,7 @@ void MDP3Listener::onFuture(
|
||||
fsec.expiration_day = expiration.day;
|
||||
|
||||
auto status = security_trading_status(def.message())
|
||||
.value_or(co2::TRADINGSTATUS_UNKNOWN);
|
||||
.value_or(domain::protobufs::TRADINGSTATUS_UNKNOWN);
|
||||
add_security(fsec, status);
|
||||
}
|
||||
|
||||
@@ -802,7 +807,7 @@ void MDP3Listener::onOption(
|
||||
: api::PUTORCALL_PUT;
|
||||
|
||||
auto status = security_trading_status(def.message())
|
||||
.value_or(co2::TRADINGSTATUS_UNKNOWN);
|
||||
.value_or(domain::protobufs::TRADINGSTATUS_UNKNOWN);
|
||||
add_security(fsec, status);
|
||||
}
|
||||
|
||||
@@ -871,8 +876,8 @@ void MDP3Listener::onSpread(
|
||||
fsec.legs[x].exchange_key = ExchangeKey(leg.legSecurityId());
|
||||
fsec.legs[x].key = invalid_security_key;
|
||||
}
|
||||
auto status =
|
||||
security_trading_status(sec).value_or(co2::TRADINGSTATUS_UNKNOWN);
|
||||
auto status = security_trading_status(sec).value_or(
|
||||
domain::protobufs::TRADINGSTATUS_UNKNOWN);
|
||||
add_security(fsec, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "MDP3Main.h"
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/config/config.h"
|
||||
#include "spark/logging/logging.h"
|
||||
#include "spark/md/MBOProcessor.h"
|
||||
@@ -29,6 +30,8 @@ using std::size_t;
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
#define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x
|
||||
|
||||
MDP3Main::MDP3Main()
|
||||
: _index(), _recorder(
|
||||
{utils::Dispatcher::current(),
|
||||
@@ -396,8 +399,7 @@ unique_ptr<MDP3Listener> MDP3Main::prepare_listener(
|
||||
db::load_securities(unit_set, [&](const api::Security &security) {
|
||||
with_security_like(security, [&](FixedSecurity &fs) {
|
||||
convert_security(security, fs, true);
|
||||
listener->add_security(
|
||||
fs, bts::co2::TradingStatus::TRADINGSTATUS_UNKNOWN);
|
||||
listener->add_security(fs, TRADING_STATUS(UNKNOWN));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
syntax = "proto3";
|
||||
package bts.domain.protobufs;
|
||||
|
||||
option csharp_namespace = "bts.domain.protobufs";
|
||||
|
||||
enum TradingStatus {
|
||||
TRADINGSTATUS_UNKNOWN = 0;
|
||||
TRADINGSTATUS_NORMAL = 2;
|
||||
TRADINGSTATUS_CLOSED = 3;
|
||||
TRADINGSTATUS_PRE_OPEN = 4;
|
||||
TRADINGSTATUS_OPENING_ROTATION = 5;
|
||||
// CBOE
|
||||
TRADINGSTATUS_FAST_MARKET = 6;
|
||||
|
||||
TRADINGSTATUS_SUSPENDED = 7;
|
||||
TRADINGSTATUS_HALTED = 8;
|
||||
// CME
|
||||
TRADINGSTATUS_PRICE_INDICATION = 9;
|
||||
TRADINGSTATUS_PRE_CROSS = 10;
|
||||
TRADINGSTATUS_CROSS = 11;
|
||||
TRADINGSTATUS_NO_CANCEL = 12;
|
||||
|
||||
TRADINGSTATUS_POST_CLOSE = 13;
|
||||
TRADINGSTATUS_NO_CHANGE = 14;
|
||||
// CME
|
||||
TRADINGSTATUS_NOT_AVAILABLE = 15;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "UserSymbol.h"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/md/Shm/MDStructure.h"
|
||||
#include "spark/sparkproto/SparkProtos.pb.h"
|
||||
#include "spark/utils/bts_export.h"
|
||||
@@ -244,7 +245,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
}
|
||||
|
||||
co2::TradingStatus trading_status() const {
|
||||
domain::protobufs::TradingStatus trading_status() const {
|
||||
switch (_type) {
|
||||
case HANDLETYPE_DEPTH:
|
||||
return book.cdata->exchange_status;
|
||||
@@ -261,11 +262,11 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
return status;
|
||||
}
|
||||
return co2::TRADINGSTATUS_UNKNOWN;
|
||||
return domain::protobufs::TRADINGSTATUS_UNKNOWN;
|
||||
}
|
||||
default:
|
||||
case HANDLETYPE_VOID:
|
||||
return co2::TRADINGSTATUS_UNKNOWN;
|
||||
return domain::protobufs::TRADINGSTATUS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
#ifndef NO_CPP0X
|
||||
#include "MDProducerHandle.h"
|
||||
#include "common.h"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
|
||||
namespace bts {
|
||||
namespace md {
|
||||
using namespace datetime;
|
||||
using namespace co2;
|
||||
|
||||
#define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x
|
||||
|
||||
MDProducerHandle::MDProducerHandle(
|
||||
ColdHeader &cheader,
|
||||
HotHeader &hheader,
|
||||
@@ -159,7 +162,7 @@ void MDProducerHandle::add_rfq(TimeStamp, const co2::QuoteRequestMessage &rfq) {
|
||||
}
|
||||
|
||||
void MDProducerHandle::update_exchange_status(TimeStamp, TradingStatus status) {
|
||||
if (status != TRADINGSTATUS_NO_CHANGE) {
|
||||
if (status != TRADING_STATUS(NO_CHANGE)) {
|
||||
cdata().exchange_status = status;
|
||||
cheader().exchange_status_count++;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "../PriceSize.h"
|
||||
#include "../common.h"
|
||||
#include "FixedSecurity.h"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/config/config.h"
|
||||
#include "spark/config/protos/market_data.pb.h"
|
||||
#include "spark/core/BoolName.h"
|
||||
@@ -211,9 +212,9 @@ struct MiscData {
|
||||
|
||||
struct ColdEntry {
|
||||
ColdEntry(size_t security_size)
|
||||
: exchange_status(co2::TRADINGSTATUS_UNKNOWN), last_trade(),
|
||||
total_volume(0), last_trade_time(), misc(), from_spread(0),
|
||||
deleted(0) {
|
||||
: exchange_status(domain::protobufs::TRADINGSTATUS_UNKNOWN),
|
||||
last_trade(), total_volume(0), last_trade_time(), misc(),
|
||||
from_spread(0), deleted(0) {
|
||||
this->security.size = security_size;
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@ struct ColdEntry {
|
||||
}
|
||||
size_t size() const { return fixed_size() + this->security.size; }
|
||||
|
||||
co2::TradingStatus exchange_status;
|
||||
domain::protobufs::TradingStatus exchange_status;
|
||||
|
||||
// Last Trade
|
||||
AtomicPriceSize last_trade;
|
||||
@@ -358,7 +359,7 @@ inline void to_json(nlohmann::json &j, const ColdEntry &c) {
|
||||
c.misc.previous_settlement_date.month,
|
||||
c.misc.previous_settlement_date.day, &prev_settle_date);
|
||||
j["prev_settle_date"] = prev_settle_date.to_iso_string();
|
||||
j["status"] = co2::TradingStatus_Name(c.exchange_status);
|
||||
j["status"] = domain::protobufs::TradingStatus_Name(c.exchange_status);
|
||||
j["deleted"] = core::BoolName::yes_no(c.deleted);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "IntPrice.h"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/domain_model/SecurityKey.h"
|
||||
#include "spark/utils/bts_export.h"
|
||||
#include "spark/utils/datetime.h"
|
||||
@@ -24,7 +25,7 @@ using api::SecurityType;
|
||||
using api::Venue;
|
||||
using bts::api::Side;
|
||||
using bts::co2::CoconutSecurityStatus;
|
||||
using bts::co2::TradingStatus;
|
||||
using domain::protobufs::TradingStatus;
|
||||
|
||||
SecurityType securitytype_of(const Security &);
|
||||
|
||||
|
||||
@@ -3,25 +3,6 @@ package bts.co2;
|
||||
option csharp_namespace="bts.co2";
|
||||
import "spark/domain_model/Security.proto";
|
||||
|
||||
enum TradingStatus {
|
||||
TRADINGSTATUS_UNKNOWN = 0;
|
||||
TRADINGSTATUS_NORMAL = 2;
|
||||
TRADINGSTATUS_CLOSED = 3;
|
||||
TRADINGSTATUS_PRE_OPEN = 4;
|
||||
TRADINGSTATUS_OPENING_ROTATION = 5;
|
||||
TRADINGSTATUS_FAST_MARKET = 6; // CBOE
|
||||
TRADINGSTATUS_SUSPENDED = 7;
|
||||
TRADINGSTATUS_HALTED = 8;
|
||||
TRADINGSTATUS_PRICE_INDICATION = 9; // CME
|
||||
TRADINGSTATUS_PRE_CROSS = 10; // CME
|
||||
TRADINGSTATUS_CROSS = 11; // CME
|
||||
TRADINGSTATUS_NO_CANCEL = 12; // CME
|
||||
TRADINGSTATUS_POST_CLOSE = 13;
|
||||
TRADINGSTATUS_NO_CHANGE = 14;
|
||||
TRADINGSTATUS_NOT_AVAILABLE = 15; // CME NotAvailableForTrading
|
||||
}
|
||||
|
||||
|
||||
enum CoconutSecurityStatus {
|
||||
COCONUTSECURITYSTATUS_OK = 0;
|
||||
COCONUTSECURITYSTATUS_PACKET_LOSS = 2;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/domain_model/Security.h"
|
||||
#include "spark/logging/logging.h"
|
||||
#include "spark/md/IntPrice.h"
|
||||
@@ -218,8 +219,8 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
|
||||
if (h.handle.key() == handle.key())
|
||||
break;
|
||||
}
|
||||
_status_subs.push_back(
|
||||
StatusRecord{handle, co2::TRADINGSTATUS_UNKNOWN});
|
||||
_status_subs.push_back(StatusRecord{
|
||||
handle, domain::protobufs::TRADINGSTATUS_UNKNOWN});
|
||||
case MDRequestType::TICKER:
|
||||
// We aren't currently monitoring for pending ticker requests
|
||||
break;
|
||||
@@ -328,14 +329,14 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
|
||||
for (auto &h : _status_subs) {
|
||||
if (h.handle.key() == k) {
|
||||
// reset status so it get resent next on_poll
|
||||
h.status = co2::TRADINGSTATUS_UNKNOWN;
|
||||
h.status = domain::protobufs::TRADINGSTATUS_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto handle = _md_consumer.get_managed_handle(k);
|
||||
if (handle->is_initialized()) {
|
||||
_status_subs.push_back(
|
||||
StatusRecord{*handle, co2::TRADINGSTATUS_UNKNOWN});
|
||||
StatusRecord{*handle, domain::protobufs::TRADINGSTATUS_UNKNOWN});
|
||||
} else {
|
||||
LOG(OrderMan, Warn, "No market data for {}. Pending handle added.", k);
|
||||
_pending_handles.push_back({handle, MDRequestType::STATUS});
|
||||
@@ -367,7 +368,7 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
|
||||
google::protobuf::RepeatedPtrField<co2::TradeMessage> _trades_buffer;
|
||||
struct StatusRecord {
|
||||
md::MDConsumerHandle handle;
|
||||
co2::TradingStatus status;
|
||||
domain::protobufs::TradingStatus status;
|
||||
};
|
||||
boost::container::small_vector<StatusRecord, 20> _status_subs;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/mercury/events/Event.h"
|
||||
#include "spark/orderman/orderman_utils/Book.h"
|
||||
#include "spark/orderman/orderman_utils/orderman_common.h"
|
||||
@@ -14,10 +15,10 @@ class StatusUpdateEvent : public mercury::Event<StatusUpdateEvent> {
|
||||
|
||||
public:
|
||||
using SynopsisPolicy = mercury::NoSynopsis;
|
||||
co2::TradingStatus status;
|
||||
domain::protobufs::TradingStatus status;
|
||||
trace::CorID trace;
|
||||
SecurityKey key() const { return _key; }
|
||||
StatusUpdateEvent(SecurityKey key, co2::TradingStatus status)
|
||||
StatusUpdateEvent(SecurityKey key, domain::protobufs::TradingStatus status)
|
||||
: _key(key), status(status), trace() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/core/FMT_IMPL.h"
|
||||
#include "spark/md/protos/co2.pb.h"
|
||||
#include "spark/orderman/calculations/ITheoCalculator.h"
|
||||
@@ -49,7 +50,8 @@ class IAlgoOrder {
|
||||
virtual void on_ticker(SecurityKey security_key, const TradeVector& trades);
|
||||
|
||||
// The trading status for the specified security has changed
|
||||
virtual void on_status(SecurityKey security_key, co2::TradingStatus status);
|
||||
virtual void on_status(
|
||||
SecurityKey security_key, domain::protobufs::TradingStatus status);
|
||||
|
||||
// The settlement price for the specified security has changed
|
||||
virtual void on_settlement(SecurityKey security_key, Price price);
|
||||
@@ -139,7 +141,8 @@ inline void IAlgoOrder::on_ticker(
|
||||
SecurityKey /*security_key*/, const TradeVector& /*trades*/) {}
|
||||
|
||||
inline void IAlgoOrder::on_status(
|
||||
SecurityKey /*security_key*/, co2::TradingStatus /*status*/) {}
|
||||
SecurityKey /*security_key*/, domain::protobufs::TradingStatus /*status*/) {
|
||||
}
|
||||
|
||||
inline void IAlgoOrder::on_settlement(
|
||||
SecurityKey /*security_key*/, Price /*price*/) {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "spark/orderman/orders/algo/algo_orders/OnSignalAlgo.h"
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/domain_model/Security.h"
|
||||
#include "spark/orderman/actors/SODPosition.h"
|
||||
#include "spark/orderman/order_factory/IOrderFactory.h"
|
||||
@@ -21,6 +22,10 @@ using namespace api::orderman;
|
||||
using namespace google::protobuf;
|
||||
using namespace boost;
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
#define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x
|
||||
|
||||
struct OnSignalLegData {
|
||||
const SecurityKey sec_key;
|
||||
ChildTemplate *order_template = nullptr;
|
||||
@@ -167,18 +172,17 @@ void OnSignalAlgo::on_child_change(OrderKey key, const ChildState &st) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
void OnSignalAlgo::on_status(SecurityKey key, co2::TradingStatus s) {
|
||||
void OnSignalAlgo::on_status(
|
||||
SecurityKey key, domain::protobufs::TradingStatus s) {
|
||||
if (me->algo_params.signal_key_1.has_value() &&
|
||||
me->algo_params.signal_key_1 == key)
|
||||
switch (me->state) {
|
||||
case (OnSignalAlgo::State::WAITING_FOR_SIGNAL):
|
||||
if (me->algo_params.preopen &&
|
||||
s == co2::TradingStatus::TRADINGSTATUS_PRE_OPEN)
|
||||
if (me->algo_params.preopen && s == TRADING_STATUS(PRE_OPEN)) {
|
||||
_fire_orders();
|
||||
else if (
|
||||
me->algo_params.open &&
|
||||
s == co2::TradingStatus::TRADINGSTATUS_NORMAL)
|
||||
} else if (me->algo_params.open && s == TRADING_STATUS(NORMAL)) {
|
||||
_fire_orders();
|
||||
}
|
||||
break;
|
||||
case (OnSignalAlgo::State::WORKING):
|
||||
case (OnSignalAlgo::State::DONE):
|
||||
@@ -234,4 +238,4 @@ void OnSignalAlgo::_switch_state(State new_state) {
|
||||
}
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
} // namespace bts
|
||||
@@ -17,7 +17,7 @@ class OnSignalAlgo : public IAlgoOrder {
|
||||
void do_launch_attached(IAlgoServices &, OrderKey, ChildState) override;
|
||||
void do_update(api::orderman::Update const &) override;
|
||||
void on_child_change(OrderKey, ChildState const &) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_status(SecurityKey, domain::protobufs::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace orderman {
|
||||
using namespace api::orderman;
|
||||
using namespace google::protobuf;
|
||||
using namespace boost;
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
template <class T>
|
||||
bool from_string(const std::string &str, T *out) {
|
||||
return google::protobuf::TextFormat::ParseFromString(str, out);
|
||||
@@ -341,7 +344,7 @@ void QuotingAlgo::on_child_change(OrderKey key, const ChildState &state) {
|
||||
}
|
||||
}
|
||||
|
||||
void QuotingAlgo::on_status(SecurityKey key, co2::TradingStatus s) {
|
||||
void QuotingAlgo::on_status(SecurityKey key, TradingStatus s) {
|
||||
LOG(OrderMan, Info, "QuotingAlgo::on_status key: {} status: {}", key.value(),
|
||||
static_cast<int>(s));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class QuotingAlgo : public IAlgoOrder {
|
||||
void do_launch_attached(IAlgoServices &, OrderKey, ChildState) override;
|
||||
void do_update(api::orderman::Update const &) override;
|
||||
void on_child_change(OrderKey key, const ChildState &state) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_status(SecurityKey, domain::protobufs::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
void on_book(SecurityKey, Book const &) override;
|
||||
void on_theos(const analytics::ITheoCalculator *theo_calculator) override;
|
||||
|
||||
@@ -339,8 +339,6 @@ void SniperAlgo::on_child_change(OrderKey key, const ChildState &st) {
|
||||
}
|
||||
}
|
||||
|
||||
void SniperAlgo::on_status(SecurityKey, co2::TradingStatus) {}
|
||||
|
||||
void SniperAlgo::on_timer() {
|
||||
if (usecs_since(me->last_periodic_opp_check_time) >=
|
||||
me->opp_check_period_usecs){
|
||||
|
||||
@@ -34,7 +34,6 @@ class SniperAlgo : public IAlgoOrder {
|
||||
Quantity /* last_quantity */,
|
||||
uint /* n_levels */) override;
|
||||
void on_child_change(OrderKey, ChildState const &) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
enum class FireImpetus;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "spark/orderman/orders/algo/algo_orders/TASAlgo.h"
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/domain_model/Security.h"
|
||||
#include "spark/orderman/order_factory/IOrderFactory.h"
|
||||
#include "spark/orderman/orderman_utils/Book.h"
|
||||
@@ -16,6 +16,10 @@ namespace orderman {
|
||||
|
||||
using namespace api::orderman;
|
||||
|
||||
#define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
enum class TASAlgo::Status { WAITING_FOR_SIGNAL, WORKING, DONE };
|
||||
|
||||
struct TASLegData {
|
||||
@@ -113,9 +117,8 @@ void TASAlgo::on_child_change(OrderKey key, ChildState const &st) {
|
||||
return;
|
||||
_cxl_and_end(false, "");
|
||||
}
|
||||
void TASAlgo::on_status(SecurityKey key, co2::TradingStatus status) {
|
||||
if (key == me->sec_key &&
|
||||
status == co2::TradingStatus::TRADINGSTATUS_PRE_OPEN) {
|
||||
void TASAlgo::on_status(SecurityKey key, TradingStatus status) {
|
||||
if (key == me->sec_key && status == TRADING_STATUS(PRE_OPEN)) {
|
||||
switch (me->state) {
|
||||
case TASAlgo::Status::WAITING_FOR_SIGNAL:
|
||||
for (auto &l : me->legs) {
|
||||
@@ -136,7 +139,7 @@ void TASAlgo::on_status(SecurityKey key, co2::TradingStatus status) {
|
||||
}
|
||||
void TASAlgo::on_timer() {
|
||||
if (bts::datetime::msecs_since(me->start_time) > 10000)
|
||||
on_status(me->sec_key, co2::TradingStatus::TRADINGSTATUS_PRE_OPEN);
|
||||
on_status(me->sec_key, TRADING_STATUS(PRE_OPEN));
|
||||
}
|
||||
IAlgoServices &TASAlgo::_algo() const { return *me->algo_services; }
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -23,7 +23,7 @@ class TASAlgo : public IAlgoOrder {
|
||||
void do_update(api::orderman::Update const &) override;
|
||||
void on_book(SecurityKey, Book const &) override;
|
||||
void on_child_change(OrderKey, ChildState const &) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_status(SecurityKey, domain::protobufs::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -269,8 +269,6 @@ void TaskingEyeAlgo::on_child_change(
|
||||
}
|
||||
}
|
||||
|
||||
void TaskingEyeAlgo::on_status(SecurityKey, co2::TradingStatus) {}
|
||||
|
||||
void TaskingEyeAlgo::on_timer() {
|
||||
_evaluate_and_shoot();
|
||||
cleanup_shots(me->shots, me->window_size_nanos);
|
||||
|
||||
@@ -20,7 +20,6 @@ class TaskingEyeAlgo : public IAlgoOrder {
|
||||
void do_launch_attached(IAlgoServices &, OrderKey, ChildState) override;
|
||||
void do_update(api::orderman::Update const &) override;
|
||||
void on_child_change(OrderKey, ChildState const &) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
void on_theos(analytics::ITheoCalculator const *theo_calculator) override;
|
||||
void on_position(PositionUpdate const &) override;
|
||||
|
||||
@@ -206,7 +206,6 @@ void VolAlgo::on_child_change(OrderKey, ChildState const &state) {
|
||||
}
|
||||
}
|
||||
|
||||
void VolAlgo::on_status(SecurityKey, co2::TradingStatus) {}
|
||||
void VolAlgo::on_timer() {}
|
||||
|
||||
void VolAlgo::on_theos(analytics::ITheoCalculator const *theo_calculator) {
|
||||
|
||||
@@ -20,7 +20,6 @@ class VolAlgo : public IAlgoOrder {
|
||||
void do_launch_attached(IAlgoServices &, OrderKey, ChildState) override;
|
||||
void do_update(api::orderman::Update const &) override;
|
||||
void on_child_change(OrderKey, ChildState const &) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
void on_theos(analytics::ITheoCalculator const *theo_calculator) override;
|
||||
void on_position(PositionUpdate const &) override;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "AlgoTestDriver.h"
|
||||
#include "catch/catch.hpp"
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/api/services/OrderService.pb.h"
|
||||
#include "spark/logging/logging.h"
|
||||
#include "spark/md/relay/RelayRecorder.h"
|
||||
@@ -14,6 +15,8 @@ namespace orderman {
|
||||
namespace test {
|
||||
using namespace api::orderman;
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
constexpr bool has_flag(ATDFlags prop, ATDFlags flag) {
|
||||
return ((uint32_t)prop & (uint32_t)flag) == (uint32_t)flag;
|
||||
}
|
||||
@@ -229,8 +232,7 @@ void AlgoTestDriverBase::update_ticker(
|
||||
me->algo.on_ticker(key, data);
|
||||
}
|
||||
}
|
||||
void AlgoTestDriverBase::update_status(
|
||||
SecurityKey key, co2::TradingStatus status) {
|
||||
void AlgoTestDriverBase::update_status(SecurityKey key, TradingStatus status) {
|
||||
auto iter = me->status_subs.find(key);
|
||||
if (iter != me->ticker_subs.end() && iter->second) {
|
||||
me->algo.on_status(key, status);
|
||||
|
||||
@@ -80,7 +80,7 @@ class AlgoTestDriverBase : private IAlgoServices {
|
||||
void update_book(const Book &);
|
||||
void update_settlement(SecurityKey, Price);
|
||||
void update_ticker(SecurityKey, const TradeVector &);
|
||||
void update_status(SecurityKey, co2::TradingStatus);
|
||||
void update_status(SecurityKey, domain::protobufs::TradingStatus);
|
||||
void update_theos(std::shared_ptr<analytics::ITheoCalculator> theo_calc);
|
||||
void advance_time(Duration, uint32_t steps = 1);
|
||||
IAlgoOrder::OnCancelResponse cancel();
|
||||
|
||||
@@ -16,7 +16,7 @@ class ExecutionTesterAlgo : public IAlgoOrder {
|
||||
void do_launch_attached(IAlgoServices &, OrderKey, ChildState) override;
|
||||
void do_update(api::orderman::Update const &) override;
|
||||
void on_child_change(OrderKey, ChildState const &) override;
|
||||
void on_status(SecurityKey, co2::TradingStatus) override;
|
||||
void on_status(SecurityKey, domain::protobufs::TradingStatus) override;
|
||||
void on_timer() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "ExecutionTesterAlgo.h"
|
||||
|
||||
#include "domain/protobufs/trading_status.pb.h"
|
||||
#include "spark/domain_model/Security.h"
|
||||
#include "spark/logging/logging.h"
|
||||
#include "spark/orderman/order_factory/IOrderFactory.h"
|
||||
@@ -25,6 +25,8 @@ using namespace api::orderman;
|
||||
using namespace google::protobuf;
|
||||
using namespace boost;
|
||||
|
||||
using bts::domain::protobufs::TradingStatus;
|
||||
|
||||
struct ETParams {
|
||||
double price_up = 1.0;
|
||||
double price_down = 1.0;
|
||||
@@ -110,7 +112,7 @@ void ExecutionTesterAlgo::on_child_change(OrderKey key, const ChildState &st) {
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionTesterAlgo::on_status(SecurityKey, co2::TradingStatus) {}
|
||||
void ExecutionTesterAlgo::on_status(SecurityKey, TradingStatus) {}
|
||||
|
||||
void ExecutionTesterAlgo::on_timer() {
|
||||
if (me->n_updates > me->et_params.n_updates)
|
||||
@@ -156,4 +158,4 @@ void ExecutionTesterAlgo::_cxl_and_end(
|
||||
}
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user