Skip to main content

Crate wickra_embed_core

Crate wickra_embed_core 

Source
Expand description

Allocation-free, #![no_std] streaming technical indicators.

wickra-embed-core runs the Wickra indicator math where there is no operating system and no heap — microcontrollers, FPGA soft-cores, HFT co-processors. Every Indicator update is O(1) with a bounded worst case, keeps its state inline in fixed-capacity buffers (no allocation), and produces the byte-for-byte identical value the std wickra-core library produces on a server.

§Design

  • No heap. Windowed indicators store their history in a const-generic Ring or a fixed array; nothing touches an allocator. The window length is the const parameter N (e.g. Sma<20>).
  • No panics in the update path. A panic on a microcontroller is a reset, so the core never uses unwrap/expect/unreachable! on the hot path; warmup and undefined states are expressed as None.
  • Deterministic to the bit. The floating-point work is done in the exact same order as wickra-core (rolling-sum add/subtract order, the periodic reseed, the final sum / period division), so the result is identical on thumbv7em-none-eabihf, thumbv6m-none-eabi and an x86-64 host alike. The few transcendental ops (abs, max, fused multiply-add) route through a single [math] switch point — std on a host, libm on bare metal — whose two implementations are IEEE-754 identical.

§Example

use wickra_embed_core::{Indicator, Sma};

let mut sma = Sma::<3>::new();
let mut last = None;
for i in 0..10 {
    last = sma.update(100.0 + f64::from(i));
}
assert!(last.is_some());

Re-exports§

pub use indicators::Atr;
pub use indicators::Ema;
pub use indicators::Roc;
pub use indicators::Rsi;
pub use indicators::Sma;
pub use ohlcv::Candle;
pub use traits::Indicator;

Modules§

indicators
The verified no-alloc indicator subset.
ohlcv
The Candle OHLC bar — the Copy input type for candle indicators.
ring
A fixed-capacity ring buffer of f64, allocation-free.
traits
The Indicator contract — the same streaming state machine wickra-core uses, narrowed to a scalar f64 output and no allocation.

Functions§

version
Crate version string (CARGO_PKG_VERSION), for the C ABI and diagnostics.