Order manager work
This commit is contained in:
1 parent
9129b5ac6c
commit
da2fce5df7
17 files changed
+258
-5
No files matched your search
+1
-1
Submodule docker/linux updated: a0b5434210...bf15905999.
+1
-1
Submodule externals updated: b60b485a25...5b0d748b03.
@@ -26,6 +26,7 @@ set (NonConfig_Protos
|
||||
api/apioptions.proto
|
||||
sparkproto/SparkProtos.proto
|
||||
md/protos/co2.proto
|
||||
order_man/protos/OrderMan.proto
|
||||
)
|
||||
|
||||
# service protos
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
syntax='proto3' ;
|
||||
package bts.orderman ;
|
||||
|
||||
enum OrderStatus
|
||||
{
|
||||
OS_UNACKNOWLEDGED = 0 ;
|
||||
OS_NEW = 48 ;
|
||||
OS_PARTIALLY_FILLED = 49 ;
|
||||
OS_FILLED = 50 ;
|
||||
OS_DONE = 51 ;
|
||||
OS_CANCELED = 52 ;
|
||||
OS_REPLACED = 53 ;
|
||||
OS_PENDING_CANCEL = 54 ;
|
||||
OS_STOPPED = 55 ;
|
||||
OS_REJECTED = 56 ;
|
||||
OS_SUSPENDED = 57 ;
|
||||
OS_PENDING_NEW = 65 ;
|
||||
OS_CALCULATED = 66 ;
|
||||
OS_EXPIRED = 67 ;
|
||||
OS_ACCEPTED_FOR_BIDDING = 68 ;
|
||||
OS_PENDING_REPLACE = 69 ;
|
||||
OS_CANCEL_ACK = 72 ;
|
||||
OS_UNDEFINED = 85 ;
|
||||
OS_ORDER_NOT_FOUND = 89 ;
|
||||
}
|
||||
|
||||
|
||||
enum TimeInForce
|
||||
{
|
||||
TIF_UNDEFINED = 0 ;
|
||||
TIF_DAY = 48 ;
|
||||
TIF_GTC = 49 ;
|
||||
TIF_OPG = 50 ;
|
||||
TIF_IOC = 51 ;
|
||||
TIF_FOK = 52 ;
|
||||
}
|
||||
|
||||
enum OrderType
|
||||
{
|
||||
OT_UNDEFINED = 0 ;
|
||||
OT_MARKET = 49 ; // 1
|
||||
OT_LIMIT = 50 ; // 2
|
||||
OT_STOP = 51 ; // 3
|
||||
OT_STOP_LIMIT = 52 ; // 4
|
||||
OT_MARKET_LIMIT = 75 ; // K
|
||||
}
|
||||
@@ -54,6 +54,10 @@ set (Sparkd_Sources
|
||||
|
||||
# user
|
||||
user/UserServiceServer.cpp
|
||||
|
||||
# orderman
|
||||
order_man/OrderMan.cpp
|
||||
order_man/IOrderStore.cpp
|
||||
|
||||
# md, mdp3 onixs platform
|
||||
# md/platforms/mdp3_onixs/MDP3Listener.cpp
|
||||
|
||||
@@ -328,3 +328,4 @@ void Executor::kill (Address from, Address to, std::function<void(RequestError)>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ typedef TimeField<122> OrigSendingTime;
|
||||
typedef StringField<56> TargetCompId;
|
||||
typedef StringField<57> TargetSubID;
|
||||
typedef StringField<142> SenderLocationID;
|
||||
typedef StringField<37> OrderID;
|
||||
typedef StringField<117> QuoteID;
|
||||
typedef IntField<117> QuoteIDInt;
|
||||
typedef IntField<204> CustomerOrFirm;
|
||||
@@ -38,6 +39,10 @@ typedef StringField<9771> MMAccount;
|
||||
typedef CharField<21> HandlInst;
|
||||
typedef CharField<40> OrdType;
|
||||
typedef CharField<59> TimeInForce;
|
||||
typedef CharField<39> OrdStatus;
|
||||
typedef StringField<41> OrigClOrdID;
|
||||
typedef StringField<9717> CorrelationClOrdID;
|
||||
typedef IntField<102> CXlRejReason;
|
||||
|
||||
|
||||
typedef FloatField<132> BidPx;
|
||||
@@ -58,6 +63,7 @@ typedef StringField<107> SecurityDesc;
|
||||
typedef StringField<48> SecurityID;
|
||||
typedef CharField<22> SecurityIDSource;
|
||||
typedef TimeField<60> TransactTime;
|
||||
typedef TimeField<5979> RequestTime;
|
||||
typedef StringField<60> TransactTimeStr;
|
||||
typedef StringField<143> TargetLocationID;
|
||||
typedef StringField<142> SenderLocationID;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "conn/bts_conn/jetfix/codec/FIXMsg.h"
|
||||
#include "conn/bts_conn/jetfix/codec/MessageTypes.h"
|
||||
#include "conn/bts_conn/jetfix/codec/FieldDefinitions.h"
|
||||
#include "server/sparkd/jetfix/codec/FIXMsg.h"
|
||||
#include "server/sparkd/jetfix/codec/MessageTypes.h"
|
||||
#include "server/sparkd/jetfix/codec/FieldDefinitions.h"
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
@@ -42,5 +42,15 @@ BusinessMessageRejectMsg;
|
||||
typedef FIXMsg<MessageTypes::Reject,Text>
|
||||
RejectMsg;
|
||||
|
||||
typedef FIXMsg<MessageTypes::CancelReject,
|
||||
Account,
|
||||
ClOrdID,
|
||||
ExecID,
|
||||
OrderID,
|
||||
OrigClOrdID,
|
||||
SecurityDesc,
|
||||
CorrelationClOrdID>
|
||||
CancelRejectMsg;
|
||||
|
||||
}}}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include "server/sparkd/jetfix/gateway/CoreGateway.h"
|
||||
|
||||
#include "server/sparkd/jetfix/gateway/ICoreGatewayObserver.h"
|
||||
#include "server/sparkd/jetfix/connection/SocketConnection.h"
|
||||
#include "server/sparkd/jetfix/store/FIXFileStore.h"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "server/sparkd/jetfix/common/OutFIXPtr.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class IFIXGateway
|
||||
{
|
||||
public:
|
||||
virtual ~IFIXGateway();
|
||||
virtual void send(jetfix::OutFIXPtr const&msg) = 0;
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "IOrderStore.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
IOrderStore::~IOrderStore () {}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class OrderState;
|
||||
|
||||
class IOrderStore
|
||||
{
|
||||
public:
|
||||
virtual ~IOrderStore();
|
||||
virtual std::vector<OrderState> get_bootstrap_state() const = 0;
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "server/sparkd/order_man/common.h"
|
||||
#include "lib/order_man/OrderMan.pb.h"
|
||||
|
||||
namespace bts {
|
||||
namespace api {
|
||||
class Security;
|
||||
}}
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class Order
|
||||
{
|
||||
public:
|
||||
api::Security const&security() const {return *_security;}
|
||||
OrderPrice price() const ;
|
||||
OrderQuantity quantity() const;
|
||||
TimeInForce time_in_force() const;
|
||||
OrderType order_type() const;
|
||||
private:
|
||||
Security const * _security;
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "OrderMan.h"
|
||||
#include "OrderState.h"
|
||||
#include "IOrderStore.h"
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
enum class OrderMan::State { DISCONNECTED, REPLAYING, READY };
|
||||
|
||||
using OrderStateMap = boost::container::flat_map<OrderID,OrderState> ;
|
||||
|
||||
struct OrderMan::PImpl
|
||||
{
|
||||
PImpl(IOrderStore &store, IFIXGateway &gw) :
|
||||
state (State::DISCONNECTED), store(store),gw(gw), state_map()
|
||||
{}
|
||||
|
||||
State state;
|
||||
IOrderStore &store;
|
||||
IFIXGateway &gw;
|
||||
OrderStateMap state_map;
|
||||
};
|
||||
|
||||
// OrderMan::OrderMan (IOrderStore &store, IFIXGateway &gw) : me (new PImpl(store,gw))
|
||||
// {
|
||||
// auto stored_state = store.get_bootstrap_state();
|
||||
// for (auto const &os : stored_state)
|
||||
// me->state_map[os.order_id()] = os;
|
||||
// }
|
||||
|
||||
OrderMan::~OrderMan () {}
|
||||
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include "server/sparkd/jetfix/codec/MessageDefinitions.h"
|
||||
#include "server/sparkd/order_man/common.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class IOrderStore;
|
||||
class IFIXGateway;
|
||||
class Order;
|
||||
class OrderState;
|
||||
|
||||
class OrderMan
|
||||
{
|
||||
public:
|
||||
struct EnterResult {};
|
||||
struct UpdateResult {};
|
||||
struct CancelResult {};
|
||||
|
||||
OrderMan (IOrderStore &store, IFIXGateway &gw);
|
||||
~OrderMan ();
|
||||
|
||||
// functionality we implement
|
||||
EnterResult enter_order(Order const &order);
|
||||
UpdateResult update_order(OrderID id, OrderPrice price);
|
||||
UpdateResult update_order(OrderID id, OrderQuantity size);
|
||||
UpdateResult update_order(OrderID id, OrderPrice price, OrderQuantity size);
|
||||
CancelResult cancel_order(OrderID id);
|
||||
|
||||
// venue events we can process
|
||||
void on_venue_ready();
|
||||
void on_venue_disconnect();
|
||||
void on_begin_replay();
|
||||
void on_end_replay();
|
||||
void on_exe_report(jetfix::fix::ExecutionReportMsg const&);
|
||||
void on_cancel_reject(jetfix::fix::CancelRejectMsg const&);
|
||||
void on_business_reject(jetfix::fix::BusinessMessageRejectMsg const&);
|
||||
void on_reject(jetfix::fix::RejectMsg const&);
|
||||
|
||||
// stream of order state updates
|
||||
std::function<OrderState const&> &order_state_change_callback();
|
||||
|
||||
private:
|
||||
struct PImpl;
|
||||
enum class State;
|
||||
std::unique_ptr<PImpl> me;
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "server/sparkd/order_man/common.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class Order;
|
||||
|
||||
class OrderState
|
||||
{
|
||||
public:
|
||||
Order const&original_order() const;
|
||||
OrderID order_id() const;
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
typedef uint32_t OrderID;
|
||||
typedef double OrderPrice;
|
||||
typedef uint32_t OrderQuantity;
|
||||
Reference in new issue
Block a user