-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave program
Description
Outlier Detection and Filtering Service
📝 Description
Implement an outlier detection service that identifies and filters anomalous or suspicious data before aggregation. This service should use multiple statistical techniques to detect prices that deviate significantly from consensus or are technically impossible (negative prices, >50% changes in seconds, etc.).
Context: Data from external APIs can have errors, glitches, or be manipulated. It's critical to filter this data before aggregating to avoid contaminating the consensus price that will be published on-chain.
Tech Stack:
- NestJS Service
- Statistical algorithms (IQR, Z-score, MAD)
- RxJS for stream processing
- TypeScript with strict types
✅ Requirements
- Implement an
OutlierDetectionServicewith multiple detection strategies - Detect prices outside reasonable ranges (e.g., negative price, >50% change)
- Implement IQR-based detection (Interquartile Range)
- Implement Z-score-based detection (standard deviation)
- Implement MAD-based detection (Median Absolute Deviation)
- Configure adjustable thresholds via environment variables
- Mark outliers instead of discarding them (for later analysis)
- Calculate data quality metrics per source
- Implement logging of detected outliers for debugging
🎯 Acceptance Criteria
- The service correctly detects negative or zero prices
- At least 3 outlier detection methods are implemented
- Thresholds are configurable via environment variables
- Outliers are marked with metadata explaining why they were detected
- Data quality metrics are generated per source (% of outliers)
- Unit tests exist with edge cases (>85% coverage)
- Each detection strategy and its parameters are documented
- The service doesn't crash with empty or insufficient data
📁 Expected files to change/structure
apps/aggregator/src/services/outlier-detection.service.ts- Main serviceapps/aggregator/src/services/outlier-detection.service.spec.ts- Testsapps/aggregator/src/strategies/outlier-detectors/- Strategiesiqr-detector.tszscore-detector.tsmad-detector.tsrange-detector.ts
apps/aggregator/src/interfaces/outlier-result.interface.ts- Detection resultapps/aggregator/src/app.module.ts- Register serviceapps/aggregator/.env.example- Configuration variablesapps/aggregator/README.md- Document strategies
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave program