Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error that stops the code running. #48

Open
stuald opened this issue Jul 16, 2024 · 1 comment
Open

error that stops the code running. #48

stuald opened this issue Jul 16, 2024 · 1 comment

Comments

@stuald
Copy link

stuald commented Jul 16, 2024

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

@elvinex
Copy link
Collaborator

elvinex commented Sep 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants