quantplay 2.0.34__tar.gz → 2.0.35__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 (61) hide show
  1. {quantplay-2.0.34 → quantplay-2.0.35}/PKG-INFO +1 -1
  2. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/aliceblue.py +2 -4
  3. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/angelone.py +4 -6
  4. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/five_paisa.py +1 -1
  5. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/generics/broker.py +4 -3
  6. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/uplink/uplink_utils.py +0 -1
  7. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/upstox.py +8 -8
  8. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/xts.py +5 -2
  9. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/xts_utils/InteractiveSocketClient.py +13 -13
  10. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/utils/pickle_utils.py +3 -3
  11. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/wrapper/aws/s3.py +3 -3
  12. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay.egg-info/PKG-INFO +1 -1
  13. {quantplay-2.0.34 → quantplay-2.0.35}/setup.py +1 -1
  14. {quantplay-2.0.34 → quantplay-2.0.35}/README.md +0 -0
  15. {quantplay-2.0.34 → quantplay-2.0.35}/pyproject.toml +0 -0
  16. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/__init__.py +0 -0
  17. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/__init__.py +0 -0
  18. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/auto_login/__init__.py +0 -0
  19. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/auto_login/aliceblue.py +0 -0
  20. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/finvasia_utils/__init__.py +0 -0
  21. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
  22. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/flattrade.py +0 -0
  23. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/ft_utils/__init__.py +0 -0
  24. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
  25. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/ft_utils/ft_noren.py +0 -0
  26. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/generics/__init__.py +0 -0
  27. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/iifl_xts.py +0 -0
  28. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/kite_utils.py +0 -0
  29. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/motilal.py +0 -0
  30. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/noren.py +0 -0
  31. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/shoonya.py +0 -0
  32. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/uplink/__init__.py +0 -0
  33. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/xts_utils/Connect.py +0 -0
  34. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/xts_utils/Exception.py +0 -0
  35. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/xts_utils/__init__.py +0 -0
  36. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/broker/zerodha.py +0 -0
  37. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/exception/__init__.py +0 -0
  38. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/exception/exceptions.py +0 -0
  39. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/model/__init__.py +0 -0
  40. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/model/broker.py +0 -0
  41. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/model/generics.py +0 -0
  42. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/model/instrument_data.py +0 -0
  43. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/model/order_event.py +0 -0
  44. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/py.typed +0 -0
  45. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/utils/__init__.py +0 -0
  46. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/utils/constant.py +0 -0
  47. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/utils/exchange.py +0 -0
  48. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/utils/number_utils.py +0 -0
  49. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/utils/selenium_utils.py +0 -0
  50. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/wrapper/__init__.py +0 -0
  51. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay/wrapper/aws/__init__.py +0 -0
  52. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay.egg-info/SOURCES.txt +0 -0
  53. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay.egg-info/dependency_links.txt +0 -0
  54. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay.egg-info/requires.txt +0 -0
  55. {quantplay-2.0.34 → quantplay-2.0.35}/quantplay.egg-info/top_level.txt +0 -0
  56. {quantplay-2.0.34 → quantplay-2.0.35}/setup.cfg +0 -0
  57. {quantplay-2.0.34 → quantplay-2.0.35}/tests/__init__.py +0 -0
  58. {quantplay-2.0.34 → quantplay-2.0.35}/tests/conftest.py +0 -0
  59. {quantplay-2.0.34 → quantplay-2.0.35}/tests/wrapper/__init__.py +0 -0
  60. {quantplay-2.0.34 → quantplay-2.0.35}/tests/wrapper/aws/__init__.py +0 -0
  61. {quantplay-2.0.34 → quantplay-2.0.35}/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.34
3
+ Version: 2.0.35
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -134,7 +134,7 @@ class Aliceblue(Broker):
134
134
  return TransactionType.Sell
135
135
 
136
136
  raise InvalidArgumentException(
137
- "transaction type {} not supported for trading".format(transaction_type)
137
+ f"transaction type {transaction_type} not supported for trading"
138
138
  )
139
139
 
140
140
  def get_order_type(self, order_type):
@@ -170,9 +170,7 @@ class Aliceblue(Broker):
170
170
  ]:
171
171
  return product
172
172
 
173
- raise InvalidArgumentException(
174
- "Product {} not supported for trading".format(product)
175
- )
173
+ raise InvalidArgumentException(f"Product {product} not supported for trading")
176
174
 
