Deployment Guide (Windows Service)¶
This guide describes how to deploy the pdmt5 REST API as a Windows service alongside the MetaTrader 5 terminal.
Prerequisites¶
- Windows 10/11
- MetaTrader 5 installed and logged in
- Python 3.11+
pdmt5[api]installed
Service Setup (NSSM)¶
- Download NSSM: https://nssm.cc/download
- Open an elevated PowerShell session.
- Create a service:
-
Set the application path and arguments:
-
Path:
C:\Path\To\Python\python.exe - Arguments:
-m uvicorn pdmt5.api.main:app --host 0.0.0.0 --port 8000 -
Startup directory: your project directory
-
Set environment variables in the NSSM GUI:
- Start the service:
Validation¶
Expected status: healthy (or unhealthy if MT5 is not connected).
Troubleshooting¶
- Ensure the MT5 terminal is running and logged in.
- Confirm firewall rules allow inbound traffic on the API port.
- Check Windows Event Viewer for NSSM service logs.