Skip to content

[Core] Expand TechnicalAnalysis: EMA, MACD, Bollinger Bands, VWAP, ATR, Stochastic + stateful RSI #4

@jackby03

Description

@jackby03

Summary

TechnicalAnalysis currently has SMA and a stateless RSI. A real trading platform needs a broader set of indicators, and RSI must use Wilder's smoothing (stateful) to match values produced by TradingView and most exchanges.

Indicators to add

Indicator Notes
EMA Exponential Moving Average
MACD EMA(12) - EMA(26) + Signal EMA(9)
Bollinger Bands SMA ± 2σ, return Upper/Mid/Lower
VWAP Cumulative since session open
ATR Average True Range (Wilder's)
Stochastic %K and %D

Stateful RSI fix

  • Current implementation recalculates full window every tick — O(n) each frame
  • Replace with Wilder's smoothing: AvgGain = (PrevAvgGain × 13 + Gain) / 14
  • Add a RsiState struct to carry state across ticks

Acceptance criteria

  • All 6 indicators listed above are implemented
  • RSI uses Wilder's smoothing and matches reference values within 0.01
  • Each indicator has a dedicated unit test with known input → expected output
  • No heap allocation in the hot path (use Span<float> where possible)

References

  • src/Omnijure.Core/Shared/Lib/Math/TechnicalAnalysis.cs
  • src/Omnijure.Core/Shared/Lib/Math/SimdOps.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions