> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kraken.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Order Lifecycle

> Order state change matrices for the Prime FIX API.

Order updates are sent as [Execution Reports](https://docs.kraken.com/institutional/api-reference/prime-fix/er.md). A rejected [Order Cancel Request](https://docs.kraken.com/institutional/api-reference/prime-fix/ocr.md) or [Order Cancel Replace Request](https://docs.kraken.com/institutional/api-reference/prime-fix/ocrr.md) is answered with an [Order Cancel Reject](https://docs.kraken.com/institutional/api-reference/prime-fix/ocrej.md) instead, which has no ExecType.

In the tables below, `A` and `B` are `ClOrdID` values. A response shown as `(B,A)` has ClOrdID(11) B and OrigClOrdID(41) A. Rows with the same time are alternatives.

### Filled order

| Time | Request | Response | ExecType | OrdStatus | OrderQty | CumQty | LeavesQty | LastQty | Comment |
| :- | :- | :- | :- | :- | :- | :- | :- | :- | :- |
| 1 | NewOrderSingle(A) | | | | 10 | | | | |
| 2 | | ExecutionReport(A) | PendingNew | PendingNew | 10 | 0 | 10 | | |
| 3 | | ExecutionReport(A) | Rejected | Rejected | 10 | 0 | 10 | | If the order is rejected |
| 3 | | ExecutionReport(A) | New | New | 10 | 0 | 10 | | |
| 4 | | ExecutionReport(A) | Trade | PartiallyFilled | 10 | 2 | 8 | 2 | |
| 5 | | ExecutionReport(A) | Trade | PartiallyFilled | 10 | 3 | 7 | 1 | |
| 6 | | ExecutionReport(A) | Trade | Filled | 10 | 10 | 0 | 7 | |

### Canceled order

| Time | Request | Response | ExecType | OrdStatus | OrderQty | CumQty | LeavesQty | LastQty | Comment |
| :- | :- | :- | :- | :- | :- | :- | :- | :- | :- |
| 1 | NewOrderSingle(A) | | | | 10 | | | | |
| 2 | | ExecutionReport(A) | PendingNew | PendingNew | 10 | 0 | 10 | | |
| 3 | | ExecutionReport(A) | Rejected | Rejected | 10 | 0 | 10 | | If the order is rejected |
| 3 | | ExecutionReport(A) | New | New | 10 | 0 | 10 | | |
| 4 | OrderCancelRequest(B,A) | | | | | | | | |
| 5 | | OrderCancelReject(B,A) | | New | 10 | 0 | 10 | | If the cancel is rejected |
| 5 | | ExecutionReport(B,A) | PendingCancel | PendingCancel | 10 | 0 | 10 | | |
| 6 | | OrderCancelReject(B,A) | | New | 10 | 0 | 10 | | If the cancel is rejected |
| 7 | | ExecutionReport(B,A) | Canceled | Canceled | 10 | 0 | 0 | | |

### Replace to increase quantity

| Time | Request | Response | ExecType | OrdStatus | OrderQty | CumQty | LeavesQty | LastQty | Comment |
| :- | :- | :- | :- | :- | :- | :- | :- | :- | :- |
| 1 | NewOrderSingle(A) | | | | 10 | | | | |
| 2 | | ExecutionReport(A) | PendingNew | PendingNew | 10 | 0 | 10 | | |
| 3 | | ExecutionReport(A) | New | New | 10 | 0 | 10 | | |
| 4 | OrderCancelReplaceRequest(B,A) | | | | 11 | | | | |
| 5 | | OrderCancelReject(B,A) | | New | 10 | 0 | 10 | | If the replace is rejected |
| 5 | | ExecutionReport(B,A) | PendingReplace | PendingReplace | 10 | 0 | 10 | | |
| 6 | | OrderCancelReject(B,A) | | New | 10 | 0 | 10 | | If the replace is rejected |
| 6 | | ExecutionReport(B,A) | Replaced | New | 11 | 0 | 11 | | |
| 7 | | ExecutionReport(B) | Trade | PartiallyFilled | 11 | 1 | 10 | 1 | |

### Replace during fill

| Time | Request | Response | ExecType | OrdStatus | OrderQty | CumQty | LeavesQty | LastQty | Comment |
| :- | :- | :- | :- | :- | :- | :- | :- | :- | :- |
| 1 | NewOrderSingle(A) | | | | 10 | | | | |
| 2 | | ExecutionReport(A) | PendingNew | PendingNew | 10 | 0 | 10 | | |
| 3 | | ExecutionReport(A) | New | New | 10 | 0 | 10 | | |
| 4 | OrderCancelReplaceRequest(B,A) | | | | 8 | | | | |
| 5 | | ExecutionReport(A) | Trade | PartiallyFilled | 10 | 1 | 9 | 1 | Fill before the replace is received |
| 6 | | ExecutionReport(B,A) | PendingReplace | PendingReplace | 10 | 1 | 9 | | |
| 7 | | ExecutionReport(A) | Trade | PendingReplace | 10 | 3 | 7 | 2 | Fill before the replace is processed |
| 8 | | ExecutionReport(B,A) | Replaced | New | 8 | 3 | 5 | | |
| 9 | | ExecutionReport(B) | Trade | Filled | 8 | 8 | 0 | 5 | |
