File tree Expand file tree Collapse file tree 4 files changed +113
-0
lines changed Expand file tree Collapse file tree 4 files changed +113
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy | Semantic Release
2+
3+ on :
4+ push :
5+ branches :
6+ - " main"
7+ jobs :
8+ release :
9+ runs-on : windows-latest
10+ concurrency : release
11+ permissions :
12+ contents : write
13+
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 0
19+
20+ - name : Python Release
21+ uses : python-semantic-release/python-semantic-release@v9.20.0
22+ with :
23+ github_token : ${{ secrets.GITHUB_TOKEN }}
24+ push : " true"
25+ changelog : " true"
Original file line number Diff line number Diff line change 1+ name : Test |Test MetaTrader5 Integration
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ test :
11+ runs-on : windows-latest
12+
13+ steps :
14+ - uses : actions/checkout@v4
15+
16+ - name : Set up Python
17+ uses : actions/setup-python@v4
18+ with :
19+ python-version : ' 3.11'
20+
21+ - name : Download MetaTrader 5
22+ run : |
23+ Invoke-WebRequest -Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" -OutFile mt5setup.exe
24+
25+ - name : Install MetaTrader 5 silently
26+ run : |
27+ Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto" -Wait
28+
29+ - name : Install Python dependencies
30+ run : |
31+ python -m pip install --upgrade pip
32+ pip install MetaTrader5
33+
34+ - name : Test MetaTrader5 connection
35+ run : |
36+ python tests/integration/test_mt5_connection.py
Original file line number Diff line number Diff line change 1+ name : Test | Pre-commit
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches :
7+ - main
8+
9+ jobs :
10+ pre-commit :
11+ permissions : write-all
12+ runs-on : windows-latest
13+
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+
18+ - name : Run Pre-commit
19+ uses : pre-commit/action@v3.0.1
20+ with :
21+ extra_args : --all-files
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+ import MetaTrader5 as mt5
4+
5+ def test_mt5_connection ():
6+ """Test basic connection to MetaTrader 5 terminal."""
7+
8+ print (f"MetaTrader5 package version: { mt5 .__version__ } " )
9+
10+ # Initialize MetaTrader 5
11+ if not mt5 .initialize ():
12+ print (f"initialize() failed, error code = { mt5 .last_error ()} " )
13+ sys .exit (1 )
14+
15+ print (mt5 .terminal_info ())
16+ print (f"MetaTrader5 terminal copyright: { mt5 .terminal_info ().copyright } " )
17+ print (f"MetaTrader5 terminal name: { mt5 .terminal_info ().name } " )
18+ print (f"MetaTrader5 terminal path: { mt5 .terminal_info ().path } " )
19+
20+ authorized = mt5 .login ()
21+ if authorized :
22+ print (f"Connected to account: { mt5 .account_info ().login } " )
23+ print (f"Balance: { mt5 .account_info ().balance } " )
24+
25+ mt5 .shutdown ()
26+
27+ print ("Test completed successfully" )
28+ return True
29+
30+ if __name__ == "__main__" :
31+ test_mt5_connection ()
You can’t perform that action at this time.
0 commit comments