mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-29 03:37:45 +00:00
eb33b7c6ea
🔧 Core System Improvements: - Enhanced backtesting engine with realistic spread modeling and ATR-based risk management - Improved bot controller with better error handling and status tracking - Optimized MT5 integration with symbol verification and market watch integration - Strengthened database queries with better performance and reliability 🎯 New Strategy Features: - Added index strategies (Index Momentum, Index Breakout Pro) for stock market trading - Implemented market condition detector for dynamic strategy adaptation - Created performance scorer for strategy evaluation and ranking - Added strategy switcher system for automatic strategy optimization 📚 Educational Framework: - New beginner guide documentation for newcomer onboarding - Enhanced FAQ section with common trading questions - Quick start guide for rapid setup and deployment - Improved AI mentor integration with personalized guidance 🌍 Multi-Asset Expansion: - Extended data collection for 20+ trading instruments (Forex, Crypto, Indices) - Enhanced broker compatibility with FBS and other platforms - Improved symbol migration system for seamless broker switching - Added holiday integration for culturally-aware trading automation 🧪 Testing & Validation: - Added comprehensive index strategy testing suite - Enhanced holiday integration validation - Dynamic strategy signal testing for improved reliability - EURUSD optimization testing with London session focus ⚡ Performance & UI: - Frontend JavaScript optimizations for better trading bot management - Enhanced templates with improved user experience - Database migration system for smooth version upgrades - Optimized data download scripts for better efficiency 📊 Analytics & Monitoring: - Strengthened Flask application architecture with better routing - Improved logging system for production deployment - Enhanced error handling across all components - Better API response handling and status reporting
95 lines
3.5 KiB
Python
95 lines
3.5 KiB
Python
# core\utils\symbols.py
|
|
|
|
import MetaTrader5 as mt5
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# --- KONFIGURASI PENTING ---
|
|
# Cukup gunakan kata kunci umum yang ada di dalam path saham.
|
|
# Logika baru akan mencari kata-kata ini di mana saja dalam path.
|
|
# Contoh path: "Stocks\\USA2\\#AAPL" -> akan cocok dengan 'stocks'.
|
|
STOCK_KEYWORDS = ['stocks', 'stock', 'share', 'equity', 'saham']
|
|
|
|
# Prefix untuk Forex, berdasarkan output Anda: "path": "Forex\\AUDCAD"
|
|
FOREX_PREFIX = 'forex\\'
|
|
|
|
def get_all_symbols_from_mt5():
|
|
"""Fungsi helper untuk mengambil semua simbol dari MT5 dengan aman."""
|
|
try:
|
|
# Koneksi sudah diinisialisasi saat aplikasi pertama kali berjalan.
|
|
# Kita tidak perlu melakukan initialize() di sini lagi.
|
|
symbols = mt5.symbols_get() # pyright: ignore
|
|
if symbols:
|
|
return symbols
|
|
logger.warning("mt5.symbols_get() tidak mengembalikan simbol apapun.")
|
|
return []
|
|
except Exception as e:
|
|
logger.error(f"Error saat mengambil simbol dari MT5: {e}", exc_info=True)
|
|
return []
|
|
|
|
def get_stock_symbols(limit=20):
|
|
"""
|
|
Mengambil simbol saham, mengurutkannya berdasarkan volume harian tertinggi,
|
|
dan mengembalikan sejumlah 'limit' teratas.
|
|
"""
|
|
all_symbols = get_all_symbols_from_mt5()
|
|
stock_details = []
|
|
|
|
if not all_symbols:
|
|
return []
|
|
|
|
for s in all_symbols:
|
|
if any(keyword in s.path.lower() for keyword in STOCK_KEYWORDS):
|
|
# Pastikan simbol diaktifkan di Market Watch
|
|
if not mt5.symbol_select(s.name, True): # pyright: ignore
|
|
logger.warning(f"Gagal mengaktifkan simbol {s.name} di Market Watch")
|
|
continue
|
|
|
|
# Ambil info detail untuk mendapatkan volume
|
|
info = mt5.symbol_info(s.name) # pyright: ignore
|
|
if info:
|
|
stock_details.append({
|
|
"name": s.name,
|
|
"description": s.description,
|
|
# Gunakan volumehigh sebagai proksi untuk aktivitas/popularitas harian
|
|
"daily_volume": info.volumehigh
|
|
})
|
|
|
|
if not stock_details:
|
|
logger.warning(f"Tidak ada simbol saham yang ditemukan dengan kata kunci: {STOCK_KEYWORDS}. Periksa path simbol Anda dan konfigurasi di core/utils/symbols.py")
|
|
return []
|
|
|
|
# Urutkan daftar saham berdasarkan volume harian, dari tertinggi ke terendah
|
|
sorted_stocks = sorted(stock_details, key=lambda x: x.get('daily_volume', 0), reverse=True)
|
|
|
|
# Kembalikan hanya sejumlah 'limit' teratas
|
|
return sorted_stocks[:limit]
|
|
|
|
def get_forex_symbols():
|
|
"""Mengambil simbol forex berdasarkan filter path."""
|
|
all_symbols = get_all_symbols_from_mt5()
|
|
forex_list = []
|
|
|
|
if not all_symbols:
|
|
return []
|
|
|
|
for s in all_symbols:
|
|
if s.path.lower().startswith(FOREX_PREFIX):
|
|
# Pastikan simbol diaktifkan di Market Watch
|
|
if not mt5.symbol_select(s.name, True): # pyright: ignore
|
|
logger.warning(f"Gagal mengaktifkan simbol {s.name} di Market Watch")
|
|
continue
|
|
|
|
tick = mt5.symbol_info_tick(s.name) # pyright: ignore
|
|
if tick:
|
|
forex_list.append({
|
|
"name": s.name,
|
|
"description": s.description,
|
|
"ask": tick.ask,
|
|
"bid": tick.bid,
|
|
"spread": s.spread,
|
|
"digits": s.digits,
|
|
})
|
|
|
|
return forex_list |