pmxt 1.3.3__py3-none-any.whl → 1.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.
- pmxt/__init__.py +1 -1
- pmxt/_server/server/bundled.js +55 -0
- pmxt/client.py +83 -1
- pmxt/models.py +57 -6
- {pmxt-1.3.3.dist-info → pmxt-1.4.0.dist-info}/METADATA +3 -1
- {pmxt-1.3.3.dist-info → pmxt-1.4.0.dist-info}/RECORD +18 -13
- pmxt_internal/__init__.py +11 -1
- pmxt_internal/api/default_api.py +573 -0
- pmxt_internal/api_client.py +1 -1
- pmxt_internal/configuration.py +1 -1
- pmxt_internal/models/__init__.py +5 -0
- pmxt_internal/models/execution_price_result.py +91 -0
- pmxt_internal/models/get_execution_price200_response.py +95 -0
- pmxt_internal/models/get_execution_price_detailed200_response.py +99 -0
- pmxt_internal/models/get_execution_price_request.py +102 -0
- pmxt_internal/models/get_execution_price_request_args_inner.py +157 -0
- {pmxt-1.3.3.dist-info → pmxt-1.4.0.dist-info}/WHEEL +0 -0
- {pmxt-1.3.3.dist-info → pmxt-1.4.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
PMXT Sidecar API
|
|
5
|
+
|
|
6
|
+
A unified local sidecar API for prediction markets (Polymarket, Kalshi). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.4.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional, Union
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class ExecutionPriceResult(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
ExecutionPriceResult
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
price: Optional[Union[StrictFloat, StrictInt]] = None
|
|
30
|
+
filled_amount: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="filledAmount")
|
|
31
|
+
fully_filled: Optional[StrictBool] = Field(default=None, alias="fullyFilled")
|
|
32
|
+
__properties: ClassVar[List[str]] = ["price", "filledAmount", "fullyFilled"]
|
|
33
|
+
|
|
34
|
+
model_config = ConfigDict(
|
|
35
|
+
populate_by_name=True,
|
|
36
|
+
validate_assignment=True,
|
|
37
|
+
protected_namespaces=(),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def to_str(self) -> str:
|
|
42
|
+
"""Returns the string representation of the model using alias"""
|
|
43
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> str:
|
|
46
|
+
"""Returns the JSON representation of the model using alias"""
|
|
47
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
48
|
+
return json.dumps(self.to_dict())
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
52
|
+
"""Create an instance of ExecutionPriceResult from a JSON string"""
|
|
53
|
+
return cls.from_dict(json.loads(json_str))
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
"""Return the dictionary representation of the model using alias.
|
|
57
|
+
|
|
58
|
+
This has the following differences from calling pydantic's
|
|
59
|
+
`self.model_dump(by_alias=True)`:
|
|
60
|
+
|
|
61
|
+
* `None` is only added to the output dict for nullable fields that
|
|
62
|
+
were set at model initialization. Other fields with value `None`
|
|
63
|
+
are ignored.
|
|
64
|
+
"""
|
|
65
|
+
excluded_fields: Set[str] = set([
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
_dict = self.model_dump(
|
|
69
|
+
by_alias=True,
|
|
70
|
+
exclude=excluded_fields,
|
|
71
|
+
exclude_none=True,
|
|
72
|
+
)
|
|
73
|
+
return _dict
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
77
|
+
"""Create an instance of ExecutionPriceResult from a dict"""
|
|
78
|
+
if obj is None:
|
|
79
|
+
return None
|
|
80
|
+
|
|
81
|
+
if not isinstance(obj, dict):
|
|
82
|
+
return cls.model_validate(obj)
|
|
83
|
+
|
|
84
|
+
_obj = cls.model_validate({
|
|
85
|
+
"price": obj.get("price"),
|
|
86
|
+
"filledAmount": obj.get("filledAmount"),
|
|
87
|
+
"fullyFilled": obj.get("fullyFilled")
|
|
88
|
+
})
|
|
89
|
+
return _obj
|
|
90
|
+
|
|
91
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
PMXT Sidecar API
|
|
5
|
+
|
|
6
|
+
A unified local sidecar API for prediction markets (Polymarket, Kalshi). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.4.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional, Union
|
|
22
|
+
from pmxt_internal.models.error_detail import ErrorDetail
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class GetExecutionPrice200Response(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
GetExecutionPrice200Response
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
success: Optional[StrictBool] = None
|
|
31
|
+
error: Optional[ErrorDetail] = None
|
|
32
|
+
data: Optional[Union[StrictFloat, StrictInt]] = None
|
|
33
|
+
__properties: ClassVar[List[str]] = ["success", "error", "data"]
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
populate_by_name=True,
|
|
37
|
+
validate_assignment=True,
|
|
38
|
+
protected_namespaces=(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def to_str(self) -> str:
|
|
43
|
+
"""Returns the string representation of the model using alias"""
|
|
44
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
45
|
+
|
|
46
|
+
def to_json(self) -> str:
|
|
47
|
+
"""Returns the JSON representation of the model using alias"""
|
|
48
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
49
|
+
return json.dumps(self.to_dict())
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
53
|
+
"""Create an instance of GetExecutionPrice200Response from a JSON string"""
|
|
54
|
+
return cls.from_dict(json.loads(json_str))
|
|
55
|
+
|
|
56
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
57
|
+
"""Return the dictionary representation of the model using alias.
|
|
58
|
+
|
|
59
|
+
This has the following differences from calling pydantic's
|
|
60
|
+
`self.model_dump(by_alias=True)`:
|
|
61
|
+
|
|
62
|
+
* `None` is only added to the output dict for nullable fields that
|
|
63
|
+
were set at model initialization. Other fields with value `None`
|
|
64
|
+
are ignored.
|
|
65
|
+
"""
|
|
66
|
+
excluded_fields: Set[str] = set([
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
_dict = self.model_dump(
|
|
70
|
+
by_alias=True,
|
|
71
|
+
exclude=excluded_fields,
|
|
72
|
+
exclude_none=True,
|
|
73
|
+
)
|
|
74
|
+
# override the default output from pydantic by calling `to_dict()` of error
|
|
75
|
+
if self.error:
|
|
76
|
+
_dict['error'] = self.error.to_dict()
|
|
77
|
+
return _dict
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
81
|
+
"""Create an instance of GetExecutionPrice200Response from a dict"""
|
|
82
|
+
if obj is None:
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
if not isinstance(obj, dict):
|
|
86
|
+
return cls.model_validate(obj)
|
|
87
|
+
|
|
88
|
+
_obj = cls.model_validate({
|
|
89
|
+
"success": obj.get("success"),
|
|
90
|
+
"error": ErrorDetail.from_dict(obj["error"]) if obj.get("error") is not None else None,
|
|
91
|
+
"data": obj.get("data")
|
|
92
|
+
})
|
|
93
|
+
return _obj
|
|
94
|
+
|
|
95
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
PMXT Sidecar API
|
|
5
|
+
|
|
6
|
+
A unified local sidecar API for prediction markets (Polymarket, Kalshi). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.4.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, StrictBool
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from pmxt_internal.models.error_detail import ErrorDetail
|
|
23
|
+
from pmxt_internal.models.execution_price_result import ExecutionPriceResult
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class GetExecutionPriceDetailed200Response(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
GetExecutionPriceDetailed200Response
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
success: Optional[StrictBool] = None
|
|
32
|
+
error: Optional[ErrorDetail] = None
|
|
33
|
+
data: Optional[ExecutionPriceResult] = None
|
|
34
|
+
__properties: ClassVar[List[str]] = ["success", "error", "data"]
|
|
35
|
+
|
|
36
|
+
model_config = ConfigDict(
|
|
37
|
+
populate_by_name=True,
|
|
38
|
+
validate_assignment=True,
|
|
39
|
+
protected_namespaces=(),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def to_str(self) -> str:
|
|
44
|
+
"""Returns the string representation of the model using alias"""
|
|
45
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
46
|
+
|
|
47
|
+
def to_json(self) -> str:
|
|
48
|
+
"""Returns the JSON representation of the model using alias"""
|
|
49
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
50
|
+
return json.dumps(self.to_dict())
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
54
|
+
"""Create an instance of GetExecutionPriceDetailed200Response from a JSON string"""
|
|
55
|
+
return cls.from_dict(json.loads(json_str))
|
|
56
|
+
|
|
57
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
58
|
+
"""Return the dictionary representation of the model using alias.
|
|
59
|
+
|
|
60
|
+
This has the following differences from calling pydantic's
|
|
61
|
+
`self.model_dump(by_alias=True)`:
|
|
62
|
+
|
|
63
|
+
* `None` is only added to the output dict for nullable fields that
|
|
64
|
+
were set at model initialization. Other fields with value `None`
|
|
65
|
+
are ignored.
|
|
66
|
+
"""
|
|
67
|
+
excluded_fields: Set[str] = set([
|
|
68
|
+
])
|
|
69
|
+
|
|
70
|
+
_dict = self.model_dump(
|
|
71
|
+
by_alias=True,
|
|
72
|
+
exclude=excluded_fields,
|
|
73
|
+
exclude_none=True,
|
|
74
|
+
)
|
|
75
|
+
# override the default output from pydantic by calling `to_dict()` of error
|
|
76
|
+
if self.error:
|
|
77
|
+
_dict['error'] = self.error.to_dict()
|
|
78
|
+
# override the default output from pydantic by calling `to_dict()` of data
|
|
79
|
+
if self.data:
|
|
80
|
+
_dict['data'] = self.data.to_dict()
|
|
81
|
+
return _dict
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
85
|
+
"""Create an instance of GetExecutionPriceDetailed200Response from a dict"""
|
|
86
|
+
if obj is None:
|
|
87
|
+
return None
|
|
88
|
+
|
|
89
|
+
if not isinstance(obj, dict):
|
|
90
|
+
return cls.model_validate(obj)
|
|
91
|
+
|
|
92
|
+
_obj = cls.model_validate({
|
|
93
|
+
"success": obj.get("success"),
|
|
94
|
+
"error": ErrorDetail.from_dict(obj["error"]) if obj.get("error") is not None else None,
|
|
95
|
+
"data": ExecutionPriceResult.from_dict(obj["data"]) if obj.get("data") is not None else None
|
|
96
|
+
})
|
|
97
|
+
return _obj
|
|
98
|
+
|
|
99
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
PMXT Sidecar API
|
|
5
|
+
|
|
6
|
+
A unified local sidecar API for prediction markets (Polymarket, Kalshi). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.4.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from typing_extensions import Annotated
|
|
23
|
+
from pmxt_internal.models.exchange_credentials import ExchangeCredentials
|
|
24
|
+
from pmxt_internal.models.get_execution_price_request_args_inner import GetExecutionPriceRequestArgsInner
|
|
25
|
+
from typing import Optional, Set
|
|
26
|
+
from typing_extensions import Self
|
|
27
|
+
|
|
28
|
+
class GetExecutionPriceRequest(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
GetExecutionPriceRequest
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
args: Annotated[List[GetExecutionPriceRequestArgsInner], Field(min_length=3, max_length=3)] = Field(description="[orderBook, side, amount]")
|
|
33
|
+
credentials: Optional[ExchangeCredentials] = None
|
|
34
|
+
__properties: ClassVar[List[str]] = ["args", "credentials"]
|
|
35
|
+
|
|
36
|
+
model_config = ConfigDict(
|
|
37
|
+
populate_by_name=True,
|
|
38
|
+
validate_assignment=True,
|
|
39
|
+
protected_namespaces=(),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def to_str(self) -> str:
|
|
44
|
+
"""Returns the string representation of the model using alias"""
|
|
45
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
46
|
+
|
|
47
|
+
def to_json(self) -> str:
|
|
48
|
+
"""Returns the JSON representation of the model using alias"""
|
|
49
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
50
|
+
return json.dumps(self.to_dict())
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
54
|
+
"""Create an instance of GetExecutionPriceRequest from a JSON string"""
|
|
55
|
+
return cls.from_dict(json.loads(json_str))
|
|
56
|
+
|
|
57
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
58
|
+
"""Return the dictionary representation of the model using alias.
|
|
59
|
+
|
|
60
|
+
This has the following differences from calling pydantic's
|
|
61
|
+
`self.model_dump(by_alias=True)`:
|
|
62
|
+
|
|
63
|
+
* `None` is only added to the output dict for nullable fields that
|
|
64
|
+
were set at model initialization. Other fields with value `None`
|
|
65
|
+
are ignored.
|
|
66
|
+
"""
|
|
67
|
+
excluded_fields: Set[str] = set([
|
|
68
|
+
])
|
|
69
|
+
|
|
70
|
+
_dict = self.model_dump(
|
|
71
|
+
by_alias=True,
|
|
72
|
+
exclude=excluded_fields,
|
|
73
|
+
exclude_none=True,
|
|
74
|
+
)
|
|
75
|
+
# override the default output from pydantic by calling `to_dict()` of each item in args (list)
|
|
76
|
+
_items = []
|
|
77
|
+
if self.args:
|
|
78
|
+
for _item_args in self.args:
|
|
79
|
+
if _item_args:
|
|
80
|
+
_items.append(_item_args.to_dict())
|
|
81
|
+
_dict['args'] = _items
|
|
82
|
+
# override the default output from pydantic by calling `to_dict()` of credentials
|
|
83
|
+
if self.credentials:
|
|
84
|
+
_dict['credentials'] = self.credentials.to_dict()
|
|
85
|
+
return _dict
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
89
|
+
"""Create an instance of GetExecutionPriceRequest from a dict"""
|
|
90
|
+
if obj is None:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
if not isinstance(obj, dict):
|
|
94
|
+
return cls.model_validate(obj)
|
|
95
|
+
|
|
96
|
+
_obj = cls.model_validate({
|
|
97
|
+
"args": [GetExecutionPriceRequestArgsInner.from_dict(_item) for _item in obj["args"]] if obj.get("args") is not None else None,
|
|
98
|
+
"credentials": ExchangeCredentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None
|
|
99
|
+
})
|
|
100
|
+
return _obj
|
|
101
|
+
|
|
102
|
+
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
PMXT Sidecar API
|
|
5
|
+
|
|
6
|
+
A unified local sidecar API for prediction markets (Polymarket, Kalshi). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.4.4
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, ValidationError, field_validator
|
|
19
|
+
from typing import Any, List, Optional, Union
|
|
20
|
+
from pmxt_internal.models.order_book import OrderBook
|
|
21
|
+
from pydantic import StrictStr, Field
|
|
22
|
+
from typing import Union, List, Set, Optional, Dict
|
|
23
|
+
from typing_extensions import Literal, Self
|
|
24
|
+
|
|
25
|
+
GETEXECUTIONPRICEREQUESTARGSINNER_ONE_OF_SCHEMAS = ["OrderBook", "float", "str"]
|
|
26
|
+
|
|
27
|
+
class GetExecutionPriceRequestArgsInner(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
GetExecutionPriceRequestArgsInner
|
|
30
|
+
"""
|
|
31
|
+
# data type: OrderBook
|
|
32
|
+
oneof_schema_1_validator: Optional[OrderBook] = None
|
|
33
|
+
# data type: str
|
|
34
|
+
oneof_schema_2_validator: Optional[StrictStr] = None
|
|
35
|
+
# data type: float
|
|
36
|
+
oneof_schema_3_validator: Optional[Union[StrictFloat, StrictInt]] = None
|
|
37
|
+
actual_instance: Optional[Union[OrderBook, float, str]] = None
|
|
38
|
+
one_of_schemas: Set[str] = { "OrderBook", "float", "str" }
|
|
39
|
+
|
|
40
|
+
model_config = ConfigDict(
|
|
41
|
+
validate_assignment=True,
|
|
42
|
+
protected_namespaces=(),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
47
|
+
if args:
|
|
48
|
+
if len(args) > 1:
|
|
49
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
50
|
+
if kwargs:
|
|
51
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
52
|
+
super().__init__(actual_instance=args[0])
|
|
53
|
+
else:
|
|
54
|
+
super().__init__(**kwargs)
|
|
55
|
+
|
|
56
|
+
@field_validator('actual_instance')
|
|
57
|
+
def actual_instance_must_validate_oneof(cls, v):
|
|
58
|
+
instance = GetExecutionPriceRequestArgsInner.model_construct()
|
|
59
|
+
error_messages = []
|
|
60
|
+
match = 0
|
|
61
|
+
# validate data type: OrderBook
|
|
62
|
+
if not isinstance(v, OrderBook):
|
|
63
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `OrderBook`")
|
|
64
|
+
else:
|
|
65
|
+
match += 1
|
|
66
|
+
# validate data type: str
|
|
67
|
+
try:
|
|
68
|
+
instance.oneof_schema_2_validator = v
|
|
69
|
+
match += 1
|
|
70
|
+
except (ValidationError, ValueError) as e:
|
|
71
|
+
error_messages.append(str(e))
|
|
72
|
+
# validate data type: float
|
|
73
|
+
try:
|
|
74
|
+
instance.oneof_schema_3_validator = v
|
|
75
|
+
match += 1
|
|
76
|
+
except (ValidationError, ValueError) as e:
|
|
77
|
+
error_messages.append(str(e))
|
|
78
|
+
if match > 1:
|
|
79
|
+
# more than 1 match
|
|
80
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in GetExecutionPriceRequestArgsInner with oneOf schemas: OrderBook, float, str. Details: " + ", ".join(error_messages))
|
|
81
|
+
elif match == 0:
|
|
82
|
+
# no match
|
|
83
|
+
raise ValueError("No match found when setting `actual_instance` in GetExecutionPriceRequestArgsInner with oneOf schemas: OrderBook, float, str. Details: " + ", ".join(error_messages))
|
|
84
|
+
else:
|
|
85
|
+
return v
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
|
89
|
+
return cls.from_json(json.dumps(obj))
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def from_json(cls, json_str: str) -> Self:
|
|
93
|
+
"""Returns the object represented by the json string"""
|
|
94
|
+
instance = cls.model_construct()
|
|
95
|
+
error_messages = []
|
|
96
|
+
match = 0
|
|
97
|
+
|
|
98
|
+
# deserialize data into OrderBook
|
|
99
|
+
try:
|
|
100
|
+
instance.actual_instance = OrderBook.from_json(json_str)
|
|
101
|
+
match += 1
|
|
102
|
+
except (ValidationError, ValueError) as e:
|
|
103
|
+
error_messages.append(str(e))
|
|
104
|
+
# deserialize data into str
|
|
105
|
+
try:
|
|
106
|
+
# validation
|
|
107
|
+
instance.oneof_schema_2_validator = json.loads(json_str)
|
|
108
|
+
# assign value to actual_instance
|
|
109
|
+
instance.actual_instance = instance.oneof_schema_2_validator
|
|
110
|
+
match += 1
|
|
111
|
+
except (ValidationError, ValueError) as e:
|
|
112
|
+
error_messages.append(str(e))
|
|
113
|
+
# deserialize data into float
|
|
114
|
+
try:
|
|
115
|
+
# validation
|
|
116
|
+
instance.oneof_schema_3_validator = json.loads(json_str)
|
|
117
|
+
# assign value to actual_instance
|
|
118
|
+
instance.actual_instance = instance.oneof_schema_3_validator
|
|
119
|
+
match += 1
|
|
120
|
+
except (ValidationError, ValueError) as e:
|
|
121
|
+
error_messages.append(str(e))
|
|
122
|
+
|
|
123
|
+
if match > 1:
|
|
124
|
+
# more than 1 match
|
|
125
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into GetExecutionPriceRequestArgsInner with oneOf schemas: OrderBook, float, str. Details: " + ", ".join(error_messages))
|
|
126
|
+
elif match == 0:
|
|
127
|
+
# no match
|
|
128
|
+
raise ValueError("No match found when deserializing the JSON string into GetExecutionPriceRequestArgsInner with oneOf schemas: OrderBook, float, str. Details: " + ", ".join(error_messages))
|
|
129
|
+
else:
|
|
130
|
+
return instance
|
|
131
|
+
|
|
132
|
+
def to_json(self) -> str:
|
|
133
|
+
"""Returns the JSON representation of the actual instance"""
|
|
134
|
+
if self.actual_instance is None:
|
|
135
|
+
return "null"
|
|
136
|
+
|
|
137
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
138
|
+
return self.actual_instance.to_json()
|
|
139
|
+
else:
|
|
140
|
+
return json.dumps(self.actual_instance)
|
|
141
|
+
|
|
142
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], OrderBook, float, str]]:
|
|
143
|
+
"""Returns the dict representation of the actual instance"""
|
|
144
|
+
if self.actual_instance is None:
|
|
145
|
+
return None
|
|
146
|
+
|
|
147
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
148
|
+
return self.actual_instance.to_dict()
|
|
149
|
+
else:
|
|
150
|
+
# primitive type
|
|
151
|
+
return self.actual_instance
|
|
152
|
+
|
|
153
|
+
def to_str(self) -> str:
|
|
154
|
+
"""Returns the string representation of the actual instance"""
|
|
155
|
+
return pprint.pformat(self.model_dump())
|
|
156
|
+
|
|
157
|
+
|
|
File without changes
|
|
File without changes
|