wiz-trader 0.19.0__py3-none-any.whl → 0.20.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.19.0"
6
+ __version__ = "0.20.0"
7
7
 
8
8
  __all__ = ["QuotesClient", "WizzerClient"]
wiz_trader/apis/client.py CHANGED
@@ -151,6 +151,15 @@ class WizzerClient:
151
151
  INTERVAL_1_HOUR = "1h"
152
152
  INTERVAL_1_DAY = "1d"
153
153
  INTERVAL_1_MONTH = "1M"
154
+
155
+ # Constants for weightage schemes
156
+ WEIGHTAGE_SCHEME_EQUI_WEIGHTED = "equi_weighted"
157
+ WEIGHTAGE_SCHEME_QUANTITY_WEIGHTED = "quantity_weighted"
158
+ WEIGHTAGE_SCHEME_PRICE_WEIGHTED = "price_weighted"
159
+ WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED = "market_cap_weighted"
160
+ WEIGHTAGE_SCHEME_FLOAT_ADJUSTED_MARKET_CAP_WEIGHTED = "float_adjusted_market_cap_weighted"
161
+ WEIGHTAGE_SCHEME_FUNDAMENTAL_WEIGHTED = "fundamental_weighted"
162
+ WEIGHTAGE_SCHEME_CUSTOM_WEIGHTED = "custom_weighted"
154
163
 
155
164
  # URIs to various API endpoints
156
165
  _routes = {
@@ -187,7 +196,8 @@ class WizzerClient:
187
196
  # Instrument & asset class endpoints
188
197
  "instrument.metrics": "/instruments/metrics",
189
198
  "instrument.option_chain": "/instruments/options/chain",
190
- "instrument.expiry_list": "/instruments/options/chain/expirylist"
199
+ "instrument.expiry_list": "/instruments/options/chain/expirylist",
200
+ "instrument.future_list": "/instruments/futures/list"
191
201
  }
192
202
 
193
203
  def __init__(
@@ -320,7 +330,8 @@ class WizzerClient:
320
330
  start_date: str,
321
331
  end_date: str,
322
332
  ohlcv: List[str],
323
- interval: str = "1d"
333
+ interval: str = "1d",
334
+ continuous: bool = False
324
335
  ) -> List[Dict[str, Any]]:
325
336
  """
326
337
  Get historical OHLCV data for specified instruments.
@@ -331,19 +342,26 @@ class WizzerClient:
331
342
  For intraday intervals: YYYY-MM-DD HH:MM:SS format.
332
343
  end_date (str): End date. For daily/monthly intervals: YYYY-MM-DD format.
333
344
  For intraday intervals: YYYY-MM-DD HH:MM:SS format.
334
- ohlcv (List[str]): List of OHLCV fields to retrieve (open, high, low, close, volume).
345
+ ohlcv (List[str]): List of OHLCV fields to retrieve.
346
+ Valid values: "open", "high", "low", "close", "volume", "oi" (open interest - F&O only).
335
347
  interval (str, optional): Data interval. Options:
336
348
  - Intraday: "1m", "2m", "3m", "5m", "10m", "15m", "30m", "45m", "1h"
337
349
  - Daily: "1d" (default)
338
350
  - Monthly: "1M" (last trading day of month)
339
351
 
340
352
  Use constants like client.INTERVAL_5_MINUTES, client.INTERVAL_1_DAY, etc.
353
+ continuous (bool, optional): Only relevant for futures. If True, returns continuous data across
354
+ multiple contract months to form a seamless data stream. Defaults to False.
341
355
 
342
356
  Returns:
343
357
  List[Dict[str, Any]]: Historical data for requested instruments.
344
358
 
345
- Note: For daily/monthly intervals, the 'date' field contains YYYY-MM-DD.
346
- For intraday intervals, the 'date' field contains YYYY-MM-DD HH:MM:SS.
359
+ Note:
360
+ - For daily/monthly intervals, the 'date' field contains YYYY-MM-DD.
361
+ - For intraday intervals, the 'date' field contains YYYY-MM-DD HH:MM:SS.
362
+ - The "oi" (open interest) field is only applicable for F&O instruments
363
+ - The "continuous" parameter is only relevant for futures instruments and allows you to get
364
+ backdated data across multiple contract months for a seamless time series
347
365
 
348
366
  Raises:
349
367
  ValueError: If datetime format doesn't match the interval requirements.
@@ -369,6 +387,10 @@ class WizzerClient:
369
387
  "ohlcv": ohlcv,
370
388
  "interval": interval
371
389
  }
390
+
391
+ # Add continuous parameter if specified
392
+ if continuous:
393
+ data["continuous"] = continuous
372
394
 
373
395
  logger.debug("Fetching historical OHLCV with data: %s", data)
374
396
  response = self._make_request("POST", endpoint, json=data)
@@ -1296,7 +1318,8 @@ class WizzerClient:
1296
1318
  instruments: List[str],
1297
1319
  execution_policy: str,
1298
1320
  order_type: str = None,
1299
- product: str = None
1321
+ product: str = None,
1322
+ weightage_scheme: str = None
1300
1323
  ) -> Dict[str, Any]:
1301
1324
  """
