quantplay 2.1.52__tar.gz → 2.1.53__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. {quantplay-2.1.52 → quantplay-2.1.53}/PKG-INFO +2 -6
  2. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/aliceblue.py +5 -5
  3. quantplay-2.1.53/quantplay/broker/angelone_utils/angeloneWS.py +117 -0
  4. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay.egg-info/PKG-INFO +2 -6
  5. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay.egg-info/SOURCES.txt +2 -0
  6. {quantplay-2.1.52 → quantplay-2.1.53}/setup.py +1 -1
  7. quantplay-2.1.53/tests/wrapper/aws/__init__.py +0 -0
  8. {quantplay-2.1.52 → quantplay-2.1.53}/README.md +0 -0
  9. {quantplay-2.1.52 → quantplay-2.1.53}/pyproject.toml +0 -0
  10. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/__init__.py +0 -0
  11. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/__init__.py +0 -0
  12. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/angelone.py +0 -0
  13. {quantplay-2.1.52/quantplay/broker/auto_login → quantplay-2.1.53/quantplay/broker/angelone_utils}/__init__.py +0 -0
  14. {quantplay-2.1.52/quantplay/broker/breeze → quantplay-2.1.53/quantplay/broker/auto_login}/__init__.py +0 -0
  15. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/auto_login/aliceblue.py +0 -0
  16. {quantplay-2.1.52/quantplay/broker/finvasia_utils → quantplay-2.1.53/quantplay/broker/breeze}/__init__.py +0 -0
  17. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/breeze/breeze_utils.py +0 -0
  18. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/broker_factory.py +0 -0
  19. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/dhan.py +0 -0
  20. {quantplay-2.1.52/quantplay/broker/ft_utils → quantplay-2.1.53/quantplay/broker/finvasia_utils}/__init__.py +0 -0
  21. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
  22. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/five_paisa.py +0 -0
  23. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/flattrade.py +0 -0
  24. {quantplay-2.1.52/quantplay/broker/generics → quantplay-2.1.53/quantplay/broker/ft_utils}/__init__.py +0 -0
  25. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
  26. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/ft_utils/ft_noren.py +0 -0
  27. {quantplay-2.1.52/quantplay/broker/kotak_utils → quantplay-2.1.53/quantplay/broker/generics}/__init__.py +0 -0
  28. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/generics/broker.py +0 -0
  29. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/icici_direct.py +0 -0
  30. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/iifl_xts.py +0 -0
  31. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/jainam_xts.py +0 -0
  32. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/kite_utils.py +0 -0
  33. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/kotak.py +0 -0
  34. {quantplay-2.1.52/quantplay/broker/uplink → quantplay-2.1.53/quantplay/broker/kotak_utils}/__init__.py +0 -0
  35. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/kotak_utils/kotak_ws.py +0 -0
  36. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/kotak_utils/kotak_ws_lib.py +0 -0
  37. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/motilal.py +0 -0
  38. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/noren.py +0 -0
  39. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/shoonya.py +0 -0
  40. {quantplay-2.1.52/quantplay/broker/xts_utils → quantplay-2.1.53/quantplay/broker/uplink}/__init__.py +0 -0
  41. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/uplink/uplink_utils.py +0 -0
  42. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/upstox.py +0 -0
  43. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/xts.py +0 -0
  44. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/xts_utils/Connect.py +0 -0
  45. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/xts_utils/Exception.py +0 -0
  46. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
  47. {quantplay-2.1.52/quantplay/broker/xts_utils_v2 → quantplay-2.1.53/quantplay/broker/xts_utils}/__init__.py +0 -0
  48. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/xts_utils_v2/ConnectV2.py +0 -0
  49. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/xts_utils_v2/InteractiveSocketClientV2.py +0 -0
  50. {quantplay-2.1.52/quantplay/core → quantplay-2.1.53/quantplay/broker/xts_utils_v2}/__init__.py +0 -0
  51. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/broker/zerodha.py +0 -0
  52. {quantplay-2.1.52/quantplay/indicator → quantplay-2.1.53/quantplay/core}/__init__.py +0 -0
  53. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/core/strategy.py +0 -0
  54. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/exception/__init__.py +0 -0
  55. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/exception/exceptions.py +0 -0
  56. {quantplay-2.1.52/quantplay/model → quantplay-2.1.53/quantplay/indicator}/__init__.py +0 -0
  57. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/indicator/iv.py +0 -0
  58. {quantplay-2.1.52/quantplay/strategy → quantplay-2.1.53/quantplay/model}/__init__.py +0 -0
  59. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/model/broker.py +0 -0
  60. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/model/broker_response.py +0 -0
  61. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/model/generics.py +0 -0
  62. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/model/instrument_data.py +0 -0
  63. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/model/order_event.py +0 -0
  64. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/py.typed +0 -0
  65. {quantplay-2.1.52/quantplay/wrapper → quantplay-2.1.53/quantplay/strategy}/__init__.py +0 -0
  66. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/strategy/iv_spike.py +0 -0
  67. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/strategy/obuy.py +0 -0
  68. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/__init__.py +0 -0
  69. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/caching.py +0 -0
  70. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/constant.py +0 -0
  71. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/exchange.py +0 -0
  72. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/number_utils.py +0 -0
  73. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/pickle_utils.py +0 -0
  74. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/utils/selenium_utils.py +0 -0
  75. {quantplay-2.1.52/quantplay/wrapper/aws → quantplay-2.1.53/quantplay/wrapper}/__init__.py +0 -0
  76. {quantplay-2.1.52/tests → quantplay-2.1.53/quantplay/wrapper/aws}/__init__.py +0 -0
  77. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/wrapper/aws/s3.py +0 -0
  78. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay/wrapper/redis.py +0 -0
  79. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay.egg-info/dependency_links.txt +0 -0
  80. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay.egg-info/requires.txt +0 -0
  81. {quantplay-2.1.52 → quantplay-2.1.53}/quantplay.egg-info/top_level.txt +0 -0
  82. {quantplay-2.1.52 → quantplay-2.1.53}/setup.cfg +0 -0
  83. {quantplay-2.1.52/tests/wrapper → quantplay-2.1.53/tests}/__init__.py +0 -0
  84. {quantplay-2.1.52 → quantplay-2.1.53}/tests/conftest.py +0 -0
  85. {quantplay-2.1.52/tests/wrapper/aws → quantplay-2.1.53/tests/wrapper}/__init__.py +0 -0
  86. {quantplay-2.1.52 → quantplay-2.1.53}/tests/wrapper/aws/s3_test.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.1.52
