Skip to content

MT5Account - Master Overview¶

One page to orient fast: what lives where, how to choose the right API, and jump links to every overview and method spec in this docs set.


🚦 Start here - Section Overviews¶


🧭 How to pick an API¶

If you need... Go to... Typical methods
Account snapshot Account Information account_summary(), account_info_double(), account_info_integer()
Quotes & symbol properties Symbol Information symbol_info_tick(), symbol_info_double(), symbols_total()
Current positions & orders Positions & Orders positions_total(), opened_orders(), opened_orders_tickets()
Historical trades Positions & Orders order_history(), positions_history()
Tick values for P/L calculation Positions & Orders tick_value_with_size()
Level II / Order book Market Depth (DOM) market_book_add(), market_book_get(), market_book_release()
Trading operations Trading Operations order_send(), order_modify(), order_close()
Pre-trade calculations Trading Operations order_calc_margin(), order_check()
Real-time updates Streaming Methods on_symbol_tick(), on_trade(), on_position_profit()

🔌 Usage pattern (Python async/await)¶

Every method follows async pattern with gRPC under the hood:

import asyncio
from MetaRpcMT5 import MT5Account

async def main():
    # Create MT5Account instance using create() - RECOMMENDED
    account = MT5Account.create(
        user=591129415,
        password="IpoHj17tYu67@",
        grpc_server="mt5.mrpc.pro:443"
    )

    # Connect to MT5 terminal
    await account.connect_by_server_name(
        server_name="FxPro-MT5 Demo",
        base_chart_symbol="EURUSD",
        timeout_seconds=120
    )

    try:
        # Call async method - using account_summary() (RECOMMENDED)
        summary = await account.account_summary()
        print(f"Balance: ${summary.account_balance:.2f}")
        print(f"Equity:  ${summary.account_equity:.2f}")

    finally:
        # Always close connection
        await account.channel.close()

asyncio.run(main())

Every method follows the same shape:

  • Async/Await: All methods are async - use await to call them
  • Automatic reconnection: Built-in execute_with_reconnect wrapper for resilience
  • Protobuf messages: Request/Response use protobuf structures under the hood
  • Return codes: Trading operations return status codes (10009 = success)
  • Streaming methods: Use async for to consume real-time data streams

Timestamps: Unix timestamps (seconds since epoch) or datetime objects.

Streaming methods: Return async generators - use async for loop to receive updates.


📚 Full Index - All Method Specs¶


📄 1. Account Information¶

Complete Snapshot¶

Individual Properties¶


📊 2. Symbol Information¶

Symbol Management¶

Symbol Properties¶

Trading Conditions¶


📦 3. Positions & Orders¶

Current Positions & Orders¶

Historical Data¶

Calculations¶


📈 4. Market Depth (DOM)¶

Level II Quotes¶


🛠 5. Trading Operations¶

Order Execution & Management¶

Pre-Trade Calculations¶


📡 6. Streaming Methods¶

Real-Time Price Updates¶

Trading Events¶

Position Monitoring¶


🎯 Quick Navigation by Use Case¶

I want to... Use this method
ACCOUNT INFORMATION
Get complete account snapshot account_summary
Get account balance account_info_double (BALANCE)
Get account equity account_info_double (EQUITY)
Get account leverage account_info_integer (LEVERAGE)
Get account currency account_info_string (CURRENCY)
POSITIONS & ORDERS
Get count of open positions positions_total
Get all open orders/positions opened_orders
Get ticket IDs only opened_orders_tickets
Get order history order_history
Get closed positions history positions_history
Get tick values for P/L calculation tick_value_with_size
MARKET DEPTH
Subscribe to Level II quotes market_book_add
Get order book data market_book_get
Unsubscribe from Level II market_book_release
TRADING OPERATIONS
Open market BUY position order_send (operation=0)
Open market SELL position order_send (operation=1)
Place BUY LIMIT order order_send (operation=2)
Place SELL LIMIT order order_send (operation=3)
Place BUY STOP order order_send (operation=4)
Place SELL STOP order order_send (operation=5)
Modify SL/TP of position order_modify
Close a position order_close
Calculate margin before trade order_calc_margin
Validate trade before execution order_check
REAL-TIME SUBSCRIPTIONS
Stream live prices on_symbol_tick
Monitor trade events on_trade
Track profit changes on_position_profit
Monitor ticket changes on_positions_and_pending_orders_tickets
Detailed transaction log on_trade_transaction

💡 Key Concepts¶

Return Codes (Trading Operations)¶

  • 10009 = Success / DONE
  • 10004 = Requote
  • 10006 = Request rejected
  • 10013 = Invalid request
  • 10014 = Invalid volume
  • 10015 = Invalid price
  • 10016 = Invalid stops
  • 10018 = Market closed
  • 10019 = Not enough money
  • 10031 = No connection with trade server

Always check returned_code field in trading operation results.


Important Notes¶

  • Check return codes: Every trading operation returns status code (10009 = success)
  • Validate parameters: Use order_check() before order_send()
  • Handle exceptions: Network/protocol errors can occur
  • Async context: All methods must be called within async context
  • Stream cleanup: Cancel streams properly using cancellation_event
  • UTC timestamps: All times are in UTC, not local time
  • Broker limitations: Not all brokers support all features (DOM, hedging, etc.)
  • Automatic reconnection: All methods have built-in reconnection logic

"Trade safe, code clean, and may your async streams always flow smoothly."