INNER CODE UNIT · Python
get_symbol_spec
flukelaster/ai-trading-agent · mt5_bridge/main.py:140
async def get_symbol_spec(symbol: str):
"""Return broker-side spec for a symbol (used by Symbol Config UI to validate + auto-fill)."""
if not ensure_connected():
return mt5_response(False, error="MT5 not connected")
info = mt5.symbol_info(symbol)
if info is None:
return mt5_response(False, error=f"Symbol {symbol} not found")
if not info.visible:
mt5.symbol_select(symbol, True)
info = mt5.symbol_info(symbol)
if info is None:
return mt5_response(False, error=f"Symbol {symbol} not available after select")
return mt5_response(True, data={
"symbol": info.name,
"digits": int(info.digits),
"point": float(info.point),
"volume_min": float(info.volume_min),
"volume_max": float(info.volume_max),