wiz-trader 0.19.0__tar.gz → 0.21.0__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.
- {wiz_trader-0.19.0/src/wiz_trader.egg-info → wiz_trader-0.21.0}/PKG-INFO +107 -1
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/README.md +106 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/pyproject.toml +1 -1
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/setup.py +1 -1
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader/__init__.py +1 -1
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader/apis/client.py +79 -8
- {wiz_trader-0.19.0 → wiz_trader-0.21.0/src/wiz_trader.egg-info}/PKG-INFO +107 -1
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/MANIFEST.in +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/setup.cfg +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader/apis/__init__.py +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader/quotes/__init__.py +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader/quotes/client.py +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader.egg-info/SOURCES.txt +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader.egg-info/dependency_links.txt +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader.egg-info/requires.txt +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/src/wiz_trader.egg-info/top_level.txt +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/tests/test_apis.py +0 -0
- {wiz_trader-0.19.0 → wiz_trader-0.21.0}/tests/test_quotes.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: wiz_trader
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.21.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
|
@@ -1574,6 +1628,58 @@ def visualize_option_chain(identifier, expiry):
|
|
1574
1628
|
visualize_option_chain("NSE:NIFTY 50:26000", "2025-05-30")
|
1575
1629
|
```
|
1576
1630
|
|
1631
|
+
#### Get Futures List
|
1632
|
+
|
1633
|
+
Fetch available futures contracts for an instrument:
|
1634
|
+
|
1635
|
+
```python
|
1636
|
+
# Get futures for an equity stock
|
1637
|
+
sbin_futures = client.get_futures_list("NSE:SBIN:3045")
|
1638
|
+
print(f"Found {len(sbin_futures)} futures contracts for SBIN")
|
1639
|
+
for future in sbin_futures:
|
1640
|
+
print(f"{future['tradingSymbol']} - Expiry: {future['expiry']} ({future['contract']})")
|
1641
|
+
|
1642
|
+
# Get futures for an index
|
1643
|
+
nifty_futures = client.get_futures_list("NSE:NIFTY 50:26000")
|
1644
|
+
print(f"Found {len(nifty_futures)} futures contracts for NIFTY 50")
|
1645
|
+
for future in nifty_futures:
|
1646
|
+
print(f"{future['tradingSymbol']} - Expiry: {future['expiry']} ({future['contract']})")
|
1647
|
+
```
|
1648
|
+
|
1649
|
+
#### Response Structure for Futures List
|
1650
|
+
|
1651
|
+
The `get_futures_list` method returns a list of dictionaries, each representing a futures contract:
|
1652
|
+
|
1653
|
+
```python
|
1654
|
+
[
|
1655
|
+
{
|
1656
|
+
# Exchange where the future is traded
|
1657
|
+
"exchange": "NSE",
|
1658
|
+
|
1659
|
+
# Trading symbol of the futures contract
|
1660
|
+
"tradingSymbol": "SBIN25MAYFUT",
|
1661
|
+
|
1662
|
+
# Exchange token for the futures contract
|
1663
|
+
"exchangeToken": 57515,
|
1664
|
+
|
1665
|
+
# Complete identifier for the futures contract
|
1666
|
+
"identifier": "NSE:SBIN25MAYFUT:57515",
|
1667
|
+
|
1668
|
+
# Expiry date in YYYY-MM-DD format
|
1669
|
+
"expiry": "2025-05-29",
|
1670
|
+
|
1671
|
+
# Contract type (near_month, mid_month, far_month)
|
1672
|
+
"contract": "near_month"
|
1673
|
+
},
|
1674
|
+
# Additional futures contracts...
|
1675
|
+
]
|
1676
|
+
```
|
1677
|
+
|
1678
|
+
The `contract` field indicates the type of futures contract:
|
1679
|
+
- **`near_month`**: Current month's futures contract
|
1680
|
+
- **`mid_month`**: Next month's futures contract
|
1681
|
+
- **`far_month`**: Month after next futures contract
|
1682
|
+
|
1577
1683
|
### Wizzer Client Examples
|
1578
1684
|
|
1579
1685
|
#### Market Data and Analysis Example
|
@@ -332,6 +332,7 @@ Available constants:
|
|
332
332
|
- Exchanges: `EXCHANGE_NSE`, `EXCHANGE_BSE`, `EXCHANGE_WZR`
|
333
333
|
- Segments: `SEGMENT_NSE_CM`, `SEGMENT_BSE_CM`, `SEGMENT_NSE_FO`, `SEGMENT_WZREQ`
|
334
334
|
- Instrument types: `INSTRUMENT_TYPE_EQ`, `INSTRUMENT_TYPE_EQLC`, `INSTRUMENT_TYPE_EQMCC`, `INSTRUMENT_TYPE_EQSCC`, `INSTRUMENT_TYPE_BASKET`
|
335
|
+
- - 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`
|
335
336
|
|
336
337
|
### Data Hub Methods
|
337
338
|
|
@@ -392,6 +393,11 @@ The `get_historical_ohlcv` method supports multiple time intervals for historica
|
|
392
393
|
- **Format**: `YYYY-MM-DD HH:MM:SS`
|
393
394
|
- **Example**: `"2024-01-15 09:30:00"`
|
394
395
|
|
396
|
+
**New Features in Historical Data API:**
|
397
|
+
|
398
|
+
- **Open Interest (`oi`)**: Now supported in the `ohlcv` parameter for futures instruments
|
399
|
+
- **Continuous Data**: The `continuous` parameter (for futures only) provides seamless data across multiple contract months when your date range spans multiple months
|
400
|
+
|
395
401
|
## Using Constants
|
396
402
|
|
397
403
|
The client provides constants for all intervals:
|
@@ -486,6 +492,25 @@ monthly_data = client.get_historical_ohlcv(
|
|
486
492
|
ohlcv=["close", "volume"],
|
487
493
|
interval=client.INTERVAL_1_MONTH
|
488
494
|
)
|
495
|
+
|
496
|
+
# Get futures data with open interest
|
497
|
+
futures_data = client.get_historical_ohlcv(
|
498
|
+
instruments=["NSE:SBIN25MAYFUT:57515"],
|
499
|
+
start_date="2024-01-01",
|
500
|
+
end_date="2024-03-01",
|
501
|
+
ohlcv=["open", "high", "low", "close", "volume", "oi"], # Include open interest
|
502
|
+
interval="1d"
|
503
|
+
)
|
504
|
+
|
505
|
+
# Get continuous futures data across multiple contract months
|
506
|
+
continuous_futures = client.get_historical_ohlcv(
|
507
|
+
instruments=["NSE:SBIN25MAYFUT:57515"],
|
508
|
+
start_date="2023-01-01",
|
509
|
+
end_date="2024-12-31",
|
510
|
+
ohlcv=["close", "oi"],
|
511
|
+
interval="1d",
|
512
|
+
continuous=True # Get seamless data across contract months
|
513
|
+
)
|
489
514
|
```
|
490
515
|
|
491
516
|
## Response Structure
|
@@ -956,6 +981,18 @@ exit_order = client.place_basket_exit_order(
|
|
956
981
|
|
957
982
|
#### Rebalance Basket
|
958
983
|
|
984
|
+
#### Available Weightage Schemes
|
985
|
+
|
986
|
+
When creating or rebalancing baskets, you can choose from several weightage schemes:
|
987
|
+
|
988
|
+
- **`WEIGHTAGE_SCHEME_EQUI_WEIGHTED`**: Equal weightage for all instruments
|
989
|
+
- **`WEIGHTAGE_SCHEME_QUANTITY_WEIGHTED`**: Weighted by quantity
|
990
|
+
- **`WEIGHTAGE_SCHEME_PRICE_WEIGHTED`**: Weighted by price
|
991
|
+
- **`WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED`**: Weighted by market capitalization
|
992
|
+
- **`WEIGHTAGE_SCHEME_FLOAT_ADJUSTED_MARKET_CAP_WEIGHTED`**: Weighted by float-adjusted market cap
|
993
|
+
- **`WEIGHTAGE_SCHEME_FUNDAMENTAL_WEIGHTED`**: Weighted by fundamental metrics
|
994
|
+
- **`WEIGHTAGE_SCHEME_CUSTOM_WEIGHTED`**: Custom weightage scheme
|
995
|
+
|
959
996
|
Rebalance a basket with new instruments:
|
960
997
|
|
961
998
|
```python
|
@@ -964,6 +1001,23 @@ rebalance_response = client.rebalance_basket(
|
|
964
1001
|
trading_symbol="/MY_BASKET",
|
965
1002
|
instruments=["NSE:SBIN:3045", "NSE:HDFCBANK:1333", "NSE:TCS:2953"]
|
966
1003
|
)
|
1004
|
+
|
1005
|
+
# Full Rebalance with market cap weighting & execution of all orders at market price
|
1006
|
+
client.rebalance_basket(
|
1007
|
+
trading_symbol="/MY_BASKET",
|
1008
|
+
instruments=["NSE:SBIN:3045", "NSE:HDFCBANK:1333"],
|
1009
|
+
execution_policy=client.REBALANCE_FULL,
|
1010
|
+
order_type=client.ORDER_TYPE_MARKET,
|
1011
|
+
weightage_scheme=client.WEIGHTAGE_SCHEME_MARKET_CAP_WEIGHTED
|
1012
|
+
)
|
1013
|
+
|
1014
|
+
# Entry-only rebalance with price weighting
|
1015
|
+
client.rebalance_basket(
|
1016
|
+
trading_symbol="/MY_BASKET",
|
1017
|
+
instruments=["NSE:SBIN:3045", "NSE:HDFCBANK:1333"],
|
1018
|
+
execution_policy=client.REBALANCE_ENTRY_ONLY,
|
1019
|
+
weightage_scheme=client.WEIGHTAGE_SCHEME_EQUI_WEIGHTED
|
1020
|
+
)
|
967
1021
|
```
|
968
1022
|
|
969
1023
|
### Instrument Management
|
@@ -1547,6 +1601,58 @@ def visualize_option_chain(identifier, expiry):
|
|
1547
1601
|
visualize_option_chain("NSE:NIFTY 50:26000", "2025-05-30")
|
1548
1602
|
```
|
1549
1603
|
|
1604
|
+
#### Get Futures List
|
1605
|
+
|
1606
|
+
Fetch available futures contracts for an instrument:
|
1607
|
+
|
1608
|
+
```python
|
1609
|
+
# Get futures for an equity stock
|
1610
|
+
sbin_futures = client.get_futures_list("NSE:SBIN:3045")
|
1611
|
+
print(f"Found {len(sbin_futures)} futures contracts for SBIN")
|
1612
|
+
for future in sbin_futures:
|
1613
|
+
print(f"{future['tradingSymbol']} - Expiry: {future['expiry']} ({future['contract']})")
|
1614
|
+
|
1615
|
+
# Get futures for an index
|
1616
|
+
nifty_futures = client.get_futures_list("NSE:NIFTY 50:26000")
|
1617
|
+
print(f"Found {len(nifty_futures)} futures contracts for NIFTY 50")
|
1618
|
+
for future in nifty_futures:
|
1619
|
+
print(f"{future['tradingSymbol']} - Expiry: {future['expiry']} ({future['contract']})")
|
1620
|
+
```
|
1621
|
+
|
1622
|
+
#### Response Structure for Futures List
|
1623
|
+
|
1624
|
+
The `get_futures_list` method returns a list of dictionaries, each representing a futures contract:
|
1625
|
+
|
1626
|
+
```python
|
1627
|
+
[
|
1628
|
+
{
|
1629
|
+
# Exchange where the future is traded
|
1630
|
+
"exchange": "NSE",
|
1631
|
+
|
1632
|
+
# Trading symbol of the futures contract
|
1633
|
+
"tradingSymbol": "SBIN25MAYFUT",
|
1634
|
+
|
1635
|
+
# Exchange token for the futures contract
|
1636
|
+
"exchangeToken": 57515,
|
1637
|
+
|
1638
|
+
# Complete identifier for the futures contract
|
1639
|
+
"identifier": "NSE:SBIN25MAYFUT:57515",
|
1640
|
+
|
1641
|
+
# Expiry date in YYYY-MM-DD format
|
1642
|
+
"expiry": "2025-05-29",
|
1643
|
+
|
1644
|
+
# Contract type (near_month, mid_month, far_month)
|
1645
|
+
"contract": "near_month"
|
1646
|
+
},
|
1647
|
+
# Additional futures contracts...
|
1648
|
+
]
|
1649
|
+
```
|
1650
|
+
|
1651
|
+
The `contract` field indicates the type of futures contract:
|
1652
|
+
- **`near_month`**: Current month's futures contract
|
1653
|
+
- **`mid_month`**: Next month's futures contract
|
1654
|
+
- **`far_month`**: Month after next futures contract
|
1655
|
+
|
1550
1656
|
### Wizzer Client Examples
|
1551
1657
|
|
1552
1658
|
#### Market Data and Analysis Example
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='wiz_trader',
|
5
|
-
version='0.
|
5
|
+
version='0.21.0',
|
6
6
|
description='A Python SDK for connecting to the Wizzer.',
|
7
7
|
long_description=open('README.md').read() if open('README.md') else "",
|
8
8
|
long_description_content_type='text/markdown',
|
@@ -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
|
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:
|
346
|
-
|
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 = "
|
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.
|
3
|
+
Version: 0.21.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
|
@@ -1574,6 +1628,58 @@ def visualize_option_chain(identifier, expiry):
|
|
1574
1628
|
visualize_option_chain("NSE:NIFTY 50:26000", "2025-05-30")
|
1575
1629
|
```
|
1576
1630
|
|
1631
|
+
#### Get Futures List
|
1632
|
+
|
1633
|
+
Fetch available futures contracts for an instrument:
|
1634
|
+
|
1635
|
+
```python
|
1636
|
+
# Get futures for an equity stock
|
1637
|
+
sbin_futures = client.get_futures_list("NSE:SBIN:3045")
|
1638
|
+
print(f"Found {len(sbin_futures)} futures contracts for SBIN")
|
1639
|
+
for future in sbin_futures:
|
1640
|
+
print(f"{future['tradingSymbol']} - Expiry: {future['expiry']} ({future['contract']})")
|
1641
|
+
|
1642
|
+
# Get futures for an index
|
1643
|
+
nifty_futures = client.get_futures_list("NSE:NIFTY 50:26000")
|
1644
|
+
print(f"Found {len(nifty_futures)} futures contracts for NIFTY 50")
|
1645
|
+
for future in nifty_futures:
|
1646
|
+
print(f"{future['tradingSymbol']} - Expiry: {future['expiry']} ({future['contract']})")
|
1647
|
+
```
|
1648
|
+
|
1649
|
+
#### Response Structure for Futures List
|
1650
|
+
|
1651
|
+
The `get_futures_list` method returns a list of dictionaries, each representing a futures contract:
|
1652
|
+
|
1653
|
+
```python
|
1654
|
+
[
|
1655
|
+
{
|
1656
|
+
# Exchange where the future is traded
|
1657
|
+
"exchange": "NSE",
|
1658
|
+
|
1659
|
+
# Trading symbol of the futures contract
|
1660
|
+
"tradingSymbol": "SBIN25MAYFUT",
|
1661
|
+
|
1662
|
+
# Exchange token for the futures contract
|
1663
|
+
"exchangeToken": 57515,
|
1664
|
+
|
1665
|
+
# Complete identifier for the futures contract
|
1666
|
+
"identifier": "NSE:SBIN25MAYFUT:57515",
|
1667
|
+
|
1668
|
+
# Expiry date in YYYY-MM-DD format
|
1669
|
+
"expiry": "2025-05-29",
|
1670
|
+
|
1671
|
+
# Contract type (near_month, mid_month, far_month)
|
1672
|
+
"contract": "near_month"
|
1673
|
+
},
|
1674
|
+
# Additional futures contracts...
|
1675
|
+
]
|
1676
|
+
```
|
1677
|
+
|
1678
|
+
The `contract` field indicates the type of futures contract:
|
1679
|
+
- **`near_month`**: Current month's futures contract
|
1680
|
+
- **`mid_month`**: Next month's futures contract
|
1681
|
+
- **`far_month`**: Month after next futures contract
|
1682
|
+
|
1577
1683
|
### Wizzer Client Examples
|
1578
1684
|
|
1579
1685
|
#### Market Data and Analysis Example
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|