Commit fc4af90
* feat(fix): order-entry message flow (closes #424)
Order-entry (OE) FIX messages over the shared codec/session engine, for both
the prediction and margin products.
Outbound (typed enum vocabulary, required fields enforced):
- NewOrderSingle (35=D), OrderCancelRequest (35=F),
OrderCancelReplaceRequest (35=G), OrderMassCancelRequest (35=q)
- Side / OrdType / TimeInForce / ExecInst (POST_ONLY) / SelfTradePreventionType
round-trip to the wire; NoPartyIDs group via the #423 components; Price rides
the FIX PRICE field (integer cents on prediction by default, fixed-point
dollars on margin / UseDollars=Y); quantities are fractional decimals.
Inbound (fields optional; char/int code fields raw for robustness):
- ExecutionReport (35=8) with NoMiscFees / NoPartyIDs / NoCollateralAmountChanges
groups, position/fee/collateral detail on ExecType=Trade
- OrderCancelReject (35=9), OrderMassCancelReport (35=r),
BusinessMessageReject (35=j)
- decode_app_message(raw) dispatches an inbound RawMessage (from
FixSession.on_message) to its typed model.
Also folds in the PR #430 review follow-ups: FixGroupMeta/_GroupSpec now type
entry_model as the public FixGroup (not the private base), and group decoding
logs (debug) on a non-integer or short NumInGroup instead of silently dropping.
13 new tests (round-trips incl. groups, enum/price wire values, dispatch,
inbound robustness, and a session send/receive integration test).
ruff + mypy --strict clean; 117 FIX tests pass.
Closes #424. Part of #402.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(fix): address PR #431 review — top-level export + test gaps
- export APP_MESSAGE_MODELS from kalshi.fix top-level __all__ (was only exported
from kalshi.fix.messages)
- comment the Kalshi compound "int;int" exec_id format on ExecutionReport
- tests: malformed group decode (short-count + non-integer NumInGroup debug
paths), decode_app_message dispatch for OrderCancelReject /
OrderMassCancelReport / BusinessMessageReject, a quantity-only
OrderCancelReplaceRequest, and the NewOrderSingle empty-parties default
Two review items were intentionally NOT changed — they apply generic FIX 5.0SP2
requiredness, not the Kalshi dictionary v1.03:
- TransactTime(60) is absent from the Kalshi NewOrderSingle/Cancel/Replace
messages (and the order-entry doc example omits tag 60); adding it would send
a tag those messages do not define.
- Price is required='N' in OrderCancelReplaceRequest (G); a quantity-only amend
is valid ("required if changing price"), so price stays optional.
ruff + mypy --strict clean; 122 FIX tests pass.
Part of #424 / #402.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(fix): address PR #431 2nd review — robust decode + immutable registry
- decode_app_message now catches ValidationError / ValueError / ArithmeticError
and returns None (logged) so a malformed inbound message is never raised into
the consumer's on_message; regression test added
- APP_MESSAGE_MODELS wrapped in MappingProxyType (read-only dispatch registry)
- comment that AllocAccount (79) is INT per Kalshi dictionary v1.03 (subaccount
number 0-32), not the FIX-standard STRING
- note the intentional TransactTime (60) omission on NewOrderSingle (absent from
the Kalshi 35=D message)
Verified against dictionary v1.03, left unchanged:
- AllocAccount (79) is INT in the Kalshi dict.
- OrderMassCancelReport (35=r) has no TotalAffectedOrders (533); tag 533 is not
in the Kalshi dictionary at all.
- NewOrderSingle field/group order matches the dictionary's 35=D layout.
ruff + mypy --strict clean; 123 FIX tests pass.
Part of #424 / #402.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(fix): cover decode_app_message None-msg-type; format nit (#431 review)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0ff1009 commit fc4af90
6 files changed
Lines changed: 736 additions & 10 deletions
File tree
- kalshi/fix
- messages
- tests/fix
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
74 | 90 | | |
| 91 | + | |
| 92 | + | |
75 | 93 | | |
76 | 94 | | |
77 | 95 | | |
78 | 96 | | |
79 | 97 | | |
80 | 98 | | |
| 99 | + | |
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
| 103 | + | |
| 104 | + | |
84 | 105 | | |
85 | 106 | | |
86 | 107 | | |
| 108 | + | |
87 | 109 | | |
88 | 110 | | |
89 | 111 | | |
90 | 112 | | |
91 | 113 | | |
92 | 114 | | |
| 115 | + | |
| 116 | + | |
93 | 117 | | |
94 | 118 | | |
95 | 119 | | |
| |||
105 | 129 | | |
106 | 130 | | |
107 | 131 | | |
| 132 | + | |
| 133 | + | |
108 | 134 | | |
| 135 | + | |
| 136 | + | |
109 | 137 | | |
110 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
111 | 145 | | |
112 | 146 | | |
113 | 147 | | |
| |||
119 | 153 | | |
120 | 154 | | |
121 | 155 | | |
| 156 | + | |
122 | 157 | | |
| 158 | + | |
123 | 159 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| |||
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
| 49 | + | |
| 50 | + | |
37 | 51 | | |
| 52 | + | |
38 | 53 | | |
39 | 54 | | |
40 | 55 | | |
| |||
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
48 | 69 | | |
49 | 70 | | |
50 | 71 | | |
51 | 72 | | |
52 | 73 | | |
| 74 | + | |
53 | 75 | | |
54 | 76 | | |
55 | 77 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
80 | | - | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| |||
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
94 | | - | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
176 | | - | |
177 | | - | |
| 179 | + | |
| 180 | + | |
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| |||
184 | 187 | | |
185 | 188 | | |
186 | 189 | | |
187 | | - | |
| 190 | + | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| |||
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
197 | 208 | | |
198 | 209 | | |
199 | 210 | | |
| |||
258 | 269 | | |
259 | 270 | | |
260 | 271 | | |
261 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
262 | 278 | | |
263 | 279 | | |
264 | 280 | | |
| |||
309 | 325 | | |
310 | 326 | | |
311 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
312 | 333 | | |
313 | 334 | | |
314 | 335 | | |
| |||
0 commit comments