87 lines
2.9 KiB
C++
87 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include "lib/domain_model/Security.pb.h"
|
|
#include "lib/domain_model/SecurityKey.h"
|
|
#include "lib/domain_model/common.h"
|
|
#include "lib/md/GeneralSecurityIndex.h"
|
|
#include "lib/md/MDClient.h"
|
|
#include "lib/md/MDProducer.h"
|
|
#include "lib/md/Shm/FixedSecurity.h"
|
|
#include "lib/md/protos/co2.pb.h"
|
|
#include "lib/orderman/CancelOrderMsg.h"
|
|
#include "lib/orderman/CancelReplaceOrderMsg.h"
|
|
#include "lib/orderman/CreateOrderMsg.h"
|
|
#include "lib/orderman/OrderMsg.h"
|
|
#include "lib/orderman/gateways/IExecutionGateway.h"
|
|
#include "lib/orderman/orderman_utils/orderman_common.h"
|
|
#include <tuple>
|
|
|
|
namespace bts::md {
|
|
class MDClient;
|
|
class MDProducer;
|
|
} // namespace bts::md
|
|
|
|
namespace bts::orderman {
|
|
class Book;
|
|
struct CreateOrderMsg;
|
|
struct CancelOrderMsg;
|
|
struct CancelReplaceOrderMsg;
|
|
} // namespace bts::orderman
|
|
|
|
namespace bts::orderman {
|
|
|
|
struct SEGOrderState;
|
|
struct SEGSecurityData;
|
|
|
|
class SimExecutionGateway : public IExecutionGateway {
|
|
public:
|
|
SimExecutionGateway(bts::api::Venue venue);
|
|
virtual ~SimExecutionGateway();
|
|
// IExecutionGateway
|
|
void start() override;
|
|
void dispatch_incoming_fix_messages() override;
|
|
void on_securities(const mercury::Update<NewSecuritiesEvent> &) override;
|
|
void on_admin_data(const mercury::Update<NewAdminDataEvent> &) override;
|
|
void send_fix(const jetfix::OutFIXPtr &fix, trace::CorID trace) override;
|
|
void send_msgs(std::vector<OrderMsg> const &, trace::CorID) override;
|
|
|
|
OnExeReport &on_exe_report() override;
|
|
OnGwStatusChange &on_gw_status_change() override;
|
|
OnCancelReject &on_cancel_reject() override;
|
|
OnExchangePositionState &on_exchange_position_state() override;
|
|
OnExchangeOpenOrdersState &on_exchange_open_orders() override;
|
|
|
|
// SimExecutionGateway
|
|
void set_producers(md::GeneralSecurityIndex *producer_map);
|
|
void do_work();
|
|
bool get_matched_book(
|
|
bts::md::SecurityKey key,
|
|
std::array<md::PriceSize, md::COCONUT_MAX_DEPTH> &bids,
|
|
std::array<md::PriceSize, md::COCONUT_MAX_DEPTH> &asks);
|
|
|
|
private:
|
|
void _internally_cross_orders(SEGSecurityData &);
|
|
bts::orderman::Book _match_order(
|
|
const bts::orderman::Book &book, SEGOrderState &seg_ord);
|
|
bts::orderman::Book _cross_order(
|
|
const bts::orderman::Book &book, SEGOrderState &seg_ord);
|
|
bts::orderman::Book _work_order(
|
|
const bts::orderman::Book &book, SEGOrderState &seg_ord);
|
|
SEGSecurityData *_find_add_security_entry(
|
|
SecurityKey security_key, bool add_if_absent, bool assert_for_presence);
|
|
void _push_execution_report(const SEGOrderState &seg_os);
|
|
void _process_transaction();
|
|
void _write_book(SecurityKey);
|
|
void _write_trade(const SEGOrderState &seg_ord, Price price, Quantity qty);
|
|
std::tuple<SEGSecurityData const *, SEGOrderState const *> _find_order(
|
|
OrderKey key) const;
|
|
std::optional<SecurityKey> _extract_sec_key(const OrderMsg &msg);
|
|
void _send_gw_status_once();
|
|
|
|
private:
|
|
struct PImpl;
|
|
PImpl *me;
|
|
};
|
|
|
|
} // namespace bts::orderman
|