p123api 2.4.0__tar.gz → 2.4.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p123api
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: Portfolio123 API wrapper
5
5
  Home-page: https://github.com/portfolio-123/p123api-py
6
6
  Author: Portfolio123
@@ -5,6 +5,9 @@ import pandas
5
5
  from string import Template
6
6
  from typing import IO, Callable, List, Literal, Optional, Union, overload
7
7
  from typing_extensions import deprecated
8
+ import numpy
9
+
10
+ numpy.any(32)
8
11
 
9
12
  from .types import (
10
13
  DataSeriesInfoResult,
@@ -481,15 +484,35 @@ class Client:
481
484
  currency="USD",
482
485
  ) -> IdResult:
483
486
  """
484
- Creates Ranking System
487
+ Creates a new ranking system.
488
+
489
+ Creates a ranking system based on the provided nodes and configuration parameters.
490
+
491
+ Args:
492
+ name: Ranking system name.
493
+ nodes: Ranking system nodes XML.
494
+ rankingMethod: Ranking method to be used.
495
+ type: Ranking method type. Use "Stock" or "ETF".
496
+ currency: Ranking method currency (e.g., "USD").
485
497
 
486
- :param name: Rank name
487
- :param nodes: Rank nodes XML
488
- :param rankingMethod: Ranking method
489
- :param type: Ranking method type ["Stock", "ETF"]
490
- :param currency: Ranking method currency. Example: USD
491
- :return: rank_id:
498
+ Returns:
499
+ A dictionary containing the new ranking system's details.
500
+
501
+ Examples:
502
+ >>> client.rank_create(
503
+ ... 'New Ranking System',
504
+ ... '<RankingSystem RankType="Higher">...</RankingSystem>',
505
+ ... rankingMethod=RankingMethod.PERCENTILE_NA_NEGATIVE,
506
+ ... type='Stock',
507
+ ... currency='USD'
508
+ ... )
509
+ {
510
+ 'id': 98765,
511
+ 'cost': 1,
512
+ 'quotaRemaining': 45678
513
+ }
492
514
  """
515
+
493
516
  return self._req_with_auth_fallback(
494
517
  method="POST",
495
518
  url=self._endpoint + RANK_CREATE,
@@ -497,26 +520,64 @@ class Client:
497
520
  )
498
521
 
499
522
  @overload
500
- def rank_get(self, *, id: int) -> RankInfoResult: ...
523
+ def rank_get(self, *, id: int) -> RankInfoResult:
524
+ """
525
+ Gets information for a specific ranking system.
526
+
527
+ Retrieves the full configuration details for a given ranking system by its ID.
528
+
529
+ Args:
530
+ id: The unique identifier of the ranking system.
531
+
532
+ Returns:
533
+ A dictionary containing the ranking system's details.
534
+
535
+ Examples:
536
+ >>> client.rank_get(id=12345)
537
+ {
538
+ 'name': 'My Ranking System',
539
+ 'id': 12345,
540
+ 'xml': '<RankingSystem>...</RankingSystem>',
541
+ 'currency': 'USD',
542
+ 'description': 'Ranking system description',
543
+ 'rankingMethod': 1,
544
+ 'type': 'Stock',
545
+ 'groupUid': 100,
546
+ 'resolveGroupUid': 200
547
+ }
548
+ """
549
+ ...
550
+
501
551
  @overload
