quantplay 2.0.96__tar.gz → 2.0.98__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 (66) hide show
  1. {quantplay-2.0.96 → quantplay-2.0.98}/PKG-INFO +1 -1
  2. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/ft_utils/flattrade_utils.py +2 -2
  3. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/generics/broker.py +4 -4
  4. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/noren.py +64 -1
  5. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay.egg-info/PKG-INFO +1 -1
  6. {quantplay-2.0.96 → quantplay-2.0.98}/setup.py +1 -1
  7. {quantplay-2.0.96 → quantplay-2.0.98}/README.md +0 -0
  8. {quantplay-2.0.96 → quantplay-2.0.98}/pyproject.toml +0 -0
  9. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/__init__.py +0 -0
  10. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/__init__.py +0 -0
  11. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/aliceblue.py +0 -0
  12. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/angelone.py +0 -0
  13. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/auto_login/__init__.py +0 -0
  14. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/auto_login/aliceblue.py +0 -0
  15. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/broker_factory.py +0 -0
  16. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/dhan.py +0 -0
  17. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/finvasia_utils/__init__.py +0 -0
  18. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
  19. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/five_paisa.py +0 -0
  20. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/flattrade.py +0 -0
  21. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/ft_utils/__init__.py +0 -0
  22. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/ft_utils/ft_noren.py +0 -0
  23. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/generics/__init__.py +0 -0
  24. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/iifl_xts.py +0 -0
  25. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/kite_utils.py +0 -0
  26. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/kotak.py +0 -0
  27. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/motilal.py +0 -0
  28. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/shoonya.py +0 -0
  29. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/uplink/__init__.py +0 -0
  30. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/uplink/uplink_utils.py +0 -0
  31. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/upstox.py +0 -0
  32. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/xts.py +0 -0
  33. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/xts_utils/Connect.py +0 -0
  34. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/xts_utils/Exception.py +0 -0
  35. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
  36. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/xts_utils/__init__.py +0 -0
  37. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/broker/zerodha.py +0 -0
  38. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/exception/__init__.py +0 -0
  39. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/exception/exceptions.py +0 -0
  40. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/model/__init__.py +0 -0
  41. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/model/broker.py +0 -0
  42. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/model/broker_response.py +0 -0
  43. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/model/generics.py +0 -0
  44. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/model/instrument_data.py +0 -0
  45. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/model/order_event.py +0 -0
  46. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/py.typed +0 -0
  47. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/__init__.py +0 -0
  48. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/caching.py +0 -0
  49. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/constant.py +0 -0
  50. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/exchange.py +0 -0
  51. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/number_utils.py +0 -0
  52. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/pickle_utils.py +0 -0
  53. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/utils/selenium_utils.py +0 -0
  54. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/wrapper/__init__.py +0 -0
  55. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/wrapper/aws/__init__.py +0 -0
  56. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay/wrapper/aws/s3.py +0 -0
  57. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay.egg-info/SOURCES.txt +0 -0
  58. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay.egg-info/dependency_links.txt +0 -0
  59. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay.egg-info/requires.txt +0 -0
  60. {quantplay-2.0.96 → quantplay-2.0.98}/quantplay.egg-info/top_level.txt +0 -0
  61. {quantplay-2.0.96 → quantplay-2.0.98}/setup.cfg +0 -0
  62. {quantplay-2.0.96 → quantplay-2.0.98}/tests/__init__.py +0 -0
  63. {quantplay-2.0.96 → quantplay-2.0.98}/tests/conftest.py +0 -0
  64. {quantplay-2.0.96 → quantplay-2.0.98}/tests/wrapper/__init__.py +0 -0
  65. {quantplay-2.0.96 → quantplay-2.0.98}/tests/wrapper/aws/__init__.py +0 -0
  66. {quantplay-2.0.96 → quantplay-2.0.98}/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.96
3
+ Version: 2.0.98
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -80,7 +80,7 @@ class FlatTradeUtils:
80
80
  )
81
81
 
82
82
  except Exception as e:
83
- Constants.logger.error(f"Flattrade Selenium Error : {e}")
83
+ Constants.logger.info(f"Flattrade Selenium Error : {e}")
84
84
  traceback.print_exc()
85
85
  raise TokenException(str(e))
86
86
 
@@ -95,7 +95,7 @@ class FlatTradeUtils:
95
95
  try:
96
96
  request_token = url.split("code=")[1].split("&")[0]
97
97
  except Exception as e:
98
- Constants.logger.error(f"Flattrade Selenium Error for {url}")
98
+ Constants.logger.info(f"Flattrade Selenium Error for {url}")
99
99
  traceback.print_exc()
100
100
  raise TokenException(str(e))
101
101
 
@@ -217,12 +217,12 @@ class Broker(ABC):
217
217
  return pd.read_csv(f"/tmp/{file_name}.csv") # type: ignore
218
218
 
219
219
  @cached(cache=TTLCache(maxsize=1, ttl=2)) # type: ignore
220
- def cached_orders(self) -> pl.DataFrame:
221
- return self.orders()
220
+ def cached_orders(self, tag: str | None = None, add_ltp: bool = True) -> pl.DataFrame:
221
+ return self.orders(tag, add_ltp)
222
222
 
223
223
  @cached(cache=TTLCache(maxsize=1, ttl=2)) # type: ignore
224
- def cached_positions(self) -> pl.DataFrame:
225
- return self.positions()
224
+ def cached_positions(self, drop_cnc: bool = True) -> pl.DataFrame:
225
+ return self.positions(drop_cnc)
226
226
 
227
227
  def get_symbol(self, symbol: str, exchange: ExchangeType | None = None):
228
228
  return symbol
@@ -1,12 +1,15 @@
1
1
  import json
2
+ import re
2
3
  import traceback
3
4
  from json.decoder import JSONDecodeError
4
5
  from queue import Queue
5
- from typing import Any, Dict
6
+ from typing import Any, Dict, List
6
7
 
7
8
  import polars as pl
8
9
  from retrying import retry # type: ignore
9
10
 
11
+ from datetime import datetime
12
+
10
13
  from quantplay.broker.finvasia_utils.fa_noren import FA_NorenApi
11
14
  from quantplay.broker.ft_utils.ft_noren import FT_NorenApi
12
15
  from quantplay.broker.generics.broker import Broker
@@ -685,6 +688,66 @@ class Noren(Broker):
685
688
  traceback.print_exc()
686
689
  raise RetryableException("Failed to Receive Data from broker. Retrying Again")
687
690
 
691
+ def basket_margin(self, basket_orders: List[Dict[str, Any]]) -> Dict[str, Any]:
692
+ basket_orders = [
693
+ {
694
+ "exchange": "NFO",
695
+ "tradingsymbol": "NIFTY2481424500CE",
696
+ "transaction_type": "SELL",
697
+ "variety": "regular",
698
+ "product": "NRML",
699
+ "order_type": "MARKET",
700
+ "quantity": 25,
701
+ },
702
+ {
703
+ "exchange": "NFO",
704
+ "tradingsymbol": "NIFTY2481424500PE",
705
+ "transaction_type": "SELL",
706
+ "variety": "regular",
707
+ "product": "NRML",
708
+ "order_type": "MARKET",
709
+ "quantity": 15,
710
+ },
711
+ ]
712
+
713
+ for order in basket_orders:
714
+ exchange = order["exchange"]
715
+ tradingsymbol = order["tradingsymbol"]
716
+ if order["exchange"] not in ["BFO", "NFO"]:
717
+ raise InvalidArgumentException(
718
+ f"Exchange {exchange} is not supported for basket margin calculation"
719
+ )
720
+
721
+ split_regex = r"([A-Z]+)(.{5})([0-9]+)(CE|PE)"
722
+
723
+ underlying, expiry, strike, instrument_type = re.findall( # type:ignore
724
+ split_regex, tradingsymbol
725
+ )[0]
726
+ order["strprc"] = str(strike) + ".00"
727
+ order["symname"] = underlying
728
+ order["instname"] = "OPTIDX"
729
+ order["netqty"] = order["quantity"]
730
+ order["sellqty"] = order["quantity"]
731
+ order["optt"] = instrument_type
732
+ order["prd"] = self.get_product(order["product"])
733
+ order["exch"] = order["exchange"]
734
+
735
+ expiry = self.symbol_data[ # type:ignore
736
+ f"{exchange}:{self.get_symbol(tradingsymbol)}"
737
+ ]["expiry"]
738
+ order["exd"] = (
739
+ datetime.strptime(expiry, "%Y-%m-%d") # type:ignore
740
+ .strftime("%d-%b-%Y")
741
+ .upper()
742
+ )
743
+
744
+ if self.user_id is None:
745
+ raise Exception(
746
+ "UserId is not set: Please contact support team and report the issue"
747
+ )
748
+ response = self.api.span_calculator(self.user_id, basket_orders)
749
+ return response
750
+
688
751
  def margins(self) -> MarginsResponse:
689
752
  api_margins = self.invoke_noren_api(self.api.get_limits)
690
753
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.0.96
3
+ Version: 2.0.98
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.96",
24
+ version="2.0.98",
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