@@ -626,7 +626,7 @@ def request_result(self, price: float, request: Dict[str, Any], type: Buys | Sel
626626 except Exception as e :
627627 msg = trade_retcode_message (result .retcode ) if result else "N/A"
628628 LOGGER .error (f"Trade Order Request, { msg } { addtionnal } , { e } " )
629- return
629+ return False
630630 if result and result .retcode != Mt5 .TRADE_RETCODE_DONE :
631631 if result .retcode == Mt5 .TRADE_RETCODE_INVALID_FILL : # 10030
632632 for fill in FILLING_TYPE :
@@ -658,7 +658,7 @@ def request_result(self, price: float, request: Dict[str, Any], type: Buys | Sel
658658 except Exception as e :
659659 msg = trade_retcode_message (result .retcode ) if result else "N/A"
660660 LOGGER .error (f"Trade Order Request, { msg } { addtionnal } , { e } " )
661- return
661+ return False
662662 if result and result .retcode == Mt5 .TRADE_RETCODE_DONE :
663663 break
664664 tries += 1
@@ -1078,7 +1078,7 @@ def break_even_request(self, tiket, price, request):
10781078 except Exception as e :
10791079 msg = trade_retcode_message (result .retcode ) if result else "N/A"
10801080 LOGGER .error (f"Break-Even Order Request, { msg } { addtionnal } , Error: { e } " )
1081- return
1081+ return False
10821082 if result and result .retcode != Mt5 .TRADE_RETCODE_DONE :
10831083 msg = trade_retcode_message (result .retcode )
10841084 if result .retcode != Mt5 .TRADE_RETCODE_NO_CHANGES :
@@ -1098,7 +1098,7 @@ def break_even_request(self, tiket, price, request):
10981098 LOGGER .error (
10991099 f"Break-Even Order Request, { msg } { addtionnal } , Error: { e } "
11001100 )
1101- return
1101+ return False
11021102 if result and result .retcode == Mt5 .TRADE_RETCODE_DONE :
11031103 break
11041104 tries += 1
@@ -1183,7 +1183,7 @@ def close_request(self, request: dict, type: str):
11831183 LOGGER .error (
11841184 f"Closing { type .capitalize ()} Request, RETCODE={ msg } { addtionnal } , Error: { e } "
11851185 )
1186- return
1186+ return False
11871187
11881188 if result and result .retcode != Mt5 .TRADE_RETCODE_DONE :
11891189 if result .retcode == Mt5 .TRADE_RETCODE_INVALID_FILL : # 10030
@@ -1210,7 +1210,7 @@ def close_request(self, request: dict, type: str):
12101210 LOGGER .error (
12111211 f"Closing { type .capitalize ()} Request, { msg } { addtionnal } , Error: { e } "
12121212 )
1213- return
1213+ return False
12141214 if result and result .retcode == Mt5 .TRADE_RETCODE_DONE :
12151215 break
12161216 tries += 1
@@ -1269,7 +1269,7 @@ def modify_order(
12691269 LOGGER .error (
12701270 f"Unable to modify Order #{ ticket } , RETCODE={ msg } , Error: { e } "
12711271 )
1272- return
1272+ return False
12731273 if result and result .retcode == Mt5 .TRADE_RETCODE_DONE :
12741274 LOGGER .info (
12751275 f"Order #{ ticket } modified, SYMBOL={ self .symbol } , PRICE={ round (request ['price' ], 5 )} ,"
@@ -1374,9 +1374,6 @@ def bulk_close(
13741374 order_type = "open"
13751375
13761376 if not tickets :
1377- LOGGER .info (
1378- f"No { order_type .upper ()} { tikets_type .upper ()} to close, SYMBOL={ self .symbol } ."
1379- )
13801377 return
13811378 failed_tickets = []
13821379 with ThreadPoolExecutor (max_workers = min (len (tickets ), 20 )) as executor :
@@ -1481,15 +1478,10 @@ def is_max_trades_reached(self) -> bool:
14811478
14821479 :return: bool
14831480 """
1484- negative_deals = 0
14851481 max_trades = self .rm .max_trade ()
14861482 today_deals = self .get_today_deals (group = self .symbol )
1487- for deal in today_deals :
1488- if deal .profit < 0 :
1489- negative_deals += 1
1490- if negative_deals >= max_trades :
1491- return True
1492- return False
1483+ negative_deals = [deal for deal in today_deals if deal .profit < 0 ]
1484+ return len (negative_deals ) >= max_trades
14931485
14941486 def get_stats (self ) -> Tuple [Dict [str , Any ], Dict [str , Any ]]:
14951487 """Retrieves aggregated session and historical trading performance."""
0 commit comments