crypticorn 1.0.0__py3-none-any.whl → 1.0.2rc1__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 (160) hide show
  1. crypticorn/__init__.py +3 -3
  2. crypticorn/client.py +722 -0
  3. crypticorn/{api.py → hive/main.py} +6 -6
  4. crypticorn/hive/requirements.txt +4 -0
  5. crypticorn/{utils.py → hive/utils.py} +2 -2
  6. crypticorn/klines/client/__init__.py +62 -0
  7. crypticorn/klines/client/api/__init__.py +9 -0
  8. crypticorn/klines/client/api/funding_rates_api.py +362 -0
  9. crypticorn/klines/client/api/health_check_api.py +281 -0
  10. crypticorn/klines/client/api/ohlcv_data_api.py +409 -0
  11. crypticorn/klines/client/api/symbols_api.py +308 -0
  12. crypticorn/klines/client/api/udf_api.py +1929 -0
  13. crypticorn/klines/client/api_client.py +797 -0
  14. crypticorn/klines/client/api_response.py +21 -0
  15. crypticorn/klines/client/configuration.py +565 -0
  16. crypticorn/klines/client/exceptions.py +216 -0
  17. crypticorn/klines/client/models/__init__.py +41 -0
  18. crypticorn/klines/client/models/base_response_health_check_response.py +108 -0
  19. crypticorn/klines/client/models/base_response_list_funding_rate_response.py +112 -0
  20. crypticorn/klines/client/models/base_response_list_str.py +104 -0
  21. crypticorn/klines/client/models/base_response_ohlcv_response.py +108 -0
  22. crypticorn/klines/client/models/error_response.py +101 -0
  23. crypticorn/klines/client/models/exchange.py +91 -0
  24. crypticorn/klines/client/models/funding_rate_response.py +92 -0
  25. crypticorn/klines/client/models/health_check_response.py +89 -0
  26. crypticorn/klines/client/models/history_error_response.py +89 -0
  27. crypticorn/klines/client/models/history_no_data_response.py +99 -0
  28. crypticorn/klines/client/models/history_success_response.py +99 -0
  29. crypticorn/klines/client/models/http_validation_error.py +95 -0
  30. crypticorn/klines/client/models/market.py +37 -0
  31. crypticorn/klines/client/models/ohlcv_response.py +98 -0
  32. crypticorn/klines/client/models/resolution.py +40 -0
  33. crypticorn/klines/client/models/response_get_history_udf_history_get.py +149 -0
  34. crypticorn/klines/client/models/search_symbol_response.py +97 -0
  35. crypticorn/klines/client/models/sort_direction.py +37 -0
  36. crypticorn/klines/client/models/symbol_group_response.py +87 -0
  37. crypticorn/klines/client/models/symbol_info_response.py +115 -0
  38. crypticorn/klines/client/models/symbol_type.py +89 -0
  39. crypticorn/klines/client/models/timeframe.py +40 -0
  40. crypticorn/klines/client/models/udf_config_response.py +121 -0
  41. crypticorn/klines/client/models/validation_error.py +99 -0
  42. crypticorn/klines/client/models/validation_error_loc_inner.py +138 -0
  43. crypticorn/klines/client/py.typed +0 -0
  44. crypticorn/klines/client/rest.py +257 -0
  45. crypticorn/klines/main.py +42 -0
  46. crypticorn/klines/requirements.txt +4 -0
  47. crypticorn/klines/test/__init__.py +0 -0
  48. crypticorn/klines/test/test_base_response_health_check_response.py +56 -0
  49. crypticorn/klines/test/test_base_response_list_funding_rate_response.py +59 -0
  50. crypticorn/klines/test/test_base_response_list_str.py +56 -0
  51. crypticorn/klines/test/test_base_response_ohlcv_response.py +72 -0
  52. crypticorn/klines/test/test_error_response.py +57 -0
  53. crypticorn/klines/test/test_exchange.py +56 -0
  54. crypticorn/klines/test/test_funding_rate_response.py +56 -0
  55. crypticorn/klines/test/test_funding_rates_api.py +38 -0
  56. crypticorn/klines/test/test_health_check_api.py +38 -0
  57. crypticorn/klines/test/test_health_check_response.py +52 -0
  58. crypticorn/klines/test/test_history_error_response.py +53 -0
  59. crypticorn/klines/test/test_history_no_data_response.py +69 -0
  60. crypticorn/klines/test/test_history_success_response.py +87 -0
  61. crypticorn/klines/test/test_http_validation_error.py +58 -0
  62. crypticorn/klines/test/test_market.py +33 -0
  63. crypticorn/klines/test/test_ohlcv_data_api.py +38 -0
  64. crypticorn/klines/test/test_ohlcv_response.py +86 -0
  65. crypticorn/klines/test/test_resolution.py +33 -0
  66. crypticorn/klines/test/test_response_get_history_udf_history_get.py +89 -0
  67. crypticorn/klines/test/test_search_symbol_response.py +62 -0
  68. crypticorn/klines/test/test_sort_direction.py +33 -0
  69. crypticorn/klines/test/test_symbol_group_response.py +53 -0
  70. crypticorn/klines/test/test_symbol_info_response.py +84 -0
  71. crypticorn/klines/test/test_symbol_type.py +54 -0
  72. crypticorn/klines/test/test_symbols_api.py +38 -0
  73. crypticorn/klines/test/test_timeframe.py +33 -0
  74. crypticorn/klines/test/test_udf_api.py +80 -0
  75. crypticorn/klines/test/test_udf_config_response.py +95 -0
  76. crypticorn/klines/test/test_validation_error.py +60 -0
  77. crypticorn/klines/test/test_validation_error_loc_inner.py +50 -0
  78. crypticorn/trade/client/__init__.py +63 -0
  79. crypticorn/trade/client/api/__init__.py +13 -0
  80. crypticorn/trade/client/api/api_keys_api.py +1468 -0
  81. crypticorn/trade/client/api/bots_api.py +1211 -0
  82. crypticorn/trade/client/api/exchanges_api.py +297 -0
  83. crypticorn/trade/client/api/futures_trading_panel_api.py +1463 -0
  84. crypticorn/trade/client/api/notifications_api.py +1767 -0
  85. crypticorn/trade/client/api/orders_api.py +331 -0
  86. crypticorn/trade/client/api/status_api.py +278 -0
  87. crypticorn/trade/client/api/strategies_api.py +331 -0
  88. crypticorn/trade/client/api/trading_actions_api.py +898 -0
  89. crypticorn/trade/client/api_client.py +797 -0
  90. crypticorn/trade/client/api_response.py +21 -0
  91. crypticorn/trade/client/configuration.py +574 -0
  92. crypticorn/trade/client/exceptions.py +216 -0
  93. crypticorn/trade/client/models/__init__.py +38 -0
  94. crypticorn/trade/client/models/action_model.py +202 -0
  95. crypticorn/trade/client/models/api_error_identifier.py +83 -0
  96. crypticorn/trade/client/models/api_key_model.py +135 -0
  97. crypticorn/trade/client/models/bot_model.py +122 -0
  98. crypticorn/trade/client/models/exchange.py +37 -0
  99. crypticorn/trade/client/models/execution_ids.py +91 -0
  100. crypticorn/trade/client/models/futures_balance.py +109 -0
  101. crypticorn/trade/client/models/futures_trading_action.py +198 -0
  102. crypticorn/trade/client/models/http_validation_error.py +95 -0
  103. crypticorn/trade/client/models/margin_mode.py +37 -0
  104. crypticorn/trade/client/models/market_type.py +37 -0
  105. crypticorn/trade/client/models/notification_model.py +113 -0
  106. crypticorn/trade/client/models/notification_type.py +39 -0
  107. crypticorn/trade/client/models/order_model.py +263 -0
  108. crypticorn/trade/client/models/order_status.py +40 -0
  109. crypticorn/trade/client/models/post_futures_action.py +93 -0
  110. crypticorn/trade/client/models/strategy_exchange_info.py +90 -0
  111. crypticorn/trade/client/models/strategy_model.py +119 -0
  112. crypticorn/trade/client/models/tpsl.py +116 -0
  113. crypticorn/trade/client/models/trading_action_type.py +39 -0
  114. crypticorn/trade/client/models/update_notification.py +91 -0
  115. crypticorn/trade/client/models/validation_error.py +99 -0
  116. crypticorn/trade/client/models/validation_error_loc_inner.py +138 -0
  117. crypticorn/trade/client/py.typed +0 -0
  118. crypticorn/trade/client/rest.py +257 -0
  119. crypticorn/trade/main.py +38 -0
  120. crypticorn/trade/requirements.txt +4 -0
  121. crypticorn/trade/test/__init__.py +0 -0
  122. crypticorn/trade/test/test_action_model.py +87 -0
  123. crypticorn/trade/test/test_api_error_identifier.py +33 -0
  124. crypticorn/trade/test/test_api_key_model.py +61 -0
  125. crypticorn/trade/test/test_api_keys_api.py +66 -0
  126. crypticorn/trade/test/test_bot_model.py +64 -0
  127. crypticorn/trade/test/test_bots_api.py +59 -0
  128. crypticorn/trade/test/test_exchange.py +33 -0
  129. crypticorn/trade/test/test_exchanges_api.py +38 -0
  130. crypticorn/trade/test/test_execution_ids.py +68 -0
  131. crypticorn/trade/test/test_futures_balance.py +62 -0
  132. crypticorn/trade/test/test_futures_trading_action.py +86 -0
  133. crypticorn/trade/test/test_futures_trading_panel_api.py +66 -0
  134. crypticorn/trade/test/test_http_validation_error.py +58 -0
  135. crypticorn/trade/test/test_margin_mode.py +33 -0
  136. crypticorn/trade/test/test_market_type.py +33 -0
  137. crypticorn/trade/test/test_notification_model.py +59 -0
  138. crypticorn/trade/test/test_notification_type.py +33 -0
  139. crypticorn/trade/test/test_notifications_api.py +73 -0
  140. crypticorn/trade/test/test_order_model.py +75 -0
  141. crypticorn/trade/test/test_order_status.py +33 -0
  142. crypticorn/trade/test/test_orders_api.py +38 -0
  143. crypticorn/trade/test/test_post_futures_action.py +72 -0
  144. crypticorn/trade/test/test_status_api.py +38 -0
  145. crypticorn/trade/test/test_strategies_api.py +38 -0
  146. crypticorn/trade/test/test_strategy_exchange_info.py +54 -0
  147. crypticorn/trade/test/test_strategy_model.py +73 -0
  148. crypticorn/trade/test/test_tpsl.py +56 -0
  149. crypticorn/trade/test/test_trading_action_type.py +33 -0
  150. crypticorn/trade/test/test_trading_actions_api.py +52 -0
  151. crypticorn/trade/test/test_update_notification.py +54 -0
  152. crypticorn/trade/test/test_validation_error.py +60 -0
  153. crypticorn/trade/test/test_validation_error_loc_inner.py +50 -0
  154. crypticorn-1.0.2rc1.dist-info/METADATA +47 -0
  155. crypticorn-1.0.2rc1.dist-info/RECORD +158 -0
  156. {crypticorn-1.0.0.dist-info → crypticorn-1.0.2rc1.dist-info}/WHEEL +1 -1
  157. crypticorn-1.0.0.dist-info/METADATA +0 -34
  158. crypticorn-1.0.0.dist-info/RECORD +0 -8
  159. {crypticorn-1.0.0.dist-info → crypticorn-1.0.2rc1.dist-info}/LICENSE.md +0 -0
  160. {crypticorn-1.0.0.dist-info → crypticorn-1.0.2rc1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,216 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ FastAPI
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from typing import Any, Optional
15
+ from typing_extensions import Self
16
+
17
+ class OpenApiException(Exception):
18
+ """The base exception class for all OpenAPIExceptions"""
19
+
20
+
21
+ class ApiTypeError(OpenApiException, TypeError):
22
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
23
+ key_type=None) -> None:
24
+ """ Raises an exception for TypeErrors
25
+
26
+ Args:
27
+ msg (str): the exception message
28
+
29
+ Keyword Args:
30
+ path_to_item (list): a list of keys an indices to get to the
31
+ current_item
32
+ None if unset
33
+ valid_classes (tuple): the primitive classes that current item
34
+ should be an instance of
35
+ None if unset
36
+ key_type (bool): False if our value is a value in a dict
37
+ True if it is a key in a dict
38
+ False if our item is an item in a list
39
+ None if unset
40
+ """
41
+ self.path_to_item = path_to_item
42
+ self.valid_classes = valid_classes
43
+ self.key_type = key_type
44
+ full_msg = msg
45
+ if path_to_item:
46
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
47
+ super(ApiTypeError, self).__init__(full_msg)
48
+
49
+
50
+ class ApiValueError(OpenApiException, ValueError):
51
+ def __init__(self, msg, path_to_item=None) -> None:
52
+ """
53
+ Args:
54
+ msg (str): the exception message
55
+
56
+ Keyword Args:
57
+ path_to_item (list) the path to the exception in the
58
+ received_data dict. None if unset
59
+ """
60
+
61
+ self.path_to_item = path_to_item
62
+ full_msg = msg
63
+ if path_to_item:
64
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
65
+ super(ApiValueError, self).__init__(full_msg)
66
+
67
+
68
+ class ApiAttributeError(OpenApiException, AttributeError):
69
+ def __init__(self, msg, path_to_item=None) -> None:
70
+ """
71
+ Raised when an attribute reference or assignment fails.
72
+
73
+ Args:
74
+ msg (str): the exception message
75
+
76
+ Keyword Args:
77
+ path_to_item (None/list) the path to the exception in the
78
+ received_data dict
79
+ """
80
+ self.path_to_item = path_to_item
81
+ full_msg = msg
82
+ if path_to_item:
83
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
84
+ super(ApiAttributeError, self).__init__(full_msg)
85
+
86
+
87
+ class ApiKeyError(OpenApiException, KeyError):
88
+ def __init__(self, msg, path_to_item=None) -> None:
89
+ """
90
+ Args:
91
+ msg (str): the exception message
92
+
93
+ Keyword Args:
94
+ path_to_item (None/list) the path to the exception in the
95
+ received_data dict
96
+ """
97
+ self.path_to_item = path_to_item
98
+ full_msg = msg
99
+ if path_to_item:
100
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
101
+ super(ApiKeyError, self).__init__(full_msg)
102
+
103
+
104
+ class ApiException(OpenApiException):
105
+
106
+ def __init__(
107
+ self,
108
+ status=None,
109
+ reason=None,
110
+ http_resp=None,
111
+ *,
112
+ body: Optional[str] = None,
113
+ data: Optional[Any] = None,
114
+ ) -> None:
115
+ self.status = status
116
+ self.reason = reason
117
+ self.body = body
118
+ self.data = data
119
+ self.headers = None
120
+
121
+ if http_resp:
122
+ if self.status is None:
123
+ self.status = http_resp.status
124
+ if self.reason is None:
125
+ self.reason = http_resp.reason
126
+ if self.body is None:
127
+ try:
128
+ self.body = http_resp.data.decode('utf-8')
129
+ except Exception:
130
+ pass
131
+ self.headers = http_resp.getheaders()
132
+
133
+ @classmethod
134
+ def from_response(
135
+ cls,
136
+ *,
137
+ http_resp,
138
+ body: Optional[str],
139
+ data: Optional[Any],
140
+ ) -> Self:
141
+ if http_resp.status == 400:
142
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
143
+
144
+ if http_resp.status == 401:
145
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
146
+
147
+ if http_resp.status == 403:
148
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
149
+
150
+ if http_resp.status == 404:
151
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
152
+
153
+ # Added new conditions for 409 and 422
154
+ if http_resp.status == 409:
155
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
156
+
157
+ if http_resp.status == 422:
158
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
159
+
160
+ if 500 <= http_resp.status <= 599:
161
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
162
+ raise ApiException(http_resp=http_resp, body=body, data=data)
163
+
164
+ def __str__(self):
165
+ """Custom error messages for exception"""
166
+ error_message = "({0})\n"\
167
+ "Reason: {1}\n".format(self.status, self.reason)
168
+ if self.headers:
169
+ error_message += "HTTP response headers: {0}\n".format(
170
+ self.headers)
171
+
172
+ if self.data or self.body:
173
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
174
+
175
+ return error_message
176
+
177
+
178
+ class BadRequestException(ApiException):
179
+ pass
180
+
181
+
182
+ class NotFoundException(ApiException):
183
+ pass
184
+
185
+
186
+ class UnauthorizedException(ApiException):
187
+ pass
188
+
189
+
190
+ class ForbiddenException(ApiException):
191
+ pass
192
+
193
+
194
+ class ServiceException(ApiException):
195
+ pass
196
+
197
+
198
+ class ConflictException(ApiException):
199
+ """Exception for HTTP 409 Conflict."""
200
+ pass
201
+
202
+
203
+ class UnprocessableEntityException(ApiException):
204
+ """Exception for HTTP 422 Unprocessable Entity."""
205
+ pass
206
+
207
+
208
+ def render_path(path_to_item):
209
+ """Returns a string representation of a path"""
210
+ result = ""
211
+ for pth in path_to_item:
212
+ if isinstance(pth, int):
213
+ result += "[{0}]".format(pth)
214
+ else:
215
+ result += "['{0}']".format(pth)
216
+ return result
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ FastAPI
6
+
7
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
8
+
9
+ The version of the OpenAPI document: 0.1.0
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ # import models into model package
17
+ from crypticorn.trade.client.models.api_key_model import APIKeyModel
18
+ from crypticorn.trade.client.models.action_model import ActionModel
19
+ from crypticorn.trade.client.models.api_error_identifier import ApiErrorIdentifier
20
+ from crypticorn.trade.client.models.bot_model import BotModel
21
+ from crypticorn.trade.client.models.exchange import Exchange
22
+ from crypticorn.trade.client.models.execution_ids import ExecutionIds
23
+ from crypticorn.trade.client.models.futures_balance import FuturesBalance
24
+ from crypticorn.trade.client.models.futures_trading_action import FuturesTradingAction
25
+ from crypticorn.trade.client.models.http_validation_error import HTTPValidationError
26
+ from crypticorn.trade.client.models.margin_mode import MarginMode
27
+ from crypticorn.trade.client.models.market_type import MarketType
28
+ from crypticorn.trade.client.models.notification_model import NotificationModel
29
+ from crypticorn.trade.client.models.notification_type import NotificationType
30
+ from crypticorn.trade.client.models.order_model import OrderModel
31
+ from crypticorn.trade.client.models.order_status import OrderStatus
32
+ from crypticorn.trade.client.models.post_futures_action import PostFuturesAction
33
+ from crypticorn.trade.client.models.strategy_exchange_info import StrategyExchangeInfo
34
+ from crypticorn.trade.client.models.strategy_model import StrategyModel
35
+ from crypticorn.trade.client.models.tpsl import TPSL
36
+ from crypticorn.trade.client.models.trading_action_type import TradingActionType
37
+ from crypticorn.trade.client.models.validation_error import ValidationError
38
+ from crypticorn.trade.client.models.validation_error_loc_inner import ValidationErrorLocInner
@@ -0,0 +1,202 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ FastAPI
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.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, StrictBool, StrictFloat, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional, Union
22
+ from typing_extensions import Annotated
23
+ from crypticorn.trade.client.models.margin_mode import MarginMode
24
+ from crypticorn.trade.client.models.market_type import MarketType
25
+ from crypticorn.trade.client.models.tpsl import TPSL
26
+ from crypticorn.trade.client.models.trading_action_type import TradingActionType
27
+ from typing import Optional, Set
28
+ from typing_extensions import Self
29
+
30
+ class ActionModel(BaseModel):
31
+ """
32
+ ActionModel
33
+ """ # noqa: E501
34
+ created_at: Optional[StrictInt] = Field(default=1742340838, description="Timestamp of creation")
35
+ updated_at: Optional[StrictInt] = Field(default=1742340838, description="Timestamp of last update")
36
+ id: Optional[StrictStr] = None
37
+ execution_id: Optional[StrictStr] = None
38
+ open_order_execution_id: Optional[StrictStr] = None
39
+ client_order_id: Optional[StrictStr] = None
40
+ action_type: TradingActionType = Field(description="The type of action.")
41
+ market_type: MarketType = Field(description="The type of market the action is for.")
42
+ strategy_id: StrictStr = Field(description="UID for the strategy.")
43
+ symbol: StrictStr = Field(description="Trading symbol or asset pair in format: 'symbol/quote_currency' (see market service for valid symbols)")
44
+ is_limit: Optional[StrictBool] = None
45
+ limit_price: Optional[Union[StrictFloat, StrictInt]] = None
46
+ allocation: Optional[Union[Annotated[float, Field(le=1.0, strict=True)], Annotated[int, Field(le=1, strict=True)]]] = Field(default=None, description="How much of bot's balance to use for the order (for open actions). How much of the position to close (for close actions). 0=0%, 1=100%.")
47
+ take_profit: Optional[List[TPSL]] = None
48
+ stop_loss: Optional[List[TPSL]] = None
49
+ expiry_timestamp: Optional[StrictInt] = None
50
+ position_id: Optional[StrictStr] = None
51
+ leverage: Optional[Annotated[int, Field(strict=True, ge=1)]]
52
+ margin_mode: Optional[MarginMode] = None
53
+ __properties: ClassVar[List[str]] = ["created_at", "updated_at", "id", "execution_id", "open_order_execution_id", "client_order_id", "action_type", "market_type", "strategy_id", "symbol", "is_limit", "limit_price", "allocation", "take_profit", "stop_loss", "expiry_timestamp", "position_id", "leverage", "margin_mode"]
54
+
55
+ model_config = ConfigDict(
56
+ populate_by_name=True,
57
+ validate_assignment=True,
58
+ protected_namespaces=(),
59
+ )
60
+
61
+
62
+ def to_str(self) -> str:
63
+ """Returns the string representation of the model using alias"""
64
+ return pprint.pformat(self.model_dump(by_alias=True))
65
+
66
+ def to_json(self) -> str:
67
+ """Returns the JSON representation of the model using alias"""
68
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
69
+ return json.dumps(self.to_dict())
70
+
71
+ @classmethod
72
+ def from_json(cls, json_str: str) -> Optional[Self]:
73
+ """Create an instance of ActionModel from a JSON string"""
74
+ return cls.from_dict(json.loads(json_str))
75
+
76
+ def to_dict(self) -> Dict[str, Any]:
77
+ """Return the dictionary representation of the model using alias.
78
+
79
+ This has the following differences from calling pydantic's
80
+ `self.model_dump(by_alias=True)`:
81
+
82
+ * `None` is only added to the output dict for nullable fields that
83
+ were set at model initialization. Other fields with value `None`
84
+ are ignored.
85
+ """
86
+ excluded_fields: Set[str] = set([
87
+ ])
88
+
89
+ _dict = self.model_dump(
90
+ by_alias=True,
91
+ exclude=excluded_fields,
92
+ exclude_none=True,
93
+ )
94
+ # override the default output from pydantic by calling `to_dict()` of each item in take_profit (list)
95
+ _items = []
96
+ if self.take_profit:
97
+ for _item_take_profit in self.take_profit:
98
+ if _item_take_profit:
99
+ _items.append(_item_take_profit.to_dict())
100
+ _dict['take_profit'] = _items
101
+ # override the default output from pydantic by calling `to_dict()` of each item in stop_loss (list)
102
+ _items = []
103
+ if self.stop_loss:
104
+ for _item_stop_loss in self.stop_loss:
105
+ if _item_stop_loss:
106
+ _items.append(_item_stop_loss.to_dict())
107
+ _dict['stop_loss'] = _items
108
+ # set to None if id (nullable) is None
109
+ # and model_fields_set contains the field
110
+ if self.id is None and "id" in self.model_fields_set:
111
+ _dict['id'] = None
112
+
113
+ # set to None if execution_id (nullable) is None
114
+ # and model_fields_set contains the field
115
+ if self.execution_id is None and "execution_id" in self.model_fields_set:
116
+ _dict['execution_id'] = None
117
+
118
+ # set to None if open_order_execution_id (nullable) is None
119
+ # and model_fields_set contains the field
120
+ if self.open_order_execution_id is None and "open_order_execution_id" in self.model_fields_set:
121
+ _dict['open_order_execution_id'] = None
122
+
123
+ # set to None if client_order_id (nullable) is None
124
+ # and model_fields_set contains the field
125
+ if self.client_order_id is None and "client_order_id" in self.model_fields_set:
126
+ _dict['client_order_id'] = None
127
+
128
+ # set to None if is_limit (nullable) is None
129
+ # and model_fields_set contains the field
130
+ if self.is_limit is None and "is_limit" in self.model_fields_set:
131
+ _dict['is_limit'] = None
132
+
133
+ # set to None if limit_price (nullable) is None
134
+ # and model_fields_set contains the field
135
+ if self.limit_price is None and "limit_price" in self.model_fields_set:
136
+ _dict['limit_price'] = None
137
+
138
+ # set to None if take_profit (nullable) is None
139
+ # and model_fields_set contains the field
140
+ if self.take_profit is None and "take_profit" in self.model_fields_set:
141
+ _dict['take_profit'] = None
142
+
143
+ # set to None if stop_loss (nullable) is None
144
+ # and model_fields_set contains the field
145
+ if self.stop_loss is None and "stop_loss" in self.model_fields_set:
146
+ _dict['stop_loss'] = None
147
+
148
+ # set to None if expiry_timestamp (nullable) is None
149
+ # and model_fields_set contains the field
150
+ if self.expiry_timestamp is None and "expiry_timestamp" in self.model_fields_set:
151
+ _dict['expiry_timestamp'] = None
152
+
153
+ # set to None if position_id (nullable) is None
154
+ # and model_fields_set contains the field
155
+ if self.position_id is None and "position_id" in self.model_fields_set:
156
+ _dict['position_id'] = None
157
+
158
+ # set to None if leverage (nullable) is None
159
+ # and model_fields_set contains the field
160
+ if self.leverage is None and "leverage" in self.model_fields_set:
161
+ _dict['leverage'] = None
162
+
163
+ # set to None if margin_mode (nullable) is None
164
+ # and model_fields_set contains the field
165
+ if self.margin_mode is None and "margin_mode" in self.model_fields_set:
166
+ _dict['margin_mode'] = None
167
+
168
+ return _dict
169
+
170
+ @classmethod
171
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
172
+ """Create an instance of ActionModel from a dict"""
173
+ if obj is None:
174
+ return None
175
+
176
+ if not isinstance(obj, dict):
177
+ return cls.model_validate(obj)
178
+
179
+ _obj = cls.model_validate({
180
+ "created_at": obj.get("created_at") if obj.get("created_at") is not None else 1742340838,
181
+ "updated_at": obj.get("updated_at") if obj.get("updated_at") is not None else 1742340838,
182
+ "id": obj.get("id"),
183
+ "execution_id": obj.get("execution_id"),
184
+ "open_order_execution_id": obj.get("open_order_execution_id"),
185
+ "client_order_id": obj.get("client_order_id"),
186
+ "action_type": obj.get("action_type"),
187
+ "market_type": obj.get("market_type"),
188
+ "strategy_id": obj.get("strategy_id"),
189
+ "symbol": obj.get("symbol"),
190
+ "is_limit": obj.get("is_limit"),
191
+ "limit_price": obj.get("limit_price"),
192
+ "allocation": obj.get("allocation"),
193
+ "take_profit": [TPSL.from_dict(_item) for _item in obj["take_profit"]] if obj.get("take_profit") is not None else None,
194
+ "stop_loss": [TPSL.from_dict(_item) for _item in obj["stop_loss"]] if obj.get("stop_loss") is not None else None,
195
+ "expiry_timestamp": obj.get("expiry_timestamp"),
196
+ "position_id": obj.get("position_id"),
197
+ "leverage": obj.get("leverage") if obj.get("leverage") is not None else 1,
198
+ "margin_mode": obj.get("margin_mode")
199
+ })
200
+ return _obj
201
+
202
+
@@ -0,0 +1,83 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ FastAPI
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.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 ApiErrorIdentifier(str, Enum):
22
+ """
23
+ API error identifiers
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ SUCCESS = 'success'
30
+ INVALID_API_KEY = 'invalid_api_key'
31
+ INVALID_SIGNATURE = 'invalid_signature'
32
+ INVALID_TIMESTAMP = 'invalid_timestamp'
33
+ IP_ADDRESS_IS_NOT_AUTHORIZED = 'ip_address_is_not_authorized'
34
+ INSUFFICIENT_PERMISSIONS_SPOT_AND_FUTURES_REQUIRED = 'insufficient_permissions_spot_and_futures_required'
35
+ USER_ACCOUNT_IS_FROZEN = 'user_account_is_frozen'
36
+ RATE_LIMIT_EXCEEDED = 'rate_limit_exceeded'
37
+ INVALID_PARAMETER_PROVIDED = 'invalid_parameter_provided'
38
+ REQUEST_SCOPE_LIMIT_EXCEEDED = 'request_scope_limit_exceeded'
39
+ INVALID_CONTENT_TYPE = 'invalid_content_type'
40
+ REQUESTED_RESOURCE_NOT_FOUND = 'requested_resource_not_found'
41
+ ORDER_DOES_NOT_EXIST = 'order_does_not_exist'
42
+ ORDER_IS_ALREADY_FILLED = 'order_is_already_filled'
43
+ ORDER_IS_BEING_PROCESSED = 'order_is_being_processed'
44
+ ORDER_QUANTITY_LIMIT_EXCEEDED = 'order_quantity_limit_exceeded'
45
+ ORDER_PRICE_IS_INVALID = 'order_price_is_invalid'
46
+ POST_ONLY_ORDER_WOULD_IMMEDIATELY_MATCH = 'post_only_order_would_immediately_match'
47
+ SYMBOL_DOES_NOT_EXIST = 'symbol_does_not_exist'
48
+ POSITION_DOES_NOT_EXIST = 'position_does_not_exist'
49
+ POSITION_LIMIT_EXCEEDED = 'position_limit_exceeded'
50
+ POSITION_OPENING_TEMPORARILY_SUSPENDED = 'position_opening_temporarily_suspended'
51
+ INSUFFICIENT_BALANCE = 'insufficient_balance'
52
+ INSUFFICIENT_MARGIN = 'insufficient_margin'
53
+ LEVERAGE_LIMIT_EXCEEDED = 'leverage_limit_exceeded'
54
+ RISK_LIMIT_EXCEEDED = 'risk_limit_exceeded'
55
+ ORDER_VIOLATES_LIQUIDATION_PRICE_CONSTRAINTS = 'order_violates_liquidation_price_constraints'
56
+ INVALID_MARGIN_MODE = 'invalid_margin_mode'
57
+ INTERNAL_SYSTEM_ERROR = 'internal_system_error'
58
+ SYSTEM_CONFIGURATION_ERROR = 'system_configuration_error'
59
+ SERVICE_TEMPORARILY_UNAVAILABLE = 'service_temporarily_unavailable'
60
+ SYSTEM_IS_BUSY_PLEASE_TRY_AGAIN_LATER = 'system_is_busy_please_try_again_later'
61
+ SYSTEM_UNDER_MAINTENANCE = 'system_under_maintenance'
62
+ RPC_TIMEOUT = 'rpc_timeout'
63
+ SYSTEM_SETTLEMENT_IN_PROCESS = 'system_settlement_in_process'
64
+ TRADING_IS_SUSPENDED = 'trading_is_suspended'
65
+ TRADING_HAS_BEEN_LOCKED = 'trading_has_been_locked'
66
+ UNKNOWN_ERROR_OCCURRED = 'unknown_error_occurred'
67
+ HTTP_REQUEST_ERROR = 'http_request_error'
68
+ BLACK_SWAN = 'black_swan'
69
+ TRADING_ACTION_EXPIRED = 'trading_action_expired'
70
+ BOT_DISABLED = 'bot_disabled'
71
+ ORDER_SIZE_TOO_SMALL = 'order_size_too_small'
72
+ ORDER_SIZE_TOO_LARGE = 'order_size_too_large'
73
+ HEDGE_MODE_NOT_ACTIVE = 'hedge_mode_not_active'
74
+ API_KEY_ALREADY_EXISTS = 'api_key_already_exists'
75
+ DELETE_BOT_ERROR = 'delete_bot_error'
76
+ JWT_EXPIRED = 'jwt_expired'
77
+
78
+ @classmethod
79
+ def from_json(cls, json_str: str) -> Self:
80
+ """Create an instance of ApiErrorIdentifier from a JSON string"""
81
+ return cls(json.loads(json_str))
82
+
83
+
@@ -0,0 +1,135 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ FastAPI
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.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, StrictBool, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class APIKeyModel(BaseModel):
26
+ """
27
+ APIKeyModel
28
+ """ # noqa: E501
29
+ created_at: Optional[StrictInt] = Field(default=1742340838, description="Timestamp of creation")
30
+ updated_at: Optional[StrictInt] = Field(default=1742340838, description="Timestamp of last update")
31
+ id: Optional[StrictStr] = None
32
+ exchange: StrictStr = Field(description="Exchange name")
33
+ api_key: Optional[StrictStr] = None
34
+ secret: Optional[StrictStr] = None
35
+ passphrase: Optional[StrictStr] = None
36
+ label: StrictStr = Field(description="Label for the API key")
37
+ enabled: Optional[StrictBool] = None
38
+ user_id: Optional[StrictStr] = None
39
+ __properties: ClassVar[List[str]] = ["created_at", "updated_at", "id", "exchange", "api_key", "secret", "passphrase", "label", "enabled", "user_id"]
40
+
41
+ model_config = ConfigDict(
42
+ populate_by_name=True,
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def to_str(self) -> str:
49
+ """Returns the string representation of the model using alias"""
50
+ return pprint.pformat(self.model_dump(by_alias=True))
51
+
52
+ def to_json(self) -> str:
53
+ """Returns the JSON representation of the model using alias"""
54
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
55
+ return json.dumps(self.to_dict())
56
+
57
+ @classmethod
58
+ def from_json(cls, json_str: str) -> Optional[Self]:
59
+ """Create an instance of APIKeyModel from a JSON string"""
60
+ return cls.from_dict(json.loads(json_str))
61
+
62
+ def to_dict(self) -> Dict[str, Any]:
63
+ """Return the dictionary representation of the model using alias.
64
+
65
+ This has the following differences from calling pydantic's
66
+ `self.model_dump(by_alias=True)`:
67
+
68
+ * `None` is only added to the output dict for nullable fields that
69
+ were set at model initialization. Other fields with value `None`
70
+ are ignored.
71
+ """
72
+ excluded_fields: Set[str] = set([
73
+ ])
74
+
75
+ _dict = self.model_dump(
76
+ by_alias=True,
77
+ exclude=excluded_fields,
78
+ exclude_none=True,
79
+ )
80
+ # set to None if id (nullable) is None
81
+ # and model_fields_set contains the field
82
+ if self.id is None and "id" in self.model_fields_set:
83
+ _dict['id'] = None
84
+
85
+ # set to None if api_key (nullable) is None
86
+ # and model_fields_set contains the field
87
+ if self.api_key is None and "api_key" in self.model_fields_set:
88
+ _dict['api_key'] = None
89
+
90
+ # set to None if secret (nullable) is None
91
+ # and model_fields_set contains the field
92
+ if self.secret is None and "secret" in self.model_fields_set:
93
+ _dict['secret'] = None
94
+
95
+ # set to None if passphrase (nullable) is None
96
+ # and model_fields_set contains the field
97
+ if self.passphrase is None and "passphrase" in self.model_fields_set:
98
+ _dict['passphrase'] = None
99
+
100
+ # set to None if enabled (nullable) is None
101
+ # and model_fields_set contains the field
102
+ if self.enabled is None and "enabled" in self.model_fields_set:
103
+ _dict['enabled'] = None
104
+
105
+ # set to None if user_id (nullable) is None
106
+ # and model_fields_set contains the field
107
+ if self.user_id is None and "user_id" in self.model_fields_set:
108
+ _dict['user_id'] = None
109
+
110
+ return _dict
111
+
112
+ @classmethod
113
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
114
+ """Create an instance of APIKeyModel from a dict"""
115
+ if obj is None:
116
+ return None
117
+
118
+ if not isinstance(obj, dict):
119
+ return cls.model_validate(obj)
120
+
121
+ _obj = cls.model_validate({
122
+ "created_at": obj.get("created_at") if obj.get("created_at") is not None else 1742340838,
123
+ "updated_at": obj.get("updated_at") if obj.get("updated_at") is not None else 1742340838,
124
+ "id": obj.get("id"),
125
+ "exchange": obj.get("exchange"),
126
+ "api_key": obj.get("api_key"),
127
+ "secret": obj.get("secret"),
128
+ "passphrase": obj.get("passphrase"),
129
+ "label": obj.get("label"),
130
+ "enabled": obj.get("enabled"),
131
+ "user_id": obj.get("user_id")
132
+ })
133
+ return _obj
134
+
135
+