lucas-campagna / mt5linux

MetaTrader5 for linux users
MIT License
73 stars 40 forks source link

Clarifying the Purpose of mt5linux for Newcomers #18

Open ananta-dev opened 10 months ago

ananta-dev commented 10 months ago

Hi, First of all, thank you Lucas for sharing this excellent work with us all.

Following Lucas' suggestion, I will point out that the description of the purpose of mt5linux and the motivation behind it in the README is rather brief, and for newcomers, like me, with limited experience in running MT5 on Linux, it can be somewhat confusing in its brevity.

I will also try and clarify some of the potential doubts.

1. Do you really need mt5linux? It depends on your goal. If all you want to do is to run Python and Metatrader 5 on a Linux machine so that your Python-based algorithmic trading system can execute trades via Metatrader 5, then you probably do not need mt5linux. To achieve that goal, all you really need to do is to install both Python for Windows and Metatrader 5 on the same virtual drive in Wine, and install the Metatrader5 library on the Python for Windows. That's it.

2. OK, then, who needs mt5linux? Let us suppose that you are a machine learning wizard and you use Python for Linux running natively on a Linux machine, where you have installed a zillion heavy libraries, such as Tensorflow in your venv or Anaconda virtual environment. If you now want this pre-existing and very rich Python for Linux to be able to interact with Metatrader 5 installed on the same Linux machine, this is not so easy to accomplish. The Metatrader5 library cannot be used in Python for Linux. It can only be used by Python for Windows.

So, what can you do?

You could install a second instance of Python on the machine. This one a Python for Windows running on Wine. You could then install MT5 on the same Wine virtual drive, and the Metatrader5 library on the Python for Windows. This Python for Windows can then control MT5.

Now, how do you communicate the Python for Linux instance running natively on the Linux machine with the Python for Windows instance running on Wine and controlling MT5?

mt5linux to the rescue!

mt5linux can act as the bridge between these two Python installations, as illustrated by the following diagram:

mt5linux

CaoDuyThanh commented 9 months ago

all you really need to do is to install both Python for Windows and Metatrader 5 on the same virtual drive in Wine, and install the Metatrader5 library on the Python for Windows

Pardon me, can you explain this part? Sure I can install python for windows and metatrader 5 inside Wine, but how do I run it? Assume I want to place order and no need to run something heavy like you said in point 2. I asked because even I just want to control Metatrader in Wine and just it, I need to use mt5linux to communicate and can't find any way around or am I missing something?

gmag11 commented 9 months ago

Hi. Hi you just need to set a WINEPREFIX env variable pointing to the configuration folder which is created first time you run wine. Then you can run wine <your Windows command> and it will be executed inside the Windows emulation besides MT5.

To run a Python script you may run wine python <your_script>.

ananta-dev commented 9 months ago

all you really need to do is to install both Python for Windows and Metatrader 5 on the same virtual drive in Wine, and install the Metatrader5 library on the Python for Windows

Pardon me, can you explain this part? Sure I can install python for windows and metatrader 5 inside Wine, but how do I run it? Assume I want to place order and no need to run something heavy like you said in point 2. I asked because even I just want to control Metatrader in Wine and just it, I need to use mt5linux to communicate and can't find any way around or am I missing something?

In addition to gmag11's comment, above...

The key is to install both Python and MT5 in the same drive within Wine. Not just install both in Wine, but within the same virtual drive in Wine.

With regards to how to run a Python script in Wine, this is something you will have to research. There are a number of ways to do it. One way, for instance, is to use wenv: https://wenv.readthedocs.io/en/latest/introduction.html#use-cases

I am not recommending wenv. It's just one option to play with Python on Wine.

Personally, I find this Python+MT5 on Linux is extremely interesting, but it is turning out to be too time consuming and I need to focus on practical solutions for profitable algorithmic trading. For now I will stick with Python+MT5 directly on Windows. Later on, when I am rich from trading with Python+MT5 and have lots of free time I will tackle the fancy stuff that can save you a few USD on VPS fees monthly.

CaoDuyThanh commented 9 months ago

it is turning out to be too time consuming

Yeah, I agree it really is time consuming

For now I will stick with Python+MT5 directly on Windows

How do you go with this solution? I plan to move to this and have 2 options: have a pc to run 24/24 hours with window OS installed on it or build the image to run on window. I want to go with 2nd option but it means I need to bring everything to window.

ananta-dev commented 9 months ago

For now I will stick with Python+MT5 directly on Windows

How do you go with this solution? I plan to move to this and have 2 options: have a pc to run 24/24 hours with window OS installed on it or build the image to run on window. I want to go with 2nd option but it means I need to bring everything to window.

One step further, CaoDuyThanh:

I want to focus on what's important, so for now, my VPS are going to be Windows VPS. One less complexity out of the way (for now). I will have time to play with Linux, MT5 and Python once I am riding the dollar, if I still want to.

So, Python+MT5 on Windows VPS for now. There are cheap Windows VPS options, like Hyonix or ProHoster. Hetzner allows you to install your own Windows (with your own Windows license) on their Linux VPS, so that for me removes most of the motivation to go with Linux.

It consumes too much time to master it. It's fascinating, but I have decided to be practical.

Sorry that I could not help you further.

vasinl124 commented 6 months ago

Thanks for the visualization, I was so confused but once I saw the image, it just clicked to me. Thanks!