unique_six 0.1.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.
- unique_six/__init__.py +17 -0
- unique_six/client.py +137 -0
- unique_six/exception.py +29 -0
- unique_six/get_creds.sh +110 -0
- unique_six/http_adapter.py +47 -0
- unique_six/schema/__init__.py +61 -0
- unique_six/schema/common/base/__init__.py +7 -0
- unique_six/schema/common/base/model.py +10 -0
- unique_six/schema/common/base/request.py +17 -0
- unique_six/schema/common/base/response.py +94 -0
- unique_six/schema/common/entity.py +28 -0
- unique_six/schema/common/instrument.py +130 -0
- unique_six/schema/common/language.py +8 -0
- unique_six/schema/common/listing.py +33 -0
- unique_six/schema/common/lookup.py +8 -0
- unique_six/schema/common/market.py +25 -0
- unique_six/schema/common/price.py +7 -0
- unique_six/schema/common/security.py +16 -0
- unique_six/schema/end_of_day_history/__init__.py +15 -0
- unique_six/schema/end_of_day_history/request.py +20 -0
- unique_six/schema/end_of_day_history/response.py +213 -0
- unique_six/schema/entity_base/__init__.py +11 -0
- unique_six/schema/entity_base/listing/request.py +14 -0
- unique_six/schema/entity_base/listing/response.py +91 -0
- unique_six/schema/free_text_search/__init__.py +27 -0
- unique_six/schema/free_text_search/entities/__init__.py +5 -0
- unique_six/schema/free_text_search/entities/request.py +7 -0
- unique_six/schema/free_text_search/entities/response.py +94 -0
- unique_six/schema/free_text_search/instruments/__init__.py +5 -0
- unique_six/schema/free_text_search/instruments/request.py +10 -0
- unique_six/schema/free_text_search/instruments/response.py +279 -0
- unique_six/schema/free_text_search/markets/__init__.py +5 -0
- unique_six/schema/free_text_search/markets/request.py +10 -0
- unique_six/schema/free_text_search/markets/response.py +101 -0
- unique_six/schema/intraday_history/__init__.py +11 -0
- unique_six/schema/intraday_history/summary/request.py +27 -0
- unique_six/schema/intraday_history/summary/response.py +94 -0
- unique_six/schema/intraday_snapshot/__init__.py +15 -0
- unique_six/schema/intraday_snapshot/quality_of_service.py +8 -0
- unique_six/schema/intraday_snapshot/request.py +17 -0
- unique_six/schema/intraday_snapshot/response.py +181 -0
- unique_six-0.1.0.dist-info/LICENSE +1 -0
- unique_six-0.1.0.dist-info/METADATA +74 -0
- unique_six-0.1.0.dist-info/RECORD +45 -0
- unique_six-0.1.0.dist-info/WHEEL +4 -0
unique_six/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from unique_six.client import (
|
|
2
|
+
SixApiClient,
|
|
3
|
+
get_six_api_client,
|
|
4
|
+
)
|
|
5
|
+
from unique_six.exception import (
|
|
6
|
+
NoCredentialsException,
|
|
7
|
+
SixApiException,
|
|
8
|
+
raise_errors_from_api_response,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"SixApiClient",
|
|
13
|
+
"get_six_api_client",
|
|
14
|
+
"SixApiException",
|
|
15
|
+
"raise_errors_from_api_response",
|
|
16
|
+
"NoCredentialsException",
|
|
17
|
+
]
|
unique_six/client.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import urllib.parse
|
|
3
|
+
import urllib.request
|
|
4
|
+
from typing import Any, Callable, ParamSpec, TypeVar
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from unique_six.http_adapter import InMemoryCertAdapter
|
|
9
|
+
from unique_six.schema import (
|
|
10
|
+
BaseRequestParams,
|
|
11
|
+
BaseResponsePayload,
|
|
12
|
+
)
|
|
13
|
+
from unique_six.schema.end_of_day_history import (
|
|
14
|
+
EndOfDayHistoryRequestParams,
|
|
15
|
+
EndOfDayHistoryResponsePayload,
|
|
16
|
+
)
|
|
17
|
+
from unique_six.schema.entity_base import (
|
|
18
|
+
EntityBaseByListingRequestParams,
|
|
19
|
+
EntityBaseByListingResponsePayload,
|
|
20
|
+
)
|
|
21
|
+
from unique_six.schema.free_text_search import (
|
|
22
|
+
FreeTextEntitiesSearchResponsePayload,
|
|
23
|
+
FreeTextInstrumentsSearchResponsePayload,
|
|
24
|
+
FreeTextMarketsSearchResponsePayload,
|
|
25
|
+
FreeTextSearchEntitiesRequestParams,
|
|
26
|
+
FreeTextSearchInstrumentsRequestParams,
|
|
27
|
+
FreeTextSearchMarketsRequestParams,
|
|
28
|
+
)
|
|
29
|
+
from unique_six.schema.intraday_history import (
|
|
30
|
+
IntradayHistorySummaryRequestParams,
|
|
31
|
+
IntradayHistorySummaryResponsePayload,
|
|
32
|
+
)
|
|
33
|
+
from unique_six.schema.intraday_snapshot import (
|
|
34
|
+
IntradaySnapshotRequestParams,
|
|
35
|
+
IntradaySnapshotResponsePayload,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
API_URL = "https://api.six-group.com/web/"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def split_cert_chain(cert: str) -> list[str]:
|
|
42
|
+
return re.findall(".*?-----END CERTIFICATE-----", cert, re.DOTALL)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class SixApiClient:
|
|
46
|
+
def __init__(self, cert: str, key: str) -> None:
|
|
47
|
+
self._session = requests.Session()
|
|
48
|
+
self._session.headers = {"accept": "application/json"}
|
|
49
|
+
self._url = API_URL
|
|
50
|
+
|
|
51
|
+
certs = [c.encode("utf-8") for c in split_cert_chain(cert)]
|
|
52
|
+
cert_adapter = InMemoryCertAdapter(
|
|
53
|
+
certs[0],
|
|
54
|
+
key.encode("utf-8"),
|
|
55
|
+
certs[1:],
|
|
56
|
+
)
|
|
57
|
+
self._session.mount(self._url, cert_adapter)
|
|
58
|
+
|
|
59
|
+
# Endpoints
|
|
60
|
+
self.end_of_day_history = endpoint(
|
|
61
|
+
self,
|
|
62
|
+
"v1/listings/marketData/endOfDayHistory",
|
|
63
|
+
EndOfDayHistoryRequestParams,
|
|
64
|
+
EndOfDayHistoryResponsePayload,
|
|
65
|
+
)
|
|
66
|
+
self.free_text_search_instruments = endpoint(
|
|
67
|
+
self,
|
|
68
|
+
"v1/search/freeTextSearch/instruments",
|
|
69
|
+
FreeTextSearchInstrumentsRequestParams,
|
|
70
|
+
FreeTextInstrumentsSearchResponsePayload,
|
|
71
|
+
)
|
|
72
|
+
self.free_text_search_entities = endpoint(
|
|
73
|
+
self,
|
|
74
|
+
"v1/search/freeTextSearch/entities",
|
|
75
|
+
FreeTextSearchEntitiesRequestParams,
|
|
76
|
+
FreeTextEntitiesSearchResponsePayload,
|
|
77
|
+
)
|
|
78
|
+
self.free_text_search_markets = endpoint(
|
|
79
|
+
self,
|
|
80
|
+
"v1/search/freeTextSearch/markets",
|
|
81
|
+
FreeTextSearchMarketsRequestParams,
|
|
82
|
+
FreeTextMarketsSearchResponsePayload,
|
|
83
|
+
)
|
|
84
|
+
self.intraday_history_summary = endpoint(
|
|
85
|
+
self,
|
|
86
|
+
"v1/listings/marketData/intradayHistory/summary",
|
|
87
|
+
IntradayHistorySummaryRequestParams,
|
|
88
|
+
IntradayHistorySummaryResponsePayload,
|
|
89
|
+
)
|
|
90
|
+
self.intraday_snapshot = endpoint(
|
|
91
|
+
self,
|
|
92
|
+
"v1/listings/marketData/intradaySnapshot",
|
|
93
|
+
IntradaySnapshotRequestParams,
|
|
94
|
+
IntradaySnapshotResponsePayload,
|
|
95
|
+
)
|
|
96
|
+
self.entity_base_by_listing = endpoint(
|
|
97
|
+
self,
|
|
98
|
+
"v1/listings/referenceData/entityBase",
|
|
99
|
+
EntityBaseByListingRequestParams,
|
|
100
|
+
EntityBaseByListingResponsePayload,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
def request(self, end_point: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
104
|
+
complete_url = f"{self._url}{end_point}?{urllib.parse.urlencode(params)}"
|
|
105
|
+
response = self._session.get(complete_url)
|
|
106
|
+
response.raise_for_status()
|
|
107
|
+
return response.json()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
ResponseType = TypeVar("ResponseType", bound=BaseResponsePayload)
|
|
111
|
+
RequestType = TypeVar("RequestType", bound=BaseRequestParams)
|
|
112
|
+
RequestConstructorSpec = ParamSpec("RequestConstructorSpec")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def endpoint(
|
|
116
|
+
client: SixApiClient,
|
|
117
|
+
url: str,
|
|
118
|
+
params: Callable[RequestConstructorSpec, RequestType],
|
|
119
|
+
response_type: type[ResponseType],
|
|
120
|
+
) -> Callable[RequestConstructorSpec, ResponseType]:
|
|
121
|
+
def endpoint_f(
|
|
122
|
+
*args: RequestConstructorSpec.args,
|
|
123
|
+
**kwargs: RequestConstructorSpec.kwargs,
|
|
124
|
+
) -> ResponseType:
|
|
125
|
+
return response_type.model_validate(
|
|
126
|
+
client.request(
|
|
127
|
+
url,
|
|
128
|
+
params(*args, **kwargs).model_dump(
|
|
129
|
+
exclude_unset=True,
|
|
130
|
+
by_alias=True,
|
|
131
|
+
exclude_defaults=True,
|
|
132
|
+
mode="json",
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
return endpoint_f
|
unique_six/exception.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from unique_six.schema.common.base.response import (
|
|
2
|
+
BaseResponsePayload,
|
|
3
|
+
ErrorDetail,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def error_to_str(error: ErrorDetail) -> str:
|
|
8
|
+
error_str = f"Error {error.code}: {error.category}"
|
|
9
|
+
if error.message:
|
|
10
|
+
error_str += f": {error.message}"
|
|
11
|
+
return error_str
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SixApiException(Exception):
|
|
15
|
+
def __init__(self, errors: list[ErrorDetail]) -> None:
|
|
16
|
+
self.errors = errors
|
|
17
|
+
|
|
18
|
+
def __str__(self) -> str:
|
|
19
|
+
if len(self.errors) == 1:
|
|
20
|
+
return error_to_str(self.errors[0])
|
|
21
|
+
else:
|
|
22
|
+
return "Errors:\n" + "\n".join(
|
|
23
|
+
[error_to_str(error) for error in self.errors]
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def raise_errors_from_api_response(response: BaseResponsePayload) -> None:
|
|
28
|
+
if response.errors is not None and len(response.errors) > 0:
|
|
29
|
+
raise SixApiException(response.errors)
|
unique_six/get_creds.sh
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
show_usage() {
|
|
6
|
+
cat <<EOF
|
|
7
|
+
Usage: $0 --cert|-c CERT_FILE --key|-k KEY_FILE [--output|-o OUTPUT_FILE]
|
|
8
|
+
|
|
9
|
+
Encode certificate and key files into a base64-encoded string
|
|
10
|
+
|
|
11
|
+
Options:
|
|
12
|
+
-c, --cert CERT_FILE Path to the certificate file
|
|
13
|
+
-k, --key KEY_FILE Path to the private key file
|
|
14
|
+
-o, --output OUTPUT_FILE Output file to write the result (if not specified, prints to stdout)
|
|
15
|
+
-h, --help Show this help message
|
|
16
|
+
|
|
17
|
+
Examples:
|
|
18
|
+
$0 --cert cert.pem --key key.pem
|
|
19
|
+
$0 -c /path/to/cert.crt -k /path/to/private.key
|
|
20
|
+
$0 -c cert.pem -k key.pem -o encoded_creds.txt
|
|
21
|
+
EOF
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get_creds() {
|
|
25
|
+
local cert_path="$1"
|
|
26
|
+
local key_path="$2"
|
|
27
|
+
|
|
28
|
+
if [[ ! -f "$cert_path" ]]; then
|
|
29
|
+
echo "Error: Certificate file not found: $cert_path" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
if [[ ! -f "$key_path" ]]; then
|
|
34
|
+
echo "Error: Key file not found: $key_path" >&2
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if ! cert_content=$(cat "$cert_path" 2>/dev/null); then
|
|
39
|
+
echo "Error reading certificate file: $cert_path" >&2
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
if ! key_content=$(cat "$key_path" 2>/dev/null); then
|
|
44
|
+
echo "Error reading key file: $key_path" >&2
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
cert_escaped=$(printf '%s' "$cert_content" | tr -d '\n')
|
|
49
|
+
key_escaped=$(printf '%s' "$key_content" | tr -d '\n')
|
|
50
|
+
|
|
51
|
+
content="[\"$cert_escaped\",\"$key_escaped\"]"
|
|
52
|
+
echo -n "$content" | base64
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
cert_path=""
|
|
56
|
+
key_path=""
|
|
57
|
+
output_file=""
|
|
58
|
+
|
|
59
|
+
while [[ $# -gt 0 ]]; do
|
|
60
|
+
case $1 in
|
|
61
|
+
-c | --cert)
|
|
62
|
+
cert_path="$2"
|
|
63
|
+
shift 2
|
|
64
|
+
;;
|
|
65
|
+
-k | --key)
|
|
66
|
+
key_path="$2"
|
|
67
|
+
shift 2
|
|
68
|
+
;;
|
|
69
|
+
-o | --output)
|
|
70
|
+
output_file="$2"
|
|
71
|
+
shift 2
|
|
72
|
+
;;
|
|
73
|
+
-h | --help)
|
|
74
|
+
show_usage
|
|
75
|
+
exit 0
|
|
76
|
+
;;
|
|
77
|
+
*)
|
|
78
|
+
echo "Error: Unknown option $1" >&2
|
|
79
|
+
show_usage
|
|
80
|
+
exit 1
|
|
81
|
+
;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
if [[ -z "$cert_path" ]]; then
|
|
86
|
+
echo "Error: Certificate file path is required" >&2
|
|
87
|
+
show_usage
|
|
88
|
+
exit 1
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
if [[ -z "$key_path" ]]; then
|
|
92
|
+
echo "Error: Key file path is required" >&2
|
|
93
|
+
show_usage
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
if ! encoded_creds=$(get_creds "$cert_path" "$key_path"); then
|
|
98
|
+
echo "Error processing files" >&2
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
if [[ -n "$output_file" ]]; then
|
|
103
|
+
if ! echo "$encoded_creds" >"$output_file"; then
|
|
104
|
+
echo "Error writing to output file: $output_file" >&2
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
echo "Encoded credentials written to: $output_file"
|
|
108
|
+
else
|
|
109
|
+
echo "$encoded_creds"
|
|
110
|
+
fi
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import Iterable
|
|
2
|
+
|
|
3
|
+
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
|
4
|
+
from cryptography.x509 import load_pem_x509_certificate
|
|
5
|
+
from requests.adapters import HTTPAdapter
|
|
6
|
+
from urllib3.contrib.pyopenssl import (
|
|
7
|
+
PyOpenSSLContext,
|
|
8
|
+
)
|
|
9
|
+
from urllib3.util.ssl_ import PROTOCOL_TLS_CLIENT
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class InMemoryCertAdapter(HTTPAdapter):
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
cert: bytes,
|
|
16
|
+
key: bytes,
|
|
17
|
+
chain_certs: Iterable[bytes] | None = None,
|
|
18
|
+
*args,
|
|
19
|
+
**kwargs,
|
|
20
|
+
) -> None:
|
|
21
|
+
self._chain_certs = tuple(chain_certs) if chain_certs else None
|
|
22
|
+
self._cert = cert
|
|
23
|
+
self._key = key
|
|
24
|
+
super().__init__(*args, **kwargs)
|
|
25
|
+
|
|
26
|
+
def init_poolmanager(self, *args, **kwargs):
|
|
27
|
+
context = self._create_ssl_context()
|
|
28
|
+
kwargs["ssl_context"] = context
|
|
29
|
+
return super().init_poolmanager(*args, **kwargs)
|
|
30
|
+
|
|
31
|
+
def _create_ssl_context(self) -> PyOpenSSLContext:
|
|
32
|
+
context = PyOpenSSLContext(PROTOCOL_TLS_CLIENT)
|
|
33
|
+
context.set_default_verify_paths()
|
|
34
|
+
|
|
35
|
+
context._ctx.use_certificate(load_pem_x509_certificate(self._cert))
|
|
36
|
+
if self._chain_certs is not None:
|
|
37
|
+
for c in self._chain_certs:
|
|
38
|
+
context._ctx.add_extra_chain_cert(load_pem_x509_certificate(c))
|
|
39
|
+
|
|
40
|
+
context._ctx.use_privatekey(
|
|
41
|
+
load_pem_private_key(self._key, password=None) # type: ignore
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Throw an exception if the private key is not valid
|
|
45
|
+
context._ctx.check_privatekey()
|
|
46
|
+
|
|
47
|
+
return context
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from unique_six.schema.common.base import (
|
|
2
|
+
BaseAPIModel,
|
|
3
|
+
BaseRequestParams,
|
|
4
|
+
BaseResponsePayload,
|
|
5
|
+
)
|
|
6
|
+
from unique_six.schema.common.entity import (
|
|
7
|
+
EntityStatus,
|
|
8
|
+
EntityType,
|
|
9
|
+
)
|
|
10
|
+
from unique_six.schema.common.instrument import (
|
|
11
|
+
ContractType,
|
|
12
|
+
ContractUnitType,
|
|
13
|
+
CurrentCouponType,
|
|
14
|
+
ExerciseType,
|
|
15
|
+
InstrumentStatus,
|
|
16
|
+
InstrumentType,
|
|
17
|
+
InstrumentUnitType,
|
|
18
|
+
MaturityType,
|
|
19
|
+
OptionType,
|
|
20
|
+
)
|
|
21
|
+
from unique_six.schema.common.language import Language
|
|
22
|
+
from unique_six.schema.common.listing import (
|
|
23
|
+
ListingIdentifierScheme,
|
|
24
|
+
ListingStatus,
|
|
25
|
+
)
|
|
26
|
+
from unique_six.schema.common.lookup import LookupStatus
|
|
27
|
+
from unique_six.schema.common.market import (
|
|
28
|
+
MarketStatus,
|
|
29
|
+
MarketType,
|
|
30
|
+
MicType,
|
|
31
|
+
)
|
|
32
|
+
from unique_six.schema.common.price import PriceAdjustment
|
|
33
|
+
from unique_six.schema.common.security import (
|
|
34
|
+
SecurityType,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"BaseAPIModel",
|
|
39
|
+
"BaseRequestParams",
|
|
40
|
+
"BaseResponsePayload",
|
|
41
|
+
"ListingIdentifierScheme",
|
|
42
|
+
"InstrumentType",
|
|
43
|
+
"InstrumentStatus",
|
|
44
|
+
"InstrumentUnitType",
|
|
45
|
+
"SecurityType",
|
|
46
|
+
"Language",
|
|
47
|
+
"ContractType",
|
|
48
|
+
"CurrentCouponType",
|
|
49
|
+
"ContractUnitType",
|
|
50
|
+
"OptionType",
|
|
51
|
+
"ExerciseType",
|
|
52
|
+
"MaturityType",
|
|
53
|
+
"EntityType",
|
|
54
|
+
"EntityStatus",
|
|
55
|
+
"MarketType",
|
|
56
|
+
"MicType",
|
|
57
|
+
"MarketStatus",
|
|
58
|
+
"PriceAdjustment",
|
|
59
|
+
"ListingStatus",
|
|
60
|
+
"LookupStatus",
|
|
61
|
+
]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from unique_six.schema.common.base.model import BaseAPIModel
|
|
2
|
+
from unique_six.schema.common.base.request import BaseRequestParams
|
|
3
|
+
from unique_six.schema.common.base.response import (
|
|
4
|
+
BaseResponsePayload,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
__all__ = ["BaseAPIModel", "BaseRequestParams", "BaseResponsePayload"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from unique_six.schema.common.base.model import BaseAPIModel
|
|
6
|
+
from unique_six.schema.common.language import Language
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RequestExtension(StrEnum):
|
|
10
|
+
EXPLAIN = "EXPLAIN"
|
|
11
|
+
DATA_STATUS = "DATA_STATUS"
|
|
12
|
+
DATASET_IDS = "DATASET_IDS"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BaseRequestParams(BaseAPIModel):
|
|
16
|
+
preferred_language: Language = Field(default=Language.EN)
|
|
17
|
+
extensions: list[RequestExtension] = Field(default=[])
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from unique_six.schema.common.base.model import BaseAPIModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ErrorCategory(StrEnum):
|
|
10
|
+
ENTITLEMENT_ERROR = "ENTITLEMENT_ERROR"
|
|
11
|
+
VALIDATION_ERROR = "VALIDATION_ERROR"
|
|
12
|
+
DATA_FETCHING_ERROR = "DATA_FETCHING_ERROR"
|
|
13
|
+
HTTP_ERROR = "HTTP_ERROR"
|
|
14
|
+
OTHER = "OTHER"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ErrorCode(StrEnum):
|
|
18
|
+
ACCESS_DENIED = "ACCESS_DENIED"
|
|
19
|
+
TIMEOUT = "TIMEOUT"
|
|
20
|
+
INVALID_PERIOD = "INVALID_PERIOD"
|
|
21
|
+
INVALID_RANGE = "INVALID_RANGE"
|
|
22
|
+
INVALID_CRITERIA = "INVALID_CRITERIA"
|
|
23
|
+
NO_DATA = "NO_DATA"
|
|
24
|
+
PARAMETER_NOT_READABLE = "PARAMETER_NOT_READABLE"
|
|
25
|
+
PARAMETER_REQUIRED = "PARAMETER_REQUIRED"
|
|
26
|
+
DATA_REPORT_ERROR = "DATA_REPORT_ERROR"
|
|
27
|
+
QUOTA_LIMIT_EXCEEDED = "QUOTA_LIMIT_EXCEEDED"
|
|
28
|
+
INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR"
|
|
29
|
+
REQUEST_NOT_ALLOWED = "REQUEST_NOT_ALLOWED"
|
|
30
|
+
TOO_MANY_OPERATIONS = "TOO_MANY_OPERATIONS"
|
|
31
|
+
DUPLICATE_STREAM_ID = "DUPLICATE_STREAM_ID"
|
|
32
|
+
NOT_SUPPORTED = "NOT_SUPPORTED"
|
|
33
|
+
OTHER = "OTHER"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class HintType(StrEnum):
|
|
37
|
+
ALLOWED_RANGE = "ALLOWED_RANGE"
|
|
38
|
+
ALLOWED_VALUES = "ALLOWED_VALUES"
|
|
39
|
+
CONTACT_SIX = "CONTACT_SIX"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Explain(BaseAPIModel):
|
|
43
|
+
query: str
|
|
44
|
+
variables: dict[str, dict[str, Any]]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class DataStatus(BaseAPIModel):
|
|
48
|
+
top_level: str | None = None
|
|
49
|
+
data_status: list[dict[str, Any]] | None = None
|
|
50
|
+
empty: bool | None = None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class DatasetIds(BaseAPIModel):
|
|
54
|
+
top_level: str | None = None
|
|
55
|
+
dataset_ids: list[dict[str, Any]] | None = None
|
|
56
|
+
empty: bool | None = None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class Details(BaseAPIModel):
|
|
60
|
+
correlation_id: str | None = None
|
|
61
|
+
user_id: str | None = None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ExtensionsData(BaseAPIModel):
|
|
65
|
+
explain: Explain | None = None
|
|
66
|
+
data_status: DataStatus | None = None
|
|
67
|
+
dataset_ids: DatasetIds | None = None
|
|
68
|
+
details: Details | None = None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ErrorHint(BaseAPIModel):
|
|
72
|
+
type: HintType
|
|
73
|
+
data: dict[str, Any]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class ErrorDetail(BaseAPIModel):
|
|
77
|
+
category: ErrorCategory = Field(
|
|
78
|
+
description="Error categories", examples=["VALIDATION_ERROR"]
|
|
79
|
+
)
|
|
80
|
+
code: ErrorCode = Field(
|
|
81
|
+
description="code is used to identify the error",
|
|
82
|
+
examples=["CANNOT_CONVERT_PARAMETER"],
|
|
83
|
+
)
|
|
84
|
+
message: str = Field(
|
|
85
|
+
...,
|
|
86
|
+
description="a human readable description of the error",
|
|
87
|
+
examples=["missing header 'X-HEADER'"],
|
|
88
|
+
)
|
|
89
|
+
hint: ErrorHint | None = None
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class BaseResponsePayload(BaseAPIModel):
|
|
93
|
+
errors: list[ErrorDetail] | None = None
|
|
94
|
+
extensions: ExtensionsData | None = None
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EntityType(StrEnum):
|
|
5
|
+
COMPANY = "COMPANY"
|
|
6
|
+
STATE = "STATE"
|
|
7
|
+
PUBLIC_CORPORATION = "PUBLIC_CORPORATION"
|
|
8
|
+
INVESTMENT_FUND = "INVESTMENT_FUND"
|
|
9
|
+
SPECIAL_PURPOSE = "SPECIAL_PURPOSE"
|
|
10
|
+
GOVERNMENT = "GOVERNMENT"
|
|
11
|
+
ASSOCIATION = "ASSOCIATION"
|
|
12
|
+
FOUNDATION = "FOUNDATION"
|
|
13
|
+
BRANCH = "BRANCH"
|
|
14
|
+
OTHER = "OTHER"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class EntityStatus(StrEnum):
|
|
18
|
+
IN_FOUNDATION = "IN_FOUNDATION"
|
|
19
|
+
IN_BANKRUPTCY_PROCEEDINGS = "IN_BANKRUPTCY_PROCEEDINGS"
|
|
20
|
+
UNDER_ADMINISTRATION = "UNDER_ADMINISTRATION"
|
|
21
|
+
INACTIVE = "INACTIVE"
|
|
22
|
+
ACTIVE = "ACTIVE"
|
|
23
|
+
CHAPTER_7 = "CHAPTER_7"
|
|
24
|
+
CHAPTER_11 = "CHAPTER_11"
|
|
25
|
+
IN_LIQUIDATION = "IN_LIQUIDATION"
|
|
26
|
+
IN_DEBT_RESTRUCTURING_LIQUIDATION = "IN_DEBT_RESTRUCTURING_LIQUIDATION"
|
|
27
|
+
IN_CHAPTER_11_LIQUIDATION = "IN_CHAPTER_11_LIQUIDATION"
|
|
28
|
+
OTHER = "OTHER"
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class InstrumentType(StrEnum):
|
|
5
|
+
BOND = "BOND"
|
|
6
|
+
EQUITY = "EQUITY"
|
|
7
|
+
MTN = "MTN"
|
|
8
|
+
INSURANCE_POLICY = "INSURANCE_POLICY"
|
|
9
|
+
STRUCTURED_PRODUCT = "STRUCTURED_PRODUCT"
|
|
10
|
+
TRUST_SHARE = "TRUST_SHARE"
|
|
11
|
+
INTEREST_RATE = "INTEREST_RATE"
|
|
12
|
+
RIGHT = "RIGHT"
|
|
13
|
+
CURRENCY = "CURRENCY"
|
|
14
|
+
TRUST_CERT_FOUNDATION = "TRUST_CERT_FOUNDATION"
|
|
15
|
+
TRUST_CERT_SHARE = "TRUST_CERT_SHARE"
|
|
16
|
+
SAVINGS_BOOK = "SAVINGS_BOOK"
|
|
17
|
+
REPO = "REPO"
|
|
18
|
+
FORWARD_TRANSACTION = "FORWARD_TRANSACTION"
|
|
19
|
+
COMBINED_TRANSACTION = "COMBINED_TRANSACTION"
|
|
20
|
+
FRN = "FRN"
|
|
21
|
+
LEVERAGED_PRODUCT = "LEVERAGED_PRODUCT"
|
|
22
|
+
REPO_BASKET = "REPO_BASKET"
|
|
23
|
+
ETD = "ETD"
|
|
24
|
+
FUTURE = "FUTURE"
|
|
25
|
+
MONEY_MARKET_INSTRUMENT = "MONEY_MARKET_INSTRUMENT"
|
|
26
|
+
COMMODITY = "COMMODITY"
|
|
27
|
+
CONVERTIBLE_BOND = "CONVERTIBLE_BOND"
|
|
28
|
+
INDEX = "INDEX"
|
|
29
|
+
OPTION = "OPTION"
|
|
30
|
+
TECHNICAL_CURRENCY = "TECHNICAL_CURRENCY"
|
|
31
|
+
OTHER = "OTHER"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class InstrumentStatus(StrEnum):
|
|
35
|
+
NOT_YET_ISSUED = "NOT_YET_ISSUED"
|
|
36
|
+
INACTIVE = "INACTIVE"
|
|
37
|
+
IN_LIQUIDATION_DISSOLUTION = "IN_LIQUIDATION_DISSOLUTION"
|
|
38
|
+
ACTIVE = "ACTIVE"
|
|
39
|
+
IN_DEFAULT = "IN_DEFAULT"
|
|
40
|
+
OTHER = "OTHER"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class InstrumentUnitType(StrEnum):
|
|
44
|
+
NOMINAL = "NOMINAL"
|
|
45
|
+
PIECE_UNIT = "PIECE_UNIT"
|
|
46
|
+
OTHER = "OTHER"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class CurrentCouponType(StrEnum):
|
|
50
|
+
FIXED = "FIXED"
|
|
51
|
+
VARIABLE = "VARIABLE"
|
|
52
|
+
OPTIONAL_PAYMENT = "OPTIONAL_PAYMENT"
|
|
53
|
+
OTHER = "OTHER"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class MaturityType(StrEnum):
|
|
57
|
+
FIXED_EXPIRATION_OR_EARLIER = "FIXED_EXPIRATION_OR_EARLIER"
|
|
58
|
+
NO_EXPIRATION_DATE = "NO_EXPIRATION_DATE"
|
|
59
|
+
EXPIRATION_FIXED_IN_ADVANCE = "EXPIRATION_FIXED_IN_ADVANCE"
|
|
60
|
+
OTHER = "OTHER"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ContractType(StrEnum):
|
|
64
|
+
ETD_ON_EQUITY = "ETD_ON_EQUITY"
|
|
65
|
+
ETD_ON_INDEX = "ETD_ON_INDEX"
|
|
66
|
+
ETD_ON_INTEREST = "ETD_ON_INTEREST"
|
|
67
|
+
ETD_ON_CURRENCY = "ETD_ON_CURRENCY"
|
|
68
|
+
ETD_ON_PRECIOUS_METAL = "ETD_ON_PRECIOUS_METAL"
|
|
69
|
+
ETD_ON_FUTURE = "ETD_ON_FUTURE"
|
|
70
|
+
ETD_ON_OPTION = "ETD_ON_OPTION"
|
|
71
|
+
ETD_ON_BASKET = "ETD_ON_BASKET"
|
|
72
|
+
ETD_ON_SWAP = "ETD_ON_SWAP"
|
|
73
|
+
ETD_ON_COMMODITY = "ETD_ON_COMMODITY"
|
|
74
|
+
ETD_ON_BOND = "ETD_ON_BOND"
|
|
75
|
+
ETD_ON_FUND = "ETD_ON_FUND"
|
|
76
|
+
ETD_ON_STRUCTURED_INSTRUMENT = "ETD_ON_STRUCTURED_INSTRUMENT"
|
|
77
|
+
ETD_ON_STRATEGY = "ETD_ON_STRATEGY"
|
|
78
|
+
ETD_ON_DIVIDEND = "ETD_ON_DIVIDEND"
|
|
79
|
+
RELATIVE_PRICE_TRANSACTION_ON_ETD = "RELATIVE_PRICE_TRANSACTION_ON_ETD"
|
|
80
|
+
ETD_ON_EQUITY_TOTAL_RETURN = "ETD_ON_EQUITY_TOTAL_RETURN"
|
|
81
|
+
OTHER = "OTHER"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class OptionType(StrEnum):
|
|
85
|
+
CALL = "CALL"
|
|
86
|
+
PUT = "PUT"
|
|
87
|
+
CONVERSION_RIGHT = "CONVERSION_RIGHT"
|
|
88
|
+
MANDATORY_CONVERSION = "MANDATORY_CONVERSION"
|
|
89
|
+
CONTINGENT_CONVERTIBLES_COCO = "CONTINGENT_CONVERTIBLES_COCO"
|
|
90
|
+
OTHER = "OTHER"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class ExerciseType(StrEnum):
|
|
94
|
+
AMERICAN = "AMERICAN"
|
|
95
|
+
EUROPEAN = "EUROPEAN"
|
|
96
|
+
BERMUDA = "BERMUDA"
|
|
97
|
+
OTHER = "OTHER"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class ContractUnitType(StrEnum):
|
|
101
|
+
NOMINAL = "NOMINAL"
|
|
102
|
+
PIECE_UNIT = "PIECE_UNIT"
|
|
103
|
+
CONTRACT = "CONTRACT"
|
|
104
|
+
PHYSICAL_UNIT = "PHYSICAL_UNIT"
|
|
105
|
+
INDEX_POINT = "INDEX_POINT"
|
|
106
|
+
NOMINAL_CURRENCY_UNIT_PER_INDEX_POINT = "NOMINAL_CURRENCY_UNIT_PER_INDEX_POINT"
|
|
107
|
+
RATIO = "RATIO"
|
|
108
|
+
POUND_LB = "POUND_LB"
|
|
109
|
+
METRIC_TONNE = "METRIC_TONNE"
|
|
110
|
+
GRAM = "GRAM"
|
|
111
|
+
KILOGRAM = "KILOGRAM"
|
|
112
|
+
OUNCE = "OUNCE"
|
|
113
|
+
BUSHEL = "BUSHEL"
|
|
114
|
+
GALLON = "GALLON"
|
|
115
|
+
GIGAWATT_HOURS_GWH = "GIGAWATT_HOURS_GWH"
|
|
116
|
+
CUBIC_METERS_M3 = "CUBIC_METERS_M3"
|
|
117
|
+
SACK = "SACK"
|
|
118
|
+
BARREL = "BARREL"
|
|
119
|
+
TAEL = "TAEL"
|
|
120
|
+
TOLA = "TOLA"
|
|
121
|
+
TROY_OUNCE = "TROY_OUNCE"
|
|
122
|
+
MEGAWATT = "MEGAWATT"
|
|
123
|
+
ARROBA = "ARROBA"
|
|
124
|
+
HUNDREDWEIGHT_CWT = "HUNDREDWEIGHT_CWT"
|
|
125
|
+
MMBTU = "MMBTU"
|
|
126
|
+
BOARD_FOOT = "BOARD_FOOT"
|
|
127
|
+
BAHT = "BAHT"
|
|
128
|
+
KILOWATT_HOURS_KWH = "KILOWATT_HOURS_KWH"
|
|
129
|
+
MEGAWATT_HOURS_MWH = "MEGAWATT_HOURS_MWH"
|
|
130
|
+
OTHER = "OTHER"
|