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