@@ -34,71 +34,54 @@ jobs:
3434 }
3535 shell : pwsh
3636
37-
38- # - name: Launch MT5
39- # shell: pwsh
40- # run: |
41- # $mt5Path = Resolve-Path "C:\Program Files\MetaTrader 5\terminal64.exe"
42-
43- # # Launch with diagnostics
44- # Start-Process $mt5Path -ArgumentList @(
45- # "/portable",
46- # "/headless",
47- # "/config:config",
48- # "/noreport"
49- # ) -NoNewWindow
50-
51- # # Verify process start
52- # $attempts = 0
53- # while ($attempts -lt 10) {
54- # if (Get-Process terminal64 -ErrorAction SilentlyContinue) {
55- # Write-Host "MT5 process detected"
56- # break
57- # }
58- # $attempts++
59- # Start-Sleep 5
60- # }
61-
62- # if (-not (Get-Process terminal64 -ErrorAction SilentlyContinue)) {
63- # Get-Content ".\MetaTrader 5\logs\*.log" | Write-Host
64- # throw "MT5 failed to start"
65- # }
66-
67- - name : Install MetaTrader5 Python package
68- run : pip install MetaTrader5
69-
70- - name : Configure Server for MT5 (Headless)
71- shell : pwsh
72- run : |
73- $configPath = ".\MetaTrader 5\config"; New-Item -Path $configPath -ItemType Directory -Force; $serverConfig = @"FreeDemoServer,Demo,demo.server.com,443"@; Set-Content "$configPath\servers.dat" -Value $serverConfig; $accountConfig = @"demouser,demo_password,demo.server.com,443"@; Set-Content "$configPath\accounts.dat" -Value $accountConfig
74-
75- - name : Launch MT5 Headless
37+ - name : Launch MT5
7638 shell : pwsh
7739 run : |
7840 $mt5Path = Resolve-Path "C:\Program Files\MetaTrader 5\terminal64.exe"
79- Start-Process $mt5Path -ArgumentList @("/portable", "/headless", "/config:config", "/noreport") -NoNewWindow
80- Start-Sleep -Seconds 15
41+
42+ # Launch with diagnostics
43+ Start-Process $mt5Path -ArgumentList @(
44+ "/portable",
45+ "/headless",
46+ "/config:config",
47+ "/noreport"
48+ ) -NoNewWindow
49+
50+ # Verify process start
51+ $attempts = 0
52+ while ($attempts -lt 10) {
53+ if (Get-Process terminal64 -ErrorAction SilentlyContinue) {
54+ Write-Host "MT5 process detected"
55+ break
56+ }
57+ $attempts++
58+ Start-Sleep 5
59+ }
60+
8161 if (-not (Get-Process terminal64 -ErrorAction SilentlyContinue)) {
62+ Get-Content ".\MetaTrader 5\logs\*.log" | Write-Host
8263 throw "MT5 failed to start"
8364 }
8465
66+ - name : Install MetaTrader5 Python package
67+ run : pip install MetaTrader5
68+
8569 - name : Run MT5 Test
86- shell : pwsh
8770 run : |
8871 python -c "import os, MetaTrader5 as mt5
8972 print('Python version:', os.sys.version)
90- print('MetaTrader5 version:', mt5.__version__)
91- # print('MetaTrader5 Initialization:', mt5.initialize(path='C:\Program Files\MetaTrader 5\terminal64.exe', portable=True))
9273 for i in range(10):
9374 try:
75+ if mt5.initialize():
76+ print('MT5 initialized successfully')
77+ print('MetaTrader5 version:', mt5.__version__)
78+ # print('MetaTrader5 Initialization:', mt5.initialize(path='C:\Program Files\MetaTrader 5\terminal64.exe', portable=True))
79+ print(mt5.terminal_info())
80+ mt5.shutdown()
9481 if mt5.initialize(login=int(os.getenv('MT5_AT_ACC')),
9582 password=os.getenv('MT5_PW'),
9683 server=os.getenv('MT5_AT_SRV'),
9784 path="C:\\Program Files\\MetaTrader 5\\terminal64.exe"):
98- print('MT5 initialized successfully')
99- print(mt5.terminal_info())
100- mt5.shutdown()
101- exit(0)
10285 print(f'Attempt {i+1} failed')
10386 except Exception as e:
10487 print(f'Error: {str(e)}')
0 commit comments