Skip to content

Commit

Permalink
Update py5paisa.py
Browse files Browse the repository at this point in the history
fixing issue with websocket init
  • Loading branch information
5paisa authored Aug 13, 2024
1 parent 2946bbe commit 7ccfdf1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions py5paisa/py5paisa.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, cred=None):
self.access_token = ""
self.request_token = None
self.scrip_data = None
self.WEBSOCKET_URL = ""
self.session = requests.Session()
self.APP_SOURCE = cred["APP_SOURCE"]
self.APP_NAME = cred["APP_NAME"]
Expand Down Expand Up @@ -528,7 +529,7 @@ def Request_Feed(self, Method: str, Operation: str, req_list: list):

def connect(self, wspayload: dict):
try:
if self.WEBSOCKET_URL == '':
if self.is_blank_or_none(self.WEBSOCKET_URL):
self.WEBSOCKET_URL=self.decode_token(self.Jwt_token)

self.web_url = f'{self.WEBSOCKET_URL}{self.Jwt_token}|{self.client_code}'
Expand All @@ -544,7 +545,10 @@ def on_open(ws):
self.ws.on_open = on_open
except Exception as e:
log_response(e)


def is_blank_or_none(self, value):
return value is None or value == "" or not value

def send_data(self, open_: any):
try:
self.ws.on_open = open_
Expand Down Expand Up @@ -1033,4 +1037,4 @@ def fetch_market_snapshot(self,reqList):
self.payload["body"]["Data"] = reqList
return self.order_request("MFS")
except Exception as e:
log_response(e)
log_response(e)

0 comments on commit 7ccfdf1

Please sign in to comment.