Completed OrderGatewy inteface
This commit is contained in:
1 parent
317fc93c76
commit
849adc5d7c
1 file changed
+21
-10
@@ -17,6 +17,8 @@ enum class TimeInForce {
|
||||
struct DeribitOrderDefinition {};
|
||||
struct GlbxOrderDefinition {};
|
||||
|
||||
// This contains the order parameters common to all exchanges. It is sent once
|
||||
// when a new order is launched
|
||||
struct OrderDefinition {
|
||||
SecurityID security_id;
|
||||
Side side;
|
||||
@@ -25,51 +27,60 @@ struct OrderDefinition {
|
||||
std::string account;
|
||||
AccountID account_id;
|
||||
TimeInForce time_in_force;
|
||||
// Exchange specific order definition (ex if a certain exchange offers
|
||||
// Iceberg orders, this is where its parameters will be)
|
||||
const std::variant<DeribitOrderDefinition, GlbxOrderDefinition>
|
||||
exchange_order = {DeribitOrderDefinition{}};
|
||||
};
|
||||
|
||||
// Sent once per order, when the order is first launched (launching an order,
|
||||
// placing, firing, sending all mean the same)
|
||||
struct NewOrder {
|
||||
OrderDefinition order_def;
|
||||
Price price;
|
||||
Quantity qty;
|
||||
};
|
||||
|
||||
// Structure for order modifications (also know as cancel-replace at some
|
||||
// exchanges).
|
||||
struct OrderUpdate {
|
||||
OrderKey order_key;
|
||||
Price price;
|
||||
Quantity qty;
|
||||
};
|
||||
|
||||
enum class ChildStatus { WORKING, COMPLETED, CANCELED };
|
||||
// Order can be in one of these states
|
||||
enum class OrderStatus { WORKING, COMPLETED, CANCELED };
|
||||
|
||||
struct DeribitOrderState {};
|
||||
struct GlbxOrderState {};
|
||||
|
||||
struct OrderState {
|
||||
ChildStatus status;
|
||||
OrderStatus status;
|
||||
Quantity total_fills;
|
||||
Price avg_price;
|
||||
Quantity last_fills;
|
||||
Price last_price;
|
||||
Price avg_filled_price;
|
||||
// If there is any exchange specific order state
|
||||
std::variant<DeribitOrderState, GlbxOrderState> exchange_order_state;
|
||||
};
|
||||
|
||||
// Order cacllbacks are passed to this interface
|
||||
class IOrderListener {
|
||||
virtual void on_order_update(
|
||||
virtual void on_order_state(
|
||||
OrderKey order_key, const OrderState &order_state) = 0;
|
||||
};
|
||||
|
||||
// Anologous to the MarketDataGateway. All order interactions happen through
|
||||
// this class.
|
||||
class OrderGateway {
|
||||
// This is called just once to register the client, to receive callback for
|
||||
// order updates
|
||||
// This is called just once to register the listening class (to get order
|
||||
// callbacks)
|
||||
void register_once(IOrderListener *listener) noexcept;
|
||||
// New orders are enterred via this function. An internal OrderKey is
|
||||
// New orders are placed via this function. An internal OrderKey is
|
||||
// generated for every order new order. This OrderKey is used for subsequent
|
||||
// API calls
|
||||
// calls as well as IOrderListener callbacks
|
||||
OrderKey launch_new_order(const NewOrder &new_order);
|
||||
// An order is changed via this method. We can start by allowing only price
|
||||
// and qty changes (these are by far the most common changes)
|
||||
void update_order(const OrderUpdate &order_update);
|
||||
void cancel_order(OrderKey order_key);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user