Skip to content

Commit 73695e4

Browse files
authoredJan 19, 2024
Add files via upload
1 parent 67f57d0 commit 73695e4

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed
 

‎algolab.py

+30-10
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def LoginUserControl(self):
138138
self.hash = content["hash"]
139139
if self.verbose:
140140
print("Login kontrolü başarılı.")
141-
#print(f"Hash: {self.hash}")
142141
self.save_settings()
143142
return True
144143
else:
@@ -245,6 +244,16 @@ def GetCandleData(self, symbol, period):
245244
except Exception as e:
246245
print(f"{f}() fonsiyonunda hata oluştu: {e}")
247246

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+
248257
def CashFlow(self, sub_account=""):
249258
try:
250259
f = inspect.stack()[0][3]
@@ -474,15 +483,26 @@ def _request(self, method, url, endpoint, payload, headers):
474483
time.sleep(0.1)
475484
LOCK = True
476485
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
486506
finally:
487507
LOCK = False
488508
return response

‎algolab_socket.py

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def recv(self):
6868
return False
6969
if self.heart_beat:
7070
r = self.ping()
71-
#print("Ping:", r, datetime.datetime.now())
7271
return data
7372

7473
def send(self, d):

‎config.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "2.1.1"
1+
version = "3.0.1"
22
hostname = "www.algolab.com.tr"
33
api_hostname = f"https://{hostname}"
44
api_url = api_hostname + "/api"
@@ -30,3 +30,9 @@
3030
URL_DELETEORDERVIOP = "/api/DeleteOrderViop"
3131
URL_SESSIONREFRESH = "/api/SessionRefresh"
3232
URL_GETCANDLEDATA = "/api/GetCandleData"
33+
URL_VIOPCOLLETERALINFO = "/api/ViopCollateralInfo"
34+
URL_RISKSIMULATION = "/api/RiskSimulation"
35+
URL_GETEQUITYORDERHISTORY = "/api/GetEquityOrderHistory"
36+
URL_GETVIOPORDERHISTORY = "/api/GetViopOrderHistory"
37+
URL_CASHFLOW = "/api/CashFlow"
38+
URL_ACCOUNTEXTRE = "/api/AccountExtre"

0 commit comments

Comments
 (0)
Please sign in to comment.