import os import MetaTrader5 as mt5 import json # # get config data # with open('config.json', 'r') as f: # config = json.load(f) # MT5_PATHWAY = config.get("mt5Pathway", r"C:\Users\wkimu\AppData\Roaming\FundedNext MT5 Terminal\terminal64.exe") # # Ensure the path exists # if not os.path.exists(MT5_PATHWAY): # print(f"MT5 terminal path does not exist: {MT5_PATHWAY}") # exit(1) # Initialize connection if not mt5.initialize(): print("MT5 connection failed") print("Error code:", mt5.last_error()) else: print("MT5 connected successfully") # Account details account_info = mt5.account_info() if account_info is not None: print("Account Info:") print(account_info) else: print("Failed to get account info:", mt5.last_error()) # Test fetching tick data symbol = "EURUSD" tick = mt5.symbol_info_tick(symbol) if tick: print(f"Latest tick for {symbol}:") print(tick) else: print(f"Failed to get tick for {symbol}. Error:", mt5.last_error()) # Close connection mt5.shutdown()