quantplay 2.0.56__tar.gz → 2.0.58__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 (65) hide show
  1. {quantplay-2.0.56 → quantplay-2.0.58}/PKG-INFO +1 -1
  2. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/broker_factory.py +59 -53
  3. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/dhan.py +9 -4
  4. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/upstox.py +12 -28
  5. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay.egg-info/PKG-INFO +1 -1
  6. {quantplay-2.0.56 → quantplay-2.0.58}/setup.py +1 -1
  7. {quantplay-2.0.56 → quantplay-2.0.58}/README.md +0 -0
  8. {quantplay-2.0.56 → quantplay-2.0.58}/pyproject.toml +0 -0
  9. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/__init__.py +0 -0
  10. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/__init__.py +0 -0
  11. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/aliceblue.py +0 -0
  12. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/angelone.py +0 -0
  13. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/auto_login/__init__.py +0 -0
  14. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/auto_login/aliceblue.py +0 -0
  15. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/finvasia_utils/__init__.py +0 -0
  16. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
  17. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/five_paisa.py +0 -0
  18. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/flattrade.py +0 -0
  19. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/ft_utils/__init__.py +0 -0
  20. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
  21. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/ft_utils/ft_noren.py +0 -0
  22. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/generics/__init__.py +0 -0
  23. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/generics/broker.py +0 -0
  24. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/iifl_xts.py +0 -0
  25. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/kite_utils.py +0 -0
  26. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/kotak.py +0 -0
  27. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/motilal.py +0 -0
  28. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/noren.py +0 -0
  29. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/shoonya.py +0 -0
  30. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/uplink/__init__.py +0 -0
  31. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/uplink/uplink_utils.py +0 -0
  32. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/xts.py +0 -0
  33. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/xts_utils/Connect.py +0 -0
  34. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/xts_utils/Exception.py +0 -0
  35. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
  36. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/xts_utils/__init__.py +0 -0
  37. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/broker/zerodha.py +0 -0
  38. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/exception/__init__.py +0 -0
  39. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/exception/exceptions.py +0 -0
  40. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/model/__init__.py +0 -0
  41. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/model/broker.py +0 -0
  42. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/model/generics.py +0 -0
  43. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/model/instrument_data.py +0 -0
  44. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/model/order_event.py +0 -0
  45. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/py.typed +0 -0
  46. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/__init__.py +0 -0
  47. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/caching.py +0 -0
  48. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/constant.py +0 -0
  49. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/exchange.py +0 -0
  50. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/number_utils.py +0 -0
  51. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/pickle_utils.py +0 -0
  52. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/utils/selenium_utils.py +0 -0
  53. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/wrapper/__init__.py +0 -0
  54. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/wrapper/aws/__init__.py +0 -0
  55. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay/wrapper/aws/s3.py +0 -0
  56. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay.egg-info/SOURCES.txt +0 -0
  57. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay.egg-info/dependency_links.txt +0 -0
  58. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay.egg-info/requires.txt +0 -0
  59. {quantplay-2.0.56 → quantplay-2.0.58}/quantplay.egg-info/top_level.txt +0 -0
  60. {quantplay-2.0.56 → quantplay-2.0.58}/setup.cfg +0 -0
  61. {quantplay-2.0.56 → quantplay-2.0.58}/tests/__init__.py +0 -0
  62. {quantplay-2.0.56 → quantplay-2.0.58}/tests/conftest.py +0 -0
  63. {quantplay-2.0.56 → quantplay-2.0.58}/tests/wrapper/__init__.py +0 -0
  64. {quantplay-2.0.56 → quantplay-2.0.58}/tests/wrapper/aws/__init__.py +0 -0
  65. {quantplay-2.0.56 → quantplay-2.0.58}/tests/wrapper/aws/s3_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.0.56
3
+ Version: 2.0.58
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -90,31 +90,32 @@ broker_required_args = {
90
90
  }
91
91
 