177
175
  def place_order(
178
176
  self,
@@ -5,7 +5,7 @@ import json
5
5
  import pickle
6
6
  from queue import Queue
7
7
  import traceback
8
- from typing import Callable, Dict
8
+ from typing import Any, Callable, Dict
9
9
 
10
10
  from SmartApi.smartExceptions import DataException
11
11
  import polars as pl
@@ -157,9 +157,7 @@ class AngelOne(Broker):
157
157
  elif product in ["BO", "MARGIN", "INTRADAY", "CARRYFORWARD", "DELIVERY"]:
158
158
  return product
159
159
 
160
- raise InvalidArgumentException(
161
- "Product {} not supported for trading".format(product)
162
- )
160
+ raise InvalidArgumentException(f"Product {product} not supported for trading")
163
161
 
164
162
  def ltp(self, exchange, tradingsymbol: str) -> float:
165
163
  if tradingsymbol in MarketConstants.INDEX_SYMBOL_TO_DERIVATIVE_SYMBOL_MAP:
@@ -224,7 +222,7 @@ class AngelOne(Broker):
224
222
  "ordertag": tag,
225
223
  }
226
224
 
227
- Constants.logger.info("[PLACING_ORDER] {}".format(json.dumps(order)))
225
+ Constants.logger.info(f"[PLACING_ORDER] {json.dumps(order)}")
228
226
  return self.invoke_angelone_api(self.wrapper.placeOrder, orderparams=order)
229
227
 
230
228
  except (TimeoutError, ConnectTimeout):
@@ -563,7 +561,7 @@ class AngelOne(Broker):
563
561
  stop_max_attempt_number=3,
564
562
  retry_on_exception=retry_exception,
565
563
  )
566
- def invoke_angelone_api(self, fn: Callable, *args, **kwargs) -> Dict:
564
+ def invoke_angelone_api(self, fn: Callable, *args, **kwargs) -> Any:
567
565
  try:
568
566
  response = fn(*args, **kwargs)
569
567
  if "errorCode" in response and response["errorCode"] == "AG8001":
@@ -5,7 +5,7 @@ from typing import Dict
5
5
 
6
6
  import polars as pl
7
7
  import pyotp
8
- from py5paisa import FivePaisaClient
8
+ from py5paisa import FivePaisaClient # type: ignore
9
9
  from retrying import retry # type: ignore
10
10
 
11
11
  from quantplay.broker.generics.broker import Broker
@@ -147,7 +147,7 @@ class Broker:
147
147
  if not input:
148
148
  raise InvalidArgumentException(message)
149
149
 
150
- def symbol_attribute(self, exchange: ExchangeType, symbol, value):
150
+ def symbol_attribute(self, exchange: ExchangeType, symbol: str, value):
151
151
  try:
152
152
  return_value = self.symbol_data[f"{exchange}:{symbol}"][value]
153
153
  return return_value
@@ -307,6 +307,7 @@ class Broker:
307
307
  file_name = url.split(".txt")[0].split("/")[-1]
308
308
  os.system("cp /tmp/{}.txt /tmp/{}.csv".format(file_name, file_name))
309
309
  time.sleep(2)
310
+
310
311
  return pd.read_csv("/tmp/{}.csv".format(file_name))
311
312
 
312
313
  def initialize_expiry_fields(self):
@@ -1166,13 +1167,13 @@ class Broker:
1166
1167
  if modification_count[order_id] > max_modification_count:
1167
1168
  order["order_type"] = "MARKET"
1168
1169
  order["price"] = 0
1169
- Constants.logger.info("Placing MARKET order [{}]".format(order))
1170
+ Constants.logger.info(f"Placing MARKET order [{order}]")
1170
1171
  self.modify_order(order) # type: ignore
1171
1172
 
1172
1173
  elif modification_count[order_id] > 20:
1173
1174
  self.cancel_order(order_id)
1174
1175
  Constants.logger.error(
1175
- "Max Modification Limit Exceeded : [{}]".format(order_id)
1176
+ f"Max Modification Limit Exceeded : [{order_id}]"
1176
1177
  )
1177
1178
 
1178
1179
  def log_event(
@@ -71,7 +71,6 @@ class UplinkUtils:
71
71
 
72
72
  time.sleep(2)
73
73
  url = f"{UplinkUtils.auth_url}dialog?response_type=code&client_id={api_key}&redirect_uri={redirect_url}"
74
- print("Upstox Url {}".format(url))
75
74
 
76
75
  driver.get(url)
77
76
  time.sleep(1)
@@ -142,8 +142,8 @@ class Upstox(Broker):
142
142
  f"{self.get_exchange(symbol_info['exchange'])}:{tradingsymbol}"
143
143
  ].last_price
