ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
indicators.hpp
Go to the documentation of this file.
1#pragma once
2
13
14#include <algorithm>
15#include <array>
16#include <optional>
17#include <string_view>
18#include <utility>
19
20namespace itch {
21namespace indicators {
22
34template <typename KeyType, std::size_t Size>
35class FrozenMap {
36 public:
37 using value_type = std::pair<KeyType, std::string_view>;
38
44 constexpr explicit FrozenMap(std::array<value_type, Size> entries) noexcept
45 : m_entries {entries} {
46 std::ranges::sort(m_entries, {}, &value_type::first);
47 }
48
53 [[nodiscard]] constexpr auto find(const KeyType& key
54 ) const noexcept -> std::optional<std::string_view> {
55 const auto iter = std::ranges::lower_bound(m_entries, key, {}, &value_type::first);
56 if (iter != m_entries.end() && iter->first == key) {
57 return iter->second;
58 }
59 return std::nullopt;
60 }
61
67 [[nodiscard]] constexpr auto at_or(const KeyType& key, std::string_view fallback) const noexcept
68 -> std::string_view {
69 return find(key).value_or(fallback);
70 }
71
72 private:
73 std::array<value_type, Size> m_entries;
74};
75
82template <typename KeyType, std::size_t Size>
83FrozenMap(std::array<std::pair<KeyType, std::string_view>, Size>) -> FrozenMap<KeyType, Size>;
84
85inline constexpr FrozenMap SYSTEM_EVENT_CODES {std::to_array<std::pair<char, std::string_view>>({
86 {'O', "Start of Messages"},
87 {'S', "Start of System hours"},
88 {'Q', "Start of Market hours"},
89 {'M', "End of Market hours"},
90 {'E', "End of System hours"},
91 {'C', "End of Messages"},
92})};
93
94inline constexpr FrozenMap MARKET_CATEGORY {std::to_array<std::pair<char, std::string_view>>({
95 {'N', "NYSE"},
96 {'A', "AMEX"},
97 {'P', "Arca"},
98 {'Q', "NASDAQ Global Select"},
99 {'G', "NASDAQ Global Market"},
100 {'S', "NASDAQ Capital Market"},
101 {'Z', "BATS"},
102 {'V', "Investors Exchange"},
103 {' ', "Not available"},
104})};
105
107 std::to_array<std::pair<char, std::string_view>>({
108 {'D', "Deficient"},
109 {'E', "Delinquent"},
110 {'Q', "Bankrupt"},
111 {'S', "Suspended"},
112 {'G', "Deficient and Bankrupt"},
113 {'H', "Deficient and Delinquent"},
114 {'J', "Delinquent and Bankrupt"},
115 {'K', "Deficient, Delinquent and Bankrupt"},
116 {'C', "Creations and/or Redemptions Suspended for Exchange Traded Product"},
117 {'N', "Normal (Default): Issuer is NOT Deficient, Delinquent, or Bankrupt"},
118 {' ', "Not available. Firms should refer to SIAC feeds for code if needed"},
119 })
120};
121
123 std::to_array<std::pair<char, std::string_view>>({
124 {'A', "American Depositary Share"},
125 {'B', "Bond"},
126 {'C', "Common Stock"},
127 {'F', "Depository Receipt"},
128 {'I', "144A"},
129 {'L', "Limited Partnership"},
130 {'N', "Notes"},
131 {'O', "Ordinary Share"},
132 {'P', "Preferred Stock"},
133 {'Q', "Other Securities"},
134 {'R', "Right"},
135 {'S', "Shares of Beneficial Interest"},
136 {'T', "Convertible Debenture"},
137 {'U', "Unit"},
138 {'V', "Units/Beneficial Interest"},
139 {'W', "Warrant"},
140 })
141};
142
144 std::to_array<std::pair<std::string_view, std::string_view>>({
145 {"A", "Preferred Trust Securities"},
146 {"AI", "Alpha Index ETNs"},
147 {"B", "Index Based Derivative"},
148 {"C", "Common Shares"},
149 {"CB", "Commodity Based Trust Shares"},
150 {"CF", "Commodity Futures Trust Shares"},
151 {"CL", "Commodity-Linked Securities"},
152 {"CM", "Commodity Index Trust Shares"},
153 {"CO", "Collateralized Mortgage Obligation"},
154 {"CT", "Currency Trust Shares"},
155 {"CU", "Commodity-Currency-Linked Securities"},
156 {"CW", "Currency Warrants"},
157 {"D", "Global Depositary Shares"},
158 {"E", "ETF-Portfolio Depositary Receipt"},
159 {"EG", "Equity Gold Shares"},
160 {"EI", "ETN-Equity Index-Linked Securities"},
161 {"EM", "NextShares Exchange Traded Managed Fund*"},
162 {"EN", "Exchange Traded Notes"},
163 {"EU", "Equity Units"},
164 {"F", "HOLDRS"},
165 {"FI", "ETN-Fixed Income-Linked Securities"},
166 {"FL", "ETN-Futures-Linked Securities"},
167 {"G", "Global Shares"},
168 {"I", "ETF-Index Fund Shares"},
169 {"IR", "Interest Rate"},
170 {"IW", "Index Warrant"},
171 {"IX", "Index-Linked Exchangeable Notes"},
172 {"J", "Corporate Backed Trust Security"},
173 {"L", "Contingent Litigation Right"},
174 {"LL", "Limited Liability Company (LLC)"},
175 {"M", "Equity-Based Derivative"},
176 {"MF", "Managed Fund Shares"},
177 {"ML", "ETN-Multi-Factor Index-Linked Securities"},
178 {"MT", "Managed Trust Securities"},
179 {"N", "NY Registry Shares"},
180 {"O", "Open Ended Mutual Fund"},
181 {"P", "Privately Held Security"},
182 {"PP", "Poison Pill"},
183 {"PU", "Partnership Units"},
184 {"Q", "Closed-End Funds"},
185 {"R", "Reg-S"},
186 {"RC", "Commodity-Redeemable Commodity-Linked Securities"},
187 {"RF", "ETN-Redeemable Futures-Linked Securities"},
188 {"RT", "REIT"},
189 {"RU", "Commodity-Redeemable Currency-Linked Securities"},
190 {"S", "SEED"},
191 {"SC", "Spot Rate Closing"},
192 {"SI", "Spot Rate Intraday"},
193 {"T", "Tracking Stock"},
194 {"TC", "Trust Certificates"},
195 {"TU", "Trust Units"},
196 {"U", "Portal"},
197 {"V", "Contingent Value Right"},
198 {"W", "Trust Issued Receipts"},
199 {"WC", "World Currency Option"},
200 {"X", "Trust"},
201 {"Y", "Other"},
202 {"Z", "Not Applicable"},
203 })
204};
205
207 std::to_array<std::pair<std::string_view, std::string_view>>({
208 {"T1", "Halt News Pending"},
209 {"T2", "Halt News Disseminated"},
210 {"T3", "News and Resumption Times"},
211 {"T5", "Single Security Trading Pause In Effect"},
212 {"T6", "Regulatory Halt - Extraordinary Market Activity"},
213 {"T7", "Single Security Trading Pause / Quotation Only Period"},
214 {"T8", "Halt ETF"},
215 {"T12", "Trading Halted; For Information Requested by Listing Market"},
216 {"H4", "Halt Non-Compliance"},
217 {"H9", "Halt Filings Not Current"},
218 {"H10", "Halt SEC Trading Suspension"},
219 {"H11", "Halt Regulatory Concern"},
220 {"O1", "Operations Halt; Contact Market Operations"},
221 {"LUDP", "Volatility Trading Pause"},
222 {"LUDS", "Volatility Trading Pause - Straddle Condition"},
223 {"MWC0", "Market Wide Circuit Breaker Halt - Carry over from previous day"},
224 {"MWC1", "Market Wide Circuit Breaker Halt - Level 1"},
225 {"MWC2", "Market Wide Circuit Breaker Halt - Level 2"},
226 {"MWC3", "Market Wide Circuit Breaker Halt - Level 3"},
227 {"MWCQ", "Market Wide Circuit Breaker Resumption"},
228 {"IPO1", "IPO Issue Not Yet Trading"},
229 {"IPOQ", "IPO Security Released for Quotation (Nasdaq Securities Only)"},
230 {"IPOE", "IPO Security - Positioning Window Extension (Nasdaq Securities Only)"},
231 {"M1", "Corporate Action"},
232 {"M2", "Quotation Not Available"},
233 {"R1", "New Issue Available"},
234 {"R2", "Issue Available"},
235 {"R4", "Qualifications Issues Reviewed/Resolved; Quotations/Trading to Resume"},
236 {"R9", "Filing Requirements Satisfied/Resolved; Quotations/Trading To Resume"},
237 {"C3", "Issuer News Not Forthcoming; Quotations/Trading To Resume"},
238 {"C4", "Qualifications Halt Ended; Maintenance Requirements Met; Resume"},
239 {"C9", "Qualifications Halt Concluded; Filings Met; Quotes/Trades To Resume"},
240 {"C11", "Trade Halt Concluded By Other Regulatory Authority; Quotes/Trades Resume"},
241 {" ", "Reason Not Available"},
242 })
243};
244
245inline constexpr FrozenMap TRADING_STATES {std::to_array<std::pair<char, std::string_view>>({
246 {'H', "Halted across all U.S. equity markets / SROs"},
247 {'P', "Paused across all U.S. equity markets / SROs"},
248 {'Q', "Quotation only period for cross-SRO halt or pause"},
249 {'T', "Trading on NASDAQ"},
250})};
251
252inline constexpr FrozenMap MARKET_MAKER_MODE {std::to_array<std::pair<char, std::string_view>>({
253 {'N', "Normal"},
254 {'P', "Passive"},
255 {'S', "Syndicate"},
256 {'R', "Pre-syndicate"},
257 {'L', "Penalty"},
258})};
259
261 std::to_array<std::pair<char, std::string_view>>({
262 {'A', "Active"},
263 {'E', "Excused"},
264 {'W', "Withdrawn"},
265 {'S', "Suspended"},
266 {'D', "Deleted"},
267 })
268};
269
271 std::to_array<std::pair<char, std::string_view>>({
272 {'L', "Less than 1%"},
273 {'1', "1 to 1.99%"},
274 {'2', "2 to 2.99%"},
275 {'3', "3 to 3.99%"},
276 {'4', "4 to 4.99%"},
277 {'5', "5 to 5.99%"},
278 {'6', "6 to 6.99%"},
279 {'7', "7 to 7.99%"},
280 {'8', "8 to 8.99%"},
281 {'9', "9 to 9.99%"},
282 {'A', "10 to 19.99%"},
283 {'B', "20 to 29.99%"},
284 {'C', "30% or greater"},
285 {' ', "Cannot be calculated"},
286 })
287};
288
289} // namespace indicators
290
291} // namespace itch
An immutable, compile-time lookup table from a key to a description.
constexpr auto find(const KeyType &key) const noexcept -> std::optional< std::string_view >
Returns the description for a key, or std::nullopt if absent.
constexpr auto at_or(const KeyType &key, std::string_view fallback) const noexcept -> std::string_view
Returns the description for a key, or a fallback if absent.
std::pair< KeyType, std::string_view > value_type
constexpr FrozenMap(std::array< value_type, Size > entries) noexcept
Constructs the map from an unsorted list of key/description entries, sorting them by key once so that...
constexpr FrozenMap TRADING_ACTION_REASON_CODES
constexpr FrozenMap MARKET_PARTICIPANT_STATE
constexpr FrozenMap MARKET_CATEGORY
constexpr FrozenMap PRICE_VARIATION_INDICATOR
constexpr FrozenMap SYSTEM_EVENT_CODES
constexpr FrozenMap TRADING_STATES
constexpr FrozenMap MARKET_MAKER_MODE
constexpr FrozenMap ISSUE_CLASSIFICATION_VALUES
constexpr FrozenMap ISSUE_SUB_TYPE_VALUES
constexpr FrozenMap FINANCIAL_STATUS_INDICATOR