92
92
  broker_generate_args = {
93
- Broker.ZERODHA: set(["user_id", "api_key", "api_secret", "password", "totp"]),
93
+ Broker.ZERODHA: set(["user_id", "api_key", "api_secret"]),
94
94
  Broker.FLATTRADE: set(["user_id" "api_secret", "password", "totp_key", "api_key"]),
95
- Broker.IIFL_XTS: set(["user_id", "wrapper", "md_wrapper"]),
95
+ Broker.IIFL_XTS: set(["api_key", "api_secret", "md_api_key", "md_api_secret"]),
96
96
  Broker.MOTILAL: set(["user_id", "password", "api_key", "two_fa", "totp"]),
97
97
  Broker.ALICEBLUE: set(["user_id", "api_key"]),
98
98
  Broker.DHAN: set(["user_id", "access_token"]),
99
- Broker.FIVEPAISA_OPENAPI: set(["user_id", "client"]),
99
+ Broker.FIVEPAISA_OPENAPI: set(
100
+ [
101
+ "app_source",
102
+ "app_user_id",
103
+ "app_password",
104
+ "user_key",
105
+ "encryption_key",
106
+ "client_id",
107
+ "totp_key",
108
+ "pin",
109
+ ]
110
+ ),
100
111
  Broker.ANGELONE: set(["user_id", "api_key", "mpin", "totp"]),
101
112
  Broker.FINVASIA: set(
102
113
  ["api_secret", "imei", "password", "totp_key", "user_id", "vendor_code"]
103
114
  ),
115
+ Broker.UPSTOX: set(["user_id", "access_token"]),
104
116
  Broker.KOTAK: set(
105
117
  ["consumer_key", "consumer_secret", "mobilenumber", "password", "mpin"]
106
118
  ),
107
- Broker.UPSTOX: set(
108
- [
109
- "user_id",
110
- "api_key",
111
- "api_secret",
112
- "totp",
113
- "mobile_number",
114
- "account_pin",
115
- "redirect_url",
116
- ]
117
- ),
118
119
  }
119
120
 
120
121
 
@@ -126,10 +127,10 @@ class BrokerFactory:
126
127
  return f"{username}:{broker_name}"
127
128
 
128
129
  def validate_broker_args(
129
- self, broker_info: Dict[str, Any], is_generator_args: bool = False
130
+ self, user_broker_account: Dict[str, Any], is_generator_args: bool = False
130
131
  ):
131
- broker = broker_info["broker"]
132
- broker_data = broker_info["broker_data"]
132
+ broker = user_broker_account["broker"]
133
+ broker_data = user_broker_account["broker_data"]
133
134
 
134
135
  compare_map = broker_generate_args if is_generator_args else broker_required_args
135
136
 
@@ -138,17 +139,19 @@ class BrokerFactory:
138
139
 
139
140
  if not compare_map[broker].issubset(broker_data.keys()):
140
141
  raise InvalidArgumentException(
141
- f"Missing Arguments for {broker_info['username']}:{broker_info['nickname']} in broker '{broker}' -> {compare_map[broker].difference(broker_info.keys())}"
142
+ f"Missing Arguments for {user_broker_account['username']}:{user_broker_account['nickname']} in broker '{broker}' -> {compare_map[broker].difference(user_broker_account.keys())}"
142
143
  )
143
144
 
144
- def generate_token(self, broker_info: Dict[str, Any]):
145
+ def generate_token(
146
+ self, user_broker_account: Dict[str, Any]
147
+ ) -> Dict[str, BrokerType | Any]:
145
148
  broker_client: BrokerType | None = None
146
149
 
147
- broker_data = broker_info["broker_data"]
148
- broker = broker_info["broker"]
150
+ broker_data = user_broker_account["broker_data"]
151
+ broker = user_broker_account["broker"]
149
152
 
150
153
  broker_client: BrokerType | None = None