3
+ Version: 2.1.53
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -36,10 +36,6 @@ Requires-Dist: python-engineio
36
36
  Requires-Dist: python-socketio
37
37
  Requires-Dist: six
38
38
  Requires-Dist: dhanhq
39
- Dynamic: description
40
- Dynamic: license
41
- Dynamic: requires-dist
42
- Dynamic: summary
43
39
 
44
40
  # Quantplay Alpha playground
45
41
 
@@ -661,8 +661,8 @@ class Aliceblue(Broker):
661
661
  def handle_order_update(self, order: dict[str, str]):
662
662
  try:
663
663
  out_order: OrderUpdateEvent = {
664
- "placed_by": order["remarks"],
665
- "tag": order["remarks"],
664
+ "placed_by": order["actid"],
665
+ "tag": order["actid"],
666
666
  "order_id": order["norenordno"],
667
667
  "exchange": order["exch"],
668
668
  "tradingsymbol": order["tsym"],
@@ -672,7 +672,7 @@ class Aliceblue(Broker):
672
672
  "exchange_order_id": order["norenordno"],
673
673
  "transaction_type": order["trantype"],
674
674
  "product": order["pcode"],
675
- "quantity": order["qty"],
675
+ "quantity": int(order["qty"]),
676
676
  } # type: ignore
677
677
 
678
678
  if out_order["exchange"] == "NSE":
@@ -703,7 +703,7 @@ class Aliceblue(Broker):
703
703
  out_order["transaction_type"] = "BUY"
704
704
  else:
