Skip to content

Fix the issue

Fix the issue #38

name: Test | Test MetaTrader5 Initialization
on:
push:
branches: ['*']
pull_request:
jobs:
test:
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Download and Install MetaTrader 5
run: |
# Download MT5 setup
Invoke-WebRequest -Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" -OutFile mt5setup.exe
# Install MT5 silently
Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto" -Wait
# Verify installation
$mtPath = "C:\Program Files\MetaTrader 5\terminal64.exe"
if (Test-Path $mtPath) {
Write-Host "MetaTrader 5 installed successfully"
} else {
Write-Error "MetaTrader 5 installation failed"
exit 1
}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install MetaTrader5
# - name: Create MT5 portable configuration
# run: |
# # Create a portable MT5 directory
# mkdir -p "$env:APPDATA\MetaTrader5Portable"
# # Set environment variables to make MT5 run in headless mode
# echo "MT5_HEADLESS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# echo "MT5_PORTABLE_PATH=$env:APPDATA\MetaTrader5Portable" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# # Copy MT5 files to portable location if needed
# if (-not (Test-Path "$env:APPDATA\MetaTrader5Portable\terminal64.exe")) {
# Copy-Item -Path "C:\Program Files\MetaTrader 5\*" -Destination "$env:APPDATA\MetaTrader5Portable\" -Recurse
# }
# # Verify portable setup
# if (Test-Path "$env:APPDATA\MetaTrader5Portable\terminal64.exe") {
# Write-Host "MetaTrader 5 portable setup created successfully"
# } else {
# Write-Error "MetaTrader 5 portable setup failed"
# exit 1
# }
- name: Test MT5 initialization
run: |
# Run the MT5 initialization test script from the repository
python test/integration/test_mt5_initialization.py