'MQL5, Python, Javascript integration. Two (or more) computers

Any MetaTrader/MQL + python integration gurus here?

It is my understanding (please correct me if I'm wrong) that I can follow the instructions here to build the equivalent of a MetaTrader 5 EA (Expert Advisor) in python instead of MQL5, calling the python functions on that documentation page to handle all the broker interaction, and all the other logic and calculations and whatever else can be in my python code.

Assuming I've understood that correctly, I want to extend that in the following way.

  1. Set up all the python stuff as per that documentation page, on a Windows PC (of course, because it won't run on a Mac or anywhere else) -- this is computer #1.
  2. Build a platform-independent (ie. PC, Mac, Linux) node/javascript app that can run on any other computer(s) -- computer #2.
  3. Computer #2 needs to somehow call the python functions on computer #1 when the functionality they provide is needed (getting tick, order, deal, position, etc. info; sending orders; etc.), and do everything else an EA and indicators would do (all the math, decision making, etc), in the javascript code on computer #2.

So, two questions:

  • Question 1. I'm 99% certain this is possible. I think it means setting up a web/API server on computer #1 (with node/python/both?) and then the JS app on computer #2 is a simple web client (browser, command line node app, etc.) that sends instructions to the computer #1 web/API server, just like any other kind of web based client-server app. However, that's just my best guess, so is that an ok approach? 1a. If it is, I don't know where to start, what to look up, how to even research it, let alone do it, or 1b. if that approach is significantly flawed, then what is the best/correct approach?
  • Question 2. I could be reading it wrong, but that documentation page seems to be focussed on using those MT5 python functions to collect data for external analysis. The suggestion there might be that these functions are not intended for interactive live algo trading. Perhaps they're too slow for the high paced information exchange and manipulation required for live trading...? Or... is the idea of using these python functions for live algo trading perfectly reasonable?

Has anyone done any of this kind of thing? Can anyone advise if it's reasonable and how I should approach this?

Thanks!


Update about a week later

In response to @PSavva's question in comments: End goal primarily is build a (much less featured but enough for my needs) platform for my own automated trading - with a few specific requirements:

  1. Compatible with my preferred brokers who now only offer MT5.
  2. Able to both run & be developed natively on my Mac (so no wine or virtualizing Windows).†
  3. JS preferably (I already know it), but I might consider python (if I can pick that up well enough without too high a learning curve for me). (A native Swift [for Mac] app is an option long term — I’m learning it but I don’t know it well enough yet. JS for an MVP to start with would be better.)
  4. Possibly other requirements that escape my mind at the moment. 😉

[† I understand I can't do it ALL on Mac. Python works fine on Mac, but trying the required pip install MetaTrader5 step gives a platform incompatibility error (of course). So I understand I need a Windows PC to run the bare minimum MT5 and its python integration functions, for broker connection and communication, but I want everything else (logic, decision making, UI, charting, etc.) developed and running on a Mac (on the same local network -- my network at home initially, then ultimately both in a data center physically close to the exchange -- to minimize latency).]



Solution 1:[1]

You can try MetaApi https://metaapi.cloud cloud service which provides REST API and WebSocket API access to both MetaTrader 4 and MetaTrader 5 accounts.

Official REST API documentation: https://metaapi.cloud/docs/client

SDKs: https://metaapi.cloud/sdks (javascript, python and Java SDKs are provided as per May 2022)

It supports reading account information, positions, orders, trade history, receiving quotes, and accessing market data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 roman