705
705
  logger.error(
706
- "[UNKNOW_VALUE] finvasia transaction type {} not supported".format(
706
+ "[UNKNOW_VALUE] Aliceblue transaction type {} not supported".format(
707
707
  order["trantype"]
708
708
  )
709
709
  )
@@ -718,7 +718,7 @@ class Aliceblue(Broker):
718
718
  elif order["status"] == "CANCELED":
719
719
  out_order["status"] = "CANCELLED"
720
720
 
721
- logger.info(f"[ORDER_FEED] {order}")
721
+ logger.info(f"[ORDER_FEED] {out_order}")
722
722
  if self.order_updates:
723
723
  self.order_updates.put(out_order)
724
724
 
@@ -0,0 +1,117 @@
1
+ import ssl
2
+ import websocket
3
+ import time
4
+
5
+ from quantplay.utils.constant import Constants
6
+
7
+ logger = Constants.logger
8
+
9
+
10
+ class AngelOneOrderUpdateWS(object):
11
+ WEBSOCKET_URI = "wss://tns.angelone.in/smart-order-update"
12
+ HEARTBEAT_MESSAGE = "ping" # Heartbeat message to maintain Socket connection.
13
+ HEARTBEAT_INTERVAL_SECONDS = (
14
+ 10 # Interval for sending heartbeat messages to keep the connection alive.
15
+ )
16
+ MAX_CONNECTION_RETRY_ATTEMPTS = (
17
+ 2 # Max retry attempts to establish Socket connection in case of failure.
18
+ )
19
+ RETRY_DELAY_SECONDS = (
20
+ 10 # Delay between retry attempts when reconnecting to Socket in case of failure.
21
+ )
22
+ wsapp = None # Socket connection instance
23
+ last_pong_timestamp = None # Timestamp of the last received pong message
24
+ current_retry_attempt = 0 # Current retry attempt count
25
+
26
+ def __init__(
27
+ self,
28
+ auth_token: str,
29
+ api_key: str,
30
+ client_code: str,
31
+ feed_token: str,
32
+ ):
33
+ self.auth_token = auth_token
34
+ self.api_key = api_key
35
+ self.client_code = client_code
36
+ self.feed_token = feed_token
37
+
38
+ def on_message(self, wsapp: websocket.WebSocket, message: str | bytes):
39
+ print(message)
40
+
41
+ def on_data(
42
+ self,
43
+ wsapp: websocket.WebSocket,
44
+ message: str,
45
+ data_type: int,
46
+ continue_flag: bool,
47
+ ):
48
+ self.on_message(wsapp, message)
49
+
50
+ def on_open(self, wsapp: websocket.WebSocket):
51
+ logger.info("Connection opened")
52
+
53
+ def on_error(self, wsapp: websocket.WebSocket, error: str):
54
+ logger.error("Error: %s", error)
55
+
56
+ def on_close(
57
+ self, wsapp: websocket.WebSocket, close_status_code: int, close_msg: str
58
+ ):
59
+ logger.info("Connection closed")
60
+ self.retry_connect()
61
+
62
+ def on_pong(self, wsapp: websocket.WebSocket, data: str):
63
+ if data == self.HEARTBEAT_MESSAGE:
64
+ timestamp = time.time()
65
+ self.last_pong_timestamp = timestamp
66
+ else:
67
+ self.on_data(wsapp, data, websocket.ABNF.OPCODE_BINARY, False)
68
+
69
+ def check_connection_status(self):
70
+ current_time = time.time()
71
+ if (
72
+ self.last_pong_timestamp is not None
73
+ and current_time - self.last_pong_timestamp
74
+ > 2 * self.HEARTBEAT_INTERVAL_SECONDS
75
+ ):
76
+ self.close_connection()
77
+
78
+ def connect(self):
79
+ headers = {
80
+ "Authorization": f"Bearer {self.auth_token}",
81
+ "x-api-key": self.api_key,
82
+ "x-client-code": self.client_code,
83
+ "x-feed-token": self.feed_token,
84
+ }
85
+ try:
86
+ self.wsapp = websocket.WebSocketApp(
87
+ self.WEBSOCKET_URI,
88
+ header=headers,
89
+ on_open=self.on_open,
90
+ on_error=self.on_error,
91
+ on_close=self.on_close,
92
+ on_data=self.on_data,
93
+ on_pong=self.on_pong,
94
+ )
95
+ self.wsapp.run_forever( # type: ignore
96
+ sslopt={"cert_reqs": ssl.CERT_NONE},
97
+ ping_interval=self.HEARTBEAT_INTERVAL_SECONDS,
98
+ ping_payload=self.HEARTBEAT_MESSAGE,
99
+ )
100
+ except Exception as e:
101
+ logger.error("Error connecting to WebSocket: %s", e)
102
+ self.retry_connect()
103
+
104
+ def retry_connect(self):
105
+ if self.current_retry_attempt < self.MAX_CONNECTION_RETRY_ATTEMPTS:
106
+ logger.info(
107
+ "Retrying connection (Attempt %s)...", self.current_retry_attempt + 1
108
+ )
109
+ time.sleep(self.RETRY_DELAY_SECONDS)
110
+ self.current_retry_attempt += 1
111
+ self.connect()
112
+ else:
113
+ logger.warning("Max retry attempts reached.")
114
+
115
+ def close_connection(self):
116
+ if self.wsapp:
117
+ self.wsapp.close() # type: ignore
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.1.52
3
+ Version: 2.1.53
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -36,10 +36,6 @@ Requires-Dist: python-engineio
36
36
  Requires-Dist: python-socketio
37
37
  Requires-Dist: six
38
38
  Requires-Dist: dhanhq
39
- Dynamic: description
40
- Dynamic: license
41
- Dynamic: requires-dist
42
- Dynamic: summary
43
39
 
44
40
  # Quantplay Alpha playground
45
41
 
@@ -26,6 +26,8 @@ quantplay/broker/shoonya.py
26
26
  quantplay/broker/upstox.py
27
27
  quantplay/broker/xts.py
28
28
  quantplay/broker/zerodha.py
29
+ quantplay/broker/angelone_utils/__init__.py
30
+ quantplay/broker/angelone_utils/angeloneWS.py
29
31
  quantplay/broker/auto_login/__init__.py
30
32
  quantplay/broker/auto_login/aliceblue.py
31
33
  quantplay/broker/breeze/__init__.py
@@ -21,7 +21,7 @@ requirements = [
21
21
  setup(
22
22
  name="quantplay",
23
23
  long_description=Path("README.md").read_text(),
24
- version="2.1.52",
24
+ version="2.1.53",
25
25
  setup_requires=["pytest-runner"],
26
26
  install_requires=requirements,
27
27
  tests_require=[],
File without changes
File without changes
File without changes
File without changes
File without changes