Skip to main content

Mt5 Lite

Overview

This project is a Python-based wrapper class designed for the MetaTrader 5 (MT5) trading platform, providing a more Pythonic interface for interacting with the MT5 terminal. The wrapper class encapsulates the MT5 library functions, utilizing Object-Oriented Programming (OOP) principles to organize and structure the utility functions. This design enhances code readability, maintainability, and reusability, making it easier for developers to integrate MT5 functionalities into their Python applications.

Features

  • OOP Structure: The wrapper is organized into classes and methods that represent key MT5 functionalities, such as managing accounts, placing orders, retrieving market data, and handling trade events.

  • Simplified API: By wrapping the native MT5 functions, the class provides a simplified and more intuitive API, reducing the complexity of direct interaction with the MT5 terminal.

  • Error Handling: The wrapper includes robust error handling, translating MT5 error codes into Python exceptions, making it easier to debug and manage errors in your trading scripts.

  • Extensibility: The class is designed with extensibility in mind, allowing developers to easily extend the base functionality by subclassing or adding new methods.

  • Thread-Safe Operations: To cater to high-frequency trading and concurrent operations, the wrapper ensures thread safety in its implementation.

  • Comprehensive Documentation: The project includes detailed documentation, explaining how to install, use, and extend the wrapper class, along with code examples for common trading operations.

Use Cases

  • Algorithmic Trading: Use the wrapper class to develop, backtest, and deploy automated trading strategies with ease.

  • Data Analysis: Simplify the process of retrieving and analyzing market data from MT5 for research or decision-making purposes.

  • Custom Trading Tools: Build custom trading applications or scripts that interact with the MT5 terminal, leveraging the wrapper’s streamlined interface.

Installation

To use this wrapper class, you need to have Python 3.x and the MetaTrader 5 terminal installed on your system. You can install the required dependencies using pip:

pip install mt5-lite

After installing the dependencies, clone this repository and import the wrapper class into your Python project.

Getting Started Here’s a quick example of how to use the wrapper class to connect to an MT5 account and retrieve market data:

from mt5 import Account

# Initialize a Trading Account instance
account = Account('34234234234', password='password', server='demo_server')

# Connect/login to the MT5 terminal
account.connect()

# Retrieve current market prices for a symbol
symbol = "EURUSD"
trade_order = account.create_buy_order(symbol=symbol, pip_factor=10, execute=False)

# since the trade order was set not to execute, it has to be manually executed with it's send method
send_result = trade_order.send()

print(f"Send Result for {symbol}: {send_result}")

# Disconnect from the MT5 terminal
account.disconnect()

Contribution

Contributions are welcome! If you have suggestions for improvements, please submit a pull request or open an issue on the GitHub repository.

This project is ideal for traders, developers, and data scientists looking to integrate MetaTrader 5 functionalities into their Python-based trading systems while maintaining a clean and modular codebase.

Metadata

Release files for mt5-lite 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mt5-lite 0.0.7
File Size Uploaded
mt5_lite-0.0.7.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mt5-lite 0.0.7
File Interpreter ABI Platform
mt5_lite-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / mt5_lite-0.0.7.tar.gz

Download URL mt5_lite-0.0.7.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ecc02d0435af406425b7df279077ccc52d4c6359c119e5f21d44f1cd7641792a
BLAKE2b-256 checksum
How to use checksums
6e2f6fcbd28bf32e8c7954d636312302d607ca485c72e83563a43d4b680138b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / mt5_lite-0.0.7-py3-none-any.whl

Download URL mt5_lite-0.0.7-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
add7cadc22703f543961fa5c043dbea3b0775c0f88ea5380b0dc3a9f61486e64
BLAKE2b-256 checksum
How to use checksums
9317d0c737ff017b15beb6123373b9689d58b5cab9e1f4ee68eee46cf6640dfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page