claw-crypto-monitor
v1.0.0
Published
Real-time cryptocurrency price monitoring and alert system with multi-exchange support and Redis caching
Maintainers
Readme
Claw Crypto Monitor
A professional real-time cryptocurrency price monitoring system with multi-exchange support, Redis caching, and alert capabilities.
Features
- Real-time price monitoring from multiple exchanges
- Redis caching for high-performance data storage
- WebSocket support for live updates
- Price alerts with customizable thresholds
- Multi-exchange support (Coinbase, Binance, etc.)
- TypeScript for type safety
- Express.js web server for API endpoints
- Winston logging for production monitoring
Installation
npm install claw-crypto-monitorQuick Start
const { cryptoMonitor } = require('claw-crypto-monitor');
// Get the monitor instance (singleton)
console.log('Crypto Monitor initialized:', cryptoMonitor.constructor.name);
// Start monitoring
cryptoMonitor.start();
// The monitor will automatically:
// 1. Fetch prices from configured exchanges
// 2. Cache results in Redis (if configured)
// 3. Provide real-time updates via WebSocket
// Get current prices
async function checkPrices() {
try {
// This would fetch current prices
console.log('Monitoring cryptocurrency prices...');
// In a real application, you would subscribe to events or call methods
} catch (error) {
console.error('Error:', error.message);
}
}
// Check prices periodically
setInterval(checkPrices, 30000); // Every 30 seconds
checkPrices(); // Initial checkAPI Documentation
CryptoMonitor Class
Constructor Options
interface MonitorOptions {
redisUrl?: string; // Redis connection URL
exchanges?: string[]; // List of exchanges to monitor
symbols?: string[]; // Trading pairs to track
updateInterval?: number;// Price update interval in seconds (default: 30)
cacheTTL?: number; // Redis cache TTL in seconds (default: 300)
}Methods
start(): Promise<void>- Start the monitoring servicestop(): Promise<void>- Stop the monitoring servicegetPrice(symbol: string): Promise<number>- Get current price for a symbolgetPrices(): Promise<Record<string, number>>- Get all current pricessetAlert(symbol: string, config: AlertConfig): void- Set price alertremoveAlert(symbol: string): void- Remove price alert
Events
priceUpdate- Fired when a price updatesalertTriggered- Fired when an alert threshold is crossederror- Fired on errors
Advanced Usage
Web Server Integration
const express = require('express');
const { CryptoMonitor } = require('claw-crypto-monitor');
const app = express();
const monitor = new CryptoMonitor();
// API endpoint to get current prices
app.get('/api/prices', async (req, res) => {
const prices = await monitor.getPrices();
res.json(prices);
});
// Start server and monitor
monitor.start();
app.listen(3000, () => {
console.log('Server running on port 3000');
});Redis Configuration
The monitor uses Redis for caching. Make sure Redis is running:
# Install Redis
sudo apt-get install redis-server
# Start Redis
sudo systemctl start redisDevelopment
# Clone the repository
git clone <repository-url>
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run tests
npm test
# Start development server
npm run devLicense
MIT © Claw Digital Familiar
