wiz-trader 0.12.0__py3-none-any.whl → 0.14.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 +1 -1
- wiz_trader/apis/client.py +511 -21
- {wiz_trader-0.12.0.dist-info → wiz_trader-0.14.0.dist-info}/METADATA +1 -1
- wiz_trader-0.14.0.dist-info/RECORD +9 -0
- {wiz_trader-0.12.0.dist-info → wiz_trader-0.14.0.dist-info}/WHEEL +1 -1
- wiz_trader-0.12.0.dist-info/RECORD +0 -9
- {wiz_trader-0.12.0.dist-info → wiz_trader-0.14.0.dist-info}/top_level.txt +0 -0
wiz_trader/__init__.py
CHANGED
wiz_trader/apis/client.py
CHANGED
@@ -37,8 +37,8 @@ class WizzerClient:
|
|
37
37
|
# Order types
|
38
38
|
ORDER_TYPE_MARKET = "MARKET"
|
39
39
|
ORDER_TYPE_LIMIT = "LIMIT"
|
40
|
-
ORDER_TYPE_SL = "
|
41
|
-
ORDER_TYPE_SLM = "
|
40
|
+
ORDER_TYPE_SL = "STOPLIMIT" # Stop Loss
|
41
|
+
ORDER_TYPE_SLM = "STOPMARKET" # Stop Loss Market
|
42
42
|
|
43
43
|
# Validity types
|
44
44
|
VALIDITY_DAY = "DAY"
|
@@ -61,11 +61,29 @@ class WizzerClient:
|
|
61
61
|
SEGMENT_BSE_CM = "BSECM" # BSE Cash Market
|
62
62
|
SEGMENT_NSE_FO = "NSEFO" # NSE Futures and Options
|
63
63
|
SEGMENT_WZREQ = "WZREQ" # Wizzer Basket Segment
|
64
|
+
|
65
|
+
# Order status constants
|
66
|
+
ORDER_STATUS_OPEN = "OPEN"
|
67
|
+
ORDER_STATUS_CANCELLED = "CANCELLED"
|
68
|
+
ORDER_STATUS_REJECTED = "REJECTED"
|
69
|
+
ORDER_STATUS_PENDING = "PENDING"
|
70
|
+
ORDER_STATUS_COMPLETED = "COMPLETED"
|
71
|
+
|
72
|
+
# Trading mode constants
|
73
|
+
TRADING_MODE_PAPER = "paper_trading"
|
74
|
+
TRADING_MODE_ADVICES = "advices"
|
75
|
+
TRADING_MODE_TRADING_AND_ADVICES = "trading_and_advices"
|
76
|
+
|
77
|
+
# Rebalance execution policies
|
78
|
+
REBALANCE_FULL = "full_rebalance"
|
79
|
+
REBALANCE_ENTRY_ONLY = "entry_only"
|
80
|
+
REBALANCE_EXIT_ONLY = "exit_only"
|
64
81
|
|
65
82
|
# URIs to various API endpoints
|
66
83
|
_routes = {
|
67
84
|
# Order related endpoints
|
68
85
|
"order.place": "/orders",
|
86
|
+
"order.get": "/orders",
|
69
87
|
"order.modify": "/orders/{order_id}",
|
70
88
|
"order.cancel": "/orders/{order_id}",
|
71
89
|
"order.info": "/orders/{order_id}",
|
@@ -241,7 +259,6 @@ class WizzerClient:
|
|
241
259
|
variety: str = None,
|
242
260
|
stoploss: float = 0,
|
243
261
|
target: float = 0,
|
244
|
-
segment: Optional[str] = None,
|
245
262
|
exchange_token: Optional[int] = None,
|
246
263
|
broker: str = None,
|
247
264
|
strategy: Optional[Dict[str, str]] = None
|
@@ -283,16 +300,6 @@ class WizzerClient:
|
|
283
300
|
if variety is None:
|
284
301
|
variety = self.VARIETY_REGULAR
|
285
302
|
|
286
|
-
# Determine segment if not provided
|
287
|
-
if not segment:
|
288
|
-
segment = f"{exchange}CM"
|
289
|
-
# If exchange is NSE, use the NSE_CM constant
|
290
|
-
if exchange == self.EXCHANGE_NSE:
|
291
|
-
segment = self.SEGMENT_NSE_CM
|
292
|
-
# If exchange is BSE, use the BSE_CM constant
|
293
|
-
elif exchange == self.EXCHANGE_BSE:
|
294
|
-
segment = self.SEGMENT_BSE_CM
|
295
|
-
|
296
303
|
# Get strategy information
|
297
304
|
strategy_info = self._get_strategy(strategy)
|
298
305
|
|
@@ -310,7 +317,6 @@ class WizzerClient:
|
|
310
317
|
"variety": variety,
|
311
318
|
"stoploss": stoploss,
|
312
319
|
"target": target,
|
313
|
-
"segment": segment,
|
314
320
|
"strategy": strategy_info
|
315
321
|
}
|
316
322
|
|
@@ -319,7 +325,7 @@ class WizzerClient:
|
|
319
325
|
data["exchangeToken"] = exchange_token
|
320
326
|
|
321
327
|
logger.debug("Placing order: %s", data)
|
322
|
-
return self._make_request("POST",
|
328
|
+
return self._make_request("POST", endpoint, json=data)
|
323
329
|
|
324
330
|
def modify_order(
|
325
331
|
self,
|
@@ -355,7 +361,480 @@ class WizzerClient:
|
|
355
361
|
|
356
362
|
logger.debug("Cancelling order: %s", order_id)
|
357
363
|
return self._make_request("DELETE", endpoint)
|
358
|
-
|
364
|
+
|
365
|
+
def get_orders(
|
366
|
+
self,
|
367
|
+
trading_modes: Optional[List[str]] = None,
|
368
|
+
order_statuses: Optional[List[str]] = None,
|
369
|
+
from_date: Optional[str] = None,
|
370
|
+
to_date: Optional[str] = None,
|
371
|
+
trading_symbols: Optional[List[str]] = None,
|
372
|
+
page_no: int = 1,
|
373
|
+
paginate: bool = False
|
374
|
+
) -> List[Dict[str, Any]]:
|
375
|
+
"""
|
376
|
+
Get orders with optional filtering.
|
377
|
+
|
378
|
+
Args:
|
379
|
+
trading_modes (Optional[List[str]], optional): Filter by trading modes.
|
380
|
+
Valid values: "paper_trading", "advices", "trading_and_advices".
|
381
|
+
order_statuses (Optional[List[str]], optional): Filter by order statuses.
|
382
|
+
Valid values: "OPEN", "CANCELLED", "REJECTED", "PENDING", "COMPLETED".
|
383
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format. Defaults to today.
|
384
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format. Defaults to today.
|
385
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
386
|
+
page_no (int, optional): Page number for pagination. Defaults to 1.
|
387
|
+
paginate (bool, optional): Whether to automatically fetch all pages. Defaults to False.
|
388
|
+
|
389
|
+
Returns:
|
390
|
+
List[Dict[str, Any]]: List of orders matching the filter criteria.
|
391
|
+
"""
|
392
|
+
endpoint = self._routes["order.get"]
|
393
|
+
|
394
|
+
# Build the base parameters without list items
|
395
|
+
params = {}
|
396
|
+
|
397
|
+
# Handle single parameters
|
398
|
+
if from_date:
|
399
|
+
params["fromDateRange"] = from_date
|
400
|
+
|
401
|
+
if to_date:
|
402
|
+
params["toDateRange"] = to_date
|
403
|
+
|
404
|
+
if not paginate:
|
405
|
+
params["pageNo"] = page_no
|
406
|
+
|
407
|
+
# Validate trading modes
|
408
|
+
if trading_modes:
|
409
|
+
for mode in trading_modes:
|
410
|
+
if mode not in [self.TRADING_MODE_PAPER, self.TRADING_MODE_ADVICES, self.TRADING_MODE_TRADING_AND_ADVICES]:
|
411
|
+
raise ValueError(f"Invalid trading mode: {mode}")
|
412
|
+
|
413
|
+
# Validate order statuses
|
414
|
+
if order_statuses:
|
415
|
+
for status in order_statuses:
|
416
|
+
if status not in [self.ORDER_STATUS_OPEN, self.ORDER_STATUS_CANCELLED,
|
417
|
+
self.ORDER_STATUS_REJECTED, self.ORDER_STATUS_PENDING,
|
418
|
+
self.ORDER_STATUS_COMPLETED]:
|
419
|
+
raise ValueError(f"Invalid order status: {status}")
|
420
|
+
|
421
|
+
# Handle pagination with properly formatted parameters
|
422
|
+
if paginate:
|
423
|
+
return self._paginate_orders(endpoint, params, trading_modes, order_statuses, trading_symbols)
|
424
|
+
else:
|
425
|
+
logger.debug("Fetching orders with params: %s", params)
|
426
|
+
return self._make_request_with_multi_params(
|
427
|
+
"GET",
|
428
|
+
endpoint,
|
429
|
+
params=params,
|
430
|
+
trading_modes=trading_modes,
|
431
|
+
order_statuses=order_statuses,
|
432
|
+
trading_symbols=trading_symbols
|
433
|
+
)
|
434
|
+
|
435
|
+
def _make_request_with_multi_params(
|
436
|
+
self,
|
437
|
+
method: str,
|
438
|
+
endpoint: str,
|
439
|
+
params: Dict[str, Any],
|
440
|
+
trading_modes: Optional[List[str]] = None,
|
441
|
+
order_statuses: Optional[List[str]] = None,
|
442
|
+
trading_symbols: Optional[List[str]] = None
|
443
|
+
) -> Any:
|
444
|
+
"""
|
445
|
+
Make an HTTP request with multiple parameters having the same name.
|
446
|
+
|
447
|
+
Args:
|
448
|
+
method (str): HTTP method (GET, POST, etc.)
|
449
|
+
endpoint (str): API endpoint path.
|
450
|
+
params (Dict[str, Any]): Base query parameters.
|
451
|
+
trading_modes (Optional[List[str]]): List of trading modes.
|
452
|
+
order_statuses (Optional[List[str]]): List of order statuses.
|
453
|
+
trading_symbols (Optional[List[str]]): List of trading symbols.
|
454
|
+
|
455
|
+
Returns:
|
456
|
+
Any: Parsed JSON response.
|
457
|
+
"""
|
458
|
+
url = f"{self.base_url}{endpoint}"
|
459
|
+
|
460
|
+
# Start with the base parameters
|
461
|
+
all_params = params.copy()
|
462
|
+
|
463
|
+
# Create a session to manually handle parameter encoding
|
464
|
+
session = requests.Session()
|
465
|
+
req = requests.Request(method, url, headers=self.headers, params=all_params)
|
466
|
+
prepped = req.prepare()
|
467
|
+
|
468
|
+
# Build the URL with additional repeated parameters
|
469
|
+
query_parts = []
|
470
|
+
if prepped.url.find('?') >= 0:
|
471
|
+
query_parts.append(prepped.url.split('?', 1)[1])
|
472
|
+
|
473
|
+
# Add repeated parameters
|
474
|
+
if trading_modes:
|
475
|
+
for mode in trading_modes:
|
476
|
+
query_parts.append(f"tradingMode={mode}")
|
477
|
+
|
478
|
+
if order_statuses:
|
479
|
+
for status in order_statuses:
|
480
|
+
query_parts.append(f"orderStatus={status}")
|
481
|
+
|
482
|
+
if trading_symbols:
|
483
|
+
for symbol in trading_symbols:
|
484
|
+
query_parts.append(f"tradingSymbols={symbol}")
|
485
|
+
|
486
|
+
# Build the final URL
|
487
|
+
final_url = prepped.url.split('?')[0]
|
488
|
+
if query_parts:
|
489
|
+
final_url += '?' + '&'.join(query_parts)
|
490
|
+
|
491
|
+
try:
|
492
|
+
logger.debug("%s request to %s", method, final_url)
|
493
|
+
response = session.send(prepped)
|
494
|
+
response.url = final_url
|
495
|
+
response.raise_for_status()
|
496
|
+
return response.json()
|
497
|
+
except requests.RequestException as e:
|
498
|
+
logger.error("API request failed: %s", e, exc_info=True)
|
499
|
+
if hasattr(e.response, 'text'):
|
500
|
+
logger.error("Response content: %s", e.response.text)
|
501
|
+
raise
|
502
|
+
|
503
|
+
def _paginate_orders(
|
504
|
+
self,
|
505
|
+
endpoint: str,
|
506
|
+
params: Dict[str, Any],
|
507
|
+
trading_modes: Optional[List[str]] = None,
|
508
|
+
order_statuses: Optional[List[str]] = None,
|
509
|
+
trading_symbols: Optional[List[str]] = None
|
510
|
+
) -> List[Dict[str, Any]]:
|
511
|
+
"""
|
512
|
+
Internal method to handle pagination for orders API with multi-value parameters.
|
513
|
+
|
514
|
+
Args:
|
515
|
+
endpoint (str): API endpoint.
|
516
|
+
params (Dict[str, Any]): Base query parameters.
|
517
|
+
trading_modes (Optional[List[str]]): List of trading modes.
|
518
|
+
order_statuses (Optional[List[str]]): List of order statuses.
|
519
|
+
trading_symbols (Optional[List[str]]): List of trading symbols.
|
520
|
+
|
521
|
+
Returns:
|
522
|
+
List[Dict[str, Any]]: Combined results from all pages.
|
523
|
+
"""
|
524
|
+
all_orders = []
|
525
|
+
page_no = 1
|
526
|
+
total_count = None
|
527
|
+
page_size = 50 # API returns 50 orders per page
|
528
|
+
|
529
|
+
while True:
|
530
|
+
current_params = params.copy()
|
531
|
+
current_params["pageNo"] = page_no
|
532
|
+
logger.debug("Fetching orders page %d", page_no)
|
533
|
+
|
534
|
+
# Build the URL with the session to get the properly formatted parameters
|
535
|
+
session = requests.Session()
|
536
|
+
req = requests.Request("GET", f"{self.base_url}{endpoint}", headers=self.headers, params=current_params)
|
537
|
+
prepped = req.prepare()
|
538
|
+
|
539
|
+
# Build the URL with additional repeated parameters
|
540
|
+
query_parts = []
|
541
|
+
if prepped.url.find('?') >= 0:
|
542
|
+
query_parts.append(prepped.url.split('?', 1)[1])
|
543
|
+
|
544
|
+
# Add repeated parameters
|
545
|
+
if trading_modes:
|
546
|
+
for mode in trading_modes:
|
547
|
+
query_parts.append(f"tradingMode={mode}")
|
548
|
+
|
549
|
+
if order_statuses:
|
550
|
+
for status in order_statuses:
|
551
|
+
query_parts.append(f"orderStatus={status}")
|
552
|
+
|
553
|
+
if trading_symbols:
|
554
|
+
for symbol in trading_symbols:
|
555
|
+
query_parts.append(f"tradingSymbols={symbol}")
|
556
|
+
|
557
|
+
# Build the final URL
|
558
|
+
final_url = prepped.url.split('?')[0]
|
559
|
+
if query_parts:
|
560
|
+
final_url += '?' + '&'.join(query_parts)
|
561
|
+
|
562
|
+
# Make the request
|
563
|
+
try:
|
564
|
+
logger.debug("GET request to %s", final_url)
|
565
|
+
prepped.url = final_url
|
566
|
+
response = session.send(prepped)
|
567
|
+
response.raise_for_status()
|
568
|
+
|
569
|
+
# Get orders from the current page
|
570
|
+
orders = response.json()
|
571
|
+
all_orders.extend(orders)
|
572
|
+
|
573
|
+
# Check if we need to fetch more pages
|
574
|
+
if total_count is None and "X-Total-Count" in response.headers:
|
575
|
+
try:
|
576
|
+
total_count = int(response.headers["X-Total-Count"])
|
577
|
+
logger.debug("Total orders count: %d", total_count)
|
578
|
+
except (ValueError, TypeError):
|
579
|
+
logger.warning("Could not parse X-Total-Count header")
|
580
|
+
break
|
581
|
+
|
582
|
+
# If we've fetched all orders or there are no more pages, stop
|
583
|
+
if not orders or len(all_orders) >= total_count or total_count is None:
|
584
|
+
break
|
585
|
+
|
586
|
+
# Move to the next page
|
587
|
+
page_no += 1
|
588
|
+
|
589
|
+
except requests.RequestException as e:
|
590
|
+
logger.error("API request failed during pagination: %s", e, exc_info=True)
|
591
|
+
if hasattr(e.response, 'text'):
|
592
|
+
logger.error("Response content: %s", e.response.text)
|
593
|
+
raise
|
594
|
+
|
595
|
+
logger.info("Fetched %d orders in total", len(all_orders))
|
596
|
+
return all_orders
|
597
|
+
|
598
|
+
def get_open_orders(
|
599
|
+
self,
|
600
|
+
trading_modes: Optional[List[str]] = None,
|
601
|
+
from_date: Optional[str] = None,
|
602
|
+
to_date: Optional[str] = None,
|
603
|
+
trading_symbols: Optional[List[str]] = None,
|
604
|
+
paginate: bool = False
|
605
|
+
) -> List[Dict[str, Any]]:
|
606
|
+
"""
|
607
|
+
Get open orders with optional filtering.
|
608
|
+
|
609
|
+
Args:
|
610
|
+
trading_modes (Optional[List[str]], optional): Filter by trading modes.
|
611
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
612
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
613
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
614
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
615
|
+
|
616
|
+
Returns:
|
617
|
+
List[Dict[str, Any]]: List of open orders matching the filter criteria.
|
618
|
+
"""
|
619
|
+
return self.get_orders(
|
620
|
+
trading_modes=trading_modes,
|
621
|
+
order_statuses=[self.ORDER_STATUS_OPEN],
|
622
|
+
from_date=from_date,
|
623
|
+
to_date=to_date,
|
624
|
+
trading_symbols=trading_symbols,
|
625
|
+
paginate=paginate
|
626
|
+
)
|
627
|
+
|
628
|
+
def get_completed_orders(
|
629
|
+
self,
|
630
|
+
trading_modes: Optional[List[str]] = None,
|
631
|
+
from_date: Optional[str] = None,
|
632
|
+
to_date: Optional[str] = None,
|
633
|
+
trading_symbols: Optional[List[str]] = None,
|
634
|
+
paginate: bool = False
|
635
|
+
) -> List[Dict[str, Any]]:
|
636
|
+
"""
|
637
|
+
Get completed orders with optional filtering.
|
638
|
+
|
639
|
+
Args:
|
640
|
+
trading_modes (Optional[List[str]], optional): Filter by trading modes.
|
641
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
642
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
643
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
644
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
645
|
+
|
646
|
+
Returns:
|
647
|
+
List[Dict[str, Any]]: List of completed orders matching the filter criteria.
|
648
|
+
"""
|
649
|
+
return self.get_orders(
|
650
|
+
trading_modes=trading_modes,
|
651
|
+
order_statuses=[self.ORDER_STATUS_COMPLETED],
|
652
|
+
from_date=from_date,
|
653
|
+
to_date=to_date,
|
654
|
+
trading_symbols=trading_symbols,
|
655
|
+
paginate=paginate
|
656
|
+
)
|
657
|
+
|
658
|
+
def get_pending_orders(
|
659
|
+
self,
|
660
|
+
trading_modes: Optional[List[str]] = None,
|
661
|
+
from_date: Optional[str] = None,
|
662
|
+
to_date: Optional[str] = None,
|
663
|
+
trading_symbols: Optional[List[str]] = None,
|
664
|
+
paginate: bool = False
|
665
|
+
) -> List[Dict[str, Any]]:
|
666
|
+
"""
|
667
|
+
Get pending orders with optional filtering.
|
668
|
+
|
669
|
+
Args:
|
670
|
+
trading_modes (Optional[List[str]], optional): Filter by trading modes.
|
671
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
672
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
673
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
674
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
675
|
+
|
676
|
+
Returns:
|
677
|
+
List[Dict[str, Any]]: List of pending orders matching the filter criteria.
|
678
|
+
"""
|
679
|
+
return self.get_orders(
|
680
|
+
trading_modes=trading_modes,
|
681
|
+
order_statuses=[self.ORDER_STATUS_PENDING],
|
682
|
+
from_date=from_date,
|
683
|
+
to_date=to_date,
|
684
|
+
trading_symbols=trading_symbols,
|
685
|
+
paginate=paginate
|
686
|
+
)
|
687
|
+
|
688
|
+
def get_cancelled_orders(
|
689
|
+
self,
|
690
|
+
trading_modes: Optional[List[str]] = None,
|
691
|
+
from_date: Optional[str] = None,
|
692
|
+
to_date: Optional[str] = None,
|
693
|
+
trading_symbols: Optional[List[str]] = None,
|
694
|
+
paginate: bool = False
|
695
|
+
) -> List[Dict[str, Any]]:
|
696
|
+
"""
|
697
|
+
Get cancelled orders with optional filtering.
|
698
|
+
|
699
|
+
Args:
|
700
|
+
trading_modes (Optional[List[str]], optional): Filter by trading modes.
|
701
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
702
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
703
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
704
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
705
|
+
|
706
|
+
Returns:
|
707
|
+
List[Dict[str, Any]]: List of cancelled orders matching the filter criteria.
|
708
|
+
"""
|
709
|
+
return self.get_orders(
|
710
|
+
trading_modes=trading_modes,
|
711
|
+
order_statuses=[self.ORDER_STATUS_CANCELLED],
|
712
|
+
from_date=from_date,
|
713
|
+
to_date=to_date,
|
714
|
+
trading_symbols=trading_symbols,
|
715
|
+
paginate=paginate
|
716
|
+
)
|
717
|
+
|
718
|
+
def get_rejected_orders(
|
719
|
+
self,
|
720
|
+
trading_modes: Optional[List[str]] = None,
|
721
|
+
from_date: Optional[str] = None,
|
722
|
+
to_date: Optional[str] = None,
|
723
|
+
trading_symbols: Optional[List[str]] = None,
|
724
|
+
paginate: bool = False
|
725
|
+
) -> List[Dict[str, Any]]:
|
726
|
+
"""
|
727
|
+
Get rejected orders with optional filtering.
|
728
|
+
|
729
|
+
Args:
|
730
|
+
trading_modes (Optional[List[str]], optional): Filter by trading modes.
|
731
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
732
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
733
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
734
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
735
|
+
|
736
|
+
Returns:
|
737
|
+
List[Dict[str, Any]]: List of rejected orders matching the filter criteria.
|
738
|
+
"""
|
739
|
+
return self.get_orders(
|
740
|
+
trading_modes=trading_modes,
|
741
|
+
order_statuses=[self.ORDER_STATUS_REJECTED],
|
742
|
+
from_date=from_date,
|
743
|
+
to_date=to_date,
|
744
|
+
trading_symbols=trading_symbols,
|
745
|
+
paginate=paginate
|
746
|
+
)
|
747
|
+
|
748
|
+
def get_paper_traded_orders(
|
749
|
+
self,
|
750
|
+
order_statuses: Optional[List[str]] = None,
|
751
|
+
from_date: Optional[str] = None,
|
752
|
+
to_date: Optional[str] = None,
|
753
|
+
trading_symbols: Optional[List[str]] = None,
|
754
|
+
paginate: bool = False
|
755
|
+
) -> List[Dict[str, Any]]:
|
756
|
+
"""
|
757
|
+
Get paper traded orders with optional filtering.
|
758
|
+
|
759
|
+
Args:
|
760
|
+
order_statuses (Optional[List[str]], optional): Filter by order statuses.
|
761
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
762
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
763
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
764
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
765
|
+
|
766
|
+
Returns:
|
767
|
+
List[Dict[str, Any]]: List of paper traded orders matching the filter criteria.
|
768
|
+
"""
|
769
|
+
return self.get_orders(
|
770
|
+
trading_modes=[self.TRADING_MODE_PAPER],
|
771
|
+
order_statuses=order_statuses,
|
772
|
+
from_date=from_date,
|
773
|
+
to_date=to_date,
|
774
|
+
trading_symbols=trading_symbols,
|
775
|
+
paginate=paginate
|
776
|
+
)
|
777
|
+
|
778
|
+
def get_advised_orders(
|
779
|
+
self,
|
780
|
+
order_statuses: Optional[List[str]] = None,
|
781
|
+
from_date: Optional[str] = None,
|
782
|
+
to_date: Optional[str] = None,
|
783
|
+
trading_symbols: Optional[List[str]] = None,
|
784
|
+
paginate: bool = False
|
785
|
+
) -> List[Dict[str, Any]]:
|
786
|
+
"""
|
787
|
+
Get advised orders with optional filtering.
|
788
|
+
|
789
|
+
Args:
|
790
|
+
order_statuses (Optional[List[str]], optional): Filter by order statuses.
|
791
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
792
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
793
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
794
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
795
|
+
|
796
|
+
Returns:
|
797
|
+
List[Dict[str, Any]]: List of advised orders matching the filter criteria.
|
798
|
+
"""
|
799
|
+
return self.get_orders(
|
800
|
+
trading_modes=[self.TRADING_MODE_ADVICES],
|
801
|
+
order_statuses=order_statuses,
|
802
|
+
from_date=from_date,
|
803
|
+
to_date=to_date,
|
804
|
+
trading_symbols=trading_symbols,
|
805
|
+
paginate=paginate
|
806
|
+
)
|
807
|
+
|
808
|
+
def get_live_traded_orders(
|
809
|
+
self,
|
810
|
+
order_statuses: Optional[List[str]] = None,
|
811
|
+
from_date: Optional[str] = None,
|
812
|
+
to_date: Optional[str] = None,
|
813
|
+
trading_symbols: Optional[List[str]] = None,
|
814
|
+
paginate: bool = False
|
815
|
+
) -> List[Dict[str, Any]]:
|
816
|
+
"""
|
817
|
+
Get live traded orders with optional filtering.
|
818
|
+
|
819
|
+
Args:
|
820
|
+
order_statuses (Optional[List[str]], optional): Filter by order statuses.
|
821
|
+
from_date (Optional[str], optional): Start date in YYYY-MM-DD format.
|
822
|
+
to_date (Optional[str], optional): End date in YYYY-MM-DD format.
|
823
|
+
trading_symbols (Optional[List[str]], optional): Filter by trading symbols.
|
824
|
+
paginate (bool, optional): Whether to automatically fetch all pages.
|
825
|
+
|
826
|
+
Returns:
|
827
|
+
List[Dict[str, Any]]: List of live traded orders matching the filter criteria.
|
828
|
+
"""
|
829
|
+
return self.get_orders(
|
830
|
+
trading_modes=[self.TRADING_MODE_TRADING_AND_ADVICES],
|
831
|
+
order_statuses=order_statuses,
|
832
|
+
from_date=from_date,
|
833
|
+
to_date=to_date,
|
834
|
+
trading_symbols=trading_symbols,
|
835
|
+
paginate=paginate
|
836
|
+
)
|
837
|
+
|
359
838
|
def get_order(self, order_id: str) -> Dict[str, Any]:
|
360
839
|
"""
|
361
840
|
Get details of a specific order by ID.
|
@@ -682,7 +1161,8 @@ class WizzerClient:
|
|
682
1161
|
def rebalance_basket(
|
683
1162
|
self,
|
684
1163
|
trading_symbol: str,
|
685
|
-
instruments: List[str]
|
1164
|
+
instruments: List[str],
|
1165
|
+
execution_policy: str
|
686
1166
|
) -> Dict[str, Any]:
|
687
1167
|
"""
|
688
1168
|
Rebalance a basket with new instruments.
|
@@ -690,6 +1170,8 @@ class WizzerClient:
|
|
690
1170
|
Args:
|
691
1171
|
trading_symbol (str): Basket trading symbol.
|
692
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".
|
693
1175
|
|
694
1176
|
Returns:
|
695
1177
|
Dict[str, Any]: Rebalance response.
|
@@ -698,10 +1180,14 @@ class WizzerClient:
|
|
698
1180
|
|
699
1181
|
data = {
|
700
1182
|
"tradingSymbol": trading_symbol,
|
701
|
-
"instruments": instruments
|
1183
|
+
"instruments": instruments,
|
1184
|
+
"policies": {
|
1185
|
+
"execution": execution_policy
|
1186
|
+
}
|
702
1187
|
}
|
703
1188
|
|
704
|
-
logger.debug("Rebalancing basket %s with instruments: %s
|
1189
|
+
logger.debug("Rebalancing basket %s with instruments: %s, policy: %s",
|
1190
|
+
trading_symbol, instruments, execution_policy)
|
705
1191
|
return self._make_request("POST", endpoint, json=data)
|
706
1192
|
|
707
1193
|
def exit_all_positions(self) -> Dict[str, Any]:
|
@@ -715,8 +1201,10 @@ class WizzerClient:
|
|
715
1201
|
"""
|
716
1202
|
endpoint = self._routes["portfolio.positions.exit.all"]
|
717
1203
|
|
1204
|
+
data = {}
|
1205
|
+
|
718
1206
|
logger.debug("Exiting all positions")
|
719
|
-
return self._make_request("POST", endpoint)
|
1207
|
+
return self._make_request("POST", endpoint, json=data)
|
720
1208
|
|
721
1209
|
def exit_strategy_positions(self, strategy_id: Optional[str] = None) -> Dict[str, Any]:
|
722
1210
|
"""
|
@@ -740,8 +1228,10 @@ class WizzerClient:
|
|
740
1228
|
|
741
1229
|
endpoint = self._routes["portfolio.positions.exit.strategy"].format(strategy_id=strategy_id)
|
742
1230
|
|
1231
|
+
data = {}
|
1232
|
+
|
743
1233
|
logger.debug("Exiting all positions for strategy: %s", strategy_id)
|
744
|
-
return self._make_request("POST", endpoint)
|
1234
|
+
return self._make_request("POST", endpoint, json=data)
|
745
1235
|
|
746
1236
|
def _make_request(
|
747
1237
|
self,
|
@@ -0,0 +1,9 @@
|
|
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,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
wiz_trader/__init__.py,sha256=cBBWbc6uPGgVrrPNV7qFpdyn5WvAHzh1GYz9Ki3Um5I,182
|
2
|
-
wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
|
3
|
-
wiz_trader/apis/client.py,sha256=d5zXSizv0WI2-EeePApIHkBMabojl9vFNR8nq2xx7mA,25582
|
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.12.0.dist-info/METADATA,sha256=s15O8GpXHECg9sXi347z6VzRGs_V89HNAV_BgzHatBY,54024
|
7
|
-
wiz_trader-0.12.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
8
|
-
wiz_trader-0.12.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
|
9
|
-
wiz_trader-0.12.0.dist-info/RECORD,,
|
File without changes
|