Clean notification system for trading applications with built-in providers for Telegram, Slack, and Discord.
- π± Built-in Providers: Telegram, Slack, Discord support
- π― Trading Focused: Trade, stop order, and portfolio notifications
- β‘ Async Processing: Concurrent message sending
- π Markdown Formatting: Clean markdown messages
- π§ Simple API: Easy to use and configure
- π¦ TypeScript Support: Full TypeScript definitions
- π― Lightweight: Minimal dependencies, small package size
npm install tracker-notificationimport {
NotificationManager,
TelegramNotificationProvider,
SlackNotificationProvider,
DiscordNotificationProvider,
TradeNotificationData
} from 'tracker-notification';
// Create notification manager
const manager = new NotificationManager();
// Add providers
const telegramProvider = new TelegramNotificationProvider({
botToken: 'your-bot-token',
chatId: 'your-chat-id',
parseMode: 'Markdown'
});
const slackProvider = new SlackNotificationProvider({
botToken: 'your-slack-token',
channelId: 'your-channel-id'
});
manager.addProvider(telegramProvider);
manager.addProvider(slackProvider);
// Send a trade notification
const tradeData: TradeNotificationData = {
symbol: 'BTCUSDT',
side: 'BUY',
quantity: '0.001',
price: '45000.00',
orderId: '12345678',
status: 'FILLED',
leverage: 10,
marginType: 'ISOLATED'
};
await manager.notifyTrade(tradeData); // Sends to all enabled providersimport { TelegramNotificationProvider } from 'tracker-notification';
const telegramProvider = new TelegramNotificationProvider({
botToken: '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',
chatId: '123456789',
parseMode: 'Markdown' // Optional, default: Markdown
});
manager.addProvider(telegramProvider);import { SlackNotificationProvider } from 'tracker-notification';
const slackProvider = new SlackNotificationProvider({
botToken: 'xoxb-your-slack-bot-token',
channelId: 'C0123456789',
username: 'Trading Bot' // Optional
});
manager.addProvider(slackProvider);const tradeData: TradeNotificationData = {
symbol: 'BTCUSDT',
side: 'BUY',
quantity: '0.001',
price: '45000.00',
orderId: '12345678',
status: 'FILLED',
leverage: 10,
marginType: 'ISOLATED'
};
await manager.notifyTrade(tradeData);const stopOrderData = {
type: 'take_profit' as const,
symbol: 'BTCUSDT',
price: '46000.00',
orderId: '87654321'
};
await manager.notifyStopOrder(stopOrderData);await manager.notifyCustom('Market analysis completed successfully');
await manager.notifyProvider('telegram', 'This goes only to Telegram');All messages are formatted in Markdown for consistency across platforms:
β
**Trade Executed**
π **LONG** BTCUSDT
π° **Quantity:** 0.001
π΅ **Price:** 45000.00
π **Order ID:** 12345678
π **Status:** FILLED
π **Time:** 30.10.2025 00:54:32
β‘ **Leverage:** 10x
π Isolated
addProvider(provider: NotificationProvider): void- Add a notification providerremoveProvider(providerName: string): boolean- Remove a provider by namenotifyTrade(data: TradeNotificationData): Promise<NotificationResult[]>- Send trade notificationnotifyStopOrder(data: StopOrderData): Promise<NotificationResult[]>- Send stop order notificationnotifyCustom(message: string): Promise<NotificationResult[]>- Send custom messagegetProviders(): NotificationProvider[]- Get all registered providers
formatTradeMessage(data: TradeNotificationData): string- Format trade messageformatStopOrderMessage(data: StopOrderData): string- Format stop order messageformatCustomMessage(message: string): string- Format custom messageformatErrorMessage(error: Error | string): string- Format error message
The system provides robust error handling with detailed results:
const results = await manager.notifyTrade(tradeData);
results.forEach(result => {
if (result.success) {
console.log(`β
${result.provider}: Message sent`);
} else {
console.log(`β ${result.provider}: ${result.error}`);
}
});MIT License - see LICENSE file for details.
Version: 1.0.0 Compatibility: Node.js 14+ TypeScript: Full support included