Skip to content

Unit tests for signal engine (packages/core) #17

@naimkatiman

Description

@naimkatiman

Tests: Signal Engine Unit Test Coverage

Current state

The signal engine in packages/core/src/signals/engine.ts has little to no unit test coverage. This is a critical path — signal logic bugs directly affect users.

What to test

For each indicator function, write tests covering:

  1. RSI calculator

    • RSI > 70 → SELL vote
    • RSI < 30 → BUY vote
    • RSI 30–70 → HOLD vote
    • Edge cases: empty data, single candle
  2. MACD crossover

    • MACD crosses above signal line → BUY
    • MACD crosses below signal line → SELL
    • No crossover → HOLD
  3. Bollinger Band squeeze

    • Bands narrow (squeeze) + breakout up → BUY
    • Bands narrow (squeeze) + breakout down → SELL
  4. EMA crossover

    • 9 EMA crosses above 21 EMA → BUY
    • 9 EMA crosses below 21 EMA → SELL
  5. Signal aggregator

    • 4 BUY votes, 1 SELL → final signal = BUY
    • Verify confidence score calculation

Tech

  • Test framework: Jest or Vitest (match whatever is in package.json)
  • Mock OHLCV data: use fixture files in __tests__/fixtures/

Acceptance criteria

  • 80%+ line coverage on packages/core/src/signals/engine.ts
  • All indicator edge cases tested
  • Tests run via npm test in CI
  • No false positives (tests pass on correct logic, fail on broken logic)

Good first issue because

Pure unit tests — no infrastructure, no Docker, just TypeScript and test fixtures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions