p123api 3.0.0a2__tar.gz → 3.0.0a4__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.
- {p123api-3.0.0a2 → p123api-3.0.0a4}/PKG-INFO +1 -1
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api/client.py +56 -89
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api.egg-info/PKG-INFO +1 -1
- {p123api-3.0.0a2 → p123api-3.0.0a4}/pyproject.toml +1 -1
- {p123api-3.0.0a2 → p123api-3.0.0a4}/LICENSE +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/README.md +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api/__init__.py +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api/types.py +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api.egg-info/SOURCES.txt +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api.egg-info/dependency_links.txt +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api.egg-info/requires.txt +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/p123api.egg-info/top_level.txt +0 -0
- {p123api-3.0.0a2 → p123api-3.0.0a4}/setup.cfg +0 -0
|
@@ -88,7 +88,8 @@ class Client:
|
|
|
88
88
|
self._max_req_retries = 5
|
|
89
89
|
self._timeout = 300
|
|
90
90
|
self._token = None
|
|
91
|
-
|
|
91
|
+
self.cost = None
|
|
92
|
+
self.quotaRemaining = None
|
|
92
93
|
if not isinstance(api_id, (str, int)):
|
|
93
94
|
raise ClientException("api_id must be str or int")
|
|
94
95
|
if not isinstance(api_key, str):
|
|
@@ -165,7 +166,7 @@ class Client:
|
|
|
165
166
|
data: str | IO | None = None,
|
|
166
167
|
headers: dict[str, str] | None = None,
|
|
167
168
|
result_type: type | None = None,
|
|
168
|
-
):
|
|
169
|
+
) -> Any:
|
|
169
170
|
"""
|
|
170
171
|
Request with authentication fallback, used by all requests (except authentication)
|
|
171
172
|
:param method: request method
|
|
@@ -194,6 +195,12 @@ class Client:
|
|
|
194
195
|
|
|
195
196
|
if resp.status_code == 200:
|
|
196
197
|
json = resp.json()
|
|
198
|
+
if isinstance(json, dict):
|
|
199
|
+
self.cost = json.get("cost")
|
|
200
|
+
self.quotaRemaining = json.get("quotaRemaining")
|
|
201
|
+
else:
|
|
202
|
+
self.cost = None
|
|
203
|
+
self.quotaRemaining = None
|
|
197
204
|
return result_type(json) if result_type is not None else json
|
|
198
205
|
|
|
199
206
|
if resp.status_code == 401 or resp.status_code == 403:
|
|
@@ -517,21 +524,17 @@ class Client:
|
|
|
517
524
|
currency: Ranking method currency (e.g., "USD").
|
|
518
525
|
|
|
519
526
|
Returns:
|
|
520
|
-
|
|
527
|
+
An object containing the new ranking system's details.
|
|
521
528
|
|
|
522
529
|
Examples:
|
|
523
530
|
>>> client.rank_create(
|
|
524
531
|
... 'New Ranking System',
|
|
525
532
|
... '<RankingSystem RankType="Higher">...</RankingSystem>',
|
|
526
|
-
... rankingMethod
|
|
533
|
+
... rankingMethod=<RankingMethod.PERCENTILE_NA_NEGATIVE: 2>,
|
|
527
534
|
... type='Stock',
|
|
528
535
|
... currency='USD'
|
|
529
536
|
... )
|
|
530
|
-
|
|
531
|
-
'id': 98765,
|
|
532
|
-
'cost': 1,
|
|
533
|
-
'quotaRemaining': 45678
|
|
534
|
-
}
|
|
537
|
+
IdResult(id=98765)
|
|
535
538
|
"""
|
|
536
539
|
|
|
537
540
|
return self._req_with_auth_fallback(
|
|
@@ -551,21 +554,21 @@ class Client:
|
|
|
551
554
|
id: The unique identifier of the ranking system.
|
|
552
555
|
|
|
553
556
|
Returns:
|
|
554
|
-
|
|
557
|
+
An object containing the ranking system's details.
|
|
555
558
|
|
|
556
559
|
Examples:
|
|
557
560
|
>>> client.rank_get(id=12345)
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
561
|
+
RankInfoResult(
|
|
562
|
+
name='My Ranking System',
|
|
563
|
+
id=12345,
|
|
564
|
+
xml='<RankingSystem,...</RankingSystem>',
|
|
565
|
+
currency='USD',
|
|
566
|
+
description='Ranking system description',
|
|
567
|
+
rankingMethod=<RankingMethod.PERCENTILE_NA_NEGATIVE: 2>,
|
|
568
|
+
type='Stock',
|
|
569
|
+
groupUid=100,
|
|
570
|
+
resolveGroupUid=200
|
|
571
|
+
)
|
|
569
572
|
"""
|
|
570
573
|
...
|
|
571
574
|
|
|
@@ -580,21 +583,21 @@ class Client:
|
|
|
580
583
|
name: The name of the ranking system.
|
|
581
584
|
|
|
582
585
|
Returns:
|
|
583
|
-
|
|
586
|
+
An object containing the ranking system's details.
|
|
584
587
|
|
|
585
588
|
Examples:
|
|
586
589
|
>>> client.rank_get(name='My Ranking System')
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
590
|
+
RankInfoResult(
|
|
591
|
+
name='My Ranking System',
|
|
592
|
+
id=12345,
|
|
593
|
+
xml='<RankingSystem,...</RankingSystem>',
|
|
594
|
+
currency='USD',
|
|
595
|
+
description='Ranking system description',
|
|
596
|
+
rankingMethod=<RankingMethod.PERCENTILE_NA_NEGATIVE: 2>,
|
|
597
|
+
type='Stock',
|
|
598
|
+
groupUid=100,
|
|
599
|
+
resolveGroupUid=200
|
|
600
|
+
)
|
|
598
601
|
"""
|
|
599
602
|
...
|
|
600
603
|
|
|
@@ -612,7 +615,7 @@ class Client:
|
|
|
612
615
|
|
|
613
616
|
return self._req_with_auth_fallback(method="GET", url=self._endpoint + STRATEGY_DETAILS_PATH.substitute(id=strategy_id))
|
|
614
617
|
|
|
615
|
-
def strategy_copy(self, id: int, name: str, type: Literal["PTF", "SIM"]) -> IdResult:
|
|
618
|
+
def strategy_copy(self, id: int, name: str, type: Literal["PTF", "SIM"] | None = None) -> IdResult:
|
|
616
619
|
"""
|
|
617
620
|
Copy an existing strategy to a new strategy.
|
|
618
621
|
|
|
@@ -624,15 +627,11 @@ class Client:
|
|
|
624
627
|
type: Type of strategy to create. Use "PTF" for a live strategy or "SIM" for simulated strategy.
|
|
625
628
|
|
|
626
629
|
Returns:
|
|
627
|
-
|
|
630
|
+
An object containing the new strategy's id.
|
|
628
631
|
|
|
629
632
|
Examples:
|
|
630
633
|
>>> client.strategy_copy(123, 'Sim copy', 'SIM')
|
|
631
|
-
|
|
632
|
-
'id': 12345,
|
|
633
|
-
'cost': 1,
|
|
634
|
-
'quotaRemaining': 45678
|
|
635
|
-
}
|
|
634
|
+
IdResult(id=12345)
|
|
636
635
|
"""
|
|
637
636
|
return self._req_with_auth_fallback(
|
|
638
637
|
method="POST",
|
|
@@ -641,7 +640,7 @@ class Client:
|
|
|
641
640
|
result_type=IdResult,
|
|
642
641
|
)
|
|
643
642
|
|
|
644
|
-
def book_copy(self, id: int, name: str, type: Literal["BOOK", "BOOKSIM"]) -> IdResult:
|
|
643
|
+
def book_copy(self, id: int, name: str, type: Literal["BOOK", "BOOKSIM"] | None = None) -> IdResult:
|
|
645
644
|
"""
|
|
646
645
|
Copy an existing book to a new book.
|
|
647
646
|
|
|
@@ -653,15 +652,11 @@ class Client:
|
|
|
653
652
|
type: Type of book to create. Use "BOOK" for a live book or "BOOKSIM" for simulated book.
|
|
654
653
|
|
|
655
654
|
Returns:
|
|
656
|
-
|
|
655
|
+
An object containing the new book's id.
|
|
657
656
|
|
|
658
657
|
Examples:
|
|
659
658
|
>>> client.book_copy(123, 'Sim book copy', 'BOOKSIM')
|
|
660
|
-
|
|
661
|
-
'id': 12345,
|
|
662
|
-
'cost': 1,
|
|
663
|
-
'quotaRemaining': 45678
|
|
664
|
-
}
|
|
659
|
+
IdResult(id=12345)
|
|
665
660
|
"""
|
|
666
661
|
return self._req_with_auth_fallback(
|
|
667
662
|
method="POST", url=self._endpoint + BOOK_COPY_PATH.substitute(id=id), json={"name": name, "type": type}, result_type=IdResult
|
|
@@ -1048,15 +1043,11 @@ class Client:
|
|
|
1048
1043
|
id: Stock factor ID.
|
|
1049
1044
|
|
|
1050
1045
|
Returns:
|
|
1051
|
-
|
|
1046
|
+
An object containing the basic stock factor info.
|
|
1052
1047
|
|
|
1053
1048
|
Examples:
|
|
1054
1049
|
>>> client.stock_factor_info(id=123)
|
|
1055
|
-
|
|
1056
|
-
'factorId': 123,
|
|
1057
|
-
'name': 'Stock factor name',
|
|
1058
|
-
'description': 'Stock factor description'
|
|
1059
|
-
}
|
|
1050
|
+
StockFactorInfoResult(factorId=123, name='Stock factor name')
|
|
1060
1051
|
"""
|
|
1061
1052
|
...
|
|
1062
1053
|
|
|
@@ -1069,15 +1060,11 @@ class Client:
|
|
|
1069
1060
|
name: Stock factor name.
|
|
1070
1061
|
|
|
1071
1062
|
Returns:
|
|
1072
|
-
|
|
1063
|
+
An object containing the basic stock factor info.
|
|
1073
1064
|
|
|
1074
1065
|
Examples:
|
|
1075
1066
|
>>> client.stock_factor_info(name='Stock factor name')
|
|
1076
|
-
|
|
1077
|
-
'factorId': 123,
|
|
1078
|
-
'name': 'Stock factor name',
|
|
1079
|
-
'description': 'Stock factor description'
|
|
1080
|
-
}
|
|
1067
|
+
StockFactorInfoResult(factorId=123, name='Stock factor name')
|
|
1081
1068
|
"""
|
|
1082
1069
|
...
|
|
1083
1070
|
|
|
@@ -1094,15 +1081,11 @@ class Client:
|
|
|
1094
1081
|
factor_id: Stock factor ID.
|
|
1095
1082
|
|
|
1096
1083
|
Returns:
|
|
1097
|
-
|
|
1084
|
+
An object containing the basic stock factor info.
|
|
1098
1085
|
|
|
1099
1086
|
Examples:
|
|
1100
1087
|
>>> client.stock_factor_info(factor_id=123)
|
|
1101
|
-
|
|
1102
|
-
'factorId': 123,
|
|
1103
|
-
'name': 'Stock factor name',
|
|
1104
|
-
'description': 'Stock factor description'
|
|
1105
|
-
}
|
|
1088
|
+
StockFactorInfoResult(factorId=123, name='Stock factor name')
|
|
1106
1089
|
"""
|
|
1107
1090
|
...
|
|
1108
1091
|
|
|
@@ -1126,15 +1109,11 @@ class Client:
|
|
|
1126
1109
|
id: Data series ID.
|
|
1127
1110
|
|
|
1128
1111
|
Returns:
|
|
1129
|
-
|
|
1112
|
+
An object containing the basic data series info.
|
|
1130
1113
|
|
|
1131
1114
|
Examples:
|
|
1132
1115
|
>>> client.data_series_info(id=123)
|
|
1133
|
-
|
|
1134
|
-
'dataSeriesId': 123,
|
|
1135
|
-
'name': 'Data series name',
|
|
1136
|
-
'description': 'Data series description'
|
|
1137
|
-
}
|
|
1116
|
+
DataSeriesInfoResult(dataSeriesId=123, name='Data series name')
|
|
1138
1117
|
"""
|
|
1139
1118
|
...
|
|
1140
1119
|
|
|
@@ -1147,15 +1126,11 @@ class Client:
|
|
|
1147
1126
|
name: Data series name.
|
|
1148
1127
|
|
|
1149
1128
|
Returns:
|
|
1150
|
-
|
|
1129
|
+
An object containing the basic data series info.
|
|
1151
1130
|
|
|
1152
1131
|
Examples:
|
|
1153
1132
|
>>> client.data_series_info(name='Data series name')
|
|
1154
|
-
|
|
1155
|
-
'dataSeriesId': 123,
|
|
1156
|
-
'name': 'Data series name',
|
|
1157
|
-
'description': 'Data series description'
|
|
1158
|
-
}
|
|
1133
|
+
DataSeriesInfoResult(dataSeriesId=123, name='Data series name')
|
|
1159
1134
|
"""
|
|
1160
1135
|
...
|
|
1161
1136
|
|
|
@@ -1176,15 +1151,11 @@ class Client:
|
|
|
1176
1151
|
id: Strategy ID.
|
|
1177
1152
|
|
|
1178
1153
|
Returns:
|
|
1179
|
-
|
|
1154
|
+
An object containing the basic strategy info.
|
|
1180
1155
|
|
|
1181
1156
|
Examples:
|
|
1182
1157
|
>>> client.strategy_info(id=123)
|
|
1183
|
-
|
|
1184
|
-
'strategyId': 123,
|
|
1185
|
-
'name': 'Strategy name',
|
|
1186
|
-
'description': 'Strategy description'
|
|
1187
|
-
}
|
|
1158
|
+
StrategyInfoResult(strategyId=123, name='Strategy name')
|
|
1188
1159
|
"""
|
|
1189
1160
|
...
|
|
1190
1161
|
|
|
@@ -1197,15 +1168,11 @@ class Client:
|
|
|
1197
1168
|
name: Strategy name.
|
|
1198
1169
|
|
|
1199
1170
|
Returns:
|
|
1200
|
-
|
|
1171
|
+
An object containing the basic strategy info.
|
|
1201
1172
|
|
|
1202
1173
|
Examples:
|
|
1203
1174
|
>>> client.strategy_info(name='Strategy name')
|
|
1204
|
-
|
|
1205
|
-
'strategyId': 123,
|
|
1206
|
-
'name': 'Strategy name',
|
|
1207
|
-
'description': 'Strategy description'
|
|
1208
|
-
}
|
|
1175
|
+
StrategyInfoResult(strategyId=123, name='Strategy name')
|
|
1209
1176
|
"""
|
|
1210
1177
|
...
|
|
1211
1178
|
|
|
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
|