Skip to content

feat: add 19 indicators for external feature-extractor coverage (377 -> 396)#175

Merged
kingchenc merged 6 commits into
mainfrom
feat/v17-feature-coverage
Jun 4, 2026
Merged

feat: add 19 indicators for external feature-extractor coverage (377 -> 396)#175
kingchenc merged 6 commits into
mainfrom
feat/v17-feature-coverage

Conversation

@kingchenc
Copy link
Copy Markdown
Collaborator

Adds 19 streaming indicators so an external trading-bot feature extractor can replace its hand-built features with native, batch/streaming-equivalent ones. Each is a real gap (verified against the existing catalogue), production-only, with full Python/Node/WASM bindings, fuzz drivers, and tests. Five commits, one per family group; counter 377 -> 396.

What's added

Price Statistics (6)LogReturn, RealizedVolatility (raw quadratic variation, the un-annualised counterpart to HistoricalVolatility), RollingQuantile, RollingIqr, RollingPercentileRank, SpreadAr1Coefficient (pairwise AR(1) rho of the spread; complements OuHalfLife).

Price Action (4)CloseVsOpen, BodySizePct, WickRatio, HighLowRange (stateless per-bar OHLC transforms).

Regime / Trend / Jump labels (3)TrendLabel (sign of the rolling OLS slope), JumpIndicator (return outliers vs trailing volatility, measured as deviation from the trailing mean so steady drift is not flagged), RegimeLabel (volatility-quantile regime split).

Risk / Performance (2)WinRate, Expectancy (R-multiple).

Microstructure (4)OrderFlowImbalance (Cont-Kukanov-Stoikov OFI), Vpin, AmihudIlliquidity, RollMeasure. These reuse the existing OrderBook / Trade inputs (no new input type).

Intentionally NOT added (already present, would be duplicates)

  • Population skew / kurtosisskewness.rs / kurtosis.rs are already population moments (divisor n).
  • Hurst R/Shurst_exponent.rs already uses rescaled-range (R/S) analysis.
  • Queue Imbalance — exactly OrderBookImbalanceTop1 ((bidSize - askSize) / (bidSize + askSize)).

Verification

cargo test -p wickra-core (lib 3187 + doc 354), cargo clippy --workspace --all-targets --all-features -D warnings clean, node npm run build && npm test (471), python pytest (784). Counter consistent across mod.rs, lib block, README, and docs/README at 396.

kingchenc added 5 commits June 4, 2026 02:42
Add six Price Statistics indicators so downstream feature extractors can
replace hand-built equivalents with native streaming ones:

- LogReturn — ln(price_t / price_{t-period}), the additive return basis
- RealizedVolatility — sqrt of summed squared log returns (raw quadratic
  variation; the un-annualised counterpart to HistoricalVolatility)
- RollingQuantile — interpolated q-th quantile over a window (type-7)
- RollingIqr — Q3 - Q1 robust dispersion
- RollingPercentileRank — self-normalising rank of the latest value
- SpreadAr1Coefficient — AR(1) rho of the spread a-b (cointegration /
  mean-reversion strength; complements OuHalfLife)

Full core + Python/Node/WASM bindings + fuzz + tests. Counter 377 -> 383.
Add four stateless per-bar OHLC transforms so feature extractors can
replace hand-built candle-geometry features natively:

- CloseVsOpen — signed body as a fraction of open, (close - open) / open
- BodySizePct — absolute body as a fraction of the bar range [0, 1]
- WickRatio — signed upper-vs-lower shadow imbalance over the range [-1, 1]
- HighLowRange — bar range as a fraction of close (scale-free volatility)

All param-free Candle -> f64, warmup 1. Full core + Python/Node/WASM
bindings (full-OHLC, open-aware) + fuzz + tests. Counter 383 -> 387.
Add three discrete {-1, 0, +1} state classifiers so feature extractors
can replace bespoke labelling logic with native streaming indicators:

- TrendLabel — sign of the rolling OLS slope (scale-invariant trend state)
- JumpIndicator — return outliers beyond threshold x trailing volatility,
  measured as deviation from the trailing mean so steady drift is not flagged
- RegimeLabel — volatility-quantile regime split (calm/-1, normal/0,
  stressed/+1) by where the rolling volatility sits in its own recent
  distribution

Full core + Python/Node/WASM bindings + fuzz + tests. Counter 387 -> 390.
Add two rolling risk/performance statistics over a return stream so
feature extractors can replace bespoke trade-stat tracking natively:

- WinRate — fraction of strictly-positive returns over the window [0, 1]
- Expectancy — expected return per unit of average loss (R-multiple);
  0 when the window has no losing returns (no risk reference)

Full core + Python/Node/WASM bindings + fuzz + tests. Counter 390 -> 392.
Add four order-book / trade-flow microstructure indicators on the
existing OrderBook and Trade inputs (no new input type) so feature
extractors can replace bespoke microstructure features natively:

- OrderFlowImbalance — rolling sum of best-level order-flow events
  (Cont-Kukanov-Stoikov OFI)
- Vpin — volume-synchronised probability of informed trading (toxicity)
- AmihudIlliquidity — average absolute return per unit of traded value
- RollMeasure — effective spread from the serial covariance of price changes

Queue Imbalance is intentionally not added: it is exactly the existing
OrderBookImbalanceTop1 ((bidSize - askSize) / (bidSize + askSize)).

Full core + custom Python/Node/WASM bindings + fuzz + dedicated tests.
Counter 392 -> 396.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Pin the by-construction-unreachable empty-side branch (reachable only via
OrderBook::new_unchecked) for 100% patch coverage.
@kingchenc kingchenc merged commit fcb221e into main Jun 4, 2026
38 checks passed
kingchenc added a commit that referenced this pull request Jun 4, 2026
Version bump 0.5.3 -> 0.5.4 for the release that ships the 19 external-feature-coverage indicators (#175, 377 -> 396).

Bumped: Cargo workspace + wickra-core dep, Cargo.lock (cargo build), pyproject.toml, node package.json (+6 optionalDependencies), 6 npm platform package.json, both package-lock.json, CHANGELOG ([Unreleased] -> [0.5.4]).

fmt/test/clippy green locally.
kingchenc added a commit to wickra-lib/wickra-docs that referenced this pull request Jun 4, 2026
Deep-dive documentation pages for the 19 indicators shipped in wickra-lib/wickra#175 (external feature-extractor coverage).

Families: price-statistics (SpreadAr1Coefficient, RealizedVolatility, LogReturn, RollingQuantile, RollingIqr, RollingPercentileRank), price-action (CloseVsOpen, BodySizePct, WickRatio, HighLowRange), regime/trend/jump labels (RegimeLabel, TrendLabel, JumpIndicator), risk/performance (WinRate, Expectancy), microstructure (AmihudIlliquidity, OrderFlowImbalance, RollMeasure, Vpin).

Sidebar, overview index, family table and warmup table updated; deep-dive page count -> 387. VitePress build verified green (no dead links).

Merge after the corresponding release publish (docs page count must not precede the registries).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant