quantplay 2.0.136__tar.gz → 2.0.138__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 (68) hide show
  1. {quantplay-2.0.136 → quantplay-2.0.138}/PKG-INFO +1 -1
  2. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/icici_direct.py +39 -17
  3. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/zerodha.py +2 -0
  4. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay.egg-info/PKG-INFO +1 -1
  5. {quantplay-2.0.136 → quantplay-2.0.138}/setup.py +1 -1
  6. {quantplay-2.0.136 → quantplay-2.0.138}/README.md +0 -0
  7. {quantplay-2.0.136 → quantplay-2.0.138}/pyproject.toml +0 -0
  8. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/__init__.py +0 -0
  9. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/__init__.py +0 -0
  10. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/aliceblue.py +0 -0
  11. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/angelone.py +0 -0
  12. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/auto_login/__init__.py +0 -0
  13. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/auto_login/aliceblue.py +0 -0
  14. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/broker_factory.py +0 -0
  15. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/dhan.py +0 -0
  16. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/finvasia_utils/__init__.py +0 -0
  17. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
  18. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/five_paisa.py +0 -0
  19. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/flattrade.py +0 -0
  20. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/ft_utils/__init__.py +0 -0
  21. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
  22. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/ft_utils/ft_noren.py +0 -0
  23. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/generics/__init__.py +0 -0
  24. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/generics/broker.py +0 -0
  25. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/iifl_xts.py +0 -0
  26. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/jainam_xts.py +0 -0
  27. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/kite_utils.py +0 -0
  28. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/kotak.py +0 -0
  29. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/motilal.py +0 -0
  30. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/noren.py +0 -0
  31. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/shoonya.py +0 -0
  32. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/uplink/__init__.py +0 -0
  33. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/uplink/uplink_utils.py +0 -0
  34. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/upstox.py +0 -0
  35. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/xts.py +0 -0
  36. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/xts_utils/Connect.py +0 -0
  37. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/xts_utils/Exception.py +0 -0
  38. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
  39. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/broker/xts_utils/__init__.py +0 -0
  40. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/exception/__init__.py +0 -0
  41. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/exception/exceptions.py +0 -0
  42. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/model/__init__.py +0 -0
  43. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/model/broker.py +0 -0
  44. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/model/broker_response.py +0 -0
  45. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/model/generics.py +0 -0
  46. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/model/instrument_data.py +0 -0
  47. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/model/order_event.py +0 -0
  48. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/py.typed +0 -0
  49. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/__init__.py +0 -0
  50. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/caching.py +0 -0
  51. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/constant.py +0 -0
  52. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/exchange.py +0 -0
  53. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/number_utils.py +0 -0
  54. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/pickle_utils.py +0 -0
  55. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/utils/selenium_utils.py +0 -0
  56. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/wrapper/__init__.py +0 -0
  57. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/wrapper/aws/__init__.py +0 -0
  58. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay/wrapper/aws/s3.py +0 -0
  59. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay.egg-info/SOURCES.txt +0 -0
  60. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay.egg-info/dependency_links.txt +0 -0
  61. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay.egg-info/requires.txt +0 -0
  62. {quantplay-2.0.136 → quantplay-2.0.138}/quantplay.egg-info/top_level.txt +0 -0
  63. {quantplay-2.0.136 → quantplay-2.0.138}/setup.cfg +0 -0
  64. {quantplay-2.0.136 → quantplay-2.0.138}/tests/__init__.py +0 -0
  65. {quantplay-2.0.136 → quantplay-2.0.138}/tests/conftest.py +0 -0
  66. {quantplay-2.0.136 → quantplay-2.0.138}/tests/wrapper/__init__.py +0 -0
  67. {quantplay-2.0.136 → quantplay-2.0.138}/tests/wrapper/aws/__init__.py +0 -0
  68. {quantplay-2.0.136 → quantplay-2.0.138}/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.136
3
+ Version: 2.0.138
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -1,7 +1,8 @@
1
1
  from collections.abc import Callable
