\n
## Sequence Diagram: GTT Expiry and Mode/Uncross Check
### Overview
This is a sequence diagram illustrating the interaction between a "GTT Expiry Check" and a "Mode/Uncross Check" over two time ticks. The diagram details the logic for determining order expiry and mode changes within an auction system, ultimately leading to a potential "UNCROSS" event. The diagram uses a timeline to show the progression of checks and decisions.
### Components/Axes
The diagram is structured into three vertical columns:
* **Time:** Represents the progression of time, labeled with "Tick 1" and "Tick 2", and initial conditions.
* **GTT Expiry Check:** Details the logic for checking if a Good-Till-Time (GTT) order has expired.
* **Mode/Uncross Check:** Details the logic for checking the auction mode and potential uncrossing of orders.
* **State:** Indicates the current state of the system at each step.
Horizontal dashed lines represent message passing or control flow between the checks. The diagram also includes initial conditions and a final state indicating a violation ("MIT201 violated").
### Detailed Analysis
**Initial State:**
* `t = 2699`, Auction Mode
* `uncross_at = 2700`, `order_expires_at = 2700`
* `market.extension = 1`
**Tick 1: t = 2699 -> 2700**
1. **Check expiry:** A message is sent from the Time column to the GTT Expiry Check.
2. **In auction mode?:** The GTT Expiry Check determines if the system is in auction mode. It extends the expiry time to `max(2700, 2700+1) = 2701`.
3. **2700 ≥ 2701? NO:** The GTT Expiry Check determines that the current time (2700) is not greater than or equal to the extended expiry time (2701).
4. **Order NOT expired:** The GTT Expiry Check concludes the order is not expired.
5. **Check mode change:** A message is sent to the Mode/Uncross Check.
6. **2700 ≥ 2700? YES:** The Mode/Uncross Check determines that the current time (2700) is greater than or equal to the uncross time (2700).
7. **Market orders present? 2700 ≥ 2700 + 1? NO:** The Mode/Uncross Check checks for market orders and if the current time is greater than or equal to the uncross time plus one. The result is NO.
8. **Stay in auction:** The system remains in auction mode.
**After Tick 1:**
* `t = 2700`, Still in auction
**Tick 2: t = 2700 -> 2701**
1. **Check expiry:** A message is sent from the Time column to the GTT Expiry Check.
2. **In auction mode?:** The GTT Expiry Check determines if the system is in auction mode. It extends the expiry time to `max(2700, 2700+1) = 2701`.
3. **2701 ≥ 2701? YES:** The GTT Expiry Check determines that the current time (2701) is greater than or equal to the extended expiry time (2701).
4. **ORDER EXPIRES:** The GTT Expiry Check concludes the order has expired.
5. **Check mode change:** A message is sent to the Mode/Uncross Check.
6. **2701 ≥ 2700? YES:** The Mode/Uncross Check determines that the current time (2701) is greater than or equal to the uncross time (2700).
7. **Market orders present? 2701 ≥ 2700 + 1? YES:** The Mode/Uncross Check checks for market orders and if the current time is greater than or equal to the uncross time plus one. The result is YES.
8. **UNCROSS:** The system triggers an uncross event.
**Final State:**
* **Both events occur in the same tick MIT201 violated:** A red box highlights that both the order expiry and uncross conditions occurred within the same tick, violating rule MIT201.
### Key Observations
* The diagram illustrates a race condition where the order expiry and uncross checks can occur simultaneously.
* The `market.extension` variable plays a crucial role in extending the order expiry time.
* The violation of MIT201 suggests a potential issue with the timing or synchronization of the checks.
* The logic relies heavily on comparing the current time (`t`) with the expiry and uncross times.
### Interpretation
This sequence diagram models a critical process within an auction system – the handling of order expiry and the potential for uncrossing orders. The diagram highlights a potential vulnerability: the simultaneous occurrence of order expiry and uncrossing, leading to a violation of MIT201. This suggests a need for more precise timing control or a re-evaluation of the order expiry and uncross logic to prevent such conflicts. The `market.extension` variable is a key parameter influencing the outcome, and its behavior should be carefully considered. The diagram is a valuable tool for understanding the system's behavior and identifying potential areas for improvement in terms of robustness and compliance with trading rules. The diagram is a precise description of the logic, and does not contain any subjective information.