wiz-trader 0.14.0__py3-none-any.whl → 0.16.0__py3-none-any.whl

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.
wiz_trader/__init__.py CHANGED
@@ -3,6 +3,6 @@
3
3
  from .quotes import QuotesClient
4
4
  from .apis import WizzerClient
5
5
 
6
- __version__ = "0.14.0"
6
+ __version__ = "0.16.0"
7
7
 
8
8
  __all__ = ["QuotesClient", "WizzerClient"]
wiz_trader/apis/client.py CHANGED
@@ -110,6 +110,9 @@ class WizzerClient:
110
110
  "datahub.indices": "/datahub/indices",
111
111
  "datahub.index.components": "/datahub/index/components",
112
112
  "datahub.historical.ohlcv": "/datahub/historical/ohlcv",
113
+
114
+ # Instrument & asset class endpoints
115
+ "instrument.metrics": "/instruments/metrics",
113
116
  }
114
117
 
115
118
  def __init__(
@@ -1159,36 +1162,69 @@ class WizzerClient:
1159
1162
  return self._make_request("PATCH", endpoint, json=params)
1160
1163
 
1161
1164
  def rebalance_basket(
1162
- self,
1163
- trading_symbol: str,
1164
- instruments: List[str],
1165
- execution_policy: str
1166
- ) -> Dict[str, Any]:
1167
- """
1168
- Rebalance a basket with new instruments.
1169
-
1170
- Args:
1171
- trading_symbol (str): Basket trading symbol.
1172
- instruments (List[str]): List of instrument identifiers for the new basket composition.
1173
- execution_policy (str): Rebalance execution policy.
1174
- Options: "full_rebalance", "entry_only", "exit_only".
1165
+ self,
1166
+ trading_symbol: str,
1167
+ instruments: List[str],
1168
+ execution_policy: str,
1169
+ order_type: str = None,
1170
+ product: str = None
1171
+ ) -> Dict[str, Any]:
1172
+ """
1173
+ Rebalance a basket with new instruments.
1175
1174
 
1176
- Returns:
1177
- Dict[str, Any]: Rebalance response.
1178
- """
1179
- endpoint = self._routes["basket.rebalance"]
1180
-
1181
- data = {
1182
- "tradingSymbol": trading_symbol,
1183
- "instruments": instruments,
1184
- "policies": {
1185
- "execution": execution_policy
1186
- }
1187
- }
1188
-
1189
- logger.debug("Rebalancing basket %s with instruments: %s, policy: %s",
1190
- trading_symbol, instruments, execution_policy)
1191
- return self._make_request("POST", endpoint, json=data)
1175
+ Args:
1176
+ trading_symbol (str): Basket trading symbol.
1177
+ instruments (List[str]): List of instrument identifiers for the new basket composition.
1178
+ execution_policy (str): Rebalance execution policy.
1179
+ Options: REBALANCE_FULL, REBALANCE_ENTRY_ONLY, REBALANCE_EXIT_ONLY.
1180
+ order_type (str, optional): Order type to use for rebalance orders.
1181
+ Options: ORDER_TYPE_MARKET, ORDER_TYPE_LIMIT
1182
+ product (str, optional): Product type to use for rebalance orders.
1183
+ Options: PRODUCT_CNC, PRODUCT_MIS
1184
+
1185
+ Returns:
1186
+ Dict[str, Any]: Rebalance response.
1187
+ """
1188
+ endpoint = "/baskets/rebalance"
1189
+
1190
+ # Validate execution policy
1191
+ valid_execution_policies = [self.REBALANCE_FULL, self.REBALANCE_ENTRY_ONLY, self.REBALANCE_EXIT_ONLY]
1192
+ if execution_policy not in valid_execution_policies:
1193
+ raise ValueError(f"execution_policy must be one of {valid_execution_policies}")
1194
+
1195
+ # Build the basic request payload
1196
+ data = {
1197
+ "tradingSymbol": trading_symbol,
1198
+ "instruments": instruments,
1199
+ "policies": {
1200
+ "execution": execution_policy
1201
+ }
1202
+ }
1203
+
1204
+ # Add order policies if specified
1205
+ if order_type or product:
1206
+ order_policies = {}
1207
+
1208
+ if order_type:
1209
+ valid_order_types = [self.ORDER_TYPE_MARKET, self.ORDER_TYPE_LIMIT]
1210
+ if order_type not in valid_order_types:
1211
+ raise ValueError(f"order_type must be one of {valid_order_types}")
1212
+ order_policies["orderType"] = order_type
1213
+
1214
+ if product:
1215
+ valid_products = [self.PRODUCT_CNC, self.PRODUCT_MIS, self.PRODUCT_NRML]
1216
+ if product not in valid_products:
1217
+ raise ValueError(f"product must be one of {valid_products}")
1218
+ order_policies["product"] = product
1219
+
1220
+ if order_policies:
1221
+ data["policies"]["orders"] = order_policies
1222
+
1223
+ logger.debug("Rebalancing basket %s with instruments: %s, policy: %s, order settings: %s",
1224
+ trading_symbol, instruments, execution_policy,
1225
+ {"order_type": order_type, "product": product})
1226
+
1227
+ return self._make_request("POST", endpoint, json=data)
1192
1228
 
1193
1229
  def exit_all_positions(self) -> Dict[str, Any]:
1194
1230
  """
@@ -1233,6 +1269,35 @@ class WizzerClient:
1233
1269
  logger.debug("Exiting all positions for strategy: %s", strategy_id)
1234
1270
  return self._make_request("POST", endpoint, json=data)
1235
1271
 
1272
+ # =====INSTRUMENT & ASSET CLASS METHODS =====
1273
+
1274
+ def get_instrument_metrics(self, identifiers: List[str]) -> List[Dict[str, Any]]:
1275
+ """
1276
+ Get detailed metrics for instruments by their identifiers.
1277
+
1278
+ Args:
1279
+ identifiers (List[str]): List of instrument identifiers in the format
1280
+ "EXCHANGE:SYMBOL:TOKEN" (e.g., "NSE:SBIN:3045").
1281
+
1282
+ Returns:
1283
+ List[Dict[str, Any]]: List of instrument metrics.
1284
+
1285
+ Example:
1286
+ >>> client.get_instrument_metrics([
1287
+ ... "NSE:SBIN:3045",
1288
+ ... "NSE:RELIANCE:2885",
1289
+ ... "NSE:NIFTY26DEC11000CE:61009"
1290
+ ... ])
1291
+ """
1292
+ endpoint = self._routes["instrument.metrics"]
1293
+ data = {
1294
+ "identifiers": identifiers
1295
+ }
1296
+
1297
+ logger.debug("Fetching instrument metrics for identifiers: %s", identifiers)
1298
+ response = self._make_request("POST", endpoint, json=data)
1299
+ return response
1300
+
1236
1301
  def _make_request(
1237
1302
  self,
1238
1303
  method: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wiz_trader
3
- Version: 0.14.0
3
+ Version: 0.16.0
4
4
  Summary: A Python SDK for connecting to the Wizzer.
5
5
  Home-page: https://bitbucket.org/wizzer-tech/quotes_sdk.git
6
6
  Author: Pawan Wagh
@@ -0,0 +1,9 @@
1
+ wiz_trader/__init__.py,sha256=ScYHyaz49WDqsMZQVcJLXExQJp_ZOdSeqRvLIiAS-lI,182
2
+ wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
3
+ wiz_trader/apis/client.py,sha256=JDw0lMCw79LSU9E0YRHt_2FCAzZTZddweB5EsJChTb4,47054
4
+ wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
5
+ wiz_trader/quotes/client.py,sha256=LJeMcQPjJIRxrTIGalWsLYh_XfinDXBP5-4cNS7qCxc,9709
6
+ wiz_trader-0.16.0.dist-info/METADATA,sha256=Xwzf-z6y-ovu7lq-c5K4tlkiyWafGTzUxwgDKJqrJTk,54024
7
+ wiz_trader-0.16.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
8
+ wiz_trader-0.16.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
9
+ wiz_trader-0.16.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.1.0)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- wiz_trader/__init__.py,sha256=mYQBSOzWjWt6PYvV7aCp3vdSf0S1lnOUMnSsWEGF5M0,182
2
- wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
3
- wiz_trader/apis/client.py,sha256=dQuB4_qQmXGMVX7BQ39eAbNgi7z0DTS2NBaaImRPNJQ,44263
4
- wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
5
- wiz_trader/quotes/client.py,sha256=LJeMcQPjJIRxrTIGalWsLYh_XfinDXBP5-4cNS7qCxc,9709
6
- wiz_trader-0.14.0.dist-info/METADATA,sha256=gL_aaiWSK8Flu7UM3RwmWFsnhP0VwoB5cHRGnizDOXU,54024
7
- wiz_trader-0.14.0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
8
- wiz_trader-0.14.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
9
- wiz_trader-0.14.0.dist-info/RECORD,,