151
- self.validate_broker_args(broker_info, is_generator_args=True)
154
+ self.validate_broker_args(user_broker_account, is_generator_args=True)
152
155
 
153
156
  if broker == Broker.MOTILAL:
154
157
  broker_client = Motilal(
@@ -181,18 +184,25 @@ class BrokerFactory:
181
184
  broker_data["configuration"] = broker_client.configuration
182
185
 
183
186
  elif broker == Broker.ZERODHA:
184
- broker_client = Zerodha(
185
- user_id=broker_data["user_id"],
186
- api_key=broker_data["api_key"],
187
- api_secret=broker_data["api_secret"],
188
- password=broker_data["password"],
189
- totp=broker_data["totp"],
190
- load_instrument=False,
191
- )
187
+ if "password" in broker_data:
188
+ broker_client = Zerodha(
189
+ user_id=broker_data["user_id"],
190
+ api_key=broker_data["api_key"],
191
+ api_secret=broker_data["api_secret"],
192
+ password=broker_data["password"],
193
+ totp=broker_data["totp"],
194
+ load_instrument=False,
195
+ )
196
+
197
+ broker_data["zerodha_wrapper"] = codecs.encode(
198
+ pickle.dumps(broker_client.wrapper), "base64"
199
+ ).decode()
192
200
 
193
- broker_data["zerodha_wrapper"] = codecs.encode(
194
- pickle.dumps(broker_client.wrapper), "base64"
195
- ).decode()
201
+ else:
202
+ broker_client = Zerodha(
203
+ wrapper=broker_data["zerodha_wrapper"],
204
+ load_instrument=False,
205
+ )
196
206
 
197
207
  elif broker == Broker.ANGELONE:
198
208
  broker_client = AngelOne(
@@ -221,13 +231,7 @@ class BrokerFactory:
221
231
  elif broker == Broker.UPSTOX:
222
232
  broker_client = Upstox(
223
233
  user_id=broker_data["user_id"],
224
- api_key=broker_data["api_key"],
225
- api_secret=broker_data["api_secret"],
226
- totp=broker_data["totp"],
227
- mobile_number=broker_data["mobile_number"],
228
- account_pin=broker_data["account_pin"],
229
- redirect_url=broker_data["redirect_url"],
230
- load_instrument=False,
234
+ access_token=broker_data["access_token"],
231
235
  )
232
236
 
233
237
  broker_data["access_token"] = broker_client.configuration.access_token
@@ -303,17 +307,17 @@ class BrokerFactory:
303
307
  }
304
308
 
305
309
  def store_broker_client(
306
- self, broker_info: Dict[str, Any], load_instrument: bool = True
310
+ self, user_broker_account: Dict[str, Any], load_instrument: bool = True
307
311
  ) -> BrokerType | None:
308
- username = broker_info["username"]
309
- nickname = broker_info["nickname"]
312
+ username = user_broker_account["username"]
313
+ nickname = user_broker_account["nickname"]
310
314
 
311
- self.validate_broker_args(broker_info)
315
+ self.validate_broker_args(user_broker_account)
312
316
 
313
317
  broker_key = self.get_broker_key(username, nickname)
314
318
 
315
- broker_data = broker_info["broker_data"]
316
- broker = broker_info["broker"]
319
+ broker_data = user_broker_account["broker_data"]
320
+ broker = user_broker_account["broker"]
317
321
 
318
322
  broker_client: BrokerType | None = None
319
323
 
@@ -400,25 +404,27 @@ class BrokerFactory:
400
404
  broker_name=broker, broker=broker_client
401
405
  )
402
406
 
403
- broker_client.username = broker_info["username"]
404
- broker_client.nickname = broker_info["nickname"]
405
- broker_client.broker_name = broker_info["broker"]
407
+ broker_client.username = user_broker_account["username"]
408
+ broker_client.nickname = user_broker_account["nickname"]
409
+ broker_client.broker_name = user_broker_account["broker"]
406
410
  broker_client.user_id = broker_data["user_id"]