144
144
  except ApiException as e:
145
- Constants.logger.error("Exception when calling MarketQuoteApi->ltp: %s\n" % e)
146
145
  self.handle_exception(e)
146
+ Constants.logger.error("Exception when calling MarketQuoteApi->ltp: %s\n" % e)
147
147
  return ltp
148
148
 
149
149
  @retry(
@@ -172,6 +172,7 @@ class Upstox(Broker):
172
172
  api_response = api_instance.modify_order(body, self.api_version)
173
173
  return api_response.status # type:ignore
174
174
  except ApiException as e:
175
+ self.handle_exception(e)
175
176
  Constants.logger.error(
176
177
  "Exception when calling OrderApi->modify_order: %s\n" % e
177
178
  )
@@ -181,10 +182,9 @@ class Upstox(Broker):
181
182
  order_to_modify["order_id"], order_to_modify["price"]
182
183
  )
183
184
  )
184
- self.handle_exception(e)
185
185
  return order_to_modify["order_id"]
186
186
 
187
- def cancel_order(self, order_id: str, variety=None) -> None:
187
+ def cancel_order(self, order_id: str, variety: str | None = None) -> None:
188
188
  api_instance = upstox_client.OrderApi(self.api_client)
189
189
 
190
190
  try:
@@ -289,8 +289,8 @@ class Upstox(Broker):
289
289
  self.email = response["email"]
290
290
  self.enabled_exchanges = response["exchanges"]
291
291
  except ApiException as e:
292
- Constants.logger.info("error when calling UserApi->get_profile: %s\n" % e)
293
292
  self.handle_exception(e)
293
+ Constants.logger.info("error when calling UserApi->get_profile: %s\n" % e)
294
294
 
295
295
  self.user_id = response["user_id"]
296
296
  return response
@@ -305,10 +305,10 @@ class Upstox(Broker):
305
305
  holdings = [holding.to_dict() for holding in api_response.data] # type:ignore
306
306
  holdings_df = pl.DataFrame(holdings)
307
307
  except ApiException as e:
308
+ self.handle_exception(e)
308
309
  Constants.logger.error(
309
310
  "Exception when calling PortfolioApi->get_holdings: %s\n" % e
310
311
  )
311
- self.handle_exception(e)
312
312
 
313
313
  if len(holdings_df) == 0:
314
314
  return pl.DataFrame(schema=self.holidings_schema)
@@ -359,10 +359,10 @@ class Upstox(Broker):
359
359
  ]
360
360
  positions_df = pl.DataFrame(positions)
361
361
  except ApiException as e:
362
+ self.handle_exception(e)
362
363
  Constants.logger.error(
363
364
  "Exception when calling PortfolioApi->get_positions: %s\n" % e
364
365
  )
365
- self.handle_exception(e)
366
366
 
367
367
  if len(positions_df) == 0:
368
368
  return pl.DataFrame(schema=self.positions_schema)
@@ -451,10 +451,10 @@ class Upstox(Broker):
451
451
  orders = [order.to_dict() for order in api_response.data] # type:ignore
452
452
  orders_df = pl.DataFrame(orders)
453
453
  except ApiException as e:
454
+ self.handle_exception(e)
454
455
  Constants.logger.error(
455
456
  "Exception when calling OrderApi->get_order_book: %s\n" % e
456
457
  )
457
- self.handle_exception(e)
458
458
 
459
459
  if len(orders_df) == 0:
460
460
  return pl.DataFrame(schema=self.orders_schema)
@@ -570,10 +570,10 @@ class Upstox(Broker):
570
570
  api_response.data["equity"].available_margin # type:ignore
571
571
  )
572
572
  except ApiException as e:
573
+ self.handle_exception(e)
573
574
  Constants.logger.error(
574
575
  "Exception when calling UserApi->get_user_fund_margin: %s\n" % e
575
576
  )
576
- self.handle_exception(e)
577
577
 
578
578
  margins = {
579
579
  "margin_used": margin_used,
@@ -52,7 +52,7 @@ class XTS(Broker):
52
52
  self.root_url = root_url
53
53
 
54
54
  try:
55
- if wrapper:
55
+ if wrapper and ClientID:
56
56
  self.set_wrapper(wrapper, md_wrapper)
57
57
  self.ClientID = ClientID
58
58
  self.wrapper.root = root_url
@@ -164,7 +164,7 @@ class XTS(Broker):
164
164
  ):
165
165
  raise TokenException(response["description"])
