dixitramjendra commited on
Commit
f050c22
Β·
1 Parent(s): 8ea05dc

Re-apply optimizations: parallel fetching, detection time fix, and UI cleanup

Browse files
Files changed (2) hide show
  1. forex_macd_dashboard.html +10 -5
  2. forex_macd_strategy.py +19 -14
forex_macd_dashboard.html CHANGED
@@ -4,7 +4,7 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>ModelFX Dashboard</title>
8
  <style>
9
  :root {
10
  --bg-color: #0f172a;
@@ -314,6 +314,8 @@
314
  text-align: center;
315
  }
316
 
 
 
317
  /* History Table Styling */
318
  .history-table-container {
319
  width: 100%;
@@ -376,12 +378,13 @@
376
  <body>
377
  <div class="container">
378
  <header>
379
- <h1>πŸ’± ModelFX Dashboard</h1>
380
  <div class="subtitle">Multi-Timeframe Analysis: Trend β€’ Momentum β€’ Entry (Varies by Category)</div>
381
  <div id="visitorCounter"
382
  style="margin-top: 0.5rem; font-size: 0.9rem; color: var(--accent); font-weight: 600;">
383
  πŸ‘₯ Visitors: <span id="activeCount">...</span> Active β€’ <span id="visitorCount">...</span> Total
384
  </div>
 
385
  </header>
386
 
387
  <div class="tabs-container" id="tabs">
@@ -660,8 +663,8 @@
660
  </div>
661
  </div>
662
  <div class="signal-row" style="margin-top: 0.5rem; border-top: 1px solid #334155; padding-top: 0.5rem;">
663
- <span class="signal-label">Signal Time</span>
664
- <span class="signal-val" style="color: var(--text-secondary); font-size: 0.85rem;">${formatDate(inst.signal.time)}</span>
665
  </div>
666
  </div>
667
  `;
@@ -919,7 +922,7 @@
919
  }
920
 
921
  fetchData();
922
- setInterval(fetchData, 30000);
923
  setInterval(sendHeartbeat, 30000); // Send heartbeat every 30 seconds
924
 
925
  // Feedback Submission
@@ -952,6 +955,8 @@
952
  statusDiv.style.color = 'var(--bearish)';
953
  }
954
  });
 
 
955
  </script>
956
  </body>
957
 
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>BiasBuster Market Dashboard</title>
8
  <style>
9
  :root {
10
  --bg-color: #0f172a;
 
314
  text-align: center;
315
  }
316
 
317
+
318
+
319
  /* History Table Styling */
320
  .history-table-container {
321
  width: 100%;
 
378
  <body>
379
  <div class="container">
380
  <header>
381
+ <h1>πŸ’± BiasBuster Market Dashboard</h1>
382
  <div class="subtitle">Multi-Timeframe Analysis: Trend β€’ Momentum β€’ Entry (Varies by Category)</div>
383
  <div id="visitorCounter"
384
  style="margin-top: 0.5rem; font-size: 0.9rem; color: var(--accent); font-weight: 600;">
385
  πŸ‘₯ Visitors: <span id="activeCount">...</span> Active β€’ <span id="visitorCount">...</span> Total
386
  </div>
387
+
388
  </header>
389
 
390
  <div class="tabs-container" id="tabs">
 
663
  </div>
664
  </div>
665
  <div class="signal-row" style="margin-top: 0.5rem; border-top: 1px solid #334155; padding-top: 0.5rem;">
666
+ <span class="signal-label">Detection Time</span>
667
+ <span class="signal-val" style="color: var(--text-secondary); font-size: 0.85rem;" title="Candle Time: ${inst.signal.candle_time ? formatDate(inst.signal.candle_time) : 'N/A'}">${formatDate(inst.signal.time)}</span>
668
  </div>
669
  </div>
670
  `;
 
922
  }
923
 
924
  fetchData();
925
+ setInterval(fetchData, 10000);
926
  setInterval(sendHeartbeat, 30000); // Send heartbeat every 30 seconds
927
 
928
  // Feedback Submission
 
955
  statusDiv.style.color = 'var(--bearish)';
956
  }
957
  });
958
+
959
+
960
  </script>
961
  </body>
962
 
forex_macd_strategy.py CHANGED
@@ -11,6 +11,7 @@ import os
11
  from datetime import datetime
12
  from typing import List, Dict, Optional
13
  from pathlib import Path
 
14
 
15
  try:
16
  import yfinance as yf
