pmxt 1.0.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.
Files changed (56) hide show
  1. pmxt/__init__.py +58 -0
  2. pmxt/client.py +713 -0
  3. pmxt/models.py +296 -0
  4. pmxt/server_manager.py +242 -0
  5. pmxt-1.0.0.dist-info/METADATA +250 -0
  6. pmxt-1.0.0.dist-info/RECORD +56 -0
  7. pmxt-1.0.0.dist-info/WHEEL +5 -0
  8. pmxt-1.0.0.dist-info/top_level.txt +2 -0
  9. pmxt_internal/__init__.py +124 -0
  10. pmxt_internal/api/__init__.py +5 -0
  11. pmxt_internal/api/default_api.py +3722 -0
  12. pmxt_internal/api_client.py +804 -0
  13. pmxt_internal/api_response.py +21 -0
  14. pmxt_internal/configuration.py +578 -0
  15. pmxt_internal/exceptions.py +219 -0
  16. pmxt_internal/models/__init__.py +54 -0
  17. pmxt_internal/models/balance.py +93 -0
  18. pmxt_internal/models/base_request.py +91 -0
  19. pmxt_internal/models/base_response.py +93 -0
  20. pmxt_internal/models/cancel_order_request.py +94 -0
  21. pmxt_internal/models/create_order200_response.py +99 -0
  22. pmxt_internal/models/create_order_params.py +111 -0
  23. pmxt_internal/models/create_order_request.py +102 -0
  24. pmxt_internal/models/error_detail.py +87 -0
  25. pmxt_internal/models/error_response.py +93 -0
  26. pmxt_internal/models/exchange_credentials.py +93 -0
  27. pmxt_internal/models/fetch_balance200_response.py +103 -0
  28. pmxt_internal/models/fetch_markets200_response.py +103 -0
  29. pmxt_internal/models/fetch_markets_request.py +102 -0
  30. pmxt_internal/models/fetch_ohlcv200_response.py +103 -0
  31. pmxt_internal/models/fetch_ohlcv_request.py +102 -0
  32. pmxt_internal/models/fetch_ohlcv_request_args_inner.py +140 -0
  33. pmxt_internal/models/fetch_open_orders200_response.py +103 -0
  34. pmxt_internal/models/fetch_open_orders_request.py +94 -0
  35. pmxt_internal/models/fetch_order_book200_response.py +99 -0
  36. pmxt_internal/models/fetch_order_book_request.py +94 -0
  37. pmxt_internal/models/fetch_positions200_response.py +103 -0
  38. pmxt_internal/models/fetch_positions_request.py +94 -0
  39. pmxt_internal/models/fetch_trades200_response.py +103 -0
  40. pmxt_internal/models/fetch_trades_request.py +102 -0
  41. pmxt_internal/models/get_markets_by_slug_request.py +94 -0
  42. pmxt_internal/models/health_check200_response.py +89 -0
  43. pmxt_internal/models/history_filter_params.py +101 -0
  44. pmxt_internal/models/market_filter_params.py +113 -0
  45. pmxt_internal/models/market_outcome.py +95 -0
  46. pmxt_internal/models/order.py +139 -0
  47. pmxt_internal/models/order_book.py +106 -0
  48. pmxt_internal/models/order_level.py +89 -0
  49. pmxt_internal/models/position.py +101 -0
  50. pmxt_internal/models/price_candle.py +97 -0
  51. pmxt_internal/models/search_markets_request.py +102 -0
  52. pmxt_internal/models/search_markets_request_args_inner.py +140 -0
  53. pmxt_internal/models/trade.py +105 -0
  54. pmxt_internal/models/unified_market.py +120 -0
  55. pmxt_internal/py.typed +0 -0
  56. pmxt_internal/rest.py +263 -0
@@ -0,0 +1,94 @@
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, StrictStr
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 typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class FetchOpenOrdersRequest(BaseModel):
28
+ """
29
+ FetchOpenOrdersRequest
30
+ """ # noqa: E501
31
+ args: Optional[Annotated[List[StrictStr], Field(max_length=1)]] = None
32
+ credentials: Optional[ExchangeCredentials] = None
33
+ __properties: ClassVar[List[str]] = ["args", "credentials"]
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 FetchOpenOrdersRequest 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 credentials
75
+ if self.credentials:
76
+ _dict['credentials'] = self.credentials.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 FetchOpenOrdersRequest 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
+ "args": obj.get("args"),
90
+ "credentials": ExchangeCredentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None
91
+ })
92
+ return _obj
93
+
94
+
@@ -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.order_book import OrderBook
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class FetchOrderBook200Response(BaseModel):
28
+ """
29
+ FetchOrderBook200Response
30
+ """ # noqa: E501
31
+ success: Optional[StrictBool] = None
32
+ error: Optional[ErrorDetail] = None
33
+ data: Optional[OrderBook] = 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 FetchOrderBook200Response 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 FetchOrderBook200Response 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": OrderBook.from_dict(obj["data"]) if obj.get("data") is not None else None
96
+ })
97
+ return _obj
98
+
99
+
@@ -0,0 +1,94 @@
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, StrictStr
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 typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class FetchOrderBookRequest(BaseModel):
28
+ """
29
+ FetchOrderBookRequest
30
+ """ # noqa: E501
31
+ args: Annotated[List[StrictStr], Field(min_length=1, max_length=1)]
32
+ credentials: Optional[ExchangeCredentials] = None
33
+ __properties: ClassVar[List[str]] = ["args", "credentials"]
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 FetchOrderBookRequest 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 credentials
75
+ if self.credentials:
76
+ _dict['credentials'] = self.credentials.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 FetchOrderBookRequest 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
+ "args": obj.get("args"),
90
+ "credentials": ExchangeCredentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None
91
+ })
92
+ return _obj
93
+
94
+
@@ -0,0 +1,103 @@
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.position import Position
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class FetchPositions200Response(BaseModel):
28
+ """
29
+ FetchPositions200Response
30
+ """ # noqa: E501
31
+ success: Optional[StrictBool] = None
32
+ error: Optional[ErrorDetail] = None
33
+ data: Optional[List[Position]] = 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 FetchPositions200Response 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 each item in data (list)
79
+ _items = []
80
+ if self.data:
81
+ for _item_data in self.data:
82
+ if _item_data:
83
+ _items.append(_item_data.to_dict())
84
+ _dict['data'] = _items
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of FetchPositions200Response 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
+ "success": obj.get("success"),
98
+ "error": ErrorDetail.from_dict(obj["error"]) if obj.get("error") is not None else None,
99
+ "data": [Position.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None
100
+ })
101
+ return _obj
102
+
103
+
@@ -0,0 +1,94 @@
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 typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class FetchPositionsRequest(BaseModel):
28
+ """
29
+ FetchPositionsRequest
30
+ """ # noqa: E501
31
+ args: Optional[Annotated[List[Any], Field(max_length=0)]] = Field(default=None, description="Empty array (no arguments)")
32
+ credentials: Optional[ExchangeCredentials] = None
33
+ __properties: ClassVar[List[str]] = ["args", "credentials"]
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 FetchPositionsRequest 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 credentials
75
+ if self.credentials:
76
+ _dict['credentials'] = self.credentials.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 FetchPositionsRequest 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
+ "args": obj.get("args"),
90
+ "credentials": ExchangeCredentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None
91
+ })
92
+ return _obj
93
+
94
+
@@ -0,0 +1,103 @@
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.trade import Trade
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class FetchTrades200Response(BaseModel):
28
+ """
29
+ FetchTrades200Response
30
+ """ # noqa: E501
31
+ success: Optional[StrictBool] = None
32
+ error: Optional[ErrorDetail] = None
33
+ data: Optional[List[Trade]] = 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 FetchTrades200Response 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 each item in data (list)
79
+ _items = []
80
+ if self.data:
81
+ for _item_data in self.data:
82
+ if _item_data:
83
+ _items.append(_item_data.to_dict())
84
+ _dict['data'] = _items
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of FetchTrades200Response 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
+ "success": obj.get("success"),
98
+ "error": ErrorDetail.from_dict(obj["error"]) if obj.get("error") is not None else None,
99
+ "data": [Trade.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None
100
+ })
101
+ return _obj
102
+
103
+
@@ -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.fetch_ohlcv_request_args_inner import FetchOHLCVRequestArgsInner
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class FetchTradesRequest(BaseModel):
29
+ """
30
+ FetchTradesRequest
31
+ """ # noqa: E501
32
+ args: Annotated[List[FetchOHLCVRequestArgsInner], Field(min_length=2, max_length=2)] = Field(description="[id, params]")
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 FetchTradesRequest 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 FetchTradesRequest 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": [FetchOHLCVRequestArgsInner.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
+