PythonMetaTrader5 1.0.7__tar.gz → 1.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PythonMetaTrader5
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: Connect MT5 with Python
5
5
  Home-page: https://github.com/Akinzou/MetaTrader5-Python
6
6
  Author: Wiktor Jelen
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = PythonMetaTrader5
3
- version = 1.0.7
3
+ version = 1.0.9
4
4
  author = Wiktor Jelen
5
5
  author_email = wiktorjn@gmail.com
6
6
  description = Connect MT5 with Python
@@ -1,8 +1,10 @@
1
1
  # internal order send
2
2
  import time
3
-
4
3
  from MetaTrader5 import *
5
4
  import colorama
5
+ import pyautogui
6
+
7
+ colorama.init()
6
8
 
7
9
  def SpacerStart():
8
10
  print(colorama.Style.RESET_ALL + "//////////////////////////////")
@@ -27,14 +29,20 @@ class Broker:
27
29
  self.server = str(server)
28
30
 
29
31
  else:
30
- print(colorama.Fore.RED + "Login failed: ")
32
+ print(colorama.Fore.RED + "Login failed: ", str(self.log))
33
+
34
+ def login(self, ToEffect = False):
35
+ while True:
36
+ print(colorama.Fore.YELLOW + "Login on: ", str(self.log))
37
+ print(self.log)
38
+ if login(self.log, self.password, server=self.server):
39
+ print(colorama.Fore.GREEN + "OK")
40
+ time.sleep(0.5)
41
+ return True
42
+ if ToEffect==False:
43
+ print(colorama.Fore.RED + "ERROR")
44
+ return False
31
45
 
32
- def login(self):
33
- print(colorama.Fore.YELLOW + "Login on: ", str(self.log))
34
- if login(self.log, self.password, server=self.server):
35
- print(colorama.Fore.GREEN + "OK")
36
- else:
37
- print(colorama.Fore.RED + "ERROR")
38
46
 
39
47
  def _RawOrderClose(self, order_type, symbol, volume, price, comment=None, ticket=None):
40
48
  order = {
@@ -137,8 +145,13 @@ class Broker:
137
145
  print(self.RetCodes[r.retcode])
138
146
  print(colorama.Style.RESET_ALL)
139
147
  time.sleep(0.5)
140
- if not(lenpositions) or r.retcode == 10027:
148
+ if not(lenpositions):
141
149
  break
150
+ if r.retcode == 10027:
151
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
152
+ print(colorama.Style.RESET_ALL)
153
+ time.sleep(1)
154
+ pyautogui.hotkey('ctrl', 'e')
142
155
 
143
156
  if not close:
144
157
  SpacerStart()
@@ -168,7 +181,10 @@ class Broker:
168
181
  print(self.RetCodes[r.retcode])
169
182
  print(colorama.Style.RESET_ALL)
170
183
  if r.retcode == 10027:
171
- break
184
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
185
+ print(colorama.Style.RESET_ALL)
186
+ time.sleep(1)
187
+ pyautogui.hotkey('ctrl', 'e')
172
188
  time.sleep(0.5)
173
189
 
174
190
 
@@ -199,8 +215,13 @@ class Broker:
199
215
  print(colorama.Fore.RED + "ERROR CAN NOT OPEN", str(self.log), ": long ", symbol)
200
216
  print(self.RetCodes[r.retcode])
201
217
  print(colorama.Style.RESET_ALL)
202
- if r.retcode == 10027 or r.retcode == 10016:
218
+ if r.retcode == 10016:
203
219
  break
220
+ if r.retcode == 10027:
221
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
222
+ print(colorama.Style.RESET_ALL)
223
+ time.sleep(1)
224
+ pyautogui.hotkey('ctrl', 'e')
204
225
  time.sleep(0.5)
205
226
 
206
227
 
@@ -234,7 +255,10 @@ class Broker:
234
255
  print(self.RetCodes[r.retcode])
235
256
  print(colorama.Style.RESET_ALL)
236
257
  if r.retcode == 10027:
237
- break
258
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
259
+ print(colorama.Style.RESET_ALL)
260
+ time.sleep(1)
261
+ pyautogui.hotkey('ctrl', 'e')
238
262
  time.sleep(0.5)
239
263
 
240
264
 
@@ -266,8 +290,13 @@ class Broker:
266
290
  print(colorama.Fore.RED + "ERROR CAN NOT OPEN", str(self.log), " short ", symbol, " sl ", sl)
267
291
  print(self.RetCodes[r.retcode])
268
292
  print(colorama.Style.RESET_ALL)
269
- if r.retcode == 10027 or r.retcode == 10016:
293
+ if r.retcode == 10016:
270
294
  break
295
+ if r.retcode == 10027:
296
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
297
+ print(colorama.Style.RESET_ALL)
298
+ time.sleep(1)
299
+ pyautogui.hotkey('ctrl', 'e')
271
300
  time.sleep(0.5)
272
301
 
273
302
 
@@ -318,7 +347,10 @@ class Broker:
318
347
  print(self.RetCodes[r.retcode])
319
348
  print(colorama.Style.RESET_ALL)
320
349
  if r.retcode == 10027:
321
- break
350
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
351
+ print(colorama.Style.RESET_ALL)
352
+ time.sleep(1)
353
+ pyautogui.hotkey('ctrl', 'e')
322
354
  time.sleep(0.5)
323
355
 
324
356
  else:
@@ -362,7 +394,10 @@ class Broker:
362
394
  print(self.RetCodes[r.retcode])
363
395
  print(colorama.Style.RESET_ALL)
364
396
  if r.retcode == 10027:
365
- break
397
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
398
+ print(colorama.Style.RESET_ALL)
399
+ time.sleep(1)
400
+ pyautogui.hotkey('ctrl', 'e')
366
401
  time.sleep(0.5)
367
402
 
368
403
 
@@ -412,8 +447,13 @@ class Broker:
412
447
  print(colorama.Style.RESET_ALL)
413
448
  time.sleep(0.5)
414
449
 
415
- if not lenpositions or r.retcode == 10027:
450
+ if not lenpositions:
416
451
  break
452
+ if r.retcode == 10027:
453
+ print(colorama.Fore.GREEN + "Enabling algotrading", str(self.log), symbol)
454
+ print(colorama.Style.RESET_ALL)
455
+ time.sleep(1)
456
+ pyautogui.hotkey('ctrl', 'e')
417
457
 
418
458
  if not len(limit_orders):
419
459
  SpacerStart()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PythonMetaTrader5
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: Connect MT5 with Python
5
5
  Home-page: https://github.com/Akinzou/MetaTrader5-Python
6
6
  Author: Wiktor Jelen