# MT5 trading gateway for VeighNa Evo
<p align="center">
<img src ="https://github.com/veighna-global/vnpy_evo/blob/dev/logo.png" width="300" height="300"/>
</p>
<p align="center">
<img src ="https://img.shields.io/badge/version-2024.3.15-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12-blue.svg"/>
<img src ="https://img.shields.io/github/license/veighna-global/vnpy_evo.svg?color=orange"/>
</p>
## Introduction
This gateway is developed based on MT5 ZeroMQ connection and supports all MT5 trading.
**Please notice: only supports netting position mode.**
## Install
Users can easily install ``vnpy_mt5`` by pip according to the following command.
```
pip install vnpy_mt5
```
Also, users can install ``vnpy_mt5`` using the source code. Clone the repository and install as follows:
```
git clone https://github.com/veighna-global/vnpy_mt5.git && cd vnpy_mt5
python setup.py install
```
## A Simple Example
Save this as run.py.
```
from vnpy_evo.event import EventEngine
from vnpy_evo.trader.engine import MainEngine
from vnpy_evo.trader.ui import MainWindow, create_qapp
from vnpy_mt5 import Mt5Gateway
def main():
"""主入口函数"""
qapp = create_qapp()
event_engine = EventEngine()
main_engine = MainEngine(event_engine)
main_engine.add_gateway(Mt5Gateway)
main_window = MainWindow(main_engine, event_engine)
main_window.showMaximized()
qapp.exec()
if __name__ == "__main__":
main()
```
## MT5 Configuration
1. Ensure that the MT5 client is installed and logged in with either a demo or a real account (note that the account provided by the broker must be in Netting mode, Hedging mode will not work).
2. Download the vnpy_mt5 source code from GitHub, enter the vnpy_mt5.vnpy_mt5 directory, and find the Experts, Include, and Libraries folders included there.
3. From the start menu, launch MetaEditor. In the left side "Navigator", find the MQL5 folder, right-click it and choose "Open Folder". Copy the three folders you previously unzipped into this directory.
4. Return to MetaEditor, right-click the MQL5 directory again, and click the "Refresh" button from the pop-up menu. Then click the + button next to the Experts directory, find the vnpy_server.mq5 file, double-click to open it, and click the green play button in the top red circle to execute the compilation. The bottom "Errors" information bar will display several compilation messages (ensure there are 0 errors).
5. MT5 will pop up a dialog for vnpy_server 1.00. In the dialog, first check the "Allow DLL imports" option under the "Dependencies" tab, then switch to the "General" tab, check the "Allow Algorithmic Trading" option, and click the "OK" button. A text prompt for vnpy_server (with very small font) will then appear at the top right corner of the chart, with a small figure icon on the right, which should have a green circle (indicating it is running).
6. Next, click the "Tools" -> "Options" button on the top menu bar of MT5, open the MT5 Options dialog, switch to the "Expert Advisors" tab, and check all the options below. Finally, remember to click the "OK" button to save the settings. This completes all the configuration work on MT5.
## Notes
1. MT5 prohibits marketable limit orders. For example, when placing a buy order, the order price must be lower than ask_price_1, otherwise, the order will be rejected.
2. Use market orders for transactions you wish to execute immediately.
3. For stop orders that you wish to trigger immediately upon conditions being met, MT5 offers server-side stop order execution (supported by Mt5Gateway). Thus, stop orders placed in the CTA strategy will be issued as server-side stop orders.
4. Be careful not to load these app modules including RpcService, RpcGateway, WebService at startup, which require the use of ZeroMQ, as this will cause ZeroMQ to report errors.
Raw data
{
"_id": null,
"home_page": "https://www.github.com/veighna-global",
"name": "vnpy-mt5",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "quant,quantitative,investment,trading,algotrading,mt5",
"author": "VeighNa Global",
"author_email": "veighna@hotmail.com",
"download_url": "https://files.pythonhosted.org/packages/6d/52/d1ede6e3ca3f9244eee48ce0505193623d0641ab8763a9fb0112adb64274/vnpy_mt5-2024.3.12.tar.gz",
"platform": null,
"description": "# MT5 trading gateway for VeighNa Evo\r\n\r\n<p align=\"center\">\r\n <img src =\"https://github.com/veighna-global/vnpy_evo/blob/dev/logo.png\" width=\"300\" height=\"300\"/>\r\n</p>\r\n\r\n<p align=\"center\">\r\n <img src =\"https://img.shields.io/badge/version-2024.3.15-blueviolet.svg\"/>\r\n <img src =\"https://img.shields.io/badge/platform-windows-yellow.svg\"/>\r\n <img src =\"https://img.shields.io/badge/python-3.10|3.11|3.12-blue.svg\"/>\r\n <img src =\"https://img.shields.io/github/license/veighna-global/vnpy_evo.svg?color=orange\"/>\r\n</p>\r\n\r\n\r\n\r\n## Introduction\r\n\r\nThis gateway is developed based on MT5 ZeroMQ connection and supports all MT5 trading.\r\n\r\n**Please notice: only supports netting position mode.**\r\n\r\n## Install\r\n\r\nUsers can easily install ``vnpy_mt5`` by pip according to the following command.\r\n\r\n```\r\npip install vnpy_mt5\r\n```\r\n\r\nAlso, users can install ``vnpy_mt5`` using the source code. Clone the repository and install as follows:\r\n\r\n```\r\ngit clone https://github.com/veighna-global/vnpy_mt5.git && cd vnpy_mt5\r\n\r\npython setup.py install\r\n```\r\n\r\n## A Simple Example\r\n\r\nSave this as run.py.\r\n\r\n```\r\nfrom vnpy_evo.event import EventEngine\r\nfrom vnpy_evo.trader.engine import MainEngine\r\nfrom vnpy_evo.trader.ui import MainWindow, create_qapp\r\n\r\nfrom vnpy_mt5 import Mt5Gateway\r\n\r\n\r\ndef main():\r\n \"\"\"\u4e3b\u5165\u53e3\u51fd\u6570\"\"\"\r\n qapp = create_qapp()\r\n\r\n event_engine = EventEngine()\r\n main_engine = MainEngine(event_engine)\r\n main_engine.add_gateway(Mt5Gateway)\r\n\r\n main_window = MainWindow(main_engine, event_engine)\r\n main_window.showMaximized()\r\n\r\n qapp.exec()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n```\r\n\r\n\r\n## MT5 Configuration\r\n\r\n1. Ensure that the MT5 client is installed and logged in with either a demo or a real account (note that the account provided by the broker must be in Netting mode, Hedging mode will not work).\r\n\r\n2. Download the vnpy_mt5 source code from GitHub, enter the vnpy_mt5.vnpy_mt5 directory, and find the Experts, Include, and Libraries folders included there.\r\n\r\n3. From the start menu, launch MetaEditor. In the left side \"Navigator\", find the MQL5 folder, right-click it and choose \"Open Folder\". Copy the three folders you previously unzipped into this directory.\r\n\r\n4. Return to MetaEditor, right-click the MQL5 directory again, and click the \"Refresh\" button from the pop-up menu. Then click the + button next to the Experts directory, find the vnpy_server.mq5 file, double-click to open it, and click the green play button in the top red circle to execute the compilation. The bottom \"Errors\" information bar will display several compilation messages (ensure there are 0 errors).\r\n\r\n5. MT5 will pop up a dialog for vnpy_server 1.00. In the dialog, first check the \"Allow DLL imports\" option under the \"Dependencies\" tab, then switch to the \"General\" tab, check the \"Allow Algorithmic Trading\" option, and click the \"OK\" button. A text prompt for vnpy_server (with very small font) will then appear at the top right corner of the chart, with a small figure icon on the right, which should have a green circle (indicating it is running).\r\n\r\n6. Next, click the \"Tools\" -> \"Options\" button on the top menu bar of MT5, open the MT5 Options dialog, switch to the \"Expert Advisors\" tab, and check all the options below. Finally, remember to click the \"OK\" button to save the settings. This completes all the configuration work on MT5.\r\n\r\n\r\n## Notes\r\n\r\n1. MT5 prohibits marketable limit orders. For example, when placing a buy order, the order price must be lower than ask_price_1, otherwise, the order will be rejected.\r\n2. Use market orders for transactions you wish to execute immediately.\r\n3. For stop orders that you wish to trigger immediately upon conditions being met, MT5 offers server-side stop order execution (supported by Mt5Gateway). Thus, stop orders placed in the CTA strategy will be issued as server-side stop orders.\r\n4. Be careful not to load these app modules including RpcService, RpcGateway, WebService at startup, which require the use of ZeroMQ, as this will cause ZeroMQ to report errors.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "MT5 trading gateway for VeighNa Evo.",
"version": "2024.3.12",
"project_urls": {
"Homepage": "https://www.github.com/veighna-global"
},
"split_keywords": [
"quant",
"quantitative",
"investment",
"trading",
"algotrading",
"mt5"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "12575b99a1ff62cd92cc645935af8c6c84f03853b74f47087a6edb5ab1819ca1",
"md5": "18442db37fc0dfb2d8b49cac33c344cf",
"sha256": "426322e27b922cd1d2933f7e47ebdb1aa22dda7b475a6942021897c81393e395"
},
"downloads": -1,
"filename": "vnpy_mt5-2024.3.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "18442db37fc0dfb2d8b49cac33c344cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9942,
"upload_time": "2024-03-15T01:26:18",
"upload_time_iso_8601": "2024-03-15T01:26:18.938013Z",
"url": "https://files.pythonhosted.org/packages/12/57/5b99a1ff62cd92cc645935af8c6c84f03853b74f47087a6edb5ab1819ca1/vnpy_mt5-2024.3.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6d52d1ede6e3ca3f9244eee48ce0505193623d0641ab8763a9fb0112adb64274",
"md5": "2b2d250b271b9ae8f548d7a5e7853366",
"sha256": "d6443184412df5afebddcca5c6fc49fb02fa323a93bc97e43537f5a14889c72d"
},
"downloads": -1,
"filename": "vnpy_mt5-2024.3.12.tar.gz",
"has_sig": false,
"md5_digest": "2b2d250b271b9ae8f548d7a5e7853366",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11127,
"upload_time": "2024-03-15T01:26:21",
"upload_time_iso_8601": "2024-03-15T01:26:21.004191Z",
"url": "https://files.pythonhosted.org/packages/6d/52/d1ede6e3ca3f9244eee48ce0505193623d0641ab8763a9fb0112adb64274/vnpy_mt5-2024.3.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-15 01:26:21",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "vnpy-mt5"
}