@@ -138,7 +138,6 @@ def LoginUserControl(self):
138
138
self .hash = content ["hash" ]
139
139
if self .verbose :
140
140
print ("Login kontrolü başarılı." )
141
- #print(f"Hash: {self.hash}")
142
141
self .save_settings ()
143
142
return True
144
143
else :
@@ -245,6 +244,16 @@ def GetCandleData(self, symbol, period):
245
244
except Exception as e :
246
245
print (f"{ f } () fonsiyonunda hata oluştu: { e } " )
247
246
247
+ def RiskSimulation (self , sub_account = "" ):
248
+ try :
249
+ f = inspect .stack ()[0 ][3 ]
250
+ end_point = URL_RISKSIMULATION
251
+ payload = {'Subaccount' : sub_account }
252
+ resp = self .post (end_point , payload )
253
+ return self .error_check (resp , f )
254
+ except Exception as e :
255
+ print (f"{ f } () fonsiyonunda hata oluştu: { e } " )
256
+
248
257
def CashFlow (self , sub_account = "" ):
249
258
try :
250
259
f = inspect .stack ()[0 ][3 ]
@@ -474,15 +483,26 @@ def _request(self, method, url, endpoint, payload, headers):
474
483
time .sleep (0.1 )
475
484
LOCK = True
476
485
try :
477
- response = ""
478
- if method == "POST" :
479
- t = time .time ()
480
- diff = t - last_request
481
- wait_for = last_request > 0.0 and diff < self .freq # son işlemden geçen süre freq saniyeden küçükse bekle
482
- if wait_for :
483
- time .sleep (self .freq - diff + 0.1 )
484
- response = requests .post (url + endpoint , json = payload , headers = headers )
485
- last_request = time .time ()
486
+ tries = 0
487
+ while True :
488
+ tries += 1
489
+ try :
490
+ response = ""
491
+ if method == "POST" :
492
+ t = time .time ()
493
+ diff = t - last_request
494
+ wait_for = last_request > 0.0 and diff < self .freq # son işlemden geçen süre freq saniyeden küçükse bekle
495
+ if wait_for :
496
+ time .sleep (self .freq - diff + 0.1 )
497
+ response = requests .post (url + endpoint , json = payload , headers = headers )
498
+ last_request = time .time ()
499
+ break
500
+ except Exception as e :
501
+ print ("_request() exception: " , e )
502
+ time .sleep (1 )
503
+ if tries > 3 :
504
+ print ("Request failed. Quit!" )
505
+ break
486
506
finally :
487
507
LOCK = False
488
508
return response
0 commit comments