1302
1325
  Rebalance a basket with new instruments.
@@ -1310,16 +1333,35 @@ class WizzerClient:
1310
1333
  Options: ORDER_TYPE_MARKET, ORDER_TYPE_LIMIT
1311
1334
  product (str, optional): Product type to use for rebalance orders.
1312
1335
  Options: PRODUCT_CNC, PRODUCT_MIS
1336
+ weightage_scheme (str, optional): Weightage scheme for rebalancing. Options:
1337
+ WEIGHTAGE_SCHEME_EQUI_WEIGHTED, WEIGHTAGE_SCHEME_QUANTITY_WEIGHTED,
1338
+ WEIGHTAGE_SCHEME_PRICE_WEIGHTED, WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED,
1339
+ WEIGHTAGE_SCHEME_FLOAT_ADJUSTED_MARKET_CAP_WEIGHTED,
1340
+ WEIGHTAGE_SCHEME_FUNDAMENTAL_WEIGHTED, WEIGHTAGE_SCHEME_CUSTOM_WEIGHTED
1313
1341
 
1314
1342
  Returns:
1315
1343
  Dict[str, Any]: Rebalance response.
1316
1344
  """
1317
- endpoint = "/baskets/rebalance"
1345
+ endpoint = self._routes["basket.rebalance"]
1318
1346
 
1319
1347
  # Validate execution policy
1320
1348
  valid_execution_policies = [self.REBALANCE_FULL, self.REBALANCE_ENTRY_ONLY, self.REBALANCE_EXIT_ONLY]
1321
1349
  if execution_policy not in valid_execution_policies:
1322
1350
  raise ValueError(f"execution_policy must be one of {valid_execution_policies}")
1351
+
1352
+ # Validate weightage scheme if provided
1353
+ if weightage_scheme:
1354
+ valid_weightage_schemes = [
1355
+ self.WEIGHTAGE_SCHEME_EQUI_WEIGHTED,
1356
+ self.WEIGHTAGE_SCHEME_QUANTITY_WEIGHTED,
1357
+ self.WEIGHTAGE_SCHEME_PRICE_WEIGHTED,
1358
+ self.WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED,
1359
+ self.WEIGHTAGE_SCHEME_FLOAT_ADJUSTED_MARKET_CAP_WEIGHTED,
1360
+ self.WEIGHTAGE_SCHEME_FUNDAMENTAL_WEIGHTED,
1361
+ self.WEIGHTAGE_SCHEME_CUSTOM_WEIGHTED
1362
+ ]
1363
+ if weightage_scheme not in valid_weightage_schemes:
1364
+ raise ValueError(f"weightage_scheme must be one of {valid_weightage_schemes}")
1323
1365
 
1324
1366
  # Build the basic request payload
1325
1367
  data = {
@@ -1348,10 +1390,14 @@ class WizzerClient:
1348
1390
 
1349
1391
  if order_policies:
1350
1392
  data["policies"]["orders"] = order_policies
1393
+
1394
+ # Add weightage scheme if specified
1395
+ if weightage_scheme:
1396
+ data["policies"]["weightageScheme"] = weightage_scheme
1351
1397
 
1352
1398
  logger.debug("Rebalancing basket %s with instruments: %s, policy: %s, order settings: %s",
1353
1399
  trading_symbol, instruments, execution_policy,
1354
- {"order_type": order_type, "product": product})
1400
+ {"order_type": order_type, "product": product, "weightage_scheme": weightage_scheme})
1355
1401
 
1356
1402
  return self._make_request("POST", endpoint, json=data)
1357
1403
 
@@ -1526,6 +1572,31 @@ class WizzerClient:
1526
1572
 
1527
1573
  logger.debug("Fetching option expiry list for %s", identifier)
1528
1574
  return self._make_request("POST", endpoint, json=data)
1575
+
1576
+ def get_futures_list(self, identifier: str) -> List[Dict[str, Any]]:
1577
+ """
1578
+ Get available futures contracts for an instrument.
1579
+
1580
+ Args:
1581
+ identifier (str): Instrument identifier (e.g., "NSE:SBIN:3045" or "NSE:NIFTY 50:26000").
1582
+
1583
+ Returns:
1584
+ List[Dict[str, Any]]: List of available futures contracts with expiry dates and contract types.
1585
+
1586
+ Example:
1587
+ # Get futures for a stock
1588
+ sbin_futures = client.get_futures_list("NSE:SBIN:3045")
1589
+ for future in sbin_futures:
1590
+ print(f"{future['tradingSymbol']} - {future['expiry']} ({future['contract']})")
1591
+
1592
+ # Get futures for an index
1593
+ nifty_futures = client.get_futures_list("NSE:NIFTY 50:26000")
1594
+ """
1595
+ endpoint = self._routes["instrument.future_list"]
1596
+ data = {"identifier": identifier}
1597
+
1598
+ logger.debug("Fetching futures list for: %s", identifier)
1599
+ return self._make_request("POST", endpoint, json=data)
1529
1600
 
1530
1601
  def _make_request(
1531
1602
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wiz_trader
3
- Version: 0.19.0
3
+ Version: 0.20.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
@@ -359,6 +359,7 @@ Available constants:
359
359
  - Exchanges: `EXCHANGE_NSE`, `EXCHANGE_BSE`, `EXCHANGE_WZR`
360
360
  - Segments: `SEGMENT_NSE_CM`, `SEGMENT_BSE_CM`, `SEGMENT_NSE_FO`, `SEGMENT_WZREQ`
361
361
  - Instrument types: `INSTRUMENT_TYPE_EQ`, `INSTRUMENT_TYPE_EQLC`, `INSTRUMENT_TYPE_EQMCC`, `INSTRUMENT_TYPE_EQSCC`, `INSTRUMENT_TYPE_BASKET`
362
+ - - Weightage schemes: `WEIGHTAGE_SCHEME_EQUI_WEIGHTED`, `WEIGHTAGE_SCHEME_QUANTITY_WEIGHTED`, `WEIGHTAGE_SCHEME_PRICE_WEIGHTED`, `WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED`, `WEIGHTAGE_SCHEME_FLOAT_ADJUSTED_MARKET_CAP_WEIGHTED`, `WEIGHTAGE_SCHEME_FUNDAMENTAL_WEIGHTED`, `WEIGHTAGE_SCHEME_CUSTOM_WEIGHTED`
362
363
 
363
364
  ### Data Hub Methods
364
365
 
@@ -419,6 +420,11 @@ The `get_historical_ohlcv` method supports multiple time intervals for historica
419
420
  - **Format**: `YYYY-MM-DD HH:MM:SS`
420
421
  - **Example**: `"2024-01-15 09:30:00"`
421
422
 
423
+ **New Features in Historical Data API:**
424
+
425
+ - **Open Interest (`oi`)**: Now supported in the `ohlcv` parameter for futures instruments
426
+ - **Continuous Data**: The `continuous` parameter (for futures only) provides seamless data across multiple contract months when your date range spans multiple months
427
+
422
428
  ## Using Constants
423
429
 
424
430
  The client provides constants for all intervals:
@@ -513,6 +519,25 @@ monthly_data = client.get_historical_ohlcv(
513
519
  ohlcv=["close", "volume"],
514
520
  interval=client.INTERVAL_1_MONTH
515
521
  )
522
+
523
+ # Get futures data with open interest
524
+ futures_data = client.get_historical_ohlcv(
525
+ instruments=["NSE:SBIN25MAYFUT:57515"],
526
+ start_date="2024-01-01",
527
+ end_date="2024-03-01",
528
+ ohlcv=["open", "high", "low", "close", "volume", "oi"], # Include open interest
529
+ interval="1d"
530
+ )
531
+
532
+ # Get continuous futures data across multiple contract months
533
+ continuous_futures = client.get_historical_ohlcv(
534
+ instruments=["NSE:SBIN25MAYFUT:57515"],
535
+ start_date="2023-01-01",
536
+ end_date="2024-12-31",
537
+ ohlcv=["close", "oi"],
538
+ interval="1d",
539
+ continuous=True # Get seamless data across contract months
540
+ )
516
541
  ```
517
542
 
518
543
  ## Response Structure
@@ -983,6 +1008,18 @@ exit_order = client.place_basket_exit_order(
983
1008
 
984
1009
  #### Rebalance Basket
985
1010
 
1011
+ #### Available Weightage Schemes
1012
+
1013
+ When creating or rebalancing baskets, you can choose from several weightage schemes:
1014
+
1015
+ - **`WEIGHTAGE_SCHEME_EQUI_WEIGHTED`**: Equal weightage for all instruments
1016
+ - **`WEIGHTAGE_SCHEME_QUANTITY_WEIGHTED`**: Weighted by quantity
1017
+ - **`WEIGHTAGE_SCHEME_PRICE_WEIGHTED`**: Weighted by price
1018
+ - **`WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED`**: Weighted by market capitalization
1019
+ - **`WEIGHTAGE_SCHEME_FLOAT_ADJUSTED_MARKET_CAP_WEIGHTED`**: Weighted by float-adjusted market cap
1020
+ - **`WEIGHTAGE_SCHEME_FUNDAMENTAL_WEIGHTED`**: Weighted by fundamental metrics
1021
+ - **`WEIGHTAGE_SCHEME_CUSTOM_WEIGHTED`**: Custom weightage scheme
1022
+
986
1023
  Rebalance a basket with new instruments:
987
1024
 
988
1025
  ```python
@@ -991,6 +1028,23 @@ rebalance_response = client.rebalance_basket(
991
1028
  trading_symbol="/MY_BASKET",
992
1029
  instruments=["NSE:SBIN:3045", "NSE:HDFCBANK:1333", "NSE:TCS:2953"]
993
1030
  )
1031
+
1032
+ # Full Rebalance with market cap weighting & execution of all orders at market price
1033
+ client.rebalance_basket(
1034
+ trading_symbol="/MY_BASKET",
1035
+ instruments=["NSE:SBIN:3045", "NSE:HDFCBANK:1333"],
1036
+ execution_policy=client.REBALANCE_FULL,
1037
+ order_type=client.ORDER_TYPE_MARKET,
1038
+ weightage_scheme=client.WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED
1039
+ )
1040
+
1041
+ # Entry-only rebalance with price weighting
1042
+ client.rebalance_basket(
1043
+ trading_symbol="/MY_BASKET",
1044
+ instruments=["NSE:SBIN:3045", "NSE:HDFCBANK:1333"],
1045
+ execution_policy=client.REBALANCE_ENTRY_ONLY,
1046
+ weightage_scheme=client.WEIGHTAGE_SCHEME_EQUI_WEIGHTED
1047
+ )
994
1048
  ```
995
1049
 
996
1050
  ### Instrument Management
@@ -0,0 +1,9 @@
1
+ wiz_trader/__init__.py,sha256=YC94wlmPJK1p-MnOePHPiRYe2f9VeHkl0_eBNB77vD8,182
2
+ wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
3
+ wiz_trader/apis/client.py,sha256=GY1aAaV4ia1tnFnB2qaNqnv-qeUvkVlvw9xOKN54qIs,59786
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.20.0.dist-info/METADATA,sha256=TmMAi3VtyYTwZSxbcNiQ7hsdDJgvNhAKrIhf7Vycp3A,85410
7
+ wiz_trader-0.20.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ wiz_trader-0.20.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
9
+ wiz_trader-0.20.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.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=iU9Crioz_4eIjYFIOJ9aqjfGXBMxvEi_836Ln39sV70,182
2
- wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
3
- wiz_trader/apis/client.py,sha256=vFoKHJWfyLTX7Alb6WK2fxJimqLj7E42ri1bl_jUDWY,56281
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.19.0.dist-info/METADATA,sha256=GxrCN8ospIwoUahWVp6WC669msDd61KTNaCQvg7_Tqw,82928
7
- wiz_trader-0.19.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
8
- wiz_trader-0.19.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
9
- wiz_trader-0.19.0.dist-info/RECORD,,