502
- def rank_get(self, *, name: str) -> RankInfoResult: ...
503
- def rank_get(self, *, id: Optional[int] = None, name: Optional[str] = None) -> RankInfoResult:
552
+ def rank_get(self, *, name: str) -> RankInfoResult:
504
553
  """
505
- Gets Rank info
506
-
507
- :param id: Rank Id
508
- :param name: Rank name
509
- :return: RankInfoResult object containing:
510
- - name (str)
511
- - id (int)
512
- - xml (str)
513
- - currency (str)
514
- - description (str)
515
- - rankingMethod (int)
516
- - type (Literal["Stock", "ETF"])
517
- - groupUid (int)
518
- - resolveGroupUid (int)
554
+ Gets information for a specific ranking system.
555
+
556
+ Retrieves the details for a given ranking system by name.
557
+
558
+ Args:
559
+ name: The name of the ranking system.
560
+
561
+ Returns:
562
+ A dictionary containing the ranking system's details.
563
+
564
+ Examples:
565
+ >>> client.rank_get(name='My Ranking System')
566
+ {
567
+ 'name': 'My Ranking System',
568
+ 'id': 12345,
569
+ 'xml': '<RankingSystem>...</RankingSystem>',
570
+ 'currency': 'USD',
571
+ 'description': 'Ranking system description',
572
+ 'rankingMethod': 1,
573
+ 'type': 'Stock',
574
+ 'groupUid': 100,
575
+ 'resolveGroupUid': 200
576
+ }
519
577
  """
578
+ ...
579
+
580
+ def rank_get(self, *, id: Optional[int] = None, name: Optional[str] = None) -> RankInfoResult:
520
581
  return self._req_with_auth_fallback(method="GET", url=self._endpoint + RANK_PATH, params={"id": id, "name": name})
521
582
 
522
583
  def strategy(self, strategy_id: int):
@@ -528,27 +589,53 @@ class Client:
528
589
 
529
590
  return self._req_with_auth_fallback(method="GET", url=self._endpoint + STRATEGY_DETAILS_PATH.substitute(id=strategy_id))
530
591
 
531
- def strategy_copy(self, id: int, name: str, type: Optional[Literal["PTF", "SIM"]] = None) -> IdResult:
592
+ def strategy_copy(self, id: int, name: str, type: Literal["PTF", "SIM"]) -> IdResult:
532
593
  """
533
- Strategy copy
594
+ Copy an existing strategy to a new strategy.
595
+
596
+ Copies a live or simulated strategy to a new live or simulated strategy. Copied live strategies are set to manual rebalance.
597
+
598
+ Args:
599
+ id: Existing strategy ID.
600
+ name: Name for the new strategy.
601
+ type: Type of strategy to create. Use "PTF" for a live strategy or "SIM" for simulated strategy.
534
602
 
535
- :param id: Strategy Id
536
- :param name: name of the strategy copy
537
- :param type: type of the strategy copy ("PTF"|"SIM")
538
- :return: id
603
+ Returns:
604
+ A dictionary containing the new strategy's details.
605
+
606
+ Examples:
607
+ >>> client.strategy_copy(123, 'Sim copy', 'SIM')
608
+ {
609
+ 'id': 12345,
610
+ 'cost': 1,
611
+ 'quotaRemaining': 45678
612
+ }
539
613
  """
540
614
  return self._req_with_auth_fallback(
541
615
  method="POST", url=self._endpoint + STRATEGY_COPY_PATH.substitute(id=id), json={"name": name, "type": type}
542
616
  )
543
617
 
544
- def book_copy(self, id: int, name: str, type: Optional[Literal["BOOK", "BOOKSIM"]] = None) -> IdResult:
618
+ def book_copy(self, id: int, name: str, type: Literal["BOOK", "BOOKSIM"]) -> IdResult:
545
619
  """
546
- Book copy
620
+ Copy an existing book to a new book.
621
+
622
+ Copies a live or simulated book to a new live or simulated book. Copied live books are set to manual rebalance.
547
623
 
548
- :param book_id:
549
- :param name: name of the book copy
550
- :param type: type of the book copy ("BOOK"|"BOOKSIM")
551
- :return: id
624
+ Args:
625
+ id: Existing book ID.
626
+ name: Name for the new book.
627
+ type: Type of book to create. Use "BOOK" for a live book or "BOOKSIM" for simulated book.
628
+
629
+ Returns:
630
+ A dictionary containing the new book's details.
631
+
632
+ Examples:
633
+ >>> client.book_copy(123, 'Sim book copy', 'BOOKSIM')
634
+ {
635
+ 'id': 12345,
636
+ 'cost': 1,
637
+ 'quotaRemaining': 45678
638
+ }
552
639
  """
553
640
  return self._req_with_auth_fallback(
554
641
  method="POST", url=self._endpoint + BOOK_COPY_PATH.substitute(id=id), json={"name": name, "type": type}
@@ -863,18 +950,75 @@ class Client:
863
950
  return pandas.DataFrame(ret["prices"]) if to_pandas else ret
864
951
 
865
952
  @overload
866
- def stock_factor_info(self, *, id: int) -> StockFactorInfoResult: ...
953
+ def stock_factor_info(self, *, id: int) -> StockFactorInfoResult:
954
+ """
955
+ Retrieve basic stock factor info by ID.
956
+
957
+ Args:
958
+ id: Stock factor ID.
959
+
960
+ Returns:
961
+ A dictionary containing the basic stock factor info.
962
+
963
+ Examples:
964
+ >>> client.stock_factor_info(id=123)
965
+ {
966
+ factorId: 123,
967
+ name: 'Stock factor name',
968
+ description: 'Stock factor description'
969
+ }
970
+ """
971
+ ...
972
+
867
973
  @overload
868
- @deprecated("use overload accepting `id` parameter instead")
869
- def stock_factor_info(self, *, factor_id: int) -> StockFactorInfoResult: ...
974
+ def stock_factor_info(self, *, name: str) -> StockFactorInfoResult:
975
+ """
976
+ Retrieve basic stock factor info by name.
977
+
978
+ Args:
979
+ name: Stock factor name.
980
+
981
+ Returns:
982
+ A dictionary containing the basic stock factor info.
983
+
984
+ Examples:
985
+ >>> client.stock_factor_info(name='Stock factor name')
986
+ {
987
+ factorId: 123,
988
+ name: 'Stock factor name',
989
+ description: 'Stock factor description'
990
+ }
991
+ """
992
+ ...
993
+
870
994
  @overload
871
- def stock_factor_info(self, *, name: str) -> StockFactorInfoResult: ...
995
+ @deprecated("use overload accepting `id` parameter instead")
996
+ def stock_factor_info(self, *, factor_id: int) -> StockFactorInfoResult:
997
+ """
998
+ Retrieve basic stock factor info by ID.
999
+
1000
+ Deprecated:
1001
+ Use overload accepting `id` parameter instead.
1002
+
1003
+ Args:
1004
+ factor_id: Stock factor ID.
1005
+
1006
+ Returns:
1007
+ A dictionary containing the basic stock factor info.
1008
+
1009
+ Examples:
1010
+ >>> client.stock_factor_info(factor_id=123)
1011
+ {
1012
+ factorId: 123,
1013
+ name: 'Stock factor name',
1014
+ description: 'Stock factor description'
1015
+ }
1016
+ """
1017
+ ...
1018
+
872
1019
  def stock_factor_info(
873
1020
  self, *, id: Optional[int] = None, factor_id: Optional[int] = None, name: Optional[str] = None
874
1021
  ) -> StockFactorInfoResult:
875
- """
876
- Stock factor info, only specify factor_id or name
877
- """
878
1022
  if id is not None:
879
1023
  params = {"id": id}
880
1024
  elif factor_id is not None:
@@ -884,25 +1028,95 @@ class Client:
884
1028
  return self._req_with_auth_fallback(method="GET", url=self._endpoint + STOCK_FACTOR_INFO_PATH, params=params)
885
1029
 
886
1030
  @overload
887
- def data_series_info(self, *, id: int) -> DataSeriesInfoResult: ...
1031
+ def data_series_info(self, *, id: int) -> DataSeriesInfoResult:
1032
+ """
1033
+ Retrieve basic data series info by ID.
1034
+
1035
+ Args:
1036
+ id: Data series ID.
1037
+
1038
+ Returns:
1039
+ A dictionary containing the basic data series info.
1040
+
1041
+ Examples:
1042
+ >>> client.data_series_info(id=123)
1043
+ {
1044
+ dataSeriesId: 123,
1045
+ name: 'Data series name',
1046
+ description: 'Data series description'
1047
+ }
1048
+ """
1049
+ ...
1050
+
888
1051
  @overload
889
- def data_series_info(self, *, name: str) -> DataSeriesInfoResult: ...
890
- def data_series_info(self, *, id: Optional[int] = None, name: Optional[str] = None) -> DataSeriesInfoResult:
1052
+ def data_series_info(self, *, name: str) -> DataSeriesInfoResult:
891
1053
  """
892
- Data series info, only specify factor_id or name
1054
+ Retrieve basic data series info by name.
1055
+
1056
+ Args:
1057
+ name: Data series name.
1058
+
1059
+ Returns:
1060
+ A dictionary containing the basic data series info.
1061
+
1062
+ Examples:
1063
+ >>> client.data_series_info(name='Data series name')
1064
+ {
1065
+ dataSeriesId: 123,
1066
+ name: 'Data series name',
1067
+ description: 'Data series description'
1068
+ }
893
1069
  """
1070
+ ...
1071
+
1072
+ def data_series_info(self, *, id: Optional[int] = None, name: Optional[str] = None) -> DataSeriesInfoResult:
894
1073
  return self._req_with_auth_fallback(
895
1074
  method="GET", url=self._endpoint + DATA_SERIES_INFO_PATH, params={"name": name} if id is None else {"id": id}
896
1075
  )
897
1076
 
898
1077
  @overload
899
- def strategy_info(self, *, id: int) -> StrategyInfoResult: ...
1078
+ def strategy_info(self, *, id: int) -> StrategyInfoResult:
1079
+ """
1080
+ Retrieve basic strategy info by ID.
1081
+
1082
+ Args:
1083
+ id: Strategy ID.
1084
+
1085
+ Returns:
1086
+ A dictionary containing the basic strategy info.
1087
+
1088
+ Examples:
1089
+ >>> client.strategy_info(id=123)
1090
+ {
1091
+ strategyId: 123,
1092
+ name: 'Strategy name',
1093
+ description: 'Strategy description'
1094
+ }
1095
+ """
1096
+ ...
1097
+
900
1098
  @overload
901
- def strategy_info(self, *, name: str) -> StrategyInfoResult: ...
902
- def strategy_info(self, *, id: Optional[int] = None, name: Optional[str] = None) -> StrategyInfoResult:
1099
+ def strategy_info(self, *, name: str) -> StrategyInfoResult:
903
1100
  """
904
- Strategy info, only specify factor_id or name
1101
+ Retrieve basic strategy info by name.
1102
+
1103
+ Args:
1104
+ name: Strategy name.
1105
+
1106
+ Returns:
1107
+ A dictionary containing the basic strategy info.
1108
+
1109
+ Examples:
1110
+ >>> client.strategy_info(name='Strategy name')
1111
+ {
1112
+ strategyId: 123,
1113
+ name: 'Strategy name',
1114
+ description: 'Strategy description'
1115
+ }
905
1116
  """
1117
+ ...
1118
+
1119
+ def strategy_info(self, *, id: Optional[int] = None, name: Optional[str] = None) -> StrategyInfoResult:
906
1120
  return self._req_with_auth_fallback(
907
1121
  method="GET", url=self._endpoint + STRATEGY_INFO_PATH, params={"name": name} if id is None else {"id": id}
908
1122
  )
@@ -47,7 +47,7 @@ class RankingMethod(IntEnum):
47
47
  NORMAL_DISTRIBUTION = 1
48
48
 
49
49
 
50
- class StrategyInfoResult(TypedDict):
50
+ class StrategyInfoResult(SharedResult):
51
51
  strategyId: int
52
52
  name: str
53
53
  description: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p123api
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: Portfolio123 API wrapper
5
5
  Home-page: https://github.com/portfolio-123/p123api-py
6
6
  Author: Portfolio123
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="p123api",
8
- version="2.4.0",
8
+ version="2.4.2",
9
9
  author="Portfolio123",
10
10
  author_email="info@portfolio123.com",
11
11
  description="Portfolio123 API wrapper",
File without changes
File without changes
File without changes
File without changes
File without changes