2
2
  from datetime import datetime, date, timedelta
3
- from typing import Any, Literal
3
+ from typing import Any, Literal, Dict
4
4
  from breeze_connect.breeze_connect import BreezeConnect # type: ignore
5
+ from quantplay.exception import QuantplayOrderPlacementException, InvalidArgumentException
5
6
 
6
7
  from quantplay.broker.generics.broker import Broker
7
8
  import polars as pl
@@ -128,7 +129,7 @@ class ICICI(Broker):
128
129
  to_date = datetime.now().isoformat()[:19] + ".000Z"
129
130
  from_date = (datetime.now() - timedelta(hours=10)).isoformat()[:19] + ".000Z"
130
131
 
131
- orders = self.wrapper.get_order_list(
132
+ orders: Dict[str, Any] = self.wrapper.get_order_list( # type:ignore
132
133
  exchange_code="NFO",
133
134
  from_date=from_date,
134
135
  to_date=to_date,
@@ -211,7 +212,7 @@ class ICICI(Broker):
211
212
  def positions(self, drop_cnc: bool = True) -> pl.DataFrame:
212
213
  to_date = datetime.now().isoformat()[:19] + ".000Z"
213
214
  from_date = (datetime.now() - timedelta(hours=10)).isoformat()[:19] + ".000Z"
214
- positions = self.wrapper.get_portfolio_holdings(
215
+ positions: Dict[str, Any] = self.wrapper.get_portfolio_holdings( # type:ignore
215
216
  exchange_code="NFO",
216
217
  from_date=from_date,
217
218
  to_date=to_date,
@@ -239,11 +240,11 @@ class ICICI(Broker):
239
240
  .then(pl.lit("PE"))
240
241
  .alias("instrument_type"),
241
242
  (
242
- pl.col("unrealized_profit").cast(pl.Float32)
243
- + pl.col("realized_profit").cast(pl.Float32)
243
+ pl.col("unrealized_profit").cast(pl.Float32)
244
+ + pl.col("realized_profit").cast(pl.Float32)
244
245
  ).alias("pnl"),
245
246
  pl.col("quantity").cast(pl.Int32).alias("quantity"),
246
- pl.col("average_price").cast(pl.Float32).alias("average_price")
247
+ pl.col("average_price").cast(pl.Float32).alias("average_price"),
247
248
  )
248
249
 
249
250
  positions_df = positions_df.with_columns(
@@ -271,14 +272,24 @@ class ICICI(Broker):
271
272
 
272
273
  positions_df = positions_df.with_columns(
273
274
  pl.when(pl.col("quantity") < 0)
274
- .then(pl.col("quantity").abs()*pl.col("average_price")).otherwise(pl.lit(0)).alias("sell_value"),
275
+ .then(pl.col("quantity").abs() * pl.col("average_price"))
276
+ .when(pl.col("quantity") == 0)
277
+ .then(pl.col("realized_profit"))
278
+ .otherwise(pl.lit(0))
279
+ .alias("sell_value"),
275
280
  pl.when(pl.col("quantity") > 0)
276
- .then(pl.col("quantity").abs() * pl.col("average_price")).otherwise(pl.lit(0)).alias("buy_value"),
281
+ .then(pl.col("quantity").abs() * pl.col("average_price"))
282
+ .otherwise(pl.lit(0))
283
+ .alias("buy_value"),
277
284
  pl.lit(0).alias("ltp"),
278
285
  pl.when(pl.col("quantity") < 0)
279
- .then(pl.col("quantity").abs()).otherwise(pl.lit(0)).alias("sell_quantity"),
286
+ .then(pl.col("quantity").abs())
287
+ .otherwise(pl.lit(0))
288
+ .alias("sell_quantity"),
280
289
  pl.when(pl.col("quantity") > 0)
281
- .then(pl.col("quantity").abs()).otherwise(pl.lit(0)).alias("buy_quantity"),
290
+ .then(pl.col("quantity").abs())
291
+ .otherwise(pl.lit(0))
292
+ .alias("buy_quantity"),
282
293
  pl.lit("NRML").alias("product"),
283
294
  pl.col("instrument_type").alias("option_type"),
284
295
  )
@@ -286,11 +297,13 @@ class ICICI(Broker):
286
297
  self.positions_schema
287
298
  )
288
299
 
289
- def get_right(self, symbol_data):
290
- if symbol_data["instrument_type"] == "CE":
300
+ def get_right(self, symbol_data: Dict[str, Any]) -> str:
301
+ instrument_type = symbol_data["instrument_type"]
302
+ if instrument_type == "CE":
291
303
  return "call"
292
- elif symbol_data["instrument_type"] == "PE":
304
+ elif instrument_type == "PE":
293
305
  return "put"
306
+ raise InvalidArgumentException(f"{instrument_type} not supported")
294
307
 
295
308
  def place_order(
296
309
  self,
@@ -304,15 +317,19 @@ class ICICI(Broker):
304
317
  price: float,
305
318
  trigger_price: float | None = None,
306
319
  ) -> str | None:
320
+ if tag is None:
321
+ tag = ""
307
322
  icici_tradingsymbol = self.get_symbol(tradingsymbol)
308
- symbol_data = self.symbol_data[f"{exchange}:{icici_tradingsymbol}"]
323
+ symbol_data: Dict[str, Any] = self.symbol_data[ # type:ignore
324
+ f"{exchange}:{icici_tradingsymbol}"
325
+ ]
309
326
  icici_product = "cash"
310
327
  if exchange in ["NFO", "BFO"]:
311
328
  icici_product = "futures"
312
329
  if tradingsymbol[-2:] in ["PE", "CE"]:
313
330
  icici_product = "options"
314
331
  if icici_product == "cash":
315
- self.wrapper.place_order(
332
+ response = self.wrapper.place_order( # type:ignore
316
333
  stock_code=icici_tradingsymbol,
317
334
  exchange_code=exchange,
318
335
  product="cash",
@@ -325,7 +342,7 @@ class ICICI(Broker):
325
342
  user_remark=tag,
326
343
  )
327
344
  else:
328
- response = self.wrapper.place_order(
345
+ response: Dict[str, Any] = self.wrapper.place_order( # type:ignore
329
346
  stock_code=symbol_data["symbol_code"],
330
347
  exchange_code="NFO",
331
348
  product=icici_product,
@@ -340,7 +357,12 @@ class ICICI(Broker):
340
357
  strike_price=str(symbol_data["strike"]),
341
358
  user_remark=tag,
342
359
  )
343
- return response["Success"]["order_id"]
360
+ if "Success" in response and "order_id" in response["Success"]:
361
+ return response["Success"]["order_id"]
362
+ else:
363
+ raise QuantplayOrderPlacementException(
364
+ f"ICICI: order placement failed {response}"
365
+ )
344
366
 
345
367
  def modify_order(self, order: ModifyOrderRequest) -> str:
346
368
  return ""
@@ -580,6 +580,7 @@ class Zerodha(Broker):
580
580
  start_time: datetime,
581
581
  interval: str,
582
582
  end_time: datetime = datetime.now(),
583
+ oi: bool = False,
583
584
  ) -> pl.DataFrame:
584
585
  tradingsymbol = self.get_symbol(tradingsymbol, exchange=exchange)
585
586
  instrument_token = self.symbol_data[f"{exchange}:{tradingsymbol}"][ # type: ignore
@@ -595,6 +596,7 @@ class Zerodha(Broker):
595
596
  end_time,
596
597
  interval, # type: ignore
597
598
  continuous=False,
599
+ oi=oi,
598
600
  )
599
601
 
600
602
  for i, val in enumerate(data):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.0.136
3
+ Version: 2.0.138
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.136",
24
+ version="2.0.138",
25
25
  setup_requires=["pytest-runner"],
26
26
  install_requires=requirements,
27
27
  tests_require=[],
File without changes
File without changes
File without changes