You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Install ZeroMQ for MQL5 [https://github.com/dingmaotu/mql-zmq](https://github.com/dingmaotu/mql-zmq)
37
-
<<<<<<< HEAD
38
31
2. Put `include/Json.mqh` from this repo to your MetaEditor `include` directoty.
39
32
3. Download and compile `experts/JsonAPI.mq5` script.
40
33
4. Check if Metatrader 5 automatic trading is allowed.
@@ -56,29 +49,6 @@ The script uses four ZeroMQ sockets:
56
49
The idea is to send requests via `System socket` and recieve results/errors via `Data socket`. For `Live socket` and `Streaming socket` event handlers should be created because server sends data to theese sockets automatically. See examples in [Usage](#usage) section.
""" Send request to server via ZeroMQ System socket """
@@ -230,7 +145,6 @@ class MTraderAPI:
230
145
raise zmq.NotDone('Data socket timeout ERROR')
231
146
return msg
232
147
233
-
<<<<<<<HEAD
234
148
deflive_socket(self, context=None):
235
149
try:
236
150
context = context or zmq.Context.instance()
@@ -378,60 +292,3 @@ while True:
378
292
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
379
293
380
294
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See `LICENSE` for more information.
381
-
=======
382
-
def live_data(self):
383
-
""" Catch live data from server """
384
-
try:
385
-
candle = self.live_socket.recv_json()
386
-
except zmq.ZMQError:
387
-
raise zmq.NotDone("Live data ERROR")
388
-
return candle
389
-
390
-
def streaming_events(self):
391
-
""" Catch events from server """
392
-
try:
393
-
candle = self.events_socket.recv_json()
394
-
except zmq.ZMQError:
395
-
raise zmq.NotDone("Streaming events ERROR")
396
-
return candle
397
-
398
-
def construct_and_send(self, **kwargs) -> dict:
399
-
""" Construct request dictionary from default """
400
-
401
-
# default dictionary
402
-
request = {
403
-
"action": None,
404
-
"actionType": None,
405
-
"symbol": None,
406
-
"chartTF": None,
407
-
"fromDate": None,
408
-
"toDate": None,
409
-
"id": None,
410
-
"magic": None,
411
-
"volume": None,
412
-
"price": None,
413
-
"stoploss": None,
414
-
"takeprofit": None,
415
-
"expiration": None,
416
-
"deviation": None,
417
-
"comment": None
418
-
}
419
-
420
-
# update dict values if exist
421
-
for key, value in kwargs.items():
422
-
if key in request:
423
-
request[key] = value
424
-
else:
425
-
raise KeyError('Unknown key in **kwargs ERROR')
426
-
427
-
# send dict to server
428
-
self._send_request(request)
429
-
430
-
# return server reply
431
-
return self._pull_reply()
432
-
433
-
```
434
-
435
-
# License
436
-
Distributed under the GNU v3 License. See `LICENSE` for more information.
0 commit comments