UNPKG

skayn-trading-sdk

Version:

Professional Bitcoin trading strategy backtesting framework with institutional-grade architecture

157 lines (141 loc) 4.63 kB
/** * Notification Provider Interface * Defines contract for sending alerts and notifications */ class INotificationProvider { /** * Initialize the notification provider * @param {Object} config - Notification configuration */ async initialize(config = {}) { throw new Error('INotificationProvider.initialize() must be implemented'); } /** * Send a trading alert * @param {string} title - Alert title * @param {string} message - Alert message * @param {string} level - Alert level (info, warning, error, critical) * @param {Object} metadata - Additional alert data * @returns {Promise<Object>} Send result */ async sendAlert(title, message, level = 'info', metadata = {}) { throw new Error('INotificationProvider.sendAlert() must be implemented'); } /** * Send trade execution notification * @param {Object} trade - Trade details * @param {string} action - Trade action (open, close, update) * @returns {Promise<Object>} Send result */ async sendTradeNotification(trade, action) { throw new Error('INotificationProvider.sendTradeNotification() must be implemented'); } /** * Send performance summary * @param {Object} performance - Performance metrics * @param {string} period - Time period (daily, weekly, monthly) * @returns {Promise<Object>} Send result */ async sendPerformanceSummary(performance, period = 'daily') { throw new Error('INotificationProvider.sendPerformanceSummary() must be implemented'); } /** * Send system health status * @param {Object} healthData - System health information * @returns {Promise<Object>} Send result */ async sendHealthStatus(healthData) { throw new Error('INotificationProvider.sendHealthStatus() must be implemented'); } /** * Send custom notification * @param {Object} notification - Custom notification data * @returns {Promise<Object>} Send result */ async sendCustomNotification(notification) { throw new Error('INotificationProvider.sendCustomNotification() must be implemented'); } /** * Set notification preferences * @param {Object} preferences - Notification preferences */ setPreferences(preferences) { throw new Error('INotificationProvider.setPreferences() must be implemented'); } /** * Get supported notification channels * @returns {Array} Array of supported channels */ getSupportedChannels() { throw new Error('INotificationProvider.getSupportedChannels() must be implemented'); } /** * Test notification delivery * @param {string} channel - Channel to test * @returns {Promise<Object>} Test result */ async testNotification(channel) { throw new Error('INotificationProvider.testNotification() must be implemented'); } /** * Get notification history * @param {Object} filters - Filter options * @returns {Promise<Array>} Array of sent notifications */ async getNotificationHistory(filters = {}) { throw new Error('INotificationProvider.getNotificationHistory() must be implemented'); } /** * Set rate limiting for notifications * @param {Object} limits - Rate limiting configuration */ setRateLimits(limits) { throw new Error('INotificationProvider.setRateLimits() must be implemented'); } /** * Enable/disable specific notification types * @param {string} type - Notification type * @param {boolean} enabled - Whether to enable */ setNotificationEnabled(type, enabled) { throw new Error('INotificationProvider.setNotificationEnabled() must be implemented'); } /** * Format message for specific channel * @param {string} message - Raw message * @param {string} channel - Target channel * @returns {string} Formatted message */ formatMessage(message, channel) { // Default implementation - can be overridden return message; } /** * Get notification provider metadata * @returns {Object} Provider information */ getNotificationProviderMetadata() { return { name: 'Unknown Notification Provider', version: '1.0.0', description: 'Base notification provider interface', supportedChannels: [], maxMessageLength: 1000, rateLimitPerMinute: 60 }; } /** * Check provider health/connectivity * @returns {Promise<Object>} Health status */ async healthCheck() { throw new Error('INotificationProvider.healthCheck() must be implemented'); } /** * Cleanup resources */ async cleanup() { // Optional cleanup - override if needed } } module.exports = INotificationProvider;