-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWs_Fix.py
More file actions
71 lines (60 loc) · 2.61 KB
/
Ws_Fix.py
File metadata and controls
71 lines (60 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
from fyers_api.Websocket import ws
def new_on_message(self, ws, msg):
self_data_type = self._FyersSocket__data_type
if self_data_type == "symbolData":
self.response = self.parse_symbol_data(msg)
if type(msg)== str:
if "error" in msg:
msg = json.loads(msg)
self.response_out["s"]=msg["s"]
self.response_out["code"]=msg["code"]
self.response_out["message"]=msg["message"]
self.response = self.response_out
self.logger.error("Response:{self.response}")
#self.logger.debug(f"Response:{self.response}")
if self.background_flag:
self.logger.debug(f"Response:{self.response}")
else:
print(f"Response:{self.response}")
self.websocket_data(self.response)
else:
self.response = msg
if self.background_flag:
if type(msg)== str:
if "error" in msg:
msg = json.loads(msg)
self.response_out["s"]=msg["s"]
self.response_out["code"]=msg["code"]
self.response_out["message"]=msg["message"]
self.response = self.response_out
self.logger.error(self.response)
self.logger.debug(f"Response:{self.response}")
else:
if type(msg)== str:
if "error" in msg:
msg = json.loads(msg)
self.response_out["s"]=msg["s"]
self.response_out["code"]=msg["code"]
self.response_out["message"]=msg["message"]
self.response = self.response_out
self.logger.error(self.response)
if self.websocket_data is not None:
self.websocket_data(self.response)
else:
print(f"Response:{self.response}")
else:
if self.websocket_data is not None:
self.websocket_data(self.response)
else:
print(f"Response:{self.response}")
else:
if self.websocket_data is not None:
self.websocket_data(self.response)
else:
print(f"Response:{self.response}")
# self.websocket_data()
return
# if self.__ws_message is not None:
# self.__ws_message(msg)
ws.FyersSocket._FyersSocket__on_message = new_on_message