Skip to content
MetaRPCPublic

About

Cloud Python SDK for MetaTrader 5 (MT5). Connect, trade, and stream market data via REST & gRPC without Windows VPS.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

637 Commits

Folders and files

Repository files navigation

PyMT5 SDK — Cloud Python SDK for MetaTrader 5 (MT5)

Python License: MIT Docs Cloud Platform

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.


⚡ Why MetaRPC PyMT5?

  • 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.

📦 Installation

pip install MetaRpcMT5

🏃 How to Run Examples

Clone 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"

🚀 30-Second Quick Start

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())

🔑 Getting Your API Key & Free Trial

  1. Sign Up: Create your free account at https://mrpc.pro/signup.
  2. Copy API Key: Open your portal dashboard at https://mrpc.pro/my and grab your personal API token.
  3. Connect: Pass your key in code or set the MRPC_API_KEY environment variable:
    export MRPC_API_KEY="your_api_token_here"

🌐 Production Endpoints

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

🏢 Compatible Brokers & Prop Firms

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.

📚 Complete Documentation & Code Examples


📄 License

This SDK is open-sourced under the MIT License.
Cloud infrastructure and API services are operated by MetaRPC.

About

Cloud Python SDK for MetaTrader 5 (MT5). Connect, trade, and stream market data via REST & gRPC without Windows VPS.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages