mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-27 18:57:47 +00:00
Fix symbol mapping bug + filling mode for XM broker
- find_mt5_symbol: broker-specific priority (XM/MetaQuotes/Exness/etc) was overwriting symbol_variants for ALL symbols, not just XAUUSD. EURUSD/GBPUSD/etc were being mapped to GOLD on XM broker. Fixed by guarding with base_symbol_cleaned == 'XAUUSD' check. - place_trade: ORDER_FILLING_FOK → ORDER_FILLING_IOC for broker compatibility (XM and most forex brokers use IOC, not FOK). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -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)
|
||||
|
||||
+13
-11
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user