ejtraderLabs / ejtraderMT

Metatrader 5 API - Trading and history OHLC Dataframe in Nano Seconds
GNU General Public License v3.0
70 stars 28 forks source link

Data Socket Timeout #7

Closed mohammadaminyza closed 1 year ago

mohammadaminyza commented 1 year ago

Hi. Thanks for your ejtraderMT, i'm trying to use it but i'm keep facing error and i've launched it on docker, this is the code that i'm trying to execute: image

this is the parameter: image

and this is my containers: image

what did i missed? can you help me, please

this is the error:

Again Traceback (most recent call last) File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:71, in Functions._pull_reply(self) 70 try: ---> 71 msg = self.sys_socket.recv_json() 72 except zmq.ZMQError:

File ~\AppData\Roaming\Python\Python310\site-packages\zmq\sugar\socket.py:1009, in Socket.recv_json(self, flags, kwargs) 990 """Receive a Python object as a message using json to serialize. 991 992 Keyword arguments are passed on to json.loads (...) 1007 for any of the reasons :func:~Socket.recv might fail 1008 """ -> 1009 msg = self.recv(flags) 1010 return self._deserialize(msg, lambda buf: jsonapi.loads(buf, kwargs))

File zmq\backend\cython\socket.pyx:805, in zmq.backend.cython.socket.Socket.recv()

File zmq\backend\cython\socket.pyx:841, in zmq.backend.cython.socket.Socket.recv()

File zmq\backend\cython\socket.pyx:199, in zmq.backend.cython.socket._recv_copy()

File zmq\backend\cython\socket.pyx:194, in zmq.backend.cython.socket._recv_copy()

File ~\AppData\Roaming\Python\Python310\site-packages\zmq\backend\cython\checkrc.pxd:22, in zmq.backend.cython.checkrc._check_rc()

Again: Resource temporarily unavailable

During handling of the above exception, another exception occurred:

NotDone Traceback (most recent call last) Cell In[1], line 3 1 from ejtraderMT import Metatrader ----> 3 api = Metatrader(host='localhost', debug=False) 5 symbol = "EURUSD" 6 fromDate = "01/01/2023"

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:138, in Metatrader.init(self, host, real_volume, tz_local, dbtype, dbhost, dbport, dbpass, dbuser, dbname, debug) 136 self.utc_timezone = timezone("UTC") 137 self.my_timezone = get_localzone() --> 138 self.utc_brockeroffset = self.utc_brocker_offset() 139 # db settings 140 self.dbtype = dbtype or "SQLITE" # SQLITE OR INFLUXDB

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:407, in Metatrader._utc_brocker_offset(self) 405 utc = datetime.now(self.utc_timezone).strftime("%Y-%m-%d %H:%M:%S") 406 try: --> 407 broker = self.accountInfo() 408 broker = datetime.strptime(broker["time"], "%Y.%m.%d %H:%M:%S") 409 except KeyError:

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:279, in Metatrader.accountInfo(self) 278 def accountInfo(self): --> 279 return self.__api.Command(action="ACCOUNT")

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:113, in Functions.Command(self, **kwargs) 110 self._send_request(request) 112 # return server reply --> 113 return self._pull_reply()

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:73, in Functions._pull_reply(self) 71 msg = self.sys_socket.recv_json() 72 except zmq.ZMQError: ---> 73 raise zmq.NotDone("Data socket timeout ERROR") 74 return msg

NotDone: Data socket timeout ERROR

github-actions[bot] commented 1 year ago

We're glad you've opened your first issue. Please provide all the necessary details and any relevant code or screenshots to help us understand the problem better. Our team will review your issue and provide assistance as soon as possible. Thank you for contributing!

traderpedroso commented 1 year ago

My apologies, I updated to the latest version and made a tremendous mistake with the ports. It should have been 15557, thus I added the default port in MQL5 as 15557, but I had added 15555 in the Python library. The error has been corrected, and thank you very much. Simply use pip install ejtraderMT -U.

mohammadaminyza commented 1 year ago

thanks for your response but some times i facing that error and some times the result is empty and some times it's ok, and i had some other question is there any way to get all the calendars for all the symbols?

when it's not raising any error and empty: image

when it raises the error: image

mohammadaminyza commented 1 year ago