@@ -504,7 +505,8 @@ def analyze_instrument(instrument: Dict) -> Dict:
504
  "tp2": tp2,
505
  "tp3": tp3,
506
  "tp_hits": [False, False, False],
507
- "time": e_last.name.isoformat(),
 
508
  "category": category
509
  }
510
  ACTIVE_SIGNALS[name] = final_signal
@@ -538,7 +540,8 @@ def analyze_instrument(instrument: Dict) -> Dict:
538
  "tp2": tp2,
539
  "tp3": tp3,
540
  "tp_hits": [False, False, False],
541
- "time": e_last.name.isoformat(),
 
542
  "category": category
543
  }
544
  ACTIVE_SIGNALS[name] = final_signal
@@ -594,21 +597,22 @@ def analyze_instrument(instrument: Dict) -> Dict:
594
 
595
  def main():
596
  print("=" * 60)
597
- print("πŸ’± FOREX MACD MULTI-TIMEFRAME STRATEGY")
598
  print("=" * 60)
599
 
600
  while True:
601
  try:
 
602
  print(f"\nπŸ”„ Running analysis {datetime.now().strftime('%H:%M:%S')}...")
603
- results = []
604
 
605
- for inst in CONFIG['instruments']:
606
- res = analyze_instrument(inst)
607
- if res:
608
- results.append(res)
609
- print(f" πŸ‘‰ {res['instrument']}: {res['overall_status']}")
610
- if res['signal']:
611
- print(f" βœ… SIGNAL: {res['signal']['type']} @ {res['signal']['entry_price']:.5f}")
 
612
 
613
  # Save to JSON
614
  output = {
@@ -623,13 +627,14 @@ def main():
623
  with open(json_path, "w") as f:
624
  json.dump(output, f, indent=2, default=str)
625
 
626
- print(f"πŸ’Ύ Saved to {json_path}")
 
627
 
628
  except Exception as e:
629
  print(f"❌ Error: {e}")
630
 
631
- print("⏳ Waiting 300s (5 min)...")
632
- time.sleep(300)
633
 
634
  if __name__ == "__main__":
635
  main()
 
11
  from datetime import datetime
12
  from typing import List, Dict, Optional
13
  from pathlib import Path
14
+ from concurrent.futures import ThreadPoolExecutor
15
 
16
  try:
17
  import yfinance as yf
 
505
  "tp2": tp2,
506
  "tp3": tp3,
507
  "tp_hits": [False, False, False],
508
+ "time": datetime.now().isoformat(),
509
+ "candle_time": e_last.name.isoformat(),
510
  "category": category
511
  }
512
  ACTIVE_SIGNALS[name] = final_signal
 
540
  "tp2": tp2,
541
  "tp3": tp3,
542
  "tp_hits": [False, False, False],
543
+ "time": datetime.now().isoformat(),
544
+ "candle_time": e_last.name.isoformat(),
545
  "category": category
546
  }
547
  ACTIVE_SIGNALS[name] = final_signal
 
597
 
598
  def main():
599
  print("=" * 60)
600
+ print("πŸ’± BIASBUSTER MARKET DASHBOARD STRATEGY")
601
  print("=" * 60)
602
 
603
  while True:
604
  try:
605
+ start_time = time.time()
606
  print(f"\nπŸ”„ Running analysis {datetime.now().strftime('%H:%M:%S')}...")
 
607
 
608
+ # Parallel analysis using ThreadPoolExecutor
609
+ with ThreadPoolExecutor(max_workers=10) as executor:
610
+ results = list(filter(None, executor.map(analyze_instrument, CONFIG['instruments'])))
611
+
612
+ for res in results:
613
+ print(f" πŸ‘‰ {res['instrument']}: {res['overall_status']}")
614
+ if res['signal']:
615
+ print(f" βœ… SIGNAL: {res['signal']['type']} @ {res['signal']['entry_price']:.5f}")
616
 
617
  # Save to JSON
618
  output = {
 
627
  with open(json_path, "w") as f:
628
  json.dump(output, f, indent=2, default=str)
629
 
630
+ duration = time.time() - start_time
631
+ print(f"πŸ’Ύ Saved to {json_path} (Cycle time: {duration:.2f}s)")
632
 
633
  except Exception as e:
634
  print(f"❌ Error: {e}")
635
 
636
+ print("⏳ Waiting 60s (1 min)...")
637
+ time.sleep(60)
638
 
639
  if __name__ == "__main__":
640
  main()