Implement Order Modification Feature
Problem Description
You are tasked with extending an existing C++ client/server trading system. This system currently supports two core order management operations: AddOrder and CancelOrder. The server maintains all active orders in memory, uniquely identified by an order_id.
Your primary goal is to implement support for a new request type: ModifyOrder.
Existing Functionality
The system currently handles:
AddOrder(order_id, symbol, side, price, quantity): Adds a new order to the system.CancelOrder(order_id): Removes an existing order from the system.
Active orders are stored in server memory, accessible via their order_id.
New Feature: ModifyOrder
Implement the ModifyOrder(order_id, new_price, new_quantity) request with the following specific requirements:
- Order Existence and Status: The modification request must be rejected if the specified
order_iddoes not correspond to an active, existing order (i.e., it doesn't exist or has already been canceled). - Immutable Attributes: The
symbolandsideattributes of an order cannot be altered by aModifyOrderrequest. - Mutable Attributes: A successful modification must update only the
priceandquantityof the existing order. - Input Validation: Both
new_priceandnew_quantitymust be positive values. Requests with non-positive values for either must be rejected. - Identifier Persistence: The
order_idof the order must remain unchanged after a successful modification. - System Integration: The new
ModifyOrderrequest must be integrated into the existing client/server communication flow, adhering to the established style and patterns of theAddOrderandCancelOrderfunctionalities.
Implementation and Discussion
Beyond implementing the feature, be prepared to discuss which parts of the existing codebase you would inspect, analyze, or potentially reuse to ensure a seamless and correct integration.
AI interview prep
Core dilemma
Maintaining data consistency and atomicity for in-memory order modifications in a high-performance, concurrent trading system, while adhering to strict business rules and integrating seamlessly with existing infrastructure.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Implement Order Modification Feature
Problem Description
You are tasked with extending an existing C++ client/server trading system. This system currently supports two core order management operations: AddOrder and CancelOrder. The server maintains all active orders in memory, uniquely identified by an order_id.
Your primary goal is to implement support for a new request type: ModifyOrder.
Existing Functionality
The system currently handles:
AddOrder(order_id, symbol, side, price, quantity): Adds a new order to the system.CancelOrder(order_id): Removes an existing order from the system.
Active orders are stored in server memory, accessible via their order_id.
New Feature: ModifyOrder
Implement the ModifyOrder(order_id, new_price, new_quantity) request with the following specific requirements:
- Order Existence and Status: The modification request must be rejected if the specified
order_iddoes not correspond to an active, existing order (i.e., it doesn't exist or has already been canceled). - Immutable Attributes: The
symbolandsideattributes of an order cannot be altered by aModifyOrderrequest. - Mutable Attributes: A successful modification must update only the
priceandquantityof the existing order. - Input Validation: Both
new_priceandnew_quantitymust be positive values. Requests with non-positive values for either must be rejected. - Identifier Persistence: The
order_idof the order must remain unchanged after a successful modification. - System Integration: The new
ModifyOrderrequest must be integrated into the existing client/server communication flow, adhering to the established style and patterns of theAddOrderandCancelOrderfunctionalities.
Implementation and Discussion
Beyond implementing the feature, be prepared to discuss which parts of the existing codebase you would inspect, analyze, or potentially reuse to ensure a seamless and correct integration.