Official Python SDK for MetaTrader 5 Cloud API via gRPC & REST.
Connect, stream live ticks, and execute trades on any MT5 broker or prop firm from Linux, macOS, Docker, or AWS Lambda — without running a Windows VPS or desktop terminal.
- Zero Windows VPS: Stop paying $20–$80/month for buggy Windows servers. Run trading bots in lightweight Linux containers or serverless workers.
- Ultra-Low Latency: High-speed gRPC streaming and execution co-located with London (LD4) and New York (NY4) broker data centers (<20ms execution).
- Universal Broker & Prop Firm Support: Connects to 500+ brokers and prop firms including FTMO, IC Markets, Pepperstone, Exness, FundedNext, Tickmill, XM, FXCM.
- Automatic Session Management: Session GUID (
id) is generated automatically by the server upon connection and attached to all subsequent requests. - Asyncio Native: Modern asynchronous Python design with automatic reconnection, heartbeat monitoring, and resilience.
pip install MetaRpcMT5Clone the repository and run the examples out-of-the-box:
git clone https://github.com/MetaRPC/PyMT5.git
cd PyMT5/examples
pip install MetaRpcMT5
# 1. Run with default TRIAL key:
python main.py
# 2. Or pass your MetaRPC API key directly:
python main.py your_api_key_here
# 3. Or use the MRPC_API_KEY environment variable:
export MRPC_API_KEY="your_api_key_here" # Windows CMD: set MRPC_API_KEY=your_api_key_here
python main.py # Windows PowerShell: $env:MRPC_API_KEY="your_api_key_here"import asyncio
from pymt5 import MT5Account
async def main():
# 1. Initialize account with your credentials
# Sign up at https://mrpc.pro/signup to get your free API key
account = MT5Account(
user=12345678, # Your MT5 Login
password="your_mt5_password", # Your MT5 Password
grpc_server="mt5.mrpc.pro:443", # Cloud gRPC Endpoint
api_key="your_mrpc_api_key" # From https://mrpc.pro/my
)
# 2. Connect by broker server name
print("Connecting to MetaTrader 5 Cloud...")
await account.connect_by_server_name("MetaQuotes-Demo", timeout_seconds=30)
print("Connected successfully!")
# 3. Get real-time account summary
summary = await account.account_summary()
print(f"Balance: ${summary.account_balance:,.2f}")
print(f"Equity: ${summary.account_equity:,.2f}")
print(f"Free Margin: ${summary.account_margin_free:,.2f}")
# 4. Fetch live quotes
quote = await account.get_quote("EURUSD")
print(f"EURUSD Bid: {quote.bid} | Ask: {quote.ask}")
if __name__ == "__main__":
asyncio.run(main())- Sign Up: Create your free account at https://mrpc.pro/signup.
- Copy API Key: Open your portal dashboard at https://mrpc.pro/my and grab your personal API token.
- Connect: Pass your key in code or set the
MRPC_API_KEYenvironment variable:export MRPC_API_KEY="your_api_token_here"
| Environment | Host / URL | Port | Protocol | Purpose |
|---|---|---|---|---|
| MT5 Production gRPC | mt5.mrpc.pro |
443 |
TLS / gRPC | High-throughput trading & streaming |
| Interactive API UI (Swagger) | https://mt5.mrpc.pro/apiui | 443 |
HTTPS / REST | Interactive REST endpoints & testing |
| Portal Dashboard | https://mrpc.pro/my | 443 |
HTTPS | Manage terminals, copiers & keys |
| Account Registration | https://mrpc.pro/signup | 443 |
HTTPS | Instant free trial registration |
Tested and verified with over 500+ MetaTrader server environments:
- Prop Firms: FTMO, FundedNext, The Funded Trader, E8 Funding, Alpha Capital, SurgeTrader.
- Brokers: IC Markets, Pepperstone, Exness, Tickmill, XM, FXCM, FP Markets, Eightcap, AvaTrade.
- 📖 Comprehensive Documentation
- 🚀 10-Minute First Project Guide
- 📡 Live Tick & Bar gRPC Streaming
- 💼 Order Execution & Position Management
- 💡 Example Scripts & Strategies
This SDK is open-sourced under the MIT License.
Cloud infrastructure and API services are operated by MetaRPC.