1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright The Pit Project Owners. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Please see https://github.com/openpitkit and the OWNERS file for details.
use cratePrice;
/// Stable lock context captured during pre-trade reservation.
///
/// `Lock` is not just a copy of request input. It is the serialized context of
/// what the engine actually reserved and how that reservation must later be
/// reconciled.
///
/// Policies may need to persist data that is known at reservation time but will
/// also be required later, when execution reports arrive and the engine must
/// release, consume, or re-price the remaining reserved state correctly.
/// Typical examples include the reservation price, translated quantities, or
/// any other policy-specific values that describe how funds were locked.
///
/// The lock context must travel together with the order lifecycle. If a policy
/// relies on execution report fill details to reconcile the reservation, the
/// lock produced during pre-trade must be stored until the final execution
/// report for that order has been processed. Dropping it too early breaks the
/// engine's ability to correctly unlock the unused remainder or finalize the
/// reserved state using the same assumptions that were applied when the order
/// was accepted.
///
/// A common case is price-sensitive reservation. The engine may reserve funds
/// using a worst execution price known during pre-trade. Later, when partial
/// fills and the final terminal report arrive, that same price must still be
/// available to compute how much reserved amount remains to be released.
/// Without the stored lock context, post-trade reconciliation would need to
/// guess, which is not a valid contract for deterministic risk handling.
///
/// In other words, `Lock` is the continuation token of reservation logic. It
/// captures the policy context that must survive from pre-trade acceptance to
/// the last execution report relevant for that reservation.
///
/// This crate exposes Serde compatibility only when the `serde` feature is
/// enabled. Applications embedding `openpit` choose the concrete transport
/// format themselves.
///
/// JSON is the canonical format for external bindings. Binary transports such
/// as MessagePack and CBOR are selected by the consuming application. Bincode
/// remains Rust-only and is outside the cross-language compatibility contract.