Open stuald opened 4 months ago
Hi,
Maybe this happens when the MQL side only wrote the file partially for some reason.
A quick fix, even though not very pretty, could be to just add json.loads(text)
inside the try/except in the try_read_file
method in dwx_client.py so that it would not return the text if the text wasnt complete.
Hopefully, MetaTrader will write the file correctly the next time.
Hi guys,
Having used this code successfully for a long time now, I have started getting this intermittent error in the python code.
Traceback (most recent call last): File "c:\Users\sturobot\Desktop\DWXi1\DWX\python\samm_2_0_v3.py", line 797, in
processor = tick_processor(MT4_files_dir)
File "c:\Users\sturobot\Desktop\DWXi1\DWX\python\samm_2_0_v3.py", line 28, in init
self.dwx = dwx_client(self, MT4_directory_path, sleep_delay,
File "c:\Users\sturobot\Desktop\DWXi1\DWX\python\api\dwx_client.py", line 87, in init
self.load_orders()
File "c:\Users\sturobot\Desktop\DWXi1\DWX\python\api\dwx_client.py", line 353, in load_orders
data = json.loads(text)
File "C:\Users\sturobot\AppData\Local\Programs\Python\Python39\lib\json__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\sturobot\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\sturobot\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
it seems to be doing this from time to time when opening and parsing the orders files coming from the MQL element. it happens across multiple instances, on multiple machines. (so i don't think its the desktop setup) I can resolve this by manually deleting all the text files in the MQL/files/DWX = data folder where MQL stores the information.
anyone else experiencing this? any ideas?
thanks Stuart