ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
imbalance.hpp
Go to the documentation of this file.
1#pragma once
2
11
12#include <array>
13#include <cstdint>
14#include <string>
15#include <string_view>
16#include <utility>
17
18#include "itch/indicators.hpp"
19#include "itch/messages.hpp"
20#include "itch/price.hpp"
21
22namespace itch::analytics {
23
30 std::uint64_t timestamp {0};
31 std::uint16_t stock_locate {0};
32 std::string stock;
33 std::uint64_t paired_shares {0};
34 std::uint64_t imbalance_shares {0};
39 char cross_type {'\0'};
41};
42
47[[nodiscard]] inline auto make_imbalance_info(const NOIIMessage& msg) -> ImbalanceInfo {
48 ImbalanceInfo info {};
49 info.timestamp = msg.timestamp;
50 info.stock_locate = msg.stock_locate;
51 info.stock = to_string(msg.stock, STOCK_LEN);
52 info.paired_shares = msg.paired_shares;
53 info.imbalance_shares = msg.imbalance_shares;
54 info.imbalance_direction = msg.imbalance_direction;
55 info.far_price = StandardPrice {msg.far_price};
56 info.near_price = StandardPrice {msg.near_price};
57 info.current_reference_price = StandardPrice {msg.current_reference_price};
58 info.cross_type = msg.cross_type;
59 info.price_variation_indicator = msg.price_variation_indicator;
60 return info;
61}
62
67[[nodiscard]] inline auto imbalance_direction_name(char direction) -> std::string_view {
68 constexpr indicators::FrozenMap directions {std::to_array<std::pair<char, std::string_view>>({
69 {'B', "Buy imbalance"},
70 {'S', "Sell imbalance"},
71 {'N', "No imbalance"},
72 {'O', "Insufficient orders to calculate"},
73 {'P', "Paused"},
74 })};
75 return directions.at_or(direction, "Unknown");
76}
77
78} // namespace itch::analytics
An immutable, compile-time lookup table from a key to a description.
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.
Compile-time lookup tables translating ITCH single- and multi-character indicator codes into human-re...
Defines every ITCH 5.0 message struct, the Message variant, and the stream-printing helpers used to f...
auto make_imbalance_info(const NOIIMessage &msg) -> ImbalanceInfo
Builds an ImbalanceInfo from a raw NOII message.
Definition imbalance.hpp:47
auto imbalance_direction_name(char direction) -> std::string_view
A human-readable description of an imbalance direction code.
Definition imbalance.hpp:67
constexpr int STOCK_LEN
Definition messages.hpp:485
auto to_string(const char *source, size_t size) -> std::string
Converts a fixed-width character array to a string, trimming trailing spaces and NUL characters.
Definition messages.hpp:495
Strongly typed, fixed-point price representation for ITCH price fields.
Net Order Imbalance Indicator (I): the imbalance and price-discovery data disseminated during the ope...
Definition messages.hpp:385
A usable, decoded view of a Net Order Imbalance Indicator (I) message.
Definition imbalance.hpp:29
StandardPrice current_reference_price
Definition imbalance.hpp:38