我需要通过 MT5Manager API(不是常规消费者版本)连接到 MetaQuotes 服务器。我仔细检查了凭据,但无法连接,没有任何有用的消息。
`from MT5Manager import ManagerAPI
def main():
# Initialize ManagerAPI object
# Specify server, login, and password
server = "MT5SERVER:443"
login = 1234 # Your MT5 account login
password = "*******************"
# Initialize ManagerAPI object with server, login, and password
manager = ManagerAPI(server=server, login=login, password=password)
# Connect to MetaTrader 5 Manager
res = manager.Connect()
if not res:
print("Failed to connect to MetaTrader 5 Manager")
return
# Subscribe to EURUSD ticks
if not manager.symbol_subscribe("EURUSD"):
print("Failed to subscribe to EURUSD ticks")
manager.disconnect()
return
# Retrieve ticks for EURUSD
ticks = manager.get_ticks("EURUSD")
if ticks is not None:
print("Ticks for EURUSD:")
for tick in ticks:
print(tick)
# Disconnect from MetaTrader 5 Manager
manager.disconnect()
if __name__ == "__main__":
main()
`
有什么建议吗?
Connect() 返回 False。
# include the library
import MT5Manager
# create the graphical interface
manager = MT5Manager.ManagerAPI()
# connect the server
if manager.Connect("192.168.1.100:443", 1001, "1234Qwe!",
MT5Manager.ManagerAPI.EnPumpModes.PUMP_MODE_USERS, 120000):
# get the list of managers on the server
managers = manager.UserGetByGroup("managers\\*")
# check the obtained list
if managers is not False:
print(f"There are {len(managers)} managers on server")
else:
# failed to get the list
print(f"Failed to get manager list: {MT5Manager.LastError()}")
# disconnect from the server
manager.Disconnect()
else:
# failed to connect to the server
print(f"Failed to connect to server: {MT5Manager.LastError()}")