how many request limit does it has pre second?

traderpedroso commented 1 year ago

how many request limit does it has pre second?

thanks for your response but some times i facing that error and some times the result is empty and some times it's ok, and i had some other question is there any way to get all the calendars for all the symbols?

when it's not raising any error and empty: image

when it raises the error: image

First, access Docker via VNC and open the desired asset on a one-month timeframe to load the history. Once the history is loaded, try again. This is because your history is not yet ready, and you are trying to fetch many months without the history on the graph. and you missing timeframe

from ejtraderMT import Metatrader
api = Metatrader() # if you docker running on other machine needs to add host="ip"
startdate = "01/01/2007"
enddate = "01/06/2023"
timeframe = "M1"
symbol = "EURUSD"
df = api.history(symbol,timeframe,fromDate=startdate,toDate=enddate)
df = df.loc[~df.index.duplicated(keep='first')]
df
mohammadaminyza commented 1 year ago

i'm doing calendar not historical

DiMiTriFrog commented 11 months ago

Hi. Thanks for your ejtraderMT, i'm trying to use it but i'm keep facing error and i've launched it on docker, this is the code that i'm trying to execute: image

this is the parameter: image

and this is my containers: image

what did i missed? can you help me, please

this is the error:

Again Traceback (most recent call last) File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:71, in Functions._pull_reply(self) 70 try: ---> 71 msg = self.sys_socket.recv_json() 72 except zmq.ZMQError:

File ~\AppData\Roaming\Python\Python310\site-packages\zmq\sugar\socket.py:1009, in Socket.recv_json(self, flags, kwargs) 990 """Receive a Python object as a message using json to serialize. 991 992 Keyword arguments are passed on to json.loads (...) 1007 for any of the reasons :func:~Socket.recv might fail 1008 """ -> 1009 msg = self.recv(flags) 1010 return self._deserialize(msg, lambda buf: jsonapi.loads(buf, kwargs))

File zmq\backend\cython\socket.pyx:805, in zmq.backend.cython.socket.Socket.recv()

File zmq\backend\cython\socket.pyx:841, in zmq.backend.cython.socket.Socket.recv()

File zmq\backend\cython\socket.pyx:199, in zmq.backend.cython.socket._recv_copy()

File zmq\backend\cython\socket.pyx:194, in zmq.backend.cython.socket._recv_copy()

File ~\AppData\Roaming\Python\Python310\site-packages\zmq\backend\cython\checkrc.pxd:22, in zmq.backend.cython.checkrc._check_rc()

Again: Resource temporarily unavailable

During handling of the above exception, another exception occurred:

NotDone Traceback (most recent call last) Cell In[1], line 3 1 from ejtraderMT import Metatrader ----> 3 api = Metatrader(host='localhost', debug=False) 5 symbol = "EURUSD" 6 fromDate = "01/01/2023"

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:138, in Metatrader.init(self, host, real_volume, tz_local, dbtype, dbhost, dbport, dbpass, dbuser, dbname, debug) 136 self.utc_timezone = timezone("UTC") 137 self.my_timezone = get_localzone() --> 138 self.utc_brockeroffset = self.utc_brocker_offset() 139 # db settings 140 self.dbtype = dbtype or "SQLITE" # SQLITE OR INFLUXDB

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:407, in Metatrader._utc_brocker_offset(self) 405 utc = datetime.now(self.utc_timezone).strftime("%Y-%m-%d %H:%M:%S") 406 try: --> 407 broker = self.accountInfo() 408 broker = datetime.strptime(broker["time"], "%Y.%m.%d %H:%M:%S") 409 except KeyError:

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:279, in Metatrader.accountInfo(self) 278 def accountInfo(self): --> 279 return self.__api.Command(action="ACCOUNT")

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:113, in Functions.Command(self, **kwargs) 110 self._send_request(request) 112 # return server reply --> 113 return self._pull_reply()

File ~\AppData\Roaming\Python\Python310\site-packages\ejtraderMT\api\mql.py:73, in Functions._pull_reply(self) 71 msg = self.sys_socket.recv_json() 72 except zmq.ZMQError: ---> 73 raise zmq.NotDone("Data socket timeout ERROR") 74 return msg

NotDone: Data socket timeout ERROR

Suddenly i'm having the same issue :(