407
411
 
408
412
  self.client_broker_data[broker_key] = broker_client
409
413
 
410
414
  return broker_client
411
415
 
412
- def get_broker_client(self, broker_info: Dict[str, Any]) -> BrokerType:
413
- username = broker_info["username"]
414
- nickname = broker_info["nickname"]
416
+ def get_broker_client(self, user_broker_account: Dict[str, Any]) -> BrokerType:
417
+ username = user_broker_account["username"]
418
+ nickname = user_broker_account["nickname"]
415
419
 
416
420
  broker_key = self.get_broker_key(username, nickname)
417
421
 
418
422
  if broker_key in self.client_broker_data:
419
423
  return self.client_broker_data[broker_key]
420
424
 
421
- broker_client = self.store_broker_client(broker_info, load_instrument=False)
425
+ broker_client = self.store_broker_client(
426
+ user_broker_account, load_instrument=False
427
+ )
422
428
 
423
429
  if broker_client is not None:
424
430
  return broker_client
@@ -10,6 +10,7 @@ from quantplay.exception.exceptions import (
10
10
  InvalidArgumentException,
11
11
  QuantplayOrderPlacementException,
12
12
  RetryableException,
13
+ TokenException,
13
14
  retry_exception,
14
15
  )
15
16
  from quantplay.model.broker import (
@@ -32,10 +33,14 @@ class Dhan(Broker):
32
33
  access_token: str,
33
34
  load_instrument: bool = True,
34
35
  ):
35
- self.dhan = dhanhq(
36
- client_id=user_id,
37
- access_token=access_token,
38
- )
36
+ try:
37
+ self.dhan = dhanhq(
38
+ client_id=user_id,
39
+ access_token=access_token,
40
+ )
41
+
42
+ except Exception:
43
+ raise TokenException("Dhan Session Expired")
39
44
 
40
45
  def load_instrument(self, file_name: str | None = None) -> None:
41
46
  super().load_instrument("upstox_instruments")
@@ -51,36 +51,20 @@ class Upstox(Broker):
51
51
  ):
52
52
  super().__init__()
53
53
 
54
- try:
55
- if access_token:
56
- self.set_access_token(access_token)
57
- self.user_id = user_id
58
- elif (
59
- api_key
60
- and api_secret
61
- and totp
62
- and mobile_number
63
- and account_pin
64
- and redirect_url
65
- ):
66
- new_access_token = self.generate_token(
67
- api_key, api_secret, totp, mobile_number, account_pin, redirect_url
68
- )
69
- self.set_access_token(new_access_token)
70
-
71
- self.configuration = upstox_client.Configuration()
72
- self.configuration.access_token = self.access_token
73
- else:
74
- raise InvalidArgumentException("Missing Args")
75
-
76
- except Exception as e:
77
- raise e
54
+ if access_token:
55
+ self.set_access_token(access_token)
56
+ self.user_id = user_id
57
+ else:
58
+ raise TokenException("Upstox Session Expired")
78
59
 
79
- self.configuration = upstox_client.Configuration()
80
- self.configuration.access_token = self.access_token
81
- self.api_version = "2.0"
60
+ try:
61
+ self.configuration = upstox_client.Configuration()
62
+ self.configuration.access_token = self.access_token
63
+ self.api_version = "2.0"
82
64
 
83
- self.api_client = upstox_client.ApiClient(self.configuration)
65
+ self.api_client = upstox_client.ApiClient(self.configuration)
66
+ except Exception:
67
+ raise TokenException("Upstox Session Expired")
84
68
 
85
69
  if load_instrument:
86
70
  self.load_instrument()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.0.56
3
+ Version: 2.0.58
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -21,7 +21,7 @@ requirements = [
21
21
  setup(
22
22
  name="quantplay",
23
23
  long_description=Path("README.md").read_text(),
24
- version="2.0.56",
24
+ version="2.0.58",
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