166
166
  if "type" in response and response["type"] == "error":
167
- raise Exception("[XTS_Error]: " + response["description"])
167
+ raise Exception(f"[XTS_Error]: {response["description"]}")
168
168
 
169
169
  @retry(
170
170
  wait_exponential_multiplier=3000,
@@ -698,6 +698,9 @@ class XTS(Broker):
698
698
  )
699
699
 
700
700
  def stream_order_updates(self):
701
+ if self.wrapper.token is None:
702
+ raise InvalidArgumentException("XTS Token Missing")
703
+
701
704
  socket = OrderSocket_io(
702
705
  userID=self.ClientID,
703
706
  token=self.wrapper.token,
@@ -1,4 +1,4 @@
1
- from typing import Literal
1
+ from typing import Dict, List, Literal
2
2
  import socketio
3
3
 
4
4
 
@@ -38,16 +38,16 @@ class OrderSocket_io(socketio.Client):
38
38
 
39
39
  def __init__(
40
40
  self,
41
- token,
42
- userID,
43
- root_url,
44
- reconnection=True,
45
- reconnection_attempts=0,
46
- reconnection_delay=1,
47
- reconnection_delay_max=50000,
48
- randomization_factor=0.5,
49
- logger=False,
50
- binary=False,
41
+ token: str,
42
+ userID: str,
43
+ root_url: str,
44
+ reconnection: bool = True,
45
+ reconnection_attempts: int = 0,
46
+ reconnection_delay: float = 1,
47
+ reconnection_delay_max: float = 50000,
48
+ randomization_factor: float = 0.5,
49
+ logger: bool = False,
50
+ binary: bool = False,
51
51
  json=None,
52
52
  **kwargs,
53
53
  ):
@@ -80,9 +80,9 @@ class OrderSocket_io(socketio.Client):
80
80
 
81
81
  def connect( # type: ignore
82
82
  self,
83
- headers={},
83
+ headers: Dict[str, str] = {},
84
84
  transports: Literal["polling", "websocket"] = "websocket",
85
- namespaces=None,
85
+ namespaces: List[str] | None = None,
86
86
  socketio_path: str = "/interactive/socket.io",
87
87
  verify: bool = False,
88
88
  ):
@@ -8,12 +8,12 @@ from quantplay.model.instrument_data import InstrumentDataType
8
8
  class PickleUtils:
9
9
  @staticmethod
10
10
  def save_data(data: Any, file_name: str):
11
- with open("/tmp/{}.pickle".format(file_name), "wb") as handle:
11
+ with open(f"/tmp/{file_name}.pickle", "wb") as handle:
12
12
  pickle.dump(data, handle, protocol=pickle.HIGHEST_PROTOCOL)
13
13
 
14
14
  @staticmethod
15
15
  def load_data(file_name: str):
16
- with open("/tmp/{}.pickle".format(file_name), "rb") as disk_data:
16
+ with open(f"/tmp/{file_name}.pickle", "rb") as disk_data:
17
17
  unserialized_data = pickle.load(disk_data)
18
18
 
19
19
  return unserialized_data
@@ -44,7 +44,7 @@ class InstrumentData:
44
44
 
45
45
  try:
46
46
  self.lock.acquire()
47
- with open("/tmp/{}.pickle".format(file_name), "rb") as disk_data:
47
+ with open(f"/tmp/{file_name}.pickle", "rb") as disk_data:
48
48
  unserialized_data = pickle.load(disk_data)
49
49
  self.instrument_data[file_name] = unserialized_data
50
50
  self.lock.release()
@@ -37,15 +37,15 @@ class S3Utils:
37
37
  lock.release()
38
38
 
39
39
  except Exception:
40
- print("Data not found for {}".format(key))
40
+ print(f"Data not found for {key}")
41
41
 
42
- print("fetching bucket from s3 {} key {}".format(bucket, key))
42
+ print(f"fetching bucket from s3 {bucket} key {key}")
43
43
 
44
44
  client = boto3.client("s3") # type: ignore
45
45
  raw_stream = client.get_object(Bucket=bucket, Key=key)
46
46
  content = raw_stream["Body"].read().decode("utf-8")
47
47
 
48
- print("Saving data at {}".format("/tmp/" + key))
48
+ print(f"Saving data at /tmp/{key}")
49
49
  full_folder_path = full_path[0 : full_path.rfind("/")]
50
50
  if not os.path.exists(full_folder_path):
51
51
  os.makedirs(full_folder_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 2.0.34
3
+ Version: 2.0.35
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.34",
24
+ version="2.0.35",
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