crypticorn 2.11.6__py3-none-any.whl → 2.11.7__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. crypticorn/common/errors.py +3 -3
  2. crypticorn/trade/client/__init__.py +27 -9
  3. crypticorn/trade/client/api/__init__.py +1 -0
  4. crypticorn/trade/client/api/admin_api.py +1455 -0
  5. crypticorn/trade/client/api/api_keys_api.py +60 -58
  6. crypticorn/trade/client/api/bots_api.py +289 -48
  7. crypticorn/trade/client/api/exchanges_api.py +474 -17
  8. crypticorn/trade/client/api/futures_trading_panel_api.py +1 -1
  9. crypticorn/trade/client/api/notifications_api.py +80 -96
  10. crypticorn/trade/client/api/orders_api.py +7 -7
  11. crypticorn/trade/client/api/status_api.py +5 -232
  12. crypticorn/trade/client/api/strategies_api.py +49 -48
  13. crypticorn/trade/client/api/trading_actions_api.py +42 -38
  14. crypticorn/trade/client/api_client.py +1 -1
  15. crypticorn/trade/client/configuration.py +1 -1
  16. crypticorn/trade/client/exceptions.py +1 -1
  17. crypticorn/trade/client/models/__init__.py +26 -9
  18. crypticorn/trade/client/models/api_error_identifier.py +116 -0
  19. crypticorn/trade/client/models/api_error_level.py +37 -0
  20. crypticorn/trade/client/models/api_error_type.py +37 -0
  21. crypticorn/trade/client/models/{bot_model.py → bot.py} +59 -60
  22. crypticorn/trade/client/models/bot_create.py +104 -0
  23. crypticorn/trade/client/models/bot_status.py +1 -1
  24. crypticorn/trade/client/models/bot_update.py +107 -0
  25. crypticorn/trade/client/models/exception_detail.py +8 -5
  26. crypticorn/trade/client/models/exchange.py +36 -0
  27. crypticorn/trade/client/models/exchange_key.py +111 -0
  28. crypticorn/trade/client/models/exchange_key_create.py +107 -0
  29. crypticorn/trade/client/models/{exchange_key_model.py → exchange_key_update.py} +12 -47
  30. crypticorn/trade/client/models/execution_ids.py +1 -1
  31. crypticorn/trade/client/models/futures_balance.py +1 -1
  32. crypticorn/trade/client/models/futures_trading_action.py +24 -16
  33. crypticorn/trade/client/models/{spot_trading_action.py → futures_trading_action_create.py} +24 -28
  34. crypticorn/trade/client/models/log_level.py +38 -0
  35. crypticorn/trade/client/models/margin_mode.py +1 -1
  36. crypticorn/trade/client/models/market_type.py +35 -0
  37. crypticorn/trade/client/models/{notification_model.py → notification.py} +35 -40
  38. crypticorn/trade/client/models/notification_create.py +114 -0
  39. crypticorn/trade/client/models/notification_update.py +96 -0
  40. crypticorn/trade/client/models/{order_model.py → order.py} +36 -31
  41. crypticorn/trade/client/models/order_status.py +1 -1
  42. crypticorn/trade/client/models/post_futures_action.py +1 -1
  43. crypticorn/trade/client/models/{action_model.py → spot_trading_action_create.py} +7 -65
  44. crypticorn/trade/client/models/{strategy_model_input.py → strategy.py} +25 -33
  45. crypticorn/trade/client/models/{strategy_model_output.py → strategy_create.py} +16 -39
  46. crypticorn/trade/client/models/strategy_exchange_info.py +4 -3
  47. crypticorn/trade/client/models/strategy_update.py +147 -0
  48. crypticorn/trade/client/models/tpsl.py +1 -1
  49. crypticorn/trade/client/models/trading_action_type.py +1 -1
  50. crypticorn/trade/client/rest.py +1 -1
  51. {crypticorn-2.11.6.dist-info → crypticorn-2.11.7.dist-info}/METADATA +1 -1
  52. {crypticorn-2.11.6.dist-info → crypticorn-2.11.7.dist-info}/RECORD +56 -42
  53. {crypticorn-2.11.6.dist-info → crypticorn-2.11.7.dist-info}/WHEEL +0 -0
  54. {crypticorn-2.11.6.dist-info → crypticorn-2.11.7.dist-info}/entry_points.txt +0 -0
  55. {crypticorn-2.11.6.dist-info → crypticorn-2.11.7.dist-info}/licenses/LICENSE +0 -0
  56. {crypticorn-2.11.6.dist-info → crypticorn-2.11.7.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@
3
3
  """
4
4
  Trading API
5
5
 
6
- API for automated trading and exchange interface
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
7
 
8
8
  The version of the OpenAPI document: 1.0.0
9
9
  Generated by OpenAPI Generator (https://openapi-generator.tech)
@@ -17,45 +17,67 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
21
21
  from typing import Any, ClassVar, Dict, List, Optional, Union
22
+ from typing_extensions import Annotated
23
+ from crypticorn.trade.client.models.api_error_identifier import ApiErrorIdentifier
22
24
  from crypticorn.trade.client.models.bot_status import BotStatus
23
25
  from typing import Optional, Set
24
26
  from typing_extensions import Self
25
27
 
26
28
 
27
- class BotModel(BaseModel):
29
+ class Bot(BaseModel):
28
30
  """
29
- BotModel
31
+ Trading bot model for read operations.
30
32
  """ # noqa: E501
31
33
 
32
- created_at: Optional[StrictInt] = None
33
- updated_at: Optional[StrictInt] = None
34
- id: Optional[StrictStr] = None
34
+ user_id: StrictStr = Field(description="UID for the user")
35
+ id: Optional[StrictStr] = Field(
36
+ default=None, description="Unique identifier for the resource"
37
+ )
38
+ created_at: Optional[StrictInt] = Field(
39
+ default=None, description="Timestamp of creation"
40
+ )
41
+ updated_at: Optional[StrictInt] = Field(
42
+ default=None, description="Timestamp of last update"
43
+ )
35
44
  name: StrictStr = Field(description="Name of the bot")
45
+ allocation: StrictInt = Field(description="Initial allocation for the bot")
46
+ status: BotStatus = Field(description="Status of the bot")
36
47
  strategy_id: StrictStr = Field(
37
48
  description="UID for the trading strategy used by the bot"
38
49
  )
39
50
  api_key_id: StrictStr = Field(description="UID for the API key")
40
- allocation: StrictInt = Field(description="Initial allocation for the bot")
41
- status: BotStatus = Field(description="Status of the bot")
42
- status_code: Optional[StrictStr] = Field(
43
- default=None, description="API error identifiers"
51
+ status_code: Optional[ApiErrorIdentifier] = None
52
+ current_allocation: Optional[
53
+ Union[
54
+ Annotated[float, Field(strict=True, ge=0.0)],
55
+ Annotated[int, Field(strict=True, ge=0)],
56
+ ]
57
+ ] = Field(
58
+ default=0,
59
+ description="Initial allocation for the bot + accumulated PnL of the orders after the last allocation change",
60
+ )
61
+ current_exposure: Optional[
62
+ Union[
63
+ Annotated[float, Field(strict=True, ge=0.0)],
64
+ Annotated[int, Field(strict=True, ge=0)],
65
+ ]
66
+ ] = Field(
67
+ default=0,
68
+ description="Current exposure of the bot, aka. the sum of the absolute values of the open positions",
44
69
  )
45
- user_id: Optional[StrictStr] = None
46
- current_allocation: Optional[Union[StrictFloat, StrictInt]] = None
47
- current_exposure: Optional[Union[StrictFloat, StrictInt]] = None
48
70
  __properties: ClassVar[List[str]] = [
71
+ "user_id",
72
+ "id",
49
73
  "created_at",
50
74
  "updated_at",
51
- "id",
52
75
  "name",
53
- "strategy_id",
54
- "api_key_id",
55
76
  "allocation",
56
77
  "status",
78
+ "strategy_id",
79
+ "api_key_id",
57
80
  "status_code",
58
- "user_id",
59
81
  "current_allocation",
60
82
  "current_exposure",
61
83
  ]
@@ -77,7 +99,7 @@ class BotModel(BaseModel):
77
99
 
78
100
  @classmethod
79
101
  def from_json(cls, json_str: str) -> Optional[Self]:
80
- """Create an instance of BotModel from a JSON string"""
102
+ """Create an instance of Bot from a JSON string"""
81
103
  return cls.from_dict(json.loads(json_str))
82
104
 
83
105
  def to_dict(self) -> Dict[str, Any]:
@@ -97,47 +119,16 @@ class BotModel(BaseModel):
97
119
  exclude=excluded_fields,
98
120
  exclude_none=True,
99
121
  )
100
- # set to None if created_at (nullable) is None
101
- # and model_fields_set contains the field
102
- if self.created_at is None and "created_at" in self.model_fields_set:
103
- _dict["created_at"] = None
104
-
105
- # set to None if updated_at (nullable) is None
106
- # and model_fields_set contains the field
107
- if self.updated_at is None and "updated_at" in self.model_fields_set:
108
- _dict["updated_at"] = None
109
-
110
- # set to None if id (nullable) is None
111
- # and model_fields_set contains the field
112
- if self.id is None and "id" in self.model_fields_set:
113
- _dict["id"] = None
114
-
115
- # set to None if user_id (nullable) is None
116
- # and model_fields_set contains the field
117
- if self.user_id is None and "user_id" in self.model_fields_set:
118
- _dict["user_id"] = None
119
-
120
- # set to None if current_allocation (nullable) is None
121
- # and model_fields_set contains the field
122
- if (
123
- self.current_allocation is None
124
- and "current_allocation" in self.model_fields_set
125
- ):
126
- _dict["current_allocation"] = None
127
-
128
- # set to None if current_exposure (nullable) is None
122
+ # set to None if status_code (nullable) is None
129
123
  # and model_fields_set contains the field
130
- if (
131
- self.current_exposure is None
132
- and "current_exposure" in self.model_fields_set
133
- ):
134
- _dict["current_exposure"] = None
124
+ if self.status_code is None and "status_code" in self.model_fields_set:
125
+ _dict["status_code"] = None
135
126
 
136
127
  return _dict
137
128
 
138
129
  @classmethod
139
130
  def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
140
- """Create an instance of BotModel from a dict"""
131
+ """Create an instance of Bot from a dict"""
141
132
  if obj is None:
142
133
  return None
143
134
 
@@ -146,18 +137,26 @@ class BotModel(BaseModel):
146
137
 
147
138
  _obj = cls.model_validate(
148
139
  {
140
+ "user_id": obj.get("user_id"),
141
+ "id": obj.get("id"),
149
142
  "created_at": obj.get("created_at"),
150
143
  "updated_at": obj.get("updated_at"),
151
- "id": obj.get("id"),
152
144
  "name": obj.get("name"),
153
- "strategy_id": obj.get("strategy_id"),
154
- "api_key_id": obj.get("api_key_id"),
155
145
  "allocation": obj.get("allocation"),
156
146
  "status": obj.get("status"),
147
+ "strategy_id": obj.get("strategy_id"),
148
+ "api_key_id": obj.get("api_key_id"),
157
149
  "status_code": obj.get("status_code"),
158
- "user_id": obj.get("user_id"),
159
- "current_allocation": obj.get("current_allocation"),
160
- "current_exposure": obj.get("current_exposure"),
150
+ "current_allocation": (
151
+ obj.get("current_allocation")
152
+ if obj.get("current_allocation") is not None
153
+ else 0
154
+ ),
155
+ "current_exposure": (
156
+ obj.get("current_exposure")
157
+ if obj.get("current_exposure") is not None
158
+ else 0
159
+ ),
161
160
  }
162
161
  )
163
162
  return _obj
@@ -0,0 +1,104 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Trading API
5
+
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
+
8
+ The version of the OpenAPI document: 1.0.0
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from crypticorn.trade.client.models.bot_status import BotStatus
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+
27
+ class BotCreate(BaseModel):
28
+ """
29
+ Trading bot model for API create operations.
30
+ """ # noqa: E501
31
+
32
+ name: StrictStr = Field(description="Name of the bot")
33
+ allocation: StrictInt = Field(description="Initial allocation for the bot")
34
+ status: BotStatus = Field(description="Status of the bot")
35
+ strategy_id: StrictStr = Field(
36
+ description="UID for the trading strategy used by the bot"
37
+ )
38
+ api_key_id: StrictStr = Field(description="UID for the API key")
39
+ __properties: ClassVar[List[str]] = [
40
+ "name",
41
+ "allocation",
42
+ "status",
43
+ "strategy_id",
44
+ "api_key_id",
45
+ ]
46
+
47
+ model_config = ConfigDict(
48
+ populate_by_name=True,
49
+ validate_assignment=True,
50
+ protected_namespaces=(),
51
+ )
52
+
53
+ def to_str(self) -> str:
54
+ """Returns the string representation of the model using alias"""
55
+ return pprint.pformat(self.model_dump(by_alias=True))
56
+
57
+ def to_json(self) -> str:
58
+ """Returns the JSON representation of the model using alias"""
59
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60
+ return json.dumps(self.to_dict())
61
+
62
+ @classmethod
63
+ def from_json(cls, json_str: str) -> Optional[Self]:
64
+ """Create an instance of BotCreate from a JSON string"""
65
+ return cls.from_dict(json.loads(json_str))
66
+
67
+ def to_dict(self) -> Dict[str, Any]:
68
+ """Return the dictionary representation of the model using alias.
69
+
70
+ This has the following differences from calling pydantic's
71
+ `self.model_dump(by_alias=True)`:
72
+
73
+ * `None` is only added to the output dict for nullable fields that
74
+ were set at model initialization. Other fields with value `None`
75
+ are ignored.
76
+ """
77
+ excluded_fields: Set[str] = set([])
78
+
79
+ _dict = self.model_dump(
80
+ by_alias=True,
81
+ exclude=excluded_fields,
82
+ exclude_none=True,
83
+ )
84
+ return _dict
85
+
86
+ @classmethod
87
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
+ """Create an instance of BotCreate from a dict"""
89
+ if obj is None:
90
+ return None
91
+
92
+ if not isinstance(obj, dict):
93
+ return cls.model_validate(obj)
94
+
95
+ _obj = cls.model_validate(
96
+ {
97
+ "name": obj.get("name"),
98
+ "allocation": obj.get("allocation"),
99
+ "status": obj.get("status"),
100
+ "strategy_id": obj.get("strategy_id"),
101
+ "api_key_id": obj.get("api_key_id"),
102
+ }
103
+ )
104
+ return _obj
@@ -3,7 +3,7 @@
3
3
  """
4
4
  Trading API
5
5
 
6
- API for automated trading and exchange interface
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
7
 
8
8
  The version of the OpenAPI document: 1.0.0
9
9
  Generated by OpenAPI Generator (https://openapi-generator.tech)
@@ -0,0 +1,107 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Trading API
5
+
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
+
8
+ The version of the OpenAPI document: 1.0.0
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from crypticorn.trade.client.models.bot_status import BotStatus
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+
27
+ class BotUpdate(BaseModel):
28
+ """
29
+ Trading bot model for API update operations.
30
+ """ # noqa: E501
31
+
32
+ name: Optional[StrictStr] = None
33
+ allocation: Optional[StrictInt] = None
34
+ status: Optional[BotStatus] = None
35
+ __properties: ClassVar[List[str]] = ["name", "allocation", "status"]
36
+
37
+ model_config = ConfigDict(
38
+ populate_by_name=True,
39
+ validate_assignment=True,
40
+ protected_namespaces=(),
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 BotUpdate 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
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # set to None if name (nullable) is None
75
+ # and model_fields_set contains the field
76
+ if self.name is None and "name" in self.model_fields_set:
77
+ _dict["name"] = None
78
+
79
+ # set to None if allocation (nullable) is None
80
+ # and model_fields_set contains the field
81
+ if self.allocation is None and "allocation" in self.model_fields_set:
82
+ _dict["allocation"] = None
83
+
84
+ # set to None if status (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.status is None and "status" in self.model_fields_set:
87
+ _dict["status"] = None
88
+
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of BotUpdate from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate(
101
+ {
102
+ "name": obj.get("name"),
103
+ "allocation": obj.get("allocation"),
104
+ "status": obj.get("status"),
105
+ }
106
+ )
107
+ return _obj
@@ -3,7 +3,7 @@
3
3
  """
4
4
  Trading API
5
5
 
6
- API for automated trading and exchange interface
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
7
 
8
8
  The version of the OpenAPI document: 1.0.0
9
9
  Generated by OpenAPI Generator (https://openapi-generator.tech)
@@ -19,19 +19,22 @@ import json
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
+ from crypticorn.trade.client.models.api_error_identifier import ApiErrorIdentifier
23
+ from crypticorn.trade.client.models.api_error_level import ApiErrorLevel
24
+ from crypticorn.trade.client.models.api_error_type import ApiErrorType
22
25
  from typing import Optional, Set
23
26
  from typing_extensions import Self
24
27
 
25
28
 
26
29
  class ExceptionDetail(BaseModel):
27
30
  """
28
- This is the detail of the exception. It is used to enrich the exception with additional information by unwrapping the ApiError into its components.
31
+ Exception details returned to the client.
29
32
  """ # noqa: E501
30
33
 
31
34
  message: Optional[StrictStr] = None
32
- code: StrictStr = Field(description="API error identifiers")
33
- type: StrictStr = Field(description="Type of API error")
34
- level: StrictStr = Field(description="API error levels")
35
+ code: ApiErrorIdentifier = Field(description="The unique error code")
36
+ type: ApiErrorType = Field(description="The type of error")
37
+ level: ApiErrorLevel = Field(description="The level of the error")
35
38
  status_code: StrictInt = Field(description="The HTTP status code")
36
39
  details: Optional[Any] = None
37
40
  __properties: ClassVar[List[str]] = [
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Trading API
5
+
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
+
8
+ The version of the OpenAPI document: 1.0.0
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
+ from enum import Enum
18
+ from typing_extensions import Self
19
+
20
+
21
+ class Exchange(str, Enum):
22
+ """
23
+ Supported exchanges for trading
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ KUCOIN = "kucoin"
30
+ BINGX = "bingx"
31
+ HYPERLIQUID = "hyperliquid"
32
+
33
+ @classmethod
34
+ def from_json(cls, json_str: str) -> Self:
35
+ """Create an instance of Exchange from a JSON string"""
36
+ return cls(json.loads(json_str))
@@ -0,0 +1,111 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Trading API
5
+
6
+ API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
7
+
8
+ The version of the OpenAPI document: 1.0.0
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from crypticorn.trade.client.models.exchange import Exchange
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+
27
+ class ExchangeKey(BaseModel):
28
+ """
29
+ Exchange key model not containing sensitive information for read operations.
30
+ """ # noqa: E501
31
+
32
+ user_id: StrictStr = Field(description="UID for the user")
33
+ id: Optional[StrictStr] = Field(
34
+ default=None, description="Unique identifier for the resource"
35
+ )
36
+ created_at: Optional[StrictInt] = Field(
37
+ default=None, description="Timestamp of creation"
38
+ )
39
+ updated_at: Optional[StrictInt] = Field(
40
+ default=None, description="Timestamp of last update"
41
+ )
42
+ label: StrictStr = Field(description="Label for the API key")
43
+ exchange: Exchange = Field(description="The exchange the API key is for.")
44
+ __properties: ClassVar[List[str]] = [
45
+ "user_id",
46
+ "id",
47
+ "created_at",
48
+ "updated_at",
49
+ "label",
50
+ "exchange",
51
+ ]
52
+
53
+ model_config = ConfigDict(
54
+ populate_by_name=True,
55
+ validate_assignment=True,
56
+ protected_namespaces=(),
57
+ )
58
+
59
+ def to_str(self) -> str:
60
+ """Returns the string representation of the model using alias"""
61
+ return pprint.pformat(self.model_dump(by_alias=True))
62
+
63
+ def to_json(self) -> str:
64
+ """Returns the JSON representation of the model using alias"""
65
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
66
+ return json.dumps(self.to_dict())
67
+
68
+ @classmethod
69
+ def from_json(cls, json_str: str) -> Optional[Self]:
70
+ """Create an instance of ExchangeKey from a JSON string"""
71
+ return cls.from_dict(json.loads(json_str))
72
+
73
+ def to_dict(self) -> Dict[str, Any]:
74
+ """Return the dictionary representation of the model using alias.
75
+
76
+ This has the following differences from calling pydantic's
77
+ `self.model_dump(by_alias=True)`:
78
+
79
+ * `None` is only added to the output dict for nullable fields that
80
+ were set at model initialization. Other fields with value `None`
81
+ are ignored.
82
+ """
83
+ excluded_fields: Set[str] = set([])
84
+
85
+ _dict = self.model_dump(
86
+ by_alias=True,
87
+ exclude=excluded_fields,
88
+ exclude_none=True,
89
+ )
90
+ return _dict
91
+
92
+ @classmethod
93
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94
+ """Create an instance of ExchangeKey from a dict"""
95
+ if obj is None:
96
+ return None
97
+
98
+ if not isinstance(obj, dict):
99
+ return cls.model_validate(obj)
100
+
101
+ _obj = cls.model_validate(
102
+ {
103
+ "user_id": obj.get("user_id"),
104
+ "id": obj.get("id"),
105
+ "created_at": obj.get("created_at"),
106
+ "updated_at": obj.get("updated_at"),
107
+ "label": obj.get("label"),
108
+ "exchange": obj.get("exchange"),
109
+ }
110
+ )
111
+ return _obj