dixitramjendra commited on
Commit
c7e0928
ยท
1 Parent(s): f0e4e80

Implement tabbed UI and categories

Browse files
Files changed (2) hide show
  1. forex_macd_dashboard.html +78 -2
  2. forex_macd_strategy.py +17 -16
forex_macd_dashboard.html CHANGED
@@ -218,6 +218,47 @@
218
  color: var(--text-secondary);
219
  font-size: 0.9rem;
220
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  </style>
222
  </head>
223
 
@@ -228,6 +269,13 @@
228
  <div class="subtitle">Multi-Timeframe Analysis: Daily Trend โ€ข 4H Momentum โ€ข 1H Entry</div>
229
  </header>
230
 
 
 
 
 
 
 
 
231
  <div id="dashboard" class="grid">
232
  <div style="grid-column: 1/-1; text-align: center; padding: 4rem;">
233
  Loading analysis data...
@@ -250,16 +298,38 @@
250
  }
251
  }
252
 
 
 
 
253
  async function fetchData() {
254
  try {
255
  const response = await fetch('forex_macd_signals.json');
256
  const data = await response.json();
 
257
  renderDashboard(data);
258
  } catch (error) {
259
  console.error('Error fetching data:', error);
260
  }
261
  }
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  function renderDashboard(data) {
264
  const container = document.getElementById('dashboard');
265
  const lastUpdated = document.getElementById('lastUpdated');
@@ -267,8 +337,14 @@
267
  container.innerHTML = '';
268
  lastUpdated.textContent = `Last Updated: ${new Date(data.last_updated).toLocaleString()}`;
269
 
 
 
 
 
 
 
270
  // Sort: Signals first, then active status, then others
271
- data.data.sort((a, b) => {
272
  const getPriority = (inst) => {
273
  if (inst.signal) return 2;
274
  if (inst.overall_status.includes('BUY') || inst.overall_status.includes('SELL')) return 1;
@@ -277,7 +353,7 @@
277
  return getPriority(b) - getPriority(a);
278
  });
279
 
280
- data.data.forEach(inst => {
281
  const card = document.createElement('div');
282
  card.className = 'card';
283
 
 
218
  color: var(--text-secondary);
219
  font-size: 0.9rem;
220
  }
221
+
222
+ /* Tabs Styling */
223
+ .tabs-container {
224
+ display: flex;
225
+ justify-content: center;
226
+ gap: 1rem;
227
+ margin-bottom: 2.5rem;
228
+ flex-wrap: wrap;
229
+ }
230
+
231
+ .tab-btn {
232
+ background: var(--card-bg);
233
+ color: var(--text-secondary);
234
+ border: 1px solid #334155;
235
+ padding: 0.75rem 1.5rem;
236
+ border-radius: 0.75rem;
237
+ cursor: pointer;
238
+ font-weight: 600;
239
+ transition: all 0.2s ease;
240
+ font-size: 1rem;
241
+ }
242
+
243
+ .tab-btn:hover {
244
+ border-color: var(--accent);
245
+ color: var(--text-primary);
246
+ }
247
+
248
+ .tab-btn.active {
249
+ background: var(--accent);
250
+ color: white;
251
+ border-color: var(--accent);
252
+ box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
253
+ }
254
+
255
+ .instrument-card-container {
256
+ display: block;
257
+ }
258
+
259
+ .instrument-card-container.hidden {
260
+ display: none;
261
+ }
262
  </style>
263
  </head>
264
 
 
269
  <div class="subtitle">Multi-Timeframe Analysis: Daily Trend โ€ข 4H Momentum โ€ข 1H Entry</div>
270
  </header>
271
 
272
+ <div class="tabs-container" id="tabs">
273
+ <button class="tab-btn active" onclick="filterCategory('All')">All Assets</button>
274
+ <button class="tab-btn" onclick="filterCategory('Forex')">Forex Pairs</button>
275
+ <button class="tab-btn" onclick="filterCategory('Metals/Energy')">Metals & Energy</button>
276
+ <button class="tab-btn" onclick="filterCategory('Cryptos')">Cryptocurrencies</button>
277
+ </div>
278
+
279
  <div id="dashboard" class="grid">
280
  <div style="grid-column: 1/-1; text-align: center; padding: 4rem;">
281
  Loading analysis data...
 
298
  }
299
  }
300
 
301
+ let currentCategory = 'All';
302
+ let cachedData = null;
303
+
304
  async function fetchData() {
305
  try {
306
  const response = await fetch('forex_macd_signals.json');
307
  const data = await response.json();
308
+ cachedData = data;
309
  renderDashboard(data);
310
  } catch (error) {
311
  console.error('Error fetching data:', error);
312
  }
313
  }
314
 
315
+ function filterCategory(category) {
316
+ currentCategory = category;
317
+
318
+ // Update active tab button
319
+ const buttons = document.querySelectorAll('.tab-btn');
320
+ buttons.forEach(btn => {
321
+ if (btn.textContent.includes(category) || (category === 'All' && btn.textContent.includes('All'))) {
322
+ btn.classList.add('active');
323
+ } else {
324
+ btn.classList.remove('active');
325
+ }
326
+ });
327
+
328
+ if (cachedData) {
329
+ renderDashboard(cachedData);
330
+ }
331
+ }
332
+
333
  function renderDashboard(data) {
334
  const container = document.getElementById('dashboard');
335
  const lastUpdated = document.getElementById('lastUpdated');
 
337
  container.innerHTML = '';
338
  lastUpdated.textContent = `Last Updated: ${new Date(data.last_updated).toLocaleString()}`;
339
 
340
+ // Filter by category
341
+ let filteredData = data.data;
342
+ if (currentCategory !== 'All') {
343
+ filteredData = data.data.filter(inst => inst.category === currentCategory);
344
+ }
345
+
346
  // Sort: Signals first, then active status, then others
347
+ filteredData.sort((a, b) => {
348
  const getPriority = (inst) => {
349
  if (inst.signal) return 2;
350
  if (inst.overall_status.includes('BUY') || inst.overall_status.includes('SELL')) return 1;
 
353
  return getPriority(b) - getPriority(a);
354
  });
355
 
356
+ filteredData.forEach(inst => {
357
  const card = document.createElement('div');
358
  card.className = 'card';
359
 
forex_macd_strategy.py CHANGED
@@ -22,22 +22,22 @@ except ImportError:
22
  # ================= CONFIGURATION =================
23
  CONFIG = {
24
  "instruments": [
25
- {"name": "US Oil (WTI)", "symbol": "CL=F", "pip_size": 0.01, "flag": "๐Ÿ›ข๏ธ"},
26
- {"name": "MCX Crude Oil", "symbol": "CL=F", "pip_size": 0.01, "flag": "๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ›ข๏ธ"},
27
- {"name": "Gold", "symbol": "GC=F", "pip_size": 0.1, "flag": "๐Ÿฅ‡"},
28
- {"name": "Silver", "symbol": "SI=F", "pip_size": 0.005, "flag": "๐Ÿฅˆ"},
29
- {"name": "EUR/USD", "symbol": "EURUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ"},
30
- {"name": "GBP/USD", "symbol": "GBPUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡บ๐Ÿ‡ธ"},
31
- {"name": "USD/JPY", "symbol": "USDJPY=X", "pip_size": 0.01, "flag": "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡ฏ๐Ÿ‡ต"},
32
- {"name": "AUD/USD", "symbol": "AUDUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ"},
33
- {"name": "USD/CHF", "symbol": "USDCHF=X", "pip_size": 0.0001, "flag": "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡จ๐Ÿ‡ญ"},
34
- {"name": "NZD/USD", "symbol": "NZDUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ณ๐Ÿ‡ฟ๐Ÿ‡บ๐Ÿ‡ธ"},
35
- {"name": "USD/CAD", "symbol": "USDCAD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡จ๐Ÿ‡ฆ"},
36
- {"name": "EUR/GBP", "symbol": "EURGBP=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡ฌ๐Ÿ‡ง"},
37
- {"name": "EUR/JPY", "symbol": "EURJPY=X", "pip_size": 0.01, "flag": "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡ฏ๐Ÿ‡ต"},
38
- {"name": "GBP/JPY", "symbol": "GBPJPY=X", "pip_size": 0.01, "flag": "๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ฏ๐Ÿ‡ต"},
39
- {"name": "Bitcoin", "symbol": "BTC-USD", "pip_size": 1.0, "flag": "โ‚ฟ"},
40
- {"name": "Ethereum", "symbol": "ETH-USD", "pip_size": 0.1, "flag": "ฮž"}
41
  ],
42
  "macd": {
43
  "fast": 12,
@@ -329,6 +329,7 @@ def analyze_instrument(instrument: Dict) -> Dict:
329
  },
330
  "overall_status": status,
331
  "signal": final_signal,
 
332
  "timestamp": datetime.now().isoformat()
333
  }
334
 
 
22
  # ================= CONFIGURATION =================
23
  CONFIG = {
24
  "instruments": [
25
+ {"name": "US Oil (WTI)", "symbol": "CL=F", "pip_size": 0.01, "flag": "๐Ÿ›ข๏ธ", "category": "Metals/Energy"},
26
+ {"name": "MCX Crude Oil", "symbol": "CL=F", "pip_size": 0.01, "flag": "๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ›ข๏ธ", "category": "Metals/Energy"},
27
+ {"name": "Gold", "symbol": "GC=F", "pip_size": 0.1, "flag": "๐Ÿฅ‡", "category": "Metals/Energy"},
28
+ {"name": "Silver", "symbol": "SI=F", "pip_size": 0.005, "flag": "๐Ÿฅˆ", "category": "Metals/Energy"},
29
+ {"name": "EUR/USD", "symbol": "EURUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ", "category": "Forex"},
30
+ {"name": "GBP/USD", "symbol": "GBPUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡บ๐Ÿ‡ธ", "category": "Forex"},
31
+ {"name": "USD/JPY", "symbol": "USDJPY=X", "pip_size": 0.01, "flag": "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡ฏ๐Ÿ‡ต", "category": "Forex"},
32
+ {"name": "AUD/USD", "symbol": "AUDUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ", "category": "Forex"},
33
+ {"name": "USD/CHF", "symbol": "USDCHF=X", "pip_size": 0.0001, "flag": "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡จ๐Ÿ‡ญ", "category": "Forex"},
34
+ {"name": "NZD/USD", "symbol": "NZDUSD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ณ๐Ÿ‡ฟ๐Ÿ‡บ๐Ÿ‡ธ", "category": "Forex"},
35
+ {"name": "USD/CAD", "symbol": "USDCAD=X", "pip_size": 0.0001, "flag": "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡จ๐Ÿ‡ฆ", "category": "Forex"},
36
+ {"name": "EUR/GBP", "symbol": "EURGBP=X", "pip_size": 0.0001, "flag": "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡ฌ๐Ÿ‡ง", "category": "Forex"},
37
+ {"name": "EUR/JPY", "symbol": "EURJPY=X", "pip_size": 0.01, "flag": "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡ฏ๐Ÿ‡ต", "category": "Forex"},
38
+ {"name": "GBP/JPY", "symbol": "GBPJPY=X", "pip_size": 0.01, "flag": "๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ฏ๐Ÿ‡ต", "category": "Forex"},
39
+ {"name": "Bitcoin", "symbol": "BTC-USD", "pip_size": 1.0, "flag": "โ‚ฟ", "category": "Cryptos"},
40
+ {"name": "Ethereum", "symbol": "ETH-USD", "pip_size": 0.1, "flag": "ฮž", "category": "Cryptos"}
41
  ],
42
  "macd": {
43
  "fast": 12,
 
329
  },
330
  "overall_status": status,
331
  "signal": final_signal,
332
+ "category": instrument.get('category', 'Other'),
333
  "timestamp": datetime.now().isoformat()
334
  }
335