26#include "../../include/srfm/stream/signal_processor.hpp"
36 if (running_.load(std::memory_order_acquire))
return;
38 stop_requested_.store(
false, std::memory_order_release);
39 running_.store(
true, std::memory_order_release);
41 thread_ = std::thread([
this]()
noexcept { run_loop(); });
47 stop_requested_.store(
true, std::memory_order_release);
48 if (thread_.joinable()) thread_.join();
49 running_.store(
false, std::memory_order_release);
56 std::int64_t bar_index)
noexcept {
60 normalizer_.update(tick.close);
61 const double norm_close = normalizer_.normalise(tick.close);
64 beta_calc_.update(tick.close);
65 const double beta = beta_calc_.
beta();
68 const double t =
static_cast<double>(bar_index);
69 const double x = norm_close;
70 const auto ev = lorentz_.transform(t, x, beta);
73 const auto mr = manifold_.update(ev.t_prime, ev.x_prime);
77 const double final_signal = ev.gamma * mr.signal;
92void SignalProcessor::run_loop() noexcept {
93 while (!stop_requested_.load(std::memory_order_acquire)) {
95 auto maybe_tick = in_ring_.
pop();
97 if (!maybe_tick.has_value()) {
98 std::this_thread::yield();
109 const OHLCVTick& t = *maybe_tick;
110 const bool close_ok = std::isfinite(t.close) && t.close > 0.0;
111 const bool volume_ok = std::isfinite(t.volume) && t.volume >= 0.0;
112 if (!close_ok || !volume_ok) {
118 const auto sig =
process_one(*maybe_tick, bar_counter_++);
121 switch (sig.regime) {
128 StreamRelativisticSignal s = sig;
129 if (!out_ring_.
push(std::move(s))) {
137 running_.store(
false, std::memory_order_release);
std::optional< T > pop() noexcept
Try to dequeue one element.
bool push(T &&item) noexcept
Try to enqueue one element.
void stop() noexcept
Stop and join the processing thread. Idempotent.
void start() noexcept
Launch the processing thread. Idempotent.
StreamRelativisticSignal process_one(const OHLCVTick &tick, std::int64_t bar_index) noexcept
Process one tick synchronously and return the resulting signal.
Single OHLCV bar tick from the market data feed.
std::uint64_t timelike_count
TIMELIKE regime events.
std::uint64_t signals_emitted
Signals pushed to output ring.
std::uint64_t ticks_rejected_invalid
Dropped: NaN/Inf/non-positive field.
std::uint64_t lightlike_count
LIGHTLIKE regime events.
std::uint64_t ticks_processed
Ticks popped from input ring.
std::uint64_t spacelike_count
SPACELIKE regime events.
std::uint64_t signals_dropped_ring_full
Dropped: output ring full.
Fully-characterised relativistic signal for one processed tick.
Regime regime
Spacetime interval regime.
double gamma
Lorentz factor γ.
std::int64_t bar
Bar sequence number.
double signal
Relativistic signal value.
double ds2
Spacetime interval Δs² (diagnostic).
double beta
Market velocity β.