itchfeed 1.0.0__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2025 Bertin Balouki SIMYELI
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Bertin Balouki SIMYELI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,217 +1,225 @@
1
- Metadata-Version: 2.4
2
- Name: itchfeed
3
- Version: 1.0.0
4
- Summary: Simple parser for ITCH messages
5
- Home-page: https://github.com/bbalouki/itch
6
- Author: Bertin Balouki SIMYELI
7
- Author-email: <bertin@bbstrader.com>
8
- Maintainer: Bertin Balouki SIMYELI
9
- License: The MIT License (MIT)
10
- Project-URL: Source Code, https://github.com/bbalouki/itch
11
- Keywords: Finance,Financial,Quantitative,Equities,Data,Feed,ETFs,Funds,Trading,Investing,Portfolio,Optimization,Performance
12
- Classifier: Development Status :: 5 - Production/Stable
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: Financial and Insurance Industry
15
- Classifier: Topic :: Office/Business :: Financial :: Investment
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Operating System :: OS Independent
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: pytest
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: keywords
28
- Dynamic: license
29
- Dynamic: license-file
30
- Dynamic: maintainer
31
- Dynamic: project-url
32
- Dynamic: requires-dist
33
- Dynamic: summary
34
-
35
- # Nasdaq TotalView-ITCH 5.0 Parser
36
-
37
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) <!-- Choose your license -->
38
-
39
- A Python library for parsing binary data conforming to the Nasdaq TotalView-ITCH 5.0 protocol specification. This parser converts the raw byte stream into structured Python objects, making it easier to work with Nasdaq market data.
40
-
41
- ## Overview
42
-
43
- The Nasdaq TotalView-ITCH 5.0 protocol is a binary protocol used by Nasdaq to disseminate full order book depth, trade information, and system events for equities traded on its execution system. This parser handles the low-level details of reading the binary format, unpacking fields according to the specification, and presenting the data as intuitive Python objects.
44
-
45
- ## Features
46
-
47
- * **Parses ITCH 5.0 Binary Data:** Accurately interprets the binary message structures defined in the official specification.
48
- * **Supports All Standard Message Types:** Implements classes for all messages defined in the ITCH 5.0 specification (System Event, Stock Directory, Add Order, Trade, etc.).
49
- * **Object-Oriented Representation:** Each ITCH message type is represented by a dedicated Python class (`SystemEventMessage`, `AddOrderMessage`, etc.), inheriting from a common `MarketMessage` base class.
50
- * **Flexible Input:** Reads and parses messages from:
51
- * Binary files (`.gz` or similar).
52
- * Raw byte streams (e.g., from network sockets).
53
- * **Data Decoding:** Provides a `.decode()` method on each message object to convert it into a human-readable `dataclass` representation, handling:
54
- * Byte-to-string conversion (ASCII).
55
- * Stripping padding spaces.
56
- * Price decoding based on defined precision.
57
- * **Timestamp Handling:** Correctly reconstructs the 6-byte (48-bit) nanosecond timestamps.
58
- * **Price Handling:** Decodes fixed-point price fields into floating-point numbers based on the standard 4 or 8 decimal place precision.
59
- * **Pure Python:** Relies only on the Python standard library . No external dependencies required.
60
-
61
- ## Installation
62
-
63
- You can install this project using ``pip``
64
-
65
- 1. **Clone the repository (or download the source code):**
66
- ```bash
67
- pip install itch
68
- ```
69
- 2. **Import the necessary modules** directly into your Python project:
70
- ```python
71
- from itch.parser import MessageParser
72
- from itch.messages import ModifyOrderMessage
73
- ```
74
-
75
- ## Usage
76
-
77
- ### Parsing from a Binary File
78
-
79
- This is useful for processing historical ITCH data stored in files. The `MessageParser` handles buffering efficiently.
80
-
81
- ```python
82
- from itch import MessageParser
83
- from itch.messages import AddOrderMessage, TradeMessage
84
-
85
- # Initialize the parser. Optionally filter messages by type.
86
- # parser = MessageParser(message_type=b"AP") # Only parse AddOrder and NonCrossTrade messages
87
- parser = MessageParser()
88
-
89
- # Path to your ITCH 5.0 data file
90
- itch_file_path = 'path/to/your/data'
91
- # you can find sample data [here](https://emi.nasdaq.com/ITCH/Nasdaq%20ITCH/)
92
-
93
- try:
94
- with open(itch_file_path, 'rb') as itch_file:
95
- # read_message_from_file returns a list of parsed message objects
96
- parsed_messages = parser.read_message_from_file(itch_file)
97
-
98
- print(f"Parsed {len(parsed_messages)} messages.")
99
-
100
- # Process the messages
101
- for message in parsed_messages:
102
- # Access attributes directly
103
- print(f"Type: {message.message_type.decode()}, Timestamp: {message.timestamp}")
104
-
105
- if isinstance(message, AddOrderMessage):
106
- print(f" Add Order: Ref={message.order_reference_number}, "
107
- f"Side={message.buy_sell_indicator.decode()}, "
108
- f"Shares={message.shares}, Stock={message.stock.decode().strip()}, "
109
- f"Price={message.decode_price('price')}")
110
-
111
- elif isinstance(message, TradeMessage):
112
- print(f" Trade: Match={message.match_number}")
113
- # Access specific trade type attributes...
114
-
115
- # Get a human-readable dataclass representation
116
- decoded_msg = message.decode()
117
- print(f" Decoded: {decoded_msg}")
118
-
119
- except FileNotFoundError:
120
- print(f"Error: File not found at {itch_file_path}")
121
- except Exception as e:
122
- print(f"An error occurred: {e}")
123
-
124
- ```
125
-
126
- ### Parsing from Raw Bytes
127
-
128
- This is suitable for real-time processing, such as reading from a network stream.
129
-
130
- ```python
131
- from itch import MessageParser
132
- from itch.messages import AddOrderMessage
133
- from queue import Queue
134
-
135
- # Initialize the parser
136
- parser = MessageParser()
137
-
138
- # Simulate receiving a chunk of binary data (e.g., from a network socket)
139
- # This chunk contains multiple ITCH messages, each prefixed with 0x00 and length byte
140
- # Example: \x00\x0bS...\x00\x25R...\x00\x27F...
141
- raw_binary_data: bytes = b"..." # Your raw ITCH 5.0 data chunk
142
-
143
- # read_message_from_bytes returns a queue of parsed message objects
144
- message_queue: Queue = parser.read_message_from_bytes(raw_binary_data)
145
-
146
- print(f"Parsed {message_queue.qsize()} messages from the byte chunk.")
147
-
148
- # Process messages from the queue
149
- while not message_queue.empty():
150
- message = message_queue.get()
151
-
152
- print(f"Type: {message.message_type.decode()}, Timestamp: {message.timestamp}")
153
-
154
- if isinstance(message, AddOrderMessage):
155
- print(f" Add Order: Ref={message.order_reference_number}, "
156
- f"Stock={message.stock.decode().strip()}, Price={message.decode_price('price')}")
157
-
158
- # Use the decoded representation
159
- decoded_msg = message.decode(prefix="Decoded")
160
- print(f" Decoded: {decoded_msg}")
161
-
162
- ```
163
-
164
- ## Supported Message Types
165
-
166
- The parser supports the following ITCH 5.0 message types. Each message object has attributes corresponding to the fields defined in the specification. Refer to the class docstrings in `itch.messages` for detailed attribute descriptions.
167
-
168
- | Type (Byte) | Class Name | Description |
169
- | :---------- | :-------------------------------- | :----------------------------------------------- |
170
- | `S` | `SystemEventMessage` | System Event Message |
171
- | `R` | `StockDirectoryMessage` | Stock Directory Message |
172
- | `H` | `StockTradingActionMessage` | Stock Trading Action Message |
173
- | `Y` | `RegSHOMessage` | Reg SHO Short Sale Price Test Restricted Indicator |
174
- | `L` | `MarketParticipantPositionMessage`| Market Participant Position message |
175
- | `V` | `MWCBDeclineLeveMessage` | Market-Wide Circuit Breaker (MWCB) Decline Level |
176
- | `W` | `MWCBStatusMessage` | Market-Wide Circuit Breaker (MWCB) Status |
177
- | `K` | `IPOQuotingPeriodUpdateMessage` | IPO Quoting Period Update Message |
178
- | `J` | `LULDAuctionCollarMessage` | LULD Auction Collar Message |
179
- | `h` | `OperationalHaltMessage` | Operational Halt Message |
180
- | `A` | `AddOrderNoMPIAttributionMessage` | Add Order (No MPID Attribution) |
181
- | `F` | `AddOrderMPIDAttribution` | Add Order (MPID Attribution) |
182
- | `E` | `OrderExecutedMessage` | Order Executed Message |
183
- | `C` | `OrderExecutedWithPriceMessage` | Order Executed With Price Message |
184
- | `X` | `OrderCancelMessage` | Order Cancel Message |
185
- | `D` | `OrderDeleteMessage` | Order Delete Message |
186
- | `U` | `OrderReplaceMessage` | Order Replace Message |
187
- | `P` | `NonCrossTradeMessage` | Trade Message (Non-Cross) |
188
- | `Q` | `CrossTradeMessage` | Cross Trade Message |
189
- | `B` | `BrokenTradeMessage` | Broken Trade / Order Execution Message |
190
- | `I` | `NOIIMessage` | Net Order Imbalance Indicator (NOII) Message |
191
- | `N` | `RetailPriceImprovementIndicator` | Retail Price Improvement Indicator (RPII) |
192
- | `O` | `DLCRMessage` | Direct Listing with Capital Raise Message |
193
-
194
- ## Data Representation
195
-
196
- * **Base Class:** All message classes inherit from `itch.messages.MarketMessage`. This base class provides common attributes like `message_type`, `description`, `stock_locate`, `tracking_number`, and `timestamp`.
197
- * **Timestamp:** Timestamps are stored as 64-bit integers representing nanoseconds since midnight. The `set_timestamp` and `split_timestamp` methods handle the conversion from/to the 6-byte representation used in the raw messages.
198
- * **Prices:** Price fields (e.g., `price`, `execution_price`, `level1_price`) are stored as integers in the raw message objects. Use the `message.decode_price('attribute_name')` method to get the correctly scaled floating-point value (usually 4 or 8 decimal places, defined by `message.price_precision`).
199
- * **Strings:** Alpha fields are stored as `bytes`. The `.decode()` method converts these to ASCII strings and removes right-padding spaces.
200
- * **Decoded Objects:** The `message.decode()` method returns a standard Python `dataclass` instance. This provides a clean, immutable, and easily inspectable representation of the message content with correct data types (float for prices, string for text).
201
-
202
- ## Contributing
203
-
204
- Contributions are welcome! If you find a bug, have a suggestion, or want to add a feature:
205
-
206
- 1. **Check Issues:** See if an issue for your topic already exists.
207
- 2. **Open an Issue:** If not, open a new issue describing the bug or feature request.
208
- 3. **Fork and Branch:** Fork the repository and create a new branch for your changes.
209
- 4. **Implement Changes:** Make your code changes, ensuring adherence to the ITCH 5.0 specification. Add tests if applicable.
210
- 5. **Submit Pull Request:** Open a pull request from your branch to the main repository, referencing the relevant issue.
211
-
212
- ## License
213
-
214
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
215
-
216
- ## References
217
- * **Nasdaq TotalView-ITCH 5.0 Specification:** The official [documentation](https://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHspecification.pdf) is the definitive source for protocol details.
1
+ Metadata-Version: 2.4
2
+ Name: itchfeed
3
+ Version: 1.0.2
4
+ Summary: Simple parser for ITCH messages
5
+ Home-page: https://github.com/bbalouki/itch
6
+ Download-URL: https://pypi.org/project/itchfeed/
7
+ Author: Bertin Balouki SIMYELI
8
+ Author-email: <bertin@bbstrader.com>
9
+ Maintainer: Bertin Balouki SIMYELI
10
+ License: The MIT License (MIT)
11
+ Project-URL: Source Code, https://github.com/bbalouki/itch
12
+ Keywords: Finance,Financial,Quantitative,Equities,Totalview-ITCH,Totalview,Nasdaq-ITCH,Nasdaq,ITCH,Data,Feed,ETFs,Funds,Trading,Investing
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Topic :: Office/Business :: Financial :: Investment
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Operating System :: OS Independent
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: pytest
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: download-url
28
+ Dynamic: home-page
29
+ Dynamic: keywords
30
+ Dynamic: license
31
+ Dynamic: license-file
32
+ Dynamic: maintainer
33
+ Dynamic: project-url
34
+ Dynamic: requires-dist
35
+ Dynamic: summary
36
+
37
+ # Nasdaq TotalView-ITCH 5.0 Parser
38
+ [![PYPI Version](https://img.shields.io/pypi/v/itchfeed)](https://pypi.org/project/itchfeed/)
39
+ [![PyPi status](https://img.shields.io/pypi/status/itchfeed.svg?maxAge=60)](https://pypi.python.org/pypi/itchfeed)
40
+ [![Supported Python Versions](https://img.shields.io/pypi/pyversions/itchfeed)](https://pypi.org/project/itchfeed/)
41
+ [![PyPI Downloads](https://static.pepy.tech/badge/itchfeed)](https://pepy.tech/projects/itchfeed)
42
+ [![CodeFactor](https://www.codefactor.io/repository/github/bbalouki/itch/badge)](https://www.codefactor.io/repository/github/bbalouki/itch)
43
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-grey?logo=Linkedin&logoColor=white)](https://www.linkedin.com/in/bertin-balouki-simyeli-15b17a1a6/)
44
+ [![PayPal Me](https://img.shields.io/badge/PayPal%20Me-blue?logo=paypal)](https://paypal.me/bertinbalouki?country.x=SN&locale.x=en_US)
45
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
46
+
47
+ A Python library for parsing binary data conforming to the Nasdaq TotalView-ITCH 5.0 protocol specification. This parser converts the raw byte stream into structured Python objects, making it easier to work with Nasdaq market data.
48
+
49
+ ## Overview
50
+
51
+ The Nasdaq TotalView-ITCH 5.0 protocol is a binary protocol used by Nasdaq to disseminate full order book depth, trade information, and system events for equities traded on its execution system. This parser handles the low-level details of reading the binary format, unpacking fields according to the specification, and presenting the data as intuitive Python objects.
52
+
53
+ ## Features
54
+
55
+ * **Parses ITCH 5.0 Binary Data:** Accurately interprets the binary message structures defined in the official specification.
56
+ * **Supports All Standard Message Types:** Implements classes for all messages defined in the ITCH 5.0 specification (System Event, Stock Directory, Add Order, Trade, etc.).
57
+ * **Object-Oriented Representation:** Each ITCH message type is represented by a dedicated Python class (`SystemEventMessage`, `AddOrderMessage`, etc.), inheriting from a common `MarketMessage` base class.
58
+ * **Flexible Input:** Reads and parses messages from:
59
+ * Binary files (`.gz` or similar).
60
+ * Raw byte streams (e.g., from network sockets).
61
+ * **Data Decoding:** Provides a `.decode()` method on each message object to convert it into a human-readable `dataclass` representation, handling:
62
+ * Byte-to-string conversion (ASCII).
63
+ * Stripping padding spaces.
64
+ * Price decoding based on defined precision.
65
+ * **Timestamp Handling:** Correctly reconstructs the 6-byte (48-bit) nanosecond timestamps.
66
+ * **Price Handling:** Decodes fixed-point price fields into floating-point numbers based on the standard 4 or 8 decimal place precision.
67
+ * **Pure Python:** Relies only on the Python standard library . No external dependencies required.
68
+
69
+ ## Installation
70
+
71
+ You can install this project using ``pip``
72
+
73
+ 1. **Clone the repository (or download the source code):**
74
+ ```bash
75
+ pip install itchfeed
76
+ ```
77
+ 2. **Import the necessary modules** directly into your Python project:
78
+ ```python
79
+ from itch.parser import MessageParser
80
+ from itch.messages import ModifyOrderMessage
81
+ ```
82
+
83
+ ## Usage
84
+
85
+ ### Parsing from a Binary File
86
+
87
+ This is useful for processing historical ITCH data stored in files. The `MessageParser` handles buffering efficiently.
88
+
89
+ ```python
90
+ from itch.parser import MessageParser
91
+ from itch.messages import AddOrderMessage, TradeMessage
92
+
93
+ # Initialize the parser. Optionally filter messages by type.
94
+ # parser = MessageParser(message_type=b"AP") # Only parse AddOrder and NonCrossTrade messages
95
+ parser = MessageParser()
96
+
97
+ # Path to your ITCH 5.0 data file
98
+ itch_file_path = 'path/to/your/data'
99
+ # you can find sample data [here](https://emi.nasdaq.com/ITCH/Nasdaq%20ITCH/)
100
+
101
+ try:
102
+ with open(itch_file_path, 'rb') as itch_file:
103
+ # read_message_from_file returns a list of parsed message objects
104
+ parsed_messages = parser.read_message_from_file(itch_file)
105
+
106
+ print(f"Parsed {len(parsed_messages)} messages.")
107
+
108
+ # Process the messages
109
+ for message in parsed_messages:
110
+ # Access attributes directly
111
+ print(f"Type: {message.message_type.decode()}, Timestamp: {message.timestamp}")
112
+
113
+ if isinstance(message, AddOrderMessage):
114
+ print(f" Add Order: Ref={message.order_reference_number}, "
115
+ f"Side={message.buy_sell_indicator.decode()}, "
116
+ f"Shares={message.shares}, Stock={message.stock.decode().strip()}, "
117
+ f"Price={message.decode_price('price')}")
118
+
119
+ elif isinstance(message, TradeMessage):
120
+ print(f" Trade: Match={message.match_number}")
121
+ # Access specific trade type attributes...
122
+
123
+ # Get a human-readable dataclass representation
124
+ decoded_msg = message.decode()
125
+ print(f" Decoded: {decoded_msg}")
126
+
127
+ except FileNotFoundError:
128
+ print(f"Error: File not found at {itch_file_path}")
129
+ except Exception as e:
130
+ print(f"An error occurred: {e}")
131
+
132
+ ```
133
+
134
+ ### Parsing from Raw Bytes
135
+
136
+ This is suitable for real-time processing, such as reading from a network stream.
137
+
138
+ ```python
139
+ from itch.parser import MessageParser
140
+ from itch.messages import AddOrderMessage
141
+ from queue import Queue
142
+
143
+ # Initialize the parser
144
+ parser = MessageParser()
145
+
146
+ # Simulate receiving a chunk of binary data (e.g., from a network socket)
147
+ # This chunk contains multiple ITCH messages, each prefixed with 0x00 and length byte
148
+ # Example: \x00\x0bS...\x00\x25R...\x00\x27F...
149
+ raw_binary_data: bytes = b"..." # Your raw ITCH 5.0 data chunk
150
+
151
+ # read_message_from_bytes returns a queue of parsed message objects
152
+ message_queue: Queue = parser.read_message_from_bytes(raw_binary_data)
153
+
154
+ print(f"Parsed {message_queue.qsize()} messages from the byte chunk.")
155
+
156
+ # Process messages from the queue
157
+ while not message_queue.empty():
158
+ message = message_queue.get()
159
+
160
+ print(f"Type: {message.message_type.decode()}, Timestamp: {message.timestamp}")
161
+
162
+ if isinstance(message, AddOrderMessage):
163
+ print(f" Add Order: Ref={message.order_reference_number}, "
164
+ f"Stock={message.stock.decode().strip()}, Price={message.decode_price('price')}")
165
+
166
+ # Use the decoded representation
167
+ decoded_msg = message.decode(prefix="Decoded")
168
+ print(f" Decoded: {decoded_msg}")
169
+
170
+ ```
171
+
172
+ ## Supported Message Types
173
+
174
+ The parser supports the following ITCH 5.0 message types. Each message object has attributes corresponding to the fields defined in the specification. Refer to the class docstrings in `itch.messages` for detailed attribute descriptions.
175
+
176
+ | Type (Byte) | Class Name | Description |
177
+ | :---------- | :-------------------------------- | :----------------------------------------------- |
178
+ | `S` | `SystemEventMessage` | System Event Message |
179
+ | `R` | `StockDirectoryMessage` | Stock Directory Message |
180
+ | `H` | `StockTradingActionMessage` | Stock Trading Action Message |
181
+ | `Y` | `RegSHOMessage` | Reg SHO Short Sale Price Test Restricted Indicator |
182
+ | `L` | `MarketParticipantPositionMessage`| Market Participant Position message |
183
+ | `V` | `MWCBDeclineLeveMessage` | Market-Wide Circuit Breaker (MWCB) Decline Level |
184
+ | `W` | `MWCBStatusMessage` | Market-Wide Circuit Breaker (MWCB) Status |
185
+ | `K` | `IPOQuotingPeriodUpdateMessage` | IPO Quoting Period Update Message |
186
+ | `J` | `LULDAuctionCollarMessage` | LULD Auction Collar Message |
187
+ | `h` | `OperationalHaltMessage` | Operational Halt Message |
188
+ | `A` | `AddOrderNoMPIAttributionMessage` | Add Order (No MPID Attribution) |
189
+ | `F` | `AddOrderMPIDAttribution` | Add Order (MPID Attribution) |
190
+ | `E` | `OrderExecutedMessage` | Order Executed Message |
191
+ | `C` | `OrderExecutedWithPriceMessage` | Order Executed With Price Message |
192
+ | `X` | `OrderCancelMessage` | Order Cancel Message |
193
+ | `D` | `OrderDeleteMessage` | Order Delete Message |
194
+ | `U` | `OrderReplaceMessage` | Order Replace Message |
195
+ | `P` | `NonCrossTradeMessage` | Trade Message (Non-Cross) |
196
+ | `Q` | `CrossTradeMessage` | Cross Trade Message |
197
+ | `B` | `BrokenTradeMessage` | Broken Trade / Order Execution Message |
198
+ | `I` | `NOIIMessage` | Net Order Imbalance Indicator (NOII) Message |
199
+ | `N` | `RetailPriceImprovementIndicator` | Retail Price Improvement Indicator (RPII) |
200
+ | `O` | `DLCRMessage` | Direct Listing with Capital Raise Message |
201
+
202
+ ## Data Representation
203
+
204
+ * **Base Class:** All message classes inherit from `itch.messages.MarketMessage`. This base class provides common attributes like `message_type`, `description`, `stock_locate`, `tracking_number`, and `timestamp`.
205
+ * **Timestamp:** Timestamps are stored as 64-bit integers representing nanoseconds since midnight. The `set_timestamp` and `split_timestamp` methods handle the conversion from/to the 6-byte representation used in the raw messages.
206
+ * **Prices:** Price fields (e.g., `price`, `execution_price`, `level1_price`) are stored as integers in the raw message objects. Use the `message.decode_price('attribute_name')` method to get the correctly scaled floating-point value (usually 4 or 8 decimal places, defined by `message.price_precision`).
207
+ * **Strings:** Alpha fields are stored as `bytes`. The `.decode()` method converts these to ASCII strings and removes right-padding spaces.
208
+ * **Decoded Objects:** The `message.decode()` method returns a standard Python `dataclass` instance. This provides a clean, immutable, and easily inspectable representation of the message content with correct data types (float for prices, string for text).
209
+
210
+ ## Contributing
211
+
212
+ Contributions are welcome! If you find a bug, have a suggestion, or want to add a feature:
213
+
214
+ 1. **Check Issues:** See if an issue for your topic already exists.
215
+ 2. **Open an Issue:** If not, open a new issue describing the bug or feature request.
216
+ 3. **Fork and Branch:** Fork the repository and create a new branch for your changes.
217
+ 4. **Implement Changes:** Make your code changes, ensuring adherence to the ITCH 5.0 specification. Add tests if applicable.
218
+ 5. **Submit Pull Request:** Open a pull request from your branch to the main repository, referencing the relevant issue.
219
+
220
+ ## License
221
+
222
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
223
+
224
+ ## References
225
+ * **Nasdaq TotalView-ITCH 5.0 Specification:** The official [documentation](https://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHspecification.pdf) is the definitive source for protocol details.