em Fetch Type ao clicar abrir pop up para inserir API key e API Secret - Initial Deployment
Browse files- README.md +7 -5
- index.html +478 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: https-huggingface-co-spaces-olywwe-bibytprivate
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,478 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Bybit OrderBook Data Fetcher</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<script>
|
| 10 |
+
tailwind.config = {
|
| 11 |
+
theme: {
|
| 12 |
+
extend: {
|
| 13 |
+
colors: {
|
| 14 |
+
primary: '#1e293b',
|
| 15 |
+
secondary: '#0f172a',
|
| 16 |
+
accent: '#3b82f6',
|
| 17 |
+
bid: '#10b981',
|
| 18 |
+
ask: '#ef4444'
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
</script>
|
| 24 |
+
<style>
|
| 25 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 26 |
+
|
| 27 |
+
body {
|
| 28 |
+
font-family: 'Inter', sans-serif;
|
| 29 |
+
background-color: #0f172a;
|
| 30 |
+
color: #e2e8f0;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.orderbook-container {
|
| 34 |
+
height: 600px;
|
| 35 |
+
overflow-y: auto;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.orderbook-row {
|
| 39 |
+
transition: all 0.3s ease;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.orderbook-row:hover {
|
| 43 |
+
background-color: rgba(59, 130, 246, 0.1);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.depth-bar {
|
| 47 |
+
height: 100%;
|
| 48 |
+
position: absolute;
|
| 49 |
+
top: 0;
|
| 50 |
+
left: 0;
|
| 51 |
+
z-index: 0;
|
| 52 |
+
opacity: 0.2;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.loading-bar {
|
| 56 |
+
height: 4px;
|
| 57 |
+
background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
|
| 58 |
+
width: 0%;
|
| 59 |
+
transition: width 0.5s ease;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.pulse {
|
| 63 |
+
animation: pulse 2s infinite;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
@keyframes pulse {
|
| 67 |
+
0% { opacity: 0.5; }
|
| 68 |
+
50% { opacity: 1; }
|
| 69 |
+
100% { opacity: 0.5; }
|
| 70 |
+
}
|
| 71 |
+
</style>
|
| 72 |
+
</head>
|
| 73 |
+
<body class="min-h-screen">
|
| 74 |
+
<div class="container mx-auto px-4 py-8">
|
| 75 |
+
<!-- Header -->
|
| 76 |
+
<header class="mb-10 text-center">
|
| 77 |
+
<h1 class="text-3xl md:text-4xl font-bold mb-2">Bybit OrderBook Data Fetcher</h1>
|
| 78 |
+
<p class="text-gray-400 mb-6">Real-time order book data with support for 1000 depth levels</p>
|
| 79 |
+
|
| 80 |
+
<div class="bg-blue-900/30 border border-blue-700 rounded-lg p-4 max-w-3xl mx-auto">
|
| 81 |
+
<div class="flex items-start">
|
| 82 |
+
<i class="fas fa-info-circle text-blue-400 mt-1 mr-3"></i>
|
| 83 |
+
<div>
|
| 84 |
+
<h3 class="font-semibold text-blue-300 mb-1">API Update Information</h3>
|
| 85 |
+
<ul class="text-sm text-gray-300 space-y-1">
|
| 86 |
+
<li><span class="text-yellow-400">Aug 21, 2025:</span> OrderBook REST API now supports 1,000 depth levels (up from 500 for futures and 200 for spot)</li>
|
| 87 |
+
<li><span class="text-red-400">Sep 11, 2025:</span> WebSocket Futures OrderBook (500 depth levels) will be offline</li>
|
| 88 |
+
</ul>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
</header>
|
| 93 |
+
|
| 94 |
+
<!-- Controls -->
|
| 95 |
+
<div class="bg-primary rounded-xl p-6 mb-8 shadow-xl">
|
| 96 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
| 97 |
+
<div>
|
| 98 |
+
<label class="block text-sm font-medium mb-2">Select Symbol</label>
|
| 99 |
+
<div class="relative">
|
| 100 |
+
<select id="symbol-select" class="w-full bg-secondary border border-gray-700 rounded-lg py-3 px-4 appearance-none focus:outline-none focus:ring-2 focus:ring-accent">
|
| 101 |
+
<option>BTCUSDT</option>
|
| 102 |
+
<option>ETHUSDT</option>
|
| 103 |
+
<option>BNBUSDT</option>
|
| 104 |
+
<option>XRPUSDT</option>
|
| 105 |
+
<option>ADAUSDT</option>
|
| 106 |
+
<option>DOGEUSDT</option>
|
| 107 |
+
<option>MATICUSDT</option>
|
| 108 |
+
<option>SOLUSDT</option>
|
| 109 |
+
</select>
|
| 110 |
+
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-400">
|
| 111 |
+
<i class="fas fa-chevron-down"></i>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
<div>
|
| 117 |
+
<label class="block text-sm font-medium mb-2">Depth Levels</label>
|
| 118 |
+
<div class="relative">
|
| 119 |
+
<select id="depth-select" class="w-full bg-secondary border border-gray-700 rounded-lg py-3 px-4 appearance-none focus:outline-none focus:ring-2 focus:ring-accent">
|
| 120 |
+
<option value="10">10 Levels</option>
|
| 121 |
+
<option value="50">50 Levels</option>
|
| 122 |
+
<option value="100" selected>100 Levels</option>
|
| 123 |
+
<option value="500">500 Levels</option>
|
| 124 |
+
<option value="1000">1000 Levels (New)</option>
|
| 125 |
+
</select>
|
| 126 |
+
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-400">
|
| 127 |
+
<i class="fas fa-chevron-down"></i>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<div>
|
| 133 |
+
<label class="block text-sm font-medium mb-2">Fetch Type</label>
|
| 134 |
+
<div class="flex space-x-4">
|
| 135 |
+
<button id="rest-btn" class="flex-1 bg-accent text-white py-3 px-4 rounded-lg font-medium hover:bg-blue-500 transition">REST API</button>
|
| 136 |
+
<button id="ws-btn" class="flex-1 bg-gray-700 text-gray-300 py-3 px-4 rounded-lg font-medium hover:bg-gray-600 transition">WebSocket</button>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<div class="mt-6 flex justify-center">
|
| 142 |
+
<button id="fetch-btn" class="bg-gradient-to-r from-blue-600 to-indigo-700 hover:from-blue-500 hover:to-indigo-600 text-white font-bold py-3 px-8 rounded-full shadow-lg transform hover:scale-105 transition-all duration-300">
|
| 143 |
+
<i class="fas fa-sync-alt mr-2"></i> Fetch Order Book Data
|
| 144 |
+
</button>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
|
| 148 |
+
<!-- Loading Bar -->
|
| 149 |
+
<div class="loading-bar rounded-full mb-6" id="loading-bar"></div>
|
| 150 |
+
|
| 151 |
+
<!-- Data Display -->
|
| 152 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
| 153 |
+
<!-- Order Book -->
|
| 154 |
+
<div class="bg-primary rounded-xl p-6 shadow-xl">
|
| 155 |
+
<div class="flex justify-between items-center mb-6">
|
| 156 |
+
<h2 class="text-xl font-bold">Order Book <span id="symbol-display" class="text-accent">BTCUSDT</span></h2>
|
| 157 |
+
<div class="flex items-center space-x-2">
|
| 158 |
+
<span class="px-3 py-1 bg-gray-800 rounded-full text-sm">Level <span id="depth-display">100</span></span>
|
| 159 |
+
<span id="connection-status" class="px-3 py-1 bg-green-900/30 text-green-400 rounded-full text-sm">Connected</span>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
|
| 163 |
+
<div class="orderbook-container rounded-lg overflow-hidden border border-gray-800">
|
| 164 |
+
<!-- Asks -->
|
| 165 |
+
<div class="bg-gradient-to-r from-red-900/20 to-transparent p-3 text-sm font-medium">
|
| 166 |
+
<div class="grid grid-cols-3 gap-4">
|
| 167 |
+
<div>Price (USDT)</div>
|
| 168 |
+
<div class="text-right">Amount (BTC)</div>
|
| 169 |
+
<div class="text-right">Total (USDT)</div>
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<div id="asks-container">
|
| 174 |
+
<!-- Asks will be populated here -->
|
| 175 |
+
</div>
|
| 176 |
+
|
| 177 |
+
<!-- Market Price -->
|
| 178 |
+
<div class="bg-gray-900 py-3 text-center border-y border-gray-800">
|
| 179 |
+
<div class="text-2xl font-bold text-gray-200">$61,842.35</div>
|
| 180 |
+
<div class="text-sm text-gray-500">Market Price</div>
|
| 181 |
+
</div>
|
| 182 |
+
|
| 183 |
+
<!-- Bids -->
|
| 184 |
+
<div class="bg-gradient-to-r from-green-900/20 to-transparent p-3 text-sm font-medium">
|
| 185 |
+
<div class="grid grid-cols-3 gap-4">
|
| 186 |
+
<div>Price (USDT)</div>
|
| 187 |
+
<div class="text-right">Amount (BTC)</div>
|
| 188 |
+
<div class="text-right">Total (USDT)</div>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
<div id="bids-container">
|
| 193 |
+
<!-- Bids will be populated here -->
|
| 194 |
+
</div>
|
| 195 |
+
</div>
|
| 196 |
+
|
| 197 |
+
<div class="mt-4 flex justify-between text-sm text-gray-500">
|
| 198 |
+
<div><i class="fas fa-circle text-green-500 mr-1"></i> Bids (Buy Orders)</div>
|
| 199 |
+
<div>Asks <i class="fas fa-circle text-red-500 ml-1"></i> (Sell Orders)</div>
|
| 200 |
+
</div>
|
| 201 |
+
</div>
|
| 202 |
+
|
| 203 |
+
<!-- API Response -->
|
| 204 |
+
<div class="bg-primary rounded-xl p-6 shadow-xl">
|
| 205 |
+
<div class="flex justify-between items-center mb-6">
|
| 206 |
+
<h2 class="text-xl font-bold">API Response</h2>
|
| 207 |
+
<button id="copy-response" class="text-sm bg-gray-800 hover:bg-gray-700 py-1 px-3 rounded-lg flex items-center">
|
| 208 |
+
<i class="far fa-copy mr-1"></i> Copy
|
| 209 |
+
</button>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<div class="bg-secondary border border-gray-800 rounded-lg p-4 h-96 overflow-auto">
|
| 213 |
+
<pre id="response-output" class="text-sm text-gray-300 whitespace-pre-wrap">{/* API response will appear here */}</pre>
|
| 214 |
+
</div>
|
| 215 |
+
|
| 216 |
+
<div class="mt-4 bg-gray-900/50 rounded-lg p-4">
|
| 217 |
+
<h3 class="font-bold mb-2">API Documentation</h3>
|
| 218 |
+
<ul class="text-sm space-y-1">
|
| 219 |
+
<li class="flex items-start">
|
| 220 |
+
<i class="fas fa-link text-accent mt-1 mr-2 text-xs"></i>
|
| 221 |
+
<a href="https://bybit-exchange.github.io/docs/v5/market/orderbook" target="_blank" class="text-blue-400 hover:underline">OrderBook REST API</a>
|
| 222 |
+
</li>
|
| 223 |
+
<li class="flex items-start">
|
| 224 |
+
<i class="fas fa-link text-accent mt-1 mr-2 text-xs"></i>
|
| 225 |
+
<a href="https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook" target="_blank" class="text-blue-400 hover:underline">WebSocket OrderBook</a>
|
| 226 |
+
</li>
|
| 227 |
+
</ul>
|
| 228 |
+
</div>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
+
|
| 232 |
+
<!-- Footer -->
|
| 233 |
+
<footer class="mt-12 text-center text-gray-500 text-sm">
|
| 234 |
+
<p>Data provided by Bybit API • As of August 2025, REST API supports 1000 depth levels • WebSocket will be upgraded</p>
|
| 235 |
+
<p class="mt-2">© 2025 OrderBook Data Fetcher | This is a demo application</p>
|
| 236 |
+
</footer>
|
| 237 |
+
</div>
|
| 238 |
+
|
| 239 |
+
<script>
|
| 240 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 241 |
+
// DOM Elements
|
| 242 |
+
const fetchBtn = document.getElementById('fetch-btn');
|
| 243 |
+
const copyBtn = document.getElementById('copy-response');
|
| 244 |
+
const restBtn = document.getElementById('rest-btn');
|
| 245 |
+
const wsBtn = document.getElementById('ws-btn');
|
| 246 |
+
const symbolSelect = document.getElementById('symbol-select');
|
| 247 |
+
const depthSelect = document.getElementById('depth-select');
|
| 248 |
+
const symbolDisplay = document.getElementById('symbol-display');
|
| 249 |
+
const depthDisplay = document.getElementById('depth-display');
|
| 250 |
+
const asksContainer = document.getElementById('asks-container');
|
| 251 |
+
const bidsContainer = document.getElementById('bids-container');
|
| 252 |
+
const responseOutput = document.getElementById('response-output');
|
| 253 |
+
const loadingBar = document.getElementById('loading-bar');
|
| 254 |
+
const connectionStatus = document.getElementById('connection-status');
|
| 255 |
+
|
| 256 |
+
// State
|
| 257 |
+
let currentFetchType = 'rest';
|
| 258 |
+
let wsConnected = false;
|
| 259 |
+
let simulatedData = null;
|
| 260 |
+
|
| 261 |
+
// Initialize UI
|
| 262 |
+
updateFetchType('rest');
|
| 263 |
+
symbolSelect.addEventListener('change', updateSymbolDisplay);
|
| 264 |
+
depthSelect.addEventListener('change', updateDepthDisplay);
|
| 265 |
+
restBtn.addEventListener('click', () => updateFetchType('rest'));
|
| 266 |
+
wsBtn.addEventListener('click', () => updateFetchType('websocket'));
|
| 267 |
+
fetchBtn.addEventListener('click', fetchOrderBookData);
|
| 268 |
+
copyBtn.addEventListener('click', copyResponse);
|
| 269 |
+
updateSymbolDisplay();
|
| 270 |
+
updateDepthDisplay();
|
| 271 |
+
|
| 272 |
+
// Fetch Data
|
| 273 |
+
async function fetchOrderBookData() {
|
| 274 |
+
const symbol = symbolSelect.value;
|
| 275 |
+
const depth = depthSelect.value;
|
| 276 |
+
symbolDisplay.textContent = symbol;
|
| 277 |
+
depthDisplay.textContent = depth;
|
| 278 |
+
|
| 279 |
+
// Show loading
|
| 280 |
+
loadingBar.style.width = '30%';
|
| 281 |
+
loadingBar.classList.add('pulse');
|
| 282 |
+
|
| 283 |
+
try {
|
| 284 |
+
// Simulate API call
|
| 285 |
+
await new Promise(resolve => setTimeout(resolve, 800));
|
| 286 |
+
|
| 287 |
+
if (currentFetchType === 'rest') {
|
| 288 |
+
// Simulate REST API response (new 1000 levels support)
|
| 289 |
+
simulatedData = generateOrderBookData(symbol, depth);
|
| 290 |
+
displayOrderBook(simulatedData);
|
| 291 |
+
displayResponse(simulatedData);
|
| 292 |
+
loadingBar.style.width = '100%';
|
| 293 |
+
connectionStatus.textContent = 'Connected (REST)';
|
| 294 |
+
connectionStatus.className = 'px-3 py-1 bg-green-900/30 text-green-400 rounded-full text-sm';
|
| 295 |
+
} else {
|
| 296 |
+
// Simulate WebSocket connection
|
| 297 |
+
if (!wsConnected) {
|
| 298 |
+
simulateWebSocketConnection();
|
| 299 |
+
} else {
|
| 300 |
+
// Update with new data
|
| 301 |
+
simulatedData = generateOrderBookData(symbol, depth);
|
| 302 |
+
displayOrderBook(simulatedData);
|
| 303 |
+
displayResponse(simulatedData);
|
| 304 |
+
}
|
| 305 |
+
loadingBar.style.width = '100%';
|
| 306 |
+
connectionStatus.textContent = 'Connected (WebSocket)';
|
| 307 |
+
connectionStatus.className = 'px-3 py-1 bg-green-900/30 text-green-400 rounded-full text-sm';
|
| 308 |
+
}
|
| 309 |
+
} catch (error) {
|
| 310 |
+
loadingBar.style.width = '0%';
|
| 311 |
+
loadingBar.classList.remove('pulse');
|
| 312 |
+
connectionStatus.textContent = 'Connection Error';
|
| 313 |
+
connectionStatus.className = 'px-3 py-1 bg-red-900/30 text-red-400 rounded-full text-sm';
|
| 314 |
+
alert('Error fetching data: ' + error.message);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
// Remove pulse after completion
|
| 318 |
+
setTimeout(() => {
|
| 319 |
+
loadingBar.classList.remove('pulse');
|
| 320 |
+
}, 500);
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
// Simulate WebSocket connection
|
| 324 |
+
function simulateWebSocketConnection() {
|
| 325 |
+
connectionStatus.textContent = 'Connecting...';
|
| 326 |
+
connectionStatus.className = 'px-3 py-1 bg-yellow-900/30 text-yellow-400 rounded-full text-sm';
|
| 327 |
+
|
| 328 |
+
setTimeout(() => {
|
| 329 |
+
wsConnected = true;
|
| 330 |
+
simulatedData = generateOrderBookData(symbolSelect.value, depthSelect.value);
|
| 331 |
+
displayOrderBook(simulatedData);
|
| 332 |
+
displayResponse(simulatedData);
|
| 333 |
+
|
| 334 |
+
// Simulate periodic updates
|
| 335 |
+
setInterval(() => {
|
| 336 |
+
if (wsConnected && currentFetchType === 'websocket') {
|
| 337 |
+
simulatedData = generateOrderBookData(symbolSelect.value, depthSelect.value);
|
| 338 |
+
displayOrderBook(simulatedData);
|
| 339 |
+
displayResponse(simulatedData);
|
| 340 |
+
}
|
| 341 |
+
}, 3000);
|
| 342 |
+
}, 1500);
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
// Update Fetch Type
|
| 346 |
+
function updateFetchType(type) {
|
| 347 |
+
currentFetchType = type;
|
| 348 |
+
if (type === 'rest') {
|
| 349 |
+
restBtn.classList.remove('bg-gray-700', 'text-gray-300');
|
| 350 |
+
restBtn.classList.add('bg-accent', 'text-white');
|
| 351 |
+
wsBtn.classList.remove('bg-accent', 'text-white');
|
| 352 |
+
wsBtn.classList.add('bg-gray-700', 'text-gray-300');
|
| 353 |
+
} else {
|
| 354 |
+
wsBtn.classList.remove('bg-gray-700', 'text-gray-300');
|
| 355 |
+
wsBtn.classList.add('bg-accent', 'text-white');
|
| 356 |
+
restBtn.classList.remove('bg-accent', 'text-white');
|
| 357 |
+
restBtn.classList.add('bg-gray-700', 'text-gray-300');
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
// Update symbol display
|
| 362 |
+
function updateSymbolDisplay() {
|
| 363 |
+
symbolDisplay.textContent = symbolSelect.value;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
// Update depth display
|
| 367 |
+
function updateDepthDisplay() {
|
| 368 |
+
depthDisplay.textContent = depthSelect.value;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
// Generate simulated order book data
|
| 372 |
+
function generateOrderBookData(symbol, depth) {
|
| 373 |
+
const data = {
|
| 374 |
+
symbol: symbol,
|
| 375 |
+
asks: [],
|
| 376 |
+
bids: [],
|
| 377 |
+
timestamp: new Date().toISOString(),
|
| 378 |
+
seq: Math.floor(Math.random() * 1000000),
|
| 379 |
+
u: Math.floor(Math.random() * 1000000)
|
| 380 |
+
};
|
| 381 |
+
|
| 382 |
+
const basePrice = 61842.35; // Base BTC price
|
| 383 |
+
const priceStep = 0.5; // Price increment between levels
|
| 384 |
+
const amountMin = 0.1;
|
| 385 |
+
const amountMax = 5.0;
|
| 386 |
+
|
| 387 |
+
// Generate asks (sell orders)
|
| 388 |
+
for (let i = 0; i < depth; i++) {
|
| 389 |
+
const price = basePrice + (i * priceStep);
|
| 390 |
+
const amount = (Math.random() * (amountMax - amountMin) + amountMin).toFixed(6);
|
| 391 |
+
const total = (price * amount).toFixed(2);
|
| 392 |
+
data.asks.push([price.toFixed(2), amount, total]);
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
// Generate bids (buy orders)
|
| 396 |
+
for (let i = 0; i < depth; i++) {
|
| 397 |
+
const price = basePrice - (i * priceStep);
|
| 398 |
+
const amount = (Math.random() * (amountMax - amountMin) + amountMin).toFixed(6);
|
| 399 |
+
const total = (price * amount).toFixed(2);
|
| 400 |
+
data.bids.push([price.toFixed(2), amount, total]);
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
return data;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
// Display order book
|
| 407 |
+
function displayOrderBook(data) {
|
| 408 |
+
// Clear containers
|
| 409 |
+
asksContainer.innerHTML = '';
|
| 410 |
+
bidsContainer.innerHTML = '';
|
| 411 |
+
|
| 412 |
+
// Find max total for depth bars
|
| 413 |
+
let maxTotal = 0;
|
| 414 |
+
[...data.asks, ...data.bids].forEach(order => {
|
| 415 |
+
const total = parseFloat(order[2]);
|
| 416 |
+
if (total > maxTotal) maxTotal = total;
|
| 417 |
+
});
|
| 418 |
+
|
| 419 |
+
// Display asks (reverse order so lowest is on top)
|
| 420 |
+
data.asks.slice().reverse().forEach(ask => {
|
| 421 |
+
const [price, amount, total] = ask;
|
| 422 |
+
const percentage = (total / maxTotal * 100).toFixed(2);
|
| 423 |
+
|
| 424 |
+
const row = document.createElement('div');
|
| 425 |
+
row.className = 'orderbook-row relative p-3 text-sm border-b border-gray-800 hover:bg-gray-800/50';
|
| 426 |
+
row.innerHTML = `
|
| 427 |
+
<div class="depth-bar bg-red-500" style="width: ${percentage}%"></div>
|
| 428 |
+
<div class="grid grid-cols-3 gap-4 relative z-10">
|
| 429 |
+
<div class="text-red-400 font-medium">${price}</div>
|
| 430 |
+
<div class="text-right">${amount}</div>
|
| 431 |
+
<div class="text-right">${total}</div>
|
| 432 |
+
</div>
|
| 433 |
+
`;
|
| 434 |
+
asksContainer.appendChild(row);
|
| 435 |
+
});
|
| 436 |
+
|
| 437 |
+
// Display bids
|
| 438 |
+
data.bids.forEach(bid => {
|
| 439 |
+
const [price, amount, total] = bid;
|
| 440 |
+
const percentage = (total / maxTotal * 100).toFixed(2);
|
| 441 |
+
|
| 442 |
+
const row = document.createElement('div');
|
| 443 |
+
row.className = 'orderbook-row relative p-3 text-sm border-b border-gray-800 hover:bg-gray-800/50';
|
| 444 |
+
row.innerHTML = `
|
| 445 |
+
<div class="depth-bar bg-green-500" style="width: ${percentage}%"></div>
|
| 446 |
+
<div class="grid grid-cols-3 gap-4 relative z-10">
|
| 447 |
+
<div class="text-green-400 font-medium">${price}</div>
|
| 448 |
+
<div class="text-right">${amount}</div>
|
| 449 |
+
<div class="text-right">${total}</div>
|
| 450 |
+
</div>
|
| 451 |
+
`;
|
| 452 |
+
bidsContainer.appendChild(row);
|
| 453 |
+
});
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
// Display API response
|
| 457 |
+
function displayResponse(data) {
|
| 458 |
+
responseOutput.textContent = JSON.stringify(data, null, 2);
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
// Copy response to clipboard
|
| 462 |
+
function copyResponse() {
|
| 463 |
+
const text = responseOutput.textContent;
|
| 464 |
+
navigator.clipboard.writeText(text).then(() => {
|
| 465 |
+
const originalText = copyBtn.innerHTML;
|
| 466 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 467 |
+
setTimeout(() => {
|
| 468 |
+
copyBtn.innerHTML = originalText;
|
| 469 |
+
}, 2000);
|
| 470 |
+
});
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
// Initial data fetch
|
| 474 |
+
fetchOrderBookData();
|
| 475 |
+
});
|
| 476 |
+
</script>
|
| 477 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=olywwe/https-huggingface-co-spaces-olywwe-bibytprivate" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 478 |
+
</html>
|