A small wrapper library round the Metatrader 5 Official library
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mt5_lite-0.0.7.tar.gz
.
File metadata
- Download URL: mt5_lite-0.0.7.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecc02d0435af406425b7df279077ccc52d4c6359c119e5f21d44f1cd7641792a |
|
MD5 | 80a75503dca6c1f047f31869c84401de |
|
BLAKE2b-256 | 6e2f6fcbd28bf32e8c7954d636312302d607ca485c72e83563a43d4b680138b4 |
File details
Details for the file mt5_lite-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: mt5_lite-0.0.7-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | add7cadc22703f543961fa5c043dbea3b0775c0f88ea5380b0dc3a9f61486e64 |
|
MD5 | 11df380a74609613b635d3eab441fda1 |
|
BLAKE2b-256 | 9317d0c737ff017b15beb6123373b9689d58b5cab9e1f4ee68eee46cf6640dfa |