Skip to main content

MT5 trading gateway for VeighNa Evo.

Project description

MT5 trading gateway for VeighNa Evo

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.

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

vnpy_mt5-2024.3.12.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

vnpy_mt5-2024.3.12-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file vnpy_mt5-2024.3.12.tar.gz.

File metadata

  • Download URL: vnpy_mt5-2024.3.12.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for vnpy_mt5-2024.3.12.tar.gz
Algorithm Hash digest
SHA256 d6443184412df5afebddcca5c6fc49fb02fa323a93bc97e43537f5a14889c72d
MD5 2b2d250b271b9ae8f548d7a5e7853366
BLAKE2b-256 6d52d1ede6e3ca3f9244eee48ce0505193623d0641ab8763a9fb0112adb64274

See more details on using hashes here.

File details

Details for the file vnpy_mt5-2024.3.12-py3-none-any.whl.

File metadata

File hashes

Hashes for vnpy_mt5-2024.3.12-py3-none-any.whl
Algorithm Hash digest
SHA256 426322e27b922cd1d2933f7e47ebdb1aa22dda7b475a6942021897c81393e395
MD5 18442db37fc0dfb2d8b49cac33c344cf
BLAKE2b-256 12575b99a1ff62cd92cc645935af8c6c84f03853b74f47087a6edb5ab1819ca1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page