@@ -34,71 +34,54 @@ jobs:
34
34
}
35
35
shell : pwsh
36
36
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
76
38
shell : pwsh
77
39
run : |
78
40
$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
+
81
61
if (-not (Get-Process terminal64 -ErrorAction SilentlyContinue)) {
62
+ Get-Content ".\MetaTrader 5\logs\*.log" | Write-Host
82
63
throw "MT5 failed to start"
83
64
}
84
65
66
+ - name : Install MetaTrader5 Python package
67
+ run : pip install MetaTrader5
68
+
85
69
- name : Run MT5 Test
86
- shell : pwsh
87
70
run : |
88
71
python -c "import os, MetaTrader5 as mt5
89
72
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))
92
73
for i in range(10):
93
74
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()
94
81
if mt5.initialize(login=int(os.getenv('MT5_AT_ACC')),
95
82
password=os.getenv('MT5_PW'),
96
83
server=os.getenv('MT5_AT_SRV'),
97
84
path="C:\\Program Files\\MetaTrader 5\\terminal64.exe"):
98
- print('MT5 initialized successfully')
99
- print(mt5.terminal_info())
100
- mt5.shutdown()
101
- exit(0)
102
85
print(f'Attempt {i+1} failed')
103
86
except Exception as e:
104
87
print(f'Error: {str(e)}')
0 commit comments