Files
spark/src/lib/orderman/ccapi/ICCAPIOrderMux.h
T

82 lines
2.8 KiB
C++

#pragma once
//#include "CCAPIOrderCallbackMsgs.h"
//#include "CCAPIOrderState.h"
//#include "lib/api/services/OrderService.pb.h"
//#include "lib/domain_model/Security.pb.h"
//#include "lib/logging/logging.h"
//#include "lib/md/common.h"
// #include "lib/orderman/CancelOrderMsg.h"
// #include "lib/orderman/CancelReplaceOrderMsg.h"
// #include "lib/orderman/CreateOrderMsg.h"
//#include "lib/orderman/RFQMsg.h"
//#include "lib/os/os.h"
//#include <bits/stdint-uintn.h>
//#include <boost/container/small_vector.hpp>
#include "CCAPIOrderCallbackMsgs.h"
#include "lib/md/SecurityOracle.h"
#include "lib/mercury/events/Update.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include <functional>
namespace bts::orderman {
struct RFQMsg;
struct CCAPIOrderState;
struct CancelOrderMsg;
struct CancelReplaceOrderMsg;
struct CreateOrderMsg;
struct CCAPIOpResult {
bool is_success;
std::string err_msg;
};
struct CCAPIPosition {
uint32_t bts_sec_key; // bts sec key
double position; // +ve for long
std::string sub_account;
};
struct CCAPIExchangeOpenOrder {};
using OnCCAPIExchangePositionUpdate =
std::function<void(const std::vector<CCAPIPosition> &)>;
using OnCCAPIExchangeOpenOrderUpdate =
std::function<void(const std::vector<CCAPIExchangeOpenOrder> &)>;
using OnCCAPIOrderUpdate = std::function<void(const CCAPIOrderState &)>;
class ICCAPIOrderMux {
public:
// System Data
virtual void on_securities(
const bts::mercury::Update<NewSecuritiesEvent> &update) = 0;
// Orders
// //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// These calls enter, update and cancel a single order respectively.
// Their results are corresponded in the order_update_cb callback
virtual CCAPIOpResult launch_new_order(const CreateOrderMsg &cr_msg) = 0;
virtual bool update_order(const CancelReplaceOrderMsg &cxl_repl_msg) = 0;
virtual bool cancel_order(const CancelOrderMsg &) = 0;
virtual void send_rfq(const RFQMsg &rfq) = 0;
virtual OnCCAPIOrderUpdate &order_update_cb() = 0;
// Dispatching incoming messages
virtual void dispatch_incoming_messages() = 0;
// Position
// ////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// This queries the exchange for the positions. the position is returned
// on the exchange_position_update_cb callback (below)
// TODO: account as a paremter
virtual void query_positions() = 0;
virtual OnCCAPIExchangePositionUpdate &exchange_position_update_cb() = 0;
// Mass orders
// /////////////////////////////////////////////////////////////
virtual void query_open_orders() = 0;
virtual OnCCAPIExchangeOpenOrderUpdate &exchange_open_orders_update_cb() = 0;
};
} // namespace bts::orderman