Skip to content

Commit 034febf

Browse files
committed
refactor: HFT optimizations (binary ingest, appender, spsc)
1 parent c1cc0fc commit 034febf

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

QuanuX-Statistics/cpp/include/stats_engine.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include "models/WelfordRolling.hpp"
33
// #include <Eigen/Dense> // Not used in this header anymore
4+
#include "quanux/SPSCQueue.hpp"
45
#include <atomic>
56
#include <cstdint>
67
#include <map>
@@ -77,5 +78,19 @@ class StatsEngine {
7778
stats_mutex_; // Protect maps from NATS callbacks if multithreaded (NATS C
7879
// is usually single threaded callback context, but safer)
7980

81+
// Signal Structure for SPSC Queue
82+
struct Signal {
83+
uint64_t tick_ts;
84+
uint32_t instrument_id;
85+
double z_score;
86+
double volatility;
87+
};
88+
89+
// Lock-Free Signal Queue (Capacity 1024)
90+
// We use a unique_ptr to defer construction or keep header clean-ish
91+
// but template needs to be visible.
92+
// Actually, we can just declare the member if we include the header.
93+
quanux::SPSCQueue<Signal> signal_queue_{4096};
94+
8095
void update_correlation(const std::string &symbol, double price);
8196
};

0 commit comments

Comments
 (0)