wiz-trader 0.2.0__py3-none-any.whl → 0.4.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
@@ -1,7 +1,8 @@
1
1
  """WizTrader SDK for connecting to the Wizzer."""
2
2
 
3
3
  from .quotes import QuotesClient
4
+ from .apis import WizzerClient
4
5
 
5
- __version__ = "0.2.0"
6
+ __version__ = "0.4.0"
6
7
 
7
- __all__ = ["QuotesClient"]
8
+ __all__ = ["QuotesClient", "WizzerClient"]
@@ -1,5 +1,6 @@
1
1
  # apis/__init__.py
2
- # Provision for REST API functionalities in future.
3
- # Currently, no APIs are implemented.
2
+ """Module for REST API integrations with Wizzer."""
4
3
 
5
- """Module for REST API integrations (future functionality)."""
4
+ from .client import WizzerClient
5
+
6
+ __all__ = ["WizzerClient"]
wiz_trader/apis/client.py CHANGED
@@ -1,2 +1,614 @@
1
- # apis/placeholder.py
2
- # This is a placeholder file for future REST API implementations.
1
+ import os
2
+ import json
3
+ import logging
4
+ from typing import Dict, List, Optional, Union, Any
5
+
6
+ import requests
7
+
8
+ # Setup module-level logger with a default handler if none exists.
9
+ logger = logging.getLogger(__name__)
10
+ if not logger.handlers:
11
+ handler = logging.StreamHandler()
12
+ formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
13
+ handler.setFormatter(formatter)
14
+ logger.addHandler(handler)
15
+
16
+ class WizzerClient:
17
+ """
18
+ A Python SDK for connecting to the Wizzer's REST API.
19
+
20
+ Attributes:
21
+ base_url (str): Base URL of the Wizzer's API server.
22
+ token (str): JWT token for authentication.
23
+ log_level (str): Logging level. Options: "error", "info", "debug".
24
+ strategy_id (str): Default strategy ID to use if not provided in methods.
25
+ """
26
+
27
+ def __init__(
28
+ self,
29
+ base_url: Optional[str] = None,
30
+ token: Optional[str] = None,
31
+ strategy_id: Optional[str] = None,
32
+ log_level: str = "error" # default only errors
33
+ ):
34
+ # Configure logger based on log_level.
35
+ valid_levels = {"error": logging.ERROR, "info": logging.INFO, "debug": logging.DEBUG}
36
+ if log_level not in valid_levels:
37
+ raise ValueError(f"log_level must be one of {list(valid_levels.keys())}")
38
+ logger.setLevel(valid_levels[log_level])
39
+
40
+ self.log_level = log_level
41
+ # System env vars take precedence over .env
42
+ self.base_url = base_url or os.environ.get("WZ__API_BASE_URL")
43
+ self.token = token or os.environ.get("WZ__TOKEN")
44
+ self.strategy_id = strategy_id or os.environ.get("WZ__STRATEGY_ID")
45
+
46
+ if not self.token:
47
+ raise ValueError("JWT token must be provided as an argument or in .env (WZ__TOKEN)")
48
+ if not self.base_url:
49
+ raise ValueError("Base URL must be provided as an argument or in .env (WZ__API_BASE_URL)")
50
+
51
+ # Prepare the authorization header
52
+ self.headers = {
53
+ "Authorization": f"Bearer {self.token}",
54
+ "Content-Type": "application/json"
55
+ }
56
+
57
+ logger.debug("Initialized WizzerClient with URL: %s", self.base_url)
58
+
59
+ def _get_strategy(self, strategy: Optional[Dict[str, str]] = None) -> Dict[str, str]:
60
+ """
61
+ Get strategy information, either from the provided parameter or from the default.
62
+
63
+ Args:
64
+ strategy (Optional[Dict[str, str]]): Strategy object with id, identifier, and name.
65
+
66
+ Returns:
67
+ Dict[str, str]: A strategy object with at least the id field.
68
+
69
+ Raises:
70
+ ValueError: If no strategy is provided and no default is set.
71
+ """
72
+ if strategy and "id" in strategy:
73
+ return strategy
74
+
75
+ if not self.strategy_id:
76
+ raise ValueError("Strategy ID must be provided either as a parameter or set in .env (WZ__STRATEGY_ID)")
77
+
78
+ return {"id": self.strategy_id}
79
+
80
+ # ===== DATA HUB METHODS =====
81
+
82
+ def get_indices(self, trading_symbol: Optional[str] = None, exchange: Optional[str] = None) -> List[Dict[str, Any]]:
83
+ """
84
+ Get list of indices available on the exchange.
85
+
86
+ Args:
87
+ trading_symbol (Optional[str]): Filter by specific index symbol.
88
+ exchange (Optional[str]): Filter by specific exchange (NSE, BSE).
89
+
90
+ Returns:
91
+ List[Dict[str, Any]]: List of index information.
92
+ """
93
+ endpoint = "/datahub/indices"
94
+ params = {}
95
+
96
+ if trading_symbol:
97
+ params["tradingSymbol"] = trading_symbol
98
+ if exchange:
99
+ params["exchange"] = exchange
100
+
101
+ logger.debug("Fetching indices with params: %s", params)
102
+ response = self._make_request("GET", endpoint, params=params)
103
+ return response
104
+
105
+ def get_index_components(self, trading_symbol: str, exchange: str) -> List[Dict[str, Any]]:
106
+ """
107
+ Get list of components (stocks) for a specific index.
108
+
109
+ Args:
110
+ trading_symbol (str): Index symbol (e.g., "NIFTY 50").
111
+ exchange (str): Exchange name (NSE, BSE).
112
+
113
+ Returns:
114
+ List[Dict[str, Any]]: List of component stocks in the index.
115
+ """
116
+ endpoint = "/datahub/index/components"
117
+ params = {
118
+ "tradingSymbol": trading_symbol,
119
+ "exchange": exchange
120
+ }
121
+
122
+ logger.debug("Fetching index components with params: %s", params)
123
+ response = self._make_request("GET", endpoint, params=params)
124
+ return response
125
+
126
+ def get_historical_ohlcv(
127
+ self,
128
+ instruments: List[str],
129
+ start_date: str,
130
+ end_date: str,
131
+ ohlcv: List[str],
132
+ interval: str = "1d"
133
+ ) -> List[Dict[str, Any]]:
134
+ """
135
+ Get historical OHLCV data for specified instruments.
136
+
137
+ Args:
138
+ instruments (List[str]): List of instrument identifiers (e.g., ["NSE:SBIN:3045"]).
139
+ start_date (str): Start date in YYYY-MM-DD format.
140
+ end_date (str): End date in YYYY-MM-DD format.
141
+ ohlcv (List[str]): List of OHLCV fields to retrieve (open, high, low, close, volume).
142
+ interval (str, optional): Data interval. Options: "1d" (daily, default), "1M" (monthly - last trading day of month).
143
+
144
+ Returns:
145
+ List[Dict[str, Any]]: Historical data for requested instruments.
146
+ """
147
+ endpoint = "/datahub/historical/ohlcv"
148
+ data = {
149
+ "instruments": instruments,
150
+ "startDate": start_date,
151
+ "endDate": end_date,
152
+ "ohlcv": ohlcv,
153
+ "interval": interval
154
+ }
155
+
156
+ logger.debug("Fetching historical OHLCV with data: %s", data)
157
+ response = self._make_request("POST", endpoint, json=data)
158
+ return response
159
+
160
+ # ===== ORDER MANAGEMENT METHODS =====
161
+
162
+ def place_order(
163
+ self,
164
+ exchange: str,
165
+ trading_symbol: str,
166
+ transaction_type: str,
167
+ quantity: int,
168
+ order_type: str = "MARKET",
169
+ product: str = "CNC",
170
+ price: float = 0,
171
+ trigger_price: float = 0,
172
+ disclosed_qty: int = 0,
173
+ validity: str = "DAY",
174
+ variety: str = "REGULAR",
175
+ stoploss: float = 0,
176
+ target: float = 0,
177
+ segment: Optional[str] = None,
178
+ exchange_token: Optional[int] = None,
179
+ broker: str = "",
180
+ strategy: Optional[Dict[str, str]] = None
181
+ ) -> Dict[str, Any]:
182
+ """
183
+ Place a regular order.
184
+
185
+ Args:
186
+ exchange (str): Exchange code (e.g., "NSE", "BSE").
187
+ trading_symbol (str): Symbol of the instrument.
188
+ transaction_type (str): "BUY" or "SELL".
189
+ quantity (int): Number of shares to trade.
190
+ order_type (str, optional): Order type (e.g., "MARKET", "LIMIT"). Defaults to "MARKET".
191
+ product (str, optional): Product code (e.g., "CNC" for delivery). Defaults to "CNC".
192
+ price (float, optional): Price for limit orders. Defaults to 0.
193
+ trigger_price (float, optional): Trigger price for stop orders. Defaults to 0.
194
+ disclosed_qty (int, optional): Disclosed quantity. Defaults to 0.
195
+ validity (str, optional): Order validity (e.g., "DAY", "IOC"). Defaults to "DAY".
196
+ variety (str, optional): Order variety. Defaults to "REGULAR".
197
+ stoploss (float, optional): Stop loss price. Defaults to 0.
198
+ target (float, optional): Target price. Defaults to 0.
199
+ segment (Optional[str], optional): Market segment. If None, determined from exchange.
200
+ exchange_token (Optional[int], optional): Exchange token for the instrument.
201
+ broker (str, optional): Broker code.
202
+ strategy (Optional[Dict[str, str]], optional): Strategy information. If None, uses default.
203
+
204
+ Returns:
205
+ Dict[str, Any]: Order response containing orderId.
206
+ """
207
+ endpoint = "/orders"
208
+
209
+ # Determine segment if not provided
210
+ if not segment:
211
+ segment = f"{exchange}CM"
212
+
213
+ # Get strategy information
214
+ strategy_info = self._get_strategy(strategy)
215
+
216
+ data = {
217
+ "exchange": exchange,
218
+ "tradingSymbol": trading_symbol,
219
+ "transactionType": transaction_type,
220
+ "qty": quantity,
221
+ "orderType": order_type,
222
+ "product": product,
223
+ "price": price,
224
+ "triggerPrice": trigger_price,
225
+ "disclosedQty": disclosed_qty,
226
+ "validity": validity,
227
+ "variety": variety,
228
+ "stoploss": stoploss,
229
+ "target": target,
230
+ "segment": segment,
231
+ "broker": broker,
232
+ "strategy": strategy_info
233
+ }
234
+
235
+ # Add exchange token if provided
236
+ if exchange_token:
237
+ data["exchangeToken"] = exchange_token
238
+
239
+ logger.debug("Placing order: %s", data)
240
+ return self._make_request("POST", endpoint, json=data)
241
+
242
+ def modify_order(
243
+ self,
244
+ order_id: str,
245
+ **params
246
+ ) -> Dict[str, Any]:
247
+ """
248
+ Modify an existing order.
249
+
250
+ Args:
251
+ order_id (str): Order ID to modify.
252
+ **params: Parameters to update in the order.
253
+
254
+ Returns:
255
+ Dict[str, Any]: Order response containing orderId.
256
+ """
257
+ endpoint = f"/orders/{order_id}"
258
+
259
+ logger.debug("Modifying order %s with params: %s", order_id, params)
260
+ return self._make_request("PATCH", endpoint, json=params)
261
+
262
+ def cancel_order(self, order_id: str) -> Dict[str, Any]:
263
+ """
264
+ Cancel an existing order.
265
+
266
+ Args:
267
+ order_id (str): Order ID to cancel.
268
+
269
+ Returns:
270
+ Dict[str, Any]: Response with the cancelled order ID.
271
+ """
272
+ endpoint = f"/orders/{order_id}"
273
+
274
+ logger.debug("Cancelling order: %s", order_id)
275
+ return self._make_request("DELETE", endpoint)
276
+
277
+ def get_positions(self) -> List[Dict[str, Any]]:
278
+ """
279
+ Get current portfolio positions.
280
+
281
+ Returns:
282
+ List[Dict[str, Any]]: List of positions.
283
+ """
284
+ endpoint = "/portfolios/positions"
285
+
286
+ logger.debug("Fetching positions")
287
+ return self._make_request("GET", endpoint)
288
+
289
+ def get_holdings(self, portfolios: Optional[str] = "default") -> List[Dict[str, Any]]:
290
+ """
291
+ Get current holdings.
292
+
293
+ Args:
294
+ portfolios (str, optional): Portfolio name. Defaults to "default".
295
+
296
+ Returns:
297
+ List[Dict[str, Any]]: List of holdings.
298
+ """
299
+ endpoint = "/portfolios/holdings"
300
+ params = {"portfolios": portfolios}
301
+
302
+ logger.debug("Fetching holdings for portfolio: %s", portfolios)
303
+ return self._make_request("GET", endpoint, params=params)
304
+
305
+ # ===== BASKET MANAGEMENT METHODS =====
306
+
307
+ def create_basket(
308
+ self,
309
+ name: str,
310
+ instruments: List[Dict[str, Any]],
311
+ weightage_scheme: str = "equi_weighted",
312
+ capital: Optional[Dict[str, float]] = None,
313
+ instrument_types: Optional[List[str]] = None,
314
+ trading_symbol: Optional[str] = None
315
+ ) -> Dict[str, Any]:
316
+ """
317
+ Create a new basket.
318
+
319
+ Args:
320
+ name (str): Name of the basket.
321
+ instruments (List[Dict[str, Any]]): List of instruments with weightage and shares.
322
+ weightage_scheme (str, optional): Weightage scheme. Defaults to "equi_weighted".
323
+ capital (Optional[Dict[str, float]], optional): Capital allocation. Defaults to {"minValue": 0, "actualValue": 0}.
324
+ instrument_types (Optional[List[str]], optional): Types of instruments. Defaults to ["EQLC"].
325
+
326
+ Returns:
327
+ Dict[str, Any]: Basket information.
328
+ """
329
+ endpoint = "/baskets"
330
+
331
+ # Set defaults
332
+ if capital is None:
333
+ capital = {"minValue": 0, "actualValue": 0}
334
+
335
+ data = {
336
+ "name": name,
337
+ "weightageScheme": weightage_scheme,
338
+ "instruments": instruments,
339
+ "capital": capital,
340
+ "instrumentTypes": instrument_types
341
+ }
342
+
343
+ logger.debug("Creating basket: %s", data)
344
+ return self._make_request("POST", endpoint, json=data)
345
+
346
+ def get_baskets(self) -> List[Dict[str, Any]]:
347
+ """
348
+ Get all baskets.
349
+
350
+ Returns:
351
+ List[Dict[str, Any]]: List of baskets.
352
+ """
353
+ endpoint = "/baskets"
354
+
355
+ logger.debug("Fetching baskets")
356
+ return self._make_request("GET", endpoint)
357
+
358
+ def get_basket(self, basket_id: str) -> Dict[str, Any]:
359
+ """
360
+ Get a specific basket by ID.
361
+
362
+ Args:
363
+ basket_id (str): Basket ID.
364
+
365
+ Returns:
366
+ Dict[str, Any]: Basket information.
367
+ """
368
+ endpoint = f"/baskets/{basket_id}"
369
+
370
+ logger.debug("Fetching basket: %s", basket_id)
371
+ return self._make_request("GET", endpoint)
372
+
373
+ def get_basket_instruments(self, basket_id: str) -> List[Dict[str, Any]]:
374
+ """
375
+ Get instruments in a basket.
376
+
377
+ Args:
378
+ basket_id (str): Basket ID.
379
+
380
+ Returns:
381
+ List[Dict[str, Any]]: List of instruments in the basket.
382
+ """
383
+ endpoint = f"/baskets/{basket_id}/instruments"
384
+
385
+ logger.debug("Fetching instruments for basket: %s", basket_id)
386
+ return self._make_request("GET", endpoint)
387
+
388
+ def place_basket_order(
389
+ self,
390
+ trading_symbol: str,
391
+ transaction_type: str,
392
+ quantity: float,
393
+ price: float = 0,
394
+ order_type: str = "MARKET",
395
+ product: str = "CNC",
396
+ validity: str = "DAY",
397
+ exchange_token: Optional[int] = None,
398
+ trigger_price: float = 0,
399
+ stoploss: float = 0,
400
+ target: float = 0,
401
+ broker: str = "wizzer",
402
+ variety: str = "REGULAR",
403
+ strategy: Optional[Dict[str, str]] = None,
404
+ disclosed_qty: int = 0,
405
+ sl_applied_level: Optional[str] = None
406
+ ) -> Dict[str, Any]:
407
+ """
408
+ Place a basket order.
409
+
410
+ Args:
411
+ trading_symbol (str): Basket trading symbol (e.g., "/BASKET_NAME").
412
+ transaction_type (str): "BUY" or "SELL".
413
+ quantity (float): Quantity/units of the basket.
414
+ price (float, optional): Price for limit orders. Defaults to 0.
415
+ order_type (str, optional): Order type. Defaults to "MARKET".
416
+ product (str, optional): Product code. Defaults to "CNC".
417
+ validity (str, optional): Order validity. Defaults to "DAY".
418
+ exchange_token (Optional[int], optional): Exchange token for the basket.
419
+ trigger_price (float, optional): Trigger price. Defaults to 0.
420
+ stoploss (float, optional): Stop loss price. Defaults to 0.
421
+ target (float, optional): Target price. Defaults to 0.
422
+ broker (str, optional): Broker code. Defaults to "wizzer".
423
+ variety (str, optional): Order variety. Defaults to "REGULAR".
424
+ strategy (Optional[Dict[str, str]], optional): Strategy information. If None, uses default.
425
+ disclosed_qty (int, optional): Disclosed quantity. Defaults to 0.
426
+ sl_applied_level (Optional[str], optional): Stop loss applied level (e.g., "basket").
427
+
428
+ Returns:
429
+ Dict[str, Any]: Order response containing orderId.
430
+ """
431
+ endpoint = "/orders/basket"
432
+
433
+ # Get strategy information
434
+ strategy_info = self._get_strategy(strategy)
435
+
436
+ data = {
437
+ "tradingSymbol": trading_symbol,
438
+ "exchange": "WZR",
439
+ "transactionType": transaction_type,
440
+ "qty": quantity,
441
+ "price": price,
442
+ "orderType": order_type,
443
+ "product": product,
444
+ "validity": validity,
445
+ "triggerPrice": trigger_price,
446
+ "stoploss": stoploss,
447
+ "target": target,
448
+ "broker": broker,
449
+ "variety": variety,
450
+ "strategy": strategy_info,
451
+ "segment": "WZREQ",
452
+ "disclosedQty": disclosed_qty
453
+ }
454
+
455
+ # Add exchange token if provided
456
+ if exchange_token:
457
+ data["exchangeToken"] = exchange_token
458
+
459
+ # Add stop loss level if provided
460
+ if sl_applied_level:
461
+ data["slAppliedLevel"] = sl_applied_level
462
+
463
+ logger.debug("Placing basket order: %s", data)
464
+ return self._make_request("POST", endpoint, json=data)
465
+
466
+ def place_basket_exit_order(
467
+ self,
468
+ trading_symbol: str,
469
+ exchange: str,
470
+ transaction_type: str,
471
+ quantity: float,
472
+ exchange_token: int,
473
+ **kwargs
474
+ ) -> Dict[str, Any]:
475
+ """
476
+ Place a basket exit order.
477
+
478
+ Args:
479
+ trading_symbol (str): Basket trading symbol.
480
+ exchange (str): Exchange code (usually "WZR" for baskets).
481
+ transaction_type (str): "BUY" or "SELL" (usually "SELL" for exit).
482
+ quantity (float): Quantity/units of the basket.
483
+ exchange_token (int): Exchange token for the basket.
484
+ **kwargs: Additional parameters for the order.
485
+
486
+ Returns:
487
+ Dict[str, Any]: Order response containing orderId.
488
+ """
489
+ endpoint = "/orders/basket/exit"
490
+
491
+ # Build base data
492
+ data = {
493
+ "tradingSymbol": trading_symbol,
494
+ "exchange": exchange,
495
+ "transactionType": transaction_type,
496
+ "qty": quantity,
497
+ "exchangeToken": exchange_token,
498
+ **kwargs
499
+ }
500
+
501
+ # Set strategy if not in kwargs
502
+ if "strategy" not in kwargs:
503
+ data["strategy"] = self._get_strategy(None)
504
+
505
+ # Set defaults if not in kwargs
506
+ defaults = {
507
+ "orderType": "MARKET",
508
+ "product": "CNC",
509
+ "validity": "DAY",
510
+ "disclosedQty": 0,
511
+ "price": 0,
512
+ "variety": "REGULAR",
513
+ "stoploss": 0,
514
+ "broker": "wizzer",
515
+ "triggerPrice": 0,
516
+ "target": 0,
517
+ "segment": "WZREQ"
518
+ }
519
+
520
+ for key, value in defaults.items():
521
+ if key not in data:
522
+ data[key] = value
523
+
524
+ logger.debug("Placing basket exit order: %s", data)
525
+ return self._make_request("POST", endpoint, json=data)
526
+
527
+ def modify_basket_order(
528
+ self,
529
+ order_id: str,
530
+ **params
531
+ ) -> Dict[str, Any]:
532
+ """
533
+ Modify an existing basket order.
534
+
535
+ Args:
536
+ order_id (str): Order ID to modify.
537
+ **params: Parameters to update in the order.
538
+
539
+ Returns:
540
+ Dict[str, Any]: Order response containing orderId.
541
+ """
542
+ endpoint = f"/orders/basket/{order_id}"
543
+
544
+ logger.debug("Modifying basket order %s with params: %s", order_id, params)
545
+ return self._make_request("PATCH", endpoint, json=params)
546
+
547
+ def rebalance_basket(
548
+ self,
549
+ trading_symbol: str,
550
+ instruments: List[str]
551
+ ) -> Dict[str, Any]:
552
+ """
553
+ Rebalance a basket with new instruments.
554
+
555
+ Args:
556
+ trading_symbol (str): Basket trading symbol.
557
+ instruments (List[str]): List of instrument identifiers for the new basket composition.
558
+
559
+ Returns:
560
+ Dict[str, Any]: Rebalance response.
561
+ """
562
+ endpoint = "/baskets/rebalance"
563
+
564
+ data = {
565
+ "tradingSymbol": trading_symbol,
566
+ "instruments": instruments
567
+ }
568
+
569
+ logger.debug("Rebalancing basket %s with instruments: %s", trading_symbol, instruments)
570
+ return self._make_request("POST", endpoint, json=data)
571
+
572
+ def _make_request(
573
+ self,
574
+ method: str,
575
+ endpoint: str,
576
+ params: Optional[Dict[str, str]] = None,
577
+ json: Optional[Dict[str, Any]] = None,
578
+ headers: Optional[Dict[str, str]] = None
579
+ ) -> Any:
580
+ """
581
+ Make an HTTP request to the API.
582
+
583
+ Args:
584
+ method (str): HTTP method (GET, POST, etc.)
585
+ endpoint (str): API endpoint path.
586
+ params (Optional[Dict[str, str]]): Query parameters for GET requests.
587
+ json (Optional[Dict[str, Any]]): JSON payload for POST requests.
588
+ headers (Optional[Dict[str, str]]): Custom headers to override the defaults.
589
+
590
+ Returns:
591
+ Any: Parsed JSON response.
592
+
593
+ Raises:
594
+ requests.RequestException: If the request fails.
595
+ """
596
+ url = f"{self.base_url}{endpoint}"
597
+ request_headers = headers if headers else self.headers
598
+
599
+ try:
600
+ logger.debug("%s request to %s", method, url)
601
+ response = requests.request(
602
+ method=method,
603
+ url=url,
604
+ headers=request_headers,
605
+ params=params,
606
+ json=json
607
+ )
608
+ response.raise_for_status()
609
+ return response.json()
610
+ except requests.RequestException as e:
611
+ logger.error("API request failed: %s", e, exc_info=True)
612
+ if hasattr(e.response, 'text'):
613
+ logger.error("Response content: %s", e.response.text)
614
+ raise
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.2
2
+ Name: wiz_trader
3
+ Version: 0.4.0
4
+ Summary: A Python SDK for connecting to the Wizzer.
5
+ Home-page: https://bitbucket.org/wizzer-tech/quotes_sdk.git
6
+ Author: Pawan Wagh
7
+ Author-email: Pawan Wagh <pawan@wizzer.in>
8
+ License: MIT
9
+ Project-URL: Homepage, https://bitbucket.org/wizzer-tech/quotes_sdk.git
10
+ Project-URL: Bug Tracker, https://bitbucket.org/wizzer-tech/quotes_sdk/issues
11
+ Keywords: finance,trading,sdk
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Topic :: Office/Business :: Financial
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.6
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: websockets
23
+ Requires-Dist: requests
24
+ Dynamic: author
25
+ Dynamic: home-page
26
+ Dynamic: requires-python
27
+
28
+ # WizTrader SDK
29
+
30
+ A Python SDK for connecting to the Wizzer trading platform.
31
+
32
+ ## Installation
33
+
34
+ You can install the package directly from PyPI:
35
+
36
+ ```bash
37
+ pip install wiz_trader
38
+ ```
39
+
40
+ ## Features
41
+
42
+ - Real-time market data through WebSocket connection
43
+ - REST API for accessing market data and indices
44
+ - Automatic WebSocket reconnection with exponential backoff
45
+ - Subscribe/unsubscribe to instruments
46
+ - Customizable logging levels
47
+
48
+ ## Quick Start - Quotes Client
49
+
50
+ ```python
51
+ import asyncio
52
+ from wiz_trader import QuotesClient
53
+
54
+ # Callback function to process market data
55
+ def process_tick(data):
56
+ print(f"Received tick: {data}")
57
+
58
+ async def main():
59
+ # Initialize client with direct parameters
60
+ client = QuotesClient(
61
+ base_url="wss://websocket-url/quotes",
62
+ token="your-jwt-token",
63
+ log_level="info" # Options: "error", "info", "debug"
64
+ )
65
+
66
+ # Set callback
67
+ client.on_tick = process_tick
68
+
69
+ # Connect in the background
70
+ connection_task = asyncio.create_task(client.connect())
71
+
72
+ # Subscribe to instruments
73
+ await client.subscribe(["NSE:SBIN:3045"])
74
+
75
+ # Keep the connection running
76
+ try:
77
+ await asyncio.sleep(3600) # Run for 1 hour
78
+ except KeyboardInterrupt:
79
+ # Unsubscribe and close
80
+ await client.unsubscribe(["NSE:SBIN:3045"])
81
+ await client.close()
82
+
83
+ await connection_task
84
+
85
+ if __name__ == "__main__":
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ ## Quick Start - DataHub Client
90
+
91
+ ```python
92
+ from wiz_trader import WizzerClient
93
+
94
+ # Initialize client
95
+ client = WizzerClient(
96
+ base_url="https://api-url.in",
97
+ token="your-jwt-token",
98
+ log_level="info" # Options: "error", "info", "debug"
99
+ )
100
+
101
+ # Get list of indices
102
+ indices = client.get_indices(exchange="NSE")
103
+ print(indices)
104
+
105
+ # Get index components
106
+ components = client.get_index_components(
107
+ trading_symbol="NIFTY 50",
108
+ exchange="NSE"
109
+ )
110
+ print(components)
111
+
112
+ # Get historical OHLCV data
113
+ historical_data = client.get_historical_ohlcv(
114
+ instruments=["NSE:SBIN:3045"],
115
+ start_date="2024-01-01",
116
+ end_date="2024-01-31",
117
+ ohlcv=["open", "high", "low", "close", "volume"]
118
+ )
119
+ print(historical_data)
120
+ ```
121
+
122
+ ## Configuration
123
+
124
+ You can configure the clients in two ways:
125
+
126
+ 1. **Direct parameter passing** (recommended):
127
+ ```python
128
+ quotes_client = QuotesClient(
129
+ base_url="wss://websocket-url/quotes",
130
+ token="your-jwt-token",
131
+ log_level="info"
132
+ )
133
+
134
+ wizzer_client = WizzerClient(
135
+ base_url="https://api-url.in",
136
+ token="your-jwt-token",
137
+ log_level="info"
138
+ )
139
+ ```
140
+
141
+ 2. **System environment variables**:
142
+ - `WZ__QUOTES_BASE_URL`: WebSocket URL for the quotes server
143
+ - `WZ__API_BASE_URL`: Base URL for the Wizzer's REST API
144
+ - `WZ__TOKEN`: JWT token for authentication
145
+
146
+ ```python
147
+ # The clients will automatically use the environment variables if parameters are not provided
148
+ quotes_client = QuotesClient(log_level="info")
149
+ wizzer_client = WizzerClient(log_level="info")
150
+ ```
151
+
152
+ ## Advanced Usage
153
+
154
+ Check the `examples/` directory for more detailed examples:
155
+
156
+ - `example_manual.py`: Demonstrates direct configuration with parameters
157
+ - `example_wizzer.py`: Demonstrates usage of the Wizzer client
158
+
159
+ ## License
160
+
161
+ This project is licensed under the MIT License - see the LICENSE file for details.
162
+
163
+ ## Contributing
164
+
165
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,9 @@
1
+ wiz_trader/__init__.py,sha256=K4mziMd-J5lkvlU2RwSmEUVmX1k39v6Iz4fYFstrMSs,181
2
+ wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
3
+ wiz_trader/apis/client.py,sha256=VM7u1LO3M9P1BYWNeoDf5BykpynWtWx4uZx0r7GMm9w,19153
4
+ wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
5
+ wiz_trader/quotes/client.py,sha256=fUHTMGDauGF9cjsFsVAzoOwqSgD555_TLoNqmnFhLdQ,6203
6
+ wiz_trader-0.4.0.dist-info/METADATA,sha256=JQOD1oxwvvJv2KxjiX9hVe-nm5m1T3smK2jebXVKOc4,4281
7
+ wiz_trader-0.4.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
8
+ wiz_trader-0.4.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
9
+ wiz_trader-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,121 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: wiz_trader
3
- Version: 0.2.0
4
- Summary: A Python SDK for connecting to the Wizzer.
5
- Home-page: https://bitbucket.org/wizzer-tech/quotes_sdk.git
6
- Author: Pawan Wagh
7
- Author-email: Pawan Wagh <pawan@wizzer.in>
8
- License: MIT
9
- Project-URL: Homepage, https://bitbucket.org/wizzer-tech/quotes_sdk.git
10
- Project-URL: Bug Tracker, https://bitbucket.org/wizzer-tech/quotes_sdk/issues
11
- Keywords: finance,trading,sdk
12
- Classifier: Development Status :: 3 - Alpha
13
- Classifier: Intended Audience :: Financial and Insurance Industry
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Operating System :: OS Independent
17
- Classifier: License :: OSI Approved :: MIT License
18
- Classifier: Topic :: Office/Business :: Financial
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Requires-Python: >=3.6
21
- Description-Content-Type: text/markdown
22
- Requires-Dist: websockets
23
- Dynamic: author
24
- Dynamic: home-page
25
- Dynamic: requires-python
26
-
27
- # WizTrader SDK
28
-
29
- A Python SDK for connecting to the Wizzer trading platform.
30
-
31
- ## Installation
32
-
33
- You can install the package directly from PyPI:
34
-
35
- ```bash
36
- pip install wiz_trader
37
- ```
38
-
39
- ## Features
40
-
41
- - Real-time market data through WebSocket connection
42
- - Automatic reconnection with exponential backoff
43
- - Subscribe/unsubscribe to instruments
44
- - Customizable logging levels
45
-
46
- ## Quick Start
47
-
48
- ```python
49
- import asyncio
50
- from wiz_trader import QuotesClient
51
-
52
- # Callback function to process market data
53
- def process_tick(data):
54
- print(f"Received tick: {data}")
55
-
56
- async def main():
57
- # Initialize client with direct parameters
58
- client = QuotesClient(
59
- base_url="wss://your-websocket-url.com/quotes",
60
- token="your-jwt-token",
61
- log_level="info" # Options: "error", "info", "debug"
62
- )
63
-
64
- # Set callback
65
- client.on_tick = process_tick
66
-
67
- # Connect in the background
68
- connection_task = asyncio.create_task(client.connect())
69
-
70
- # Subscribe to instruments
71
- await client.subscribe(["NSE:SBIN:3045"])
72
-
73
- # Keep the connection running
74
- try:
75
- await asyncio.sleep(3600) # Run for 1 hour
76
- except KeyboardInterrupt:
77
- # Unsubscribe and close
78
- await client.unsubscribe(["NSE:SBIN:3045"])
79
- await client.close()
80
-
81
- await connection_task
82
-
83
- if __name__ == "__main__":
84
- asyncio.run(main())
85
- ```
86
-
87
- ## Configuration
88
-
89
- You can configure the client in two ways:
90
-
91
- 1. **Direct parameter passing** (recommended):
92
- ```python
93
- client = QuotesClient(
94
- base_url="wss://your-websocket-url.com/quotes",
95
- token="your-jwt-token",
96
- log_level="info"
97
- )
98
- ```
99
-
100
- 2. **System environment variables**:
101
- - `WZ__QUOTES_BASE_URL`: WebSocket URL for the quotes server
102
- - `WZ__TOKEN`: JWT token for authentication
103
-
104
- ```python
105
- # The client will automatically use the environment variables if parameters are not provided
106
- client = QuotesClient(log_level="info")
107
- ```
108
-
109
- ## Advanced Usage
110
-
111
- Check the `examples/` directory for more detailed examples:
112
-
113
- - `example_manual.py`: Demonstrates direct configuration with parameters
114
-
115
- ## License
116
-
117
- This project is licensed under the MIT License - see the LICENSE file for details.
118
-
119
- ## Contributing
120
-
121
- Contributions are welcome! Please feel free to submit a Pull Request.
@@ -1,9 +0,0 @@
1
- wiz_trader/__init__.py,sha256=eF_WT0HrgsF5TUUwqYzVybEmjT-q-hKPAV9Gi0txSTs,134
2
- wiz_trader/apis/__init__.py,sha256=mcwt2QZZ1q576tKc4bXsx8PoFNimZkgYqOQrrbD43XE,172
3
- wiz_trader/apis/client.py,sha256=NJ9cPIK0LIe1rhC8CIRIXRvQ3zksIuNJCFlnTJlYm9E,88
4
- wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
5
- wiz_trader/quotes/client.py,sha256=fUHTMGDauGF9cjsFsVAzoOwqSgD555_TLoNqmnFhLdQ,6203
6
- wiz_trader-0.2.0.dist-info/METADATA,sha256=PdGKFSHFTxEgLTC6qzNOzgpmr1G4QS2v1df4ne9pXdA,3280
7
- wiz_trader-0.2.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
8
- wiz_trader-0.2.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
9
- wiz_trader-0.2.0.dist-info/RECORD,,