Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Aug 13, 2024
1 parent 3850acc commit 87991f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
9 changes: 5 additions & 4 deletions quotexpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ async def connect(self) -> bool:

return ok

def check_connect(self):
if isinstance(self.api, QuotexAPI) and self.api.check_websocket_if_connect == 1:
return True
@property
def is_connected(self):
if isinstance(self.api, QuotexAPI):
return self.api.check_websocket_if_connect == 1
return False

async def re_subscribe_stream(self):
Expand Down Expand Up @@ -108,7 +109,7 @@ async def get_candles(self, asset: str, offset: int, period: int) -> typing.List
try:
tm = expiration.get_timestamp()
self.api.get_candles(asset, index, offset, period, tm)
while self.check_connect and self.api.candles.candles_data is None:
while self.is_connected and self.api.candles.candles_data is None:
await asyncio.sleep(0.1)
if self.api.candles.candles_data is not None:
break
Expand Down
24 changes: 13 additions & 11 deletions quotexpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def unsubscribe_realtime_candle(self, asset) -> None:
data = f'42["subfor", {json.dumps(asset)}]'
self.send_websocket_request(data)

def send_websocket_request(self, data: str, no_force_send=True) -> None:
def send_websocket_request(self, data: str, sync=True, no_force_send=True) -> None:
"""Send websocket request to Quotex server.
:param data: The websocket request data.
:param no_force_send: Default True.
Expand All @@ -229,16 +229,18 @@ def send_websocket_request(self, data: str, no_force_send=True) -> None:

self.logger.debug(data)
self.websocket.send(data)
self.websocket.send('42["tick"]')
self.websocket.send('42["indicator/list"]')
self.websocket.send('42["drawing/load"]')
self.websocket.send('42["pending/list"]')
self.websocket.send('42["chart_notification/get"]')

if self.current_asset:
payload = json.dumps({"asset": self.current_asset, "period": self.time_period})
self.websocket.send(f'42["instruments/update",{payload}]')
self.websocket.send(f'42["depth/follow","{self.current_asset}"]')

if sync:
self.websocket.send('42["tick"]')
self.websocket.send('42["indicator/list"]')
self.websocket.send('42["drawing/load"]')
self.websocket.send('42["pending/list"]')
self.websocket.send('42["chart_notification/get"]')

if self.current_asset:
payload = json.dumps({"asset": self.current_asset, "period": self.time_period})
self.websocket.send(f'42["instruments/update",{payload}]')
self.websocket.send(f'42["depth/follow","{self.current_asset}"]')

self.ssl_Mutual_exclusion_write = False

Expand Down

0 comments on commit 87991f2

Please sign in to comment.