Automated trading on linux, using multiple accounts simultaneously

 

Hi, I am looking into changing my current trading setup from using multiple instances of MT4 to creating microservices in python.

The idea is to have python scripts (bots) running with my algorithms that can execute trades on multiple accounts at multiple brokers at the same time.

Long term I would like the system to be scalable. So when I have more bots and more accounts that I can just add additional servers when I need them. The whole thing should be scriptable so that I can automate the creation of bots and load balance the system dynamically. Therefore I would love to do that with python on linux, also as I am familiar with those.

As far as I understand right now, there are the following options to proceed:

  1. Go via the APIs from the brokers. My preferred approach, as I would be independent of MT5 and Windows/Wine.
  2. Go via a tool like https://github.com/khramkov/MQL5-JSON-API to communicate through MT5
  3. Use python on Windows and use the python library for MT5 (https://pypi.org/project/MetaTrader5/)

Questions that I have:

1) Not all brokers seem to provide an API and I would have to implement each API. Is this correct? Or is there a way to use the API that MT5 uses?

2) Do I need to have an instance of MT5 running for each account/broker?
    Or can I execute multiple orders on multiple accounts in one MT5 instance at the same time?
    The MQL5-JSON-API tool seems not to support multiple accounts.

3) How much overhead is involved using the python library? Can I make hundreds of calls to multiple accounts without worrying about performance?
    And could I create my own python proxy on Windows that delegates the requests from my linux bots?

Has anyone experience on how to approach this?

Thanks a lot.

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
momonu:

Hi, I am looking into changing my current trading setup from using multiple instances of MT4 to creating microservices in python.

The idea is to have python scripts (bots) running with my algorithms that can execute trades on multiple accounts at multiple brokers at the same time.

Long term I would like the system to be scalable. So when I have more bots and more accounts that I can just add additional servers when I need them. The whole thing should be scriptable so that I can automate the creation of bots and load balance the system dynamically. Therefore I would love to do that with python on linux, also as I am familiar with those.

As far as I understand right now, there are the following options to proceed:

  1. Go via the APIs from the brokers. My preferred approach, as I would be independent of MT5 and Windows/Wine.
  2. Go via a tool like https://github.com/khramkov/MQL5-JSON-API to communicate through MT5
  3. Use python on Windows and use the python library for MT5 (https://pypi.org/project/MetaTrader5/)

Questions that I have:

1) Not all brokers seem to provide an API and I would have to implement each API. Is this correct? Or is there a way to use the API that MT5 uses?

2) Do I need to have an instance of MT5 running for each account/broker?
    Or can I execute multiple orders on multiple accounts in one MT5 instance at the same time?
    The MQL5-JSON-API tool seems not to support multiple accounts.

3) How much overhead is involved using the python library? Can I make hundreds of calls to multiple accounts without worrying about performance?
    And could I create my own python proxy on Windows that delegates the requests from my linux bots?

Has anyone experience on how to approach this?

Thanks a lot.

Hey did you find the solution? I am also looking for the having the same problem. 
 
My guess is the best approach is to use the mt5-json-api.

Mt5 supports one login per instance. So you need one instance per account.

You could build an json-api proxy to accumulate all mt5 instances into one API for better handling.


Reason: