17. docker deployment
This commit is contained in:
@ -3,185 +3,410 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>COBY - Market Data Dashboard</title>
|
||||
<link rel="stylesheet" href="/static/css/dashboard.css">
|
||||
<link rel="stylesheet" href="/static/css/heatmap.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://unpkg.com/d3@7"></script>
|
||||
<title>COBY - Multi-Exchange Data Aggregation</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #333;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
padding: 1rem 2rem;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
color: white;
|
||||
font-size: 2rem;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.header p {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
flex: 1;
|
||||
padding: 2rem;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.status-card {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 12px;
|
||||
padding: 1.5rem;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.status-card h3 {
|
||||
color: #333;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.status-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.status-dot.healthy {
|
||||
background: #4CAF50;
|
||||
box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
|
||||
}
|
||||
|
||||
.status-dot.warning {
|
||||
background: #FF9800;
|
||||
box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
|
||||
}
|
||||
|
||||
.status-dot.error {
|
||||
background: #F44336;
|
||||
box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
|
||||
}
|
||||
|
||||
.status-dot.unknown {
|
||||
background: #9E9E9E;
|
||||
}
|
||||
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
padding: 0.75rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 0.9rem;
|
||||
color: #666;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.error-message {
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
border: 1px solid rgba(244, 67, 54, 0.3);
|
||||
color: #F44336;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.refresh-button {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.refresh-button:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.footer {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
padding: 1rem 2rem;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.header {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.status-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- Header -->
|
||||
<header class="dashboard-header">
|
||||
<div class="header-content">
|
||||
<h1 class="logo">COBY</h1>
|
||||
<div class="header-info">
|
||||
<span class="connection-status" id="connectionStatus">Connecting...</span>
|
||||
<span class="last-update" id="lastUpdate">Never</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Dashboard -->
|
||||
<main class="dashboard-main">
|
||||
<!-- Symbol Selector -->
|
||||
<div class="symbol-selector">
|
||||
<select id="symbolSelect" class="symbol-dropdown">
|
||||
<option value="BTCUSDT">BTC/USDT</option>
|
||||
<option value="ETHUSDT">ETH/USDT</option>
|
||||
</select>
|
||||
<div class="exchange-toggles" id="exchangeToggles">
|
||||
<!-- Exchange toggles will be populated dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Market Overview Cards -->
|
||||
<div class="market-overview">
|
||||
<div class="metric-card">
|
||||
<h3>Mid Price</h3>
|
||||
<div class="metric-value" id="midPrice">--</div>
|
||||
<div class="metric-change" id="priceChange">--</div>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<h3>Spread</h3>
|
||||
<div class="metric-value" id="spread">--</div>
|
||||
<div class="metric-change" id="spreadChange">--</div>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<h3>Volume Imbalance</h3>
|
||||
<div class="metric-value" id="volumeImbalance">--</div>
|
||||
<div class="imbalance-bar" id="imbalanceBar"></div>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<h3>Liquidity Score</h3>
|
||||
<div class="metric-value" id="liquidityScore">--</div>
|
||||
<div class="liquidity-indicator" id="liquidityIndicator"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Heatmap Container -->
|
||||
<div class="heatmap-container">
|
||||
<div class="heatmap-header">
|
||||
<h2>Order Book Heatmap</h2>
|
||||
<div class="heatmap-controls">
|
||||
<button class="control-btn" id="zoomInBtn">Zoom In</button>
|
||||
<button class="control-btn" id="zoomOutBtn">Zoom Out</button>
|
||||
<button class="control-btn" id="resetZoomBtn">Reset</button>
|
||||
<label class="control-label">
|
||||
<input type="checkbox" id="smoothingToggle"> Smoothing
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="heatmap-wrapper">
|
||||
<div class="price-axis" id="priceAxis"></div>
|
||||
<div class="heatmap-canvas-container">
|
||||
<canvas id="heatmapCanvas" width="800" height="600"></canvas>
|
||||
<div class="heatmap-overlay" id="heatmapOverlay"></div>
|
||||
</div>
|
||||
<div class="volume-axis" id="volumeAxis"></div>
|
||||
</div>
|
||||
<div class="heatmap-legend">
|
||||
<div class="legend-item">
|
||||
<div class="legend-color bid-color"></div>
|
||||
<span>Bids</span>
|
||||
</div>
|
||||
<div class="legend-item">
|
||||
<div class="legend-color ask-color"></div>
|
||||
<span>Asks</span>
|
||||
</div>
|
||||
<div class="intensity-scale">
|
||||
<span>Low</span>
|
||||
<div class="intensity-gradient"></div>
|
||||
<span>High</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Side Panels -->
|
||||
<div class="side-panels">
|
||||
<!-- Order Book Panel -->
|
||||
<div class="panel order-book-panel">
|
||||
<h3>Order Book</h3>
|
||||
<div class="order-book-container">
|
||||
<div class="asks-section">
|
||||
<div class="section-header">Asks</div>
|
||||
<div class="order-levels" id="askLevels"></div>
|
||||
</div>
|
||||
<div class="spread-indicator" id="spreadIndicator">
|
||||
<span class="spread-value">Spread: --</span>
|
||||
</div>
|
||||
<div class="bids-section">
|
||||
<div class="section-header">Bids</div>
|
||||
<div class="order-levels" id="bidLevels"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Exchange Status Panel -->
|
||||
<div class="panel exchange-status-panel">
|
||||
<h3>Exchange Status</h3>
|
||||
<div class="exchange-list" id="exchangeList">
|
||||
<!-- Exchange status items will be populated dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistics Panel -->
|
||||
<div class="panel stats-panel">
|
||||
<h3>Statistics</h3>
|
||||
<div class="stats-grid" id="statsGrid">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Updates/sec</span>
|
||||
<span class="stat-value" id="updatesPerSec">0</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Total Points</span>
|
||||
<span class="stat-value" id="totalPoints">0</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Bid Points</span>
|
||||
<span class="stat-value" id="bidPoints">0</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Ask Points</span>
|
||||
<span class="stat-value" id="askPoints">0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="dashboard-footer">
|
||||
<div class="footer-content">
|
||||
<span>COBY Market Data Dashboard v1.0</span>
|
||||
<span id="systemStatus">System: Online</span>
|
||||
</div>
|
||||
</footer>
|
||||
<div class="header">
|
||||
<h1>COBY Dashboard</h1>
|
||||
<p>Multi-Exchange Data Aggregation System</p>
|
||||
</div>
|
||||
|
||||
<!-- Loading Overlay -->
|
||||
<div id="loadingOverlay" class="loading-overlay">
|
||||
<div class="loading-spinner"></div>
|
||||
<div class="loading-text">Loading market data...</div>
|
||||
</div>
|
||||
|
||||
<!-- Error Modal -->
|
||||
<div id="errorModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3>Error</h3>
|
||||
<button class="modal-close" id="errorModalClose">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p id="errorMessage">An error occurred</p>
|
||||
|
||||
<div class="container">
|
||||
<div id="error-container"></div>
|
||||
|
||||
<div id="loading" class="loading">
|
||||
<p>Loading system status...</p>
|
||||
</div>
|
||||
|
||||
<div id="dashboard" style="display: none;">
|
||||
<div class="status-grid">
|
||||
<div class="status-card">
|
||||
<h3>System Status</h3>
|
||||
<div id="system-status">
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot unknown"></div>
|
||||
<span>Checking system health...</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="refresh-button" onclick="refreshData()">Refresh</button>
|
||||
</div>
|
||||
|
||||
<div class="status-card">
|
||||
<h3>Exchange Connections</h3>
|
||||
<div id="exchange-status">
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot unknown"></div>
|
||||
<span>Loading exchange status...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-card">
|
||||
<h3>Performance Metrics</h3>
|
||||
<div class="metrics-grid" id="performance-metrics">
|
||||
<div class="metric-item">
|
||||
<div class="metric-label">CPU Usage</div>
|
||||
<div class="metric-value">--</div>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<div class="metric-label">Memory Usage</div>
|
||||
<div class="metric-value">--</div>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<div class="metric-label">Throughput</div>
|
||||
<div class="metric-value">--</div>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<div class="metric-label">Latency</div>
|
||||
<div class="metric-value">--</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-card">
|
||||
<h3>Data Processing</h3>
|
||||
<div id="processing-status">
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot unknown"></div>
|
||||
<span>Loading processing status...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="/static/js/websocket-client.js"></script>
|
||||
<script src="/static/js/heatmap-renderer.js"></script>
|
||||
<script src="/static/js/dashboard-controller.js"></script>
|
||||
<script src="/static/js/app.js"></script>
|
||||
|
||||
<div class="footer">
|
||||
<p>© 2024 COBY Multi-Exchange Data Aggregation System</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let ws = null;
|
||||
let reconnectAttempts = 0;
|
||||
const maxReconnectAttempts = 5;
|
||||
|
||||
// Initialize dashboard
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadInitialData();
|
||||
connectWebSocket();
|
||||
});
|
||||
|
||||
async function loadInitialData() {
|
||||
try {
|
||||
const response = await fetch('/api/health');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
updateSystemStatus(data);
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
document.getElementById('dashboard').style.display = 'block';
|
||||
} else {
|
||||
showError('Failed to load system status');
|
||||
}
|
||||
} catch (error) {
|
||||
showError('Unable to connect to COBY API: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function connectWebSocket() {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsUrl = `${protocol}//${window.location.host}/ws/dashboard`;
|
||||
|
||||
ws = new WebSocket(wsUrl);
|
||||
|
||||
ws.onopen = function() {
|
||||
console.log('WebSocket connected');
|
||||
reconnectAttempts = 0;
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
updateDashboard(data);
|
||||
} catch (error) {
|
||||
console.error('Error parsing WebSocket message:', error);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
console.log('WebSocket disconnected');
|
||||
if (reconnectAttempts < maxReconnectAttempts) {
|
||||
setTimeout(() => {
|
||||
reconnectAttempts++;
|
||||
connectWebSocket();
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = function(error) {
|
||||
console.error('WebSocket error:', error);
|
||||
};
|
||||
}
|
||||
|
||||
function updateSystemStatus(data) {
|
||||
const systemStatus = document.getElementById('system-status');
|
||||
const status = data.status || 'unknown';
|
||||
const healthy = status === 'healthy';
|
||||
|
||||
systemStatus.innerHTML = `
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot ${healthy ? 'healthy' : 'error'}"></div>
|
||||
<span>System ${healthy ? 'Healthy' : 'Unhealthy'}</span>
|
||||
</div>
|
||||
<p style="margin-top: 0.5rem; font-size: 0.9rem; color: #666;">
|
||||
Last updated: ${new Date(data.timestamp || Date.now()).toLocaleString()}
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
|
||||
function updateDashboard(data) {
|
||||
// Update performance metrics if available
|
||||
if (data.performance) {
|
||||
updatePerformanceMetrics(data.performance);
|
||||
}
|
||||
|
||||
// Update exchange status if available
|
||||
if (data.exchanges) {
|
||||
updateExchangeStatus(data.exchanges);
|
||||
}
|
||||
|
||||
// Update processing status if available
|
||||
if (data.processing) {
|
||||
updateProcessingStatus(data.processing);
|
||||
}
|
||||
}
|
||||
|
||||
function updatePerformanceMetrics(performance) {
|
||||
const metricsContainer = document.getElementById('performance-metrics');
|
||||
const metrics = [
|
||||
{ label: 'CPU Usage', value: `${(performance.cpu_usage || 0).toFixed(1)}%` },
|
||||
{ label: 'Memory Usage', value: `${(performance.memory_usage || 0).toFixed(1)}%` },
|
||||
{ label: 'Throughput', value: `${(performance.throughput || 0).toFixed(0)} ops/s` },
|
||||
{ label: 'Latency', value: `${(performance.avg_latency || 0).toFixed(1)}ms` }
|
||||
];
|
||||
|
||||
metricsContainer.innerHTML = metrics.map(metric => `
|
||||
<div class="metric-item">
|
||||
<div class="metric-label">${metric.label}</div>
|
||||
<div class="metric-value">${metric.value}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function updateExchangeStatus(exchanges) {
|
||||
const exchangeStatus = document.getElementById('exchange-status');
|
||||
const connectedCount = Object.values(exchanges).filter(status => status === 'connected').length;
|
||||
const totalCount = Object.keys(exchanges).length;
|
||||
|
||||
exchangeStatus.innerHTML = `
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot ${connectedCount === totalCount ? 'healthy' : connectedCount > 0 ? 'warning' : 'error'}"></div>
|
||||
<span>${connectedCount}/${totalCount} exchanges connected</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function updateProcessingStatus(processing) {
|
||||
const processingStatus = document.getElementById('processing-status');
|
||||
const isProcessing = processing.active || false;
|
||||
|
||||
processingStatus.innerHTML = `
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot ${isProcessing ? 'healthy' : 'warning'}"></div>
|
||||
<span>Data processing ${isProcessing ? 'active' : 'inactive'}</span>
|
||||
</div>
|
||||
<p style="margin-top: 0.5rem; font-size: 0.9rem; color: #666;">
|
||||
Processed: ${processing.total_processed || 0} events
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
const errorContainer = document.getElementById('error-container');
|
||||
errorContainer.innerHTML = `
|
||||
<div class="error-message">
|
||||
<strong>Error:</strong> ${message}
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
}
|
||||
|
||||
async function refreshData() {
|
||||
await loadInitialData();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user