diff --git a/core/mt5/trade.py b/core/mt5/trade.py index ca7cc6c..b37ba3f 100644 --- a/core/mt5/trade.py +++ b/core/mt5/trade.py @@ -112,7 +112,7 @@ def place_trade(symbol, order_type, risk_percent, sl_atr_multiplier, tp_atr_mult "magic": magic_id, "comment": "QuantumBotX Trade", "type_time": mt5.ORDER_TIME_GTC, - "type_filling": mt5.ORDER_FILLING_FOK, + "type_filling": mt5.ORDER_FILLING_IOC, } result = mt5.order_send(request) @@ -137,7 +137,7 @@ def close_trade(position): request = { "action": mt5.TRADE_ACTION_DEAL, "position": position.ticket, "symbol": position.symbol, "volume": position.volume, "type": close_order_type, "price": price, "magic": position.magic, - "comment": "QuantumBotX Close", "type_time": mt5.ORDER_TIME_GTC, "type_filling": mt5.ORDER_FILLING_FOK, + "comment": "QuantumBotX Close", "type_time": mt5.ORDER_TIME_GTC, "type_filling": mt5.ORDER_FILLING_IOC, } result = mt5.order_send(request) diff --git a/core/utils/mt5.py b/core/utils/mt5.py index 3274ed2..d4a4470 100644 --- a/core/utils/mt5.py +++ b/core/utils/mt5.py @@ -178,22 +178,24 @@ def find_mt5_symbol(base_symbol: str) -> Optional[str]: if base_symbol_cleaned in BROKER_SYMBOL_MAP: symbol_variants = BROKER_SYMBOL_MAP[base_symbol_cleaned] - # Prioritize based on broker + # Broker-specific priority (only for XAUUSD/GOLD variants) + # IMPORTANT: guard with base_symbol_cleaned check to avoid + # overwriting symbol_variants for EURUSD, GBPUSD, etc. if 'XM' in broker_name: - # XM Global: prioritize GOLD, GOLDmicro - symbol_variants = ['GOLD', 'GOLDmicro', 'XAUUSD'] + [s for s in symbol_variants if s not in ['GOLD', 'GOLDmicro', 'XAUUSD']] + if base_symbol_cleaned == 'XAUUSD': + symbol_variants = ['GOLD', 'GOLDmicro', 'XAUUSD'] + [s for s in symbol_variants if s not in ['GOLD', 'GOLDmicro', 'XAUUSD']] elif 'DEMO' in broker_name or 'METAQUOTES' in broker_name: - # MetaTrader Demo: prioritize XAUUSD - symbol_variants = ['XAUUSD', 'GOLD'] + [s for s in symbol_variants if s not in ['XAUUSD', 'GOLD']] + if base_symbol_cleaned == 'XAUUSD': + symbol_variants = ['XAUUSD', 'GOLD'] + [s for s in symbol_variants if s not in ['XAUUSD', 'GOLD']] elif 'EXNESS' in broker_name: - # Exness: prioritize XAUUSDm, GOLD - symbol_variants = ['XAUUSDm', 'GOLD', 'XAUUSD'] + [s for s in symbol_variants if s not in ['XAUUSDm', 'GOLD', 'XAUUSD']] + if base_symbol_cleaned == 'XAUUSD': + symbol_variants = ['XAUUSDm', 'GOLD', 'XAUUSD'] + [s for s in symbol_variants if s not in ['XAUUSDm', 'GOLD', 'XAUUSD']] elif 'ALPARI' in broker_name: - # Alpari: prioritize XAUUSD.c - symbol_variants = ['XAUUSD.c', 'XAUUSD'] + [s for s in symbol_variants if s not in ['XAUUSD.c', 'XAUUSD']] + if base_symbol_cleaned == 'XAUUSD': + symbol_variants = ['XAUUSD.c', 'XAUUSD'] + [s for s in symbol_variants if s not in ['XAUUSD.c', 'XAUUSD']] elif 'FBS' in broker_name: - # FBS: typically uses standard naming - symbol_variants = ['XAUUSD', 'GOLD'] + [s for s in symbol_variants if s not in ['XAUUSD', 'GOLD']] + if base_symbol_cleaned == 'XAUUSD': + symbol_variants = ['XAUUSD', 'GOLD'] + [s for s in symbol_variants if s not in ['XAUUSD', 'GOLD']] # Test each variant in priority order for variant in symbol_variants: