Context:
Users need to see real-time performance of signals (P&L, success rate) to make informed decisions. Signal providers earn reputation based on outcomes.
Problem:
Create a system that tracks signal outcomes, calculates P&L, updates provider statistics, and triggers notifications.
What Done Looks Like:
- Background job that monitors signal outcomes
- P&L calculation based on market prices
- Provider reputation scoring
- Signal status updates (ACTIVE → CLOSED)
- Performance history aggregation
Folder Structure:
src/
├── signals/
│ ├── services/
│ │ ├── signal-performance.service.ts
│ │ └── provider-stats.service.ts
│ ├── jobs/
│ │ └── track-signal-outcomes.job.ts
│ └── entities/
│ └── signal-performance.entity.ts
Implementation Guidelines:
- Use Bull queue for background processing
- Run performance check every 5 minutes
- Fetch current prices from SDEX
- Calculate P&L:
(currentPrice - entryPrice) / entryPrice * 100
- Update signal status when target/stop-loss hit
- Aggregate provider stats: total signals, win rate, avg P&L
- Emit events for notifications
Metrics to Track:
- Current P&L percentage
- Max drawdown
- Time to target/stop-loss
- Number of copiers
- Total volume copied
Edge Cases:
- Asset not trading on SDEX
- Price feed unavailable
- Signal expires before hitting target/stop-loss
Validation:
- Performance updates correctly
- Provider stats aggregate accurately
- Status transitions work
- Background job runs on schedule
Context:
Users need to see real-time performance of signals (P&L, success rate) to make informed decisions. Signal providers earn reputation based on outcomes.
Problem:
Create a system that tracks signal outcomes, calculates P&L, updates provider statistics, and triggers notifications.
What Done Looks Like:
Folder Structure:
Implementation Guidelines:
(currentPrice - entryPrice) / entryPrice * 100Metrics to Track:
Edge Cases:
Validation: