quantplay 2.0.166__tar.gz → 2.0.168__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 (70) hide show
  1. {quantplay-2.0.166 → quantplay-2.0.168}/PKG-INFO +1 -1
  2. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/kotak.py +83 -7
  3. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay.egg-info/PKG-INFO +1 -1
  4. {quantplay-2.0.166 → quantplay-2.0.168}/setup.py +1 -1
  5. {quantplay-2.0.166 → quantplay-2.0.168}/README.md +0 -0
  6. {quantplay-2.0.166 → quantplay-2.0.168}/pyproject.toml +0 -0
  7. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/__init__.py +0 -0
  8. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/__init__.py +0 -0
  9. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/aliceblue.py +0 -0
  10. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/angelone.py +0 -0
  11. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/auto_login/__init__.py +0 -0
  12. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/auto_login/aliceblue.py +0 -0
  13. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/breeze/__init__.py +0 -0
  14. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/breeze/breeze_utils.py +0 -0
  15. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/broker_factory.py +0 -0
  16. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/dhan.py +0 -0
  17. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/finvasia_utils/__init__.py +0 -0
  18. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
  19. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/five_paisa.py +0 -0
  20. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/flattrade.py +0 -0
  21. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/ft_utils/__init__.py +0 -0
  22. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
  23. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/ft_utils/ft_noren.py +0 -0
  24. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/generics/__init__.py +0 -0
  25. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/generics/broker.py +0 -0
  26. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/icici_direct.py +0 -0
  27. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/iifl_xts.py +0 -0
  28. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/jainam_xts.py +0 -0
  29. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/kite_utils.py +0 -0
  30. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/motilal.py +0 -0
  31. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/noren.py +0 -0
  32. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/shoonya.py +0 -0
  33. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/uplink/__init__.py +0 -0
  34. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/uplink/uplink_utils.py +0 -0
  35. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/upstox.py +0 -0
  36. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/xts.py +0 -0
  37. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/xts_utils/Connect.py +0 -0
  38. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/xts_utils/Exception.py +0 -0
  39. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
  40. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/xts_utils/__init__.py +0 -0
  41. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/broker/zerodha.py +0 -0
  42. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/exception/__init__.py +0 -0
  43. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/exception/exceptions.py +0 -0
  44. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/model/__init__.py +0 -0
  45. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/model/broker.py +0 -0
  46. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/model/broker_response.py +0 -0
  47. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/model/generics.py +0 -0
  48. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/model/instrument_data.py +0 -0
  49. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/model/order_event.py +0 -0
  50. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/py.typed +0 -0
  51. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/__init__.py +0 -0
  52. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/caching.py +0 -0
  53. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/constant.py +0 -0
  54. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/exchange.py +0 -0
  55. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/number_utils.py +0 -0
  56. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/pickle_utils.py +0 -0
  57. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/utils/selenium_utils.py +0 -0
  58. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/wrapper/__init__.py +0 -0
  59. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/wrapper/aws/__init__.py +0 -0
  60. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay/wrapper/aws/s3.py +0 -0
  61. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay.egg-info/SOURCES.txt +0 -0
  62. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay.egg-info/dependency_links.txt +0 -0
  63. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay.egg-info/requires.txt +0 -0
  64. {quantplay-2.0.166 → quantplay-2.0.168}/quantplay.egg-info/top_level.txt +0 -0
  65. {quantplay-2.0.166 → quantplay-2.0.168}/setup.cfg +0 -0
  66. {quantplay-2.0.166 → quantplay-2.0.168}/tests/__init__.py +0 -0
  67. {quantplay-2.0.166 → quantplay-2.0.168}/tests/conftest.py +0 -0
  68. {quantplay-2.0.166 → quantplay-2.0.168}/tests/wrapper/__init__.py +0 -0
  69. {quantplay-2.0.166 → quantplay-2.0.168}/tests/wrapper/aws/__init__.py +0 -0
  70. {quantplay-2.0.166 → quantplay-2.0.168}/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.166
3
+ Version: 2.0.168
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -61,6 +61,7 @@ class Kotak(Broker):
61
61
  "bearer_token": configuration["bearer_token"],
62
62
  "view_token": configuration["view_token"],
63
63
  "sid": configuration["sid"],
64
+ "kotakUserId": configuration["kotakUserId"],
64
65
  "edit_token": configuration.get("edit_token"),
65
66
  "edit_sid": configuration.get("edit_sid"),
66
67
  "edit_rid": configuration.get("edit_rid"),
@@ -139,7 +140,7 @@ class Kotak(Broker):
139
140
  self.configuration["view_token"], options={"verify_signature": False}
140
141
  )
141
142
  userid = decode_jwt.get("sub")
142
- self.kotakUserId = userid
143
+ self.configuration["kotakUserId"] = userid
143
144
 
144
145
  generate_otp_resp = requests.post(
145
146
  url=f"{PROD_BASE_URL}login/1.0/login/otp/generate",
@@ -154,6 +155,7 @@ class Kotak(Broker):
154
155
  self.configuration["bearer_token"] is None
155
156
  or self.configuration["sid"] is None
156
157
  or self.configuration["view_token"] is None
158
+ or self.configuration["kotakUserId"] is None
157
159
  ):
158
160
  raise InvalidArgumentException("Missing Params")
159
161
 
@@ -165,7 +167,7 @@ class Kotak(Broker):
165
167
  "Auth": self.configuration["view_token"],
166
168
  "Content-Type": "application/json",
167
169
  },
168
- data=json.dumps({"userId": self.kotakUserId, "otp": otp}),
170
+ data=json.dumps({"userId": self.configuration["kotakUserId"], "otp": otp}),
169
171
  )
170
172
 
171
173
  edit_token_resp = json.loads(login_resp.text)
@@ -180,7 +182,39 @@ class Kotak(Broker):
180
182
  def order_history(self, order_id: str) -> pl.DataFrame:
181
183
  body = {"nOrdNo": order_id}
182
184
  order_history = self.request("order_history", body=body)["data"] # type:ignore
183
- return pl.DataFrame(order_history)
185
+ order_history_df = pl.DataFrame(order_history)[
186
+ [
187
+ "tok",
188
+ "flDtTm",
189
+ "nOrdNo",
190
+ "exch",
191
+ "prod",
192
+ "trdSym",
193
+ "trnsTp",
194
+ "qty",
195
+ "prcTp",
196
+ ]
197
+ ]
198
+ order_history_df = order_history_df.rename(
199
+ {
200
+ "tok": "token",
201
+ "flDtTm": "update_timestamp",
202
+ "nOrdNo": "order_id",
203
+ "exch": "exchange",
204
+ "prod": "product",
205
+ "trdSym": "tradingsymbol",
206
+ "trnsTp": "transaction_type",
207
+ "qty": "quantity",
208
+ "prcTp": "order_type",
209
+ }
210
+ )
211
+ order_history_df = order_history_df.with_columns(
212
+ pl.col("update_timestamp")
213
+ .str.strptime(pl.Datetime(time_unit="ms"), format="%d-%b-%Y %H:%M:%S")
214
+ .alias("update_timestamp")
215
+ ).sort("update_timestamp")
216
+
217
+ return order_history_df
184
218
 
185
219
  # **
186
220
  # ** GET Api's
@@ -455,11 +489,53 @@ class Kotak(Broker):
455
489
  self.request("cancel_order", body=body)
456
490
 
457
491
  def modify_order(self, order: ModifyOrderRequest) -> str:
458
- return ""
492
+ order_id = order["order_id"]
493
+ price = order.get("price")
494
+ trigger_price = order.get("trigger_price", 0)
459
495
 
460
- # **
461
- # ** General Utils
462
- # **
496
+ order_history = self.order_history(order_id).to_dicts()[-1]
497
+
498
+ order_type = self.get_order_type(
499
+ order.get("order_type", order_history["order_type"])
500
+ )
501
+ quantity = str(order.get("quantity", order_history["quantity"]))
502
+ modify_order_request = {
503
+ "tk": str(order_history["token"]),
504
+ "mp": "0",
505
+ "pc": order_history["product"],
506
+ "dd": "NA",
507
+ "dq": "0",
508
+ "vd": "DAY",
509
+ "ts": order_history["tradingsymbol"],
510
+ "tt": order_history["transaction_type"],
511
+ "pr": str(price),
512
+ "tp": str(trigger_price),
513
+ "qt": quantity,
514
+ "no": order_id,
515
+ "es": self.get_exchange(order_history["exchange"]),
516
+ "pt": order_type,
517
+ }
518
+
519
+ try:
520
+ Constants.logger.info(f"Modifying order [{order_id}] new price [{price}]")
521
+
522
+ modify_order_response = self.request( # type:ignore
523
+ "modify_order", body=modify_order_request
524
+ )
525
+
526
+ return modify_order_response["nOrdNo"]
527
+
528
+ except Exception as e:
529
+ exception_message = (
530
+ f"OrderModificationFailed for {order_id} failed with exception {e}"
531
+ )
532
+ if (
533
+ "Order cannot be modified as it is being processed"
534
+ not in exception_message
535
+ ):
536
+ Constants.logger.error(f"{exception_message}")
537
+
538
+ return order_id
463
539
 
464
540
  def get_transaction_type(self, transaction_type: TransactionType) -> str:
465
541
  transaction_type_map: dict[TransactionType, str] = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.0.166
3
+ Version: 2.0.168
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.166",
24
+ version="2.0.168",
25
25
  setup_requires=["pytest-runner"],
26
26
  install_requires=requirements,
27
27
  tests_require=[],
File without changes
File without changes
File without changes