Skip to content

Commit 6a33a71

Browse files
authored
Merge pull request #55 from TheSnowGuru/Branly76-patch-4
Added check terminal type
2 parents a44ff63 + e95d73a commit 6a33a71

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Pytrader_API_V3_02a.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
ERROR_DICT['01101'] = 'Undefined check terminal connection error'
2828

29+
ERROR_DICT['01201'] = 'Undefined check MT type error'
30+
2931
ERROR_DICT['00401'] = 'Instrument not in demo'
3032
ERROR_DICT['00402'] = 'Instrument not exists for broker'
3133

@@ -286,7 +288,7 @@ def Check_terminal_server_connection(self) -> bool:
286288
x = dataString.split('^')
287289

288290
if x[2] == 'OK':
289-
self.timeout = True
291+
self.timeout = False
290292
self.command_OK = True
291293
return True
292294
else:
@@ -298,6 +300,45 @@ def Check_terminal_server_connection(self) -> bool:
298300
self.command_return_error = ERROR_DICT['01101']
299301
self.command_OK = False
300302
return False
303+
304+
def Check_terminal_type(self) -> str:
305+
"""
306+
Checks for MT4 or MT5 terminal.
307+
Args:
308+
None
309+
Returns:
310+
string: if function for MT4 terminal answer would be 'MT4', for MT5 terminal 'MT5'
311+
312+
"""
313+
314+
self.command = 'F012^1^'
315+
self.command_return_error = ''
316+
ok, dataString = self.send_command(self.command)
317+
318+
try:
319+
if (ok == False):
320+
self.command_OK = False
321+
return False
322+
323+
x = dataString.split('^')
324+
325+
if x[3] == 'MT4':
326+
self.timeout = False
327+
self.command_OK = True
328+
return 'MT4'
329+
elif x[3] == 'MT5':
330+
self.timeout = False
331+
self.command_OK = True
332+
return 'MT5'
333+
else:
334+
self.timeout = False
335+
self.command_return_error = ERROR_DICT['99900']
336+
self.command_OK = True
337+
return False
338+
except:
339+
self.command_return_error = ERROR_DICT['01201']
340+
self.command_OK = False
341+
return False
301342

302343
@property
303344
def IsConnected(self) -> bool:
@@ -2291,3 +2332,4 @@ def create_empty_DataFrame(self,
22912332
('comment', str) ]
22922333

22932334

2335+

0 commit comments

Comments
 (0)