gmag11 / MetaTrader5-Docker-Image

Docker image that runs Metatrader 5 with VNC web server
MIT License
109 stars 51 forks source link

install datetime python library? #14

Open dhcho-dnotitia opened 1 month ago

dhcho-dnotitia commented 1 month ago

Hello, currently trying to use your wonderful work.

when trying to fetch some historical data (tics or trade logs), I've got some errors which designates that there is no 'datetime' library.

I tried to install to the library into the running docker container as below but still failed to resolve the error.

sudo wine ~/.wine/drive_c/Program\ Files\ \(x86\)/Python39-32/python.exe -m pip install datetime

any ideas on it?

gmag11 commented 1 month ago

Hi. So you mean internal Wine misses datetime library, don't you? Can you copy the log here?

dhcho-dnotitia commented 1 month ago

I tried to follow the example in the link.

After mt5 login,

from_date=datetime.datetime(2020,1,1)
to_date=datetime.datetime.now()
history_orders=fxs.mt5_l.history_orders_get(from_date, to_date, group="*GBP*")

the output msg is as follows:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[3], [line 3](vscode-notebook-cell:?execution_count=3&line=3)
      [1](vscode-notebook-cell:?execution_count=3&line=1) from_date=datetime.datetime(2020,1,1)
      [2](vscode-notebook-cell:?execution_count=3&line=2) to_date=datetime.datetime.now()
----> [3](vscode-notebook-cell:?execution_count=3&line=3) history_orders=fxs.mt5_l.history_orders_get(from_date, to_date, group="*GBP*")

File /opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3763, in MetaTrader5.history_orders_get(self, *args, **kwargs)
   [3626](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3626)         r'''
   [3627](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3627) #history_orders_get
   [3628](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3628) 
   (...)
   [3760](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3760) 
   [3761](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3761)         '''
   [3762](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3762)         code=f'mt5.history_orders_get(*{args},**{kwargs})'
-> [3763](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/mt5linux/__init__.py:3763)         return self.__conn.eval(code)

File /opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:240, in _make_method.<locals>.__call__(_self, *args, **kwargs)
    [238](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:238) def __call__(_self, *args, **kwargs):
    [239](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:239)     kwargs = tuple(kwargs.items())
--> [240](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:240)     return syncreq(_self, consts.HANDLE_CALL, args, kwargs)

File /opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:63, in syncreq(proxy, handler, *args)
     [51](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:51) """Performs a synchronous request on the given proxy object.
     [52](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f66782d686f73742d64656d6f2d646863686f227d-0040ssh-002dremote-002b7b22686f73744e616d65223a22444e2d707269766174652d736572766572227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.10/site-packages/rpyc/core/netref.py:52) Not intended to be invoked directly.
...
  File "C:\Program Files (x86)\Python39-32\lib\site-packages\rpyc\core\service.py", line 156, in eval
    return eval(text, self.namespace)
  File "<string>", line 1, in <module>
NameError: name 'datetime' is not defined

hope the datetime library would be installed via Dockerfile. I tried to do it but failed..

thepyninja commented 3 weeks ago

same issue