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,122 @@
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 import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class BotModel(BaseModel):
26
+ """
27
+ BotModel
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
+ name: StrictStr = Field(description="Name of the bot")
33
+ strategy_id: StrictStr = Field(description="UID for the trading strategy used by the bot")
34
+ api_key_id: StrictStr = Field(description="UID for the API key")
35
+ allocation: StrictInt = Field(description="Initial allocation for the bot")
36
+ enabled: StrictBool = Field(description="Status of the bot")
37
+ deleted: Optional[StrictBool] = Field(default=False, description="Whether the bot has been deleted")
38
+ user_id: Optional[StrictStr] = None
39
+ current_allocation: Optional[Union[StrictFloat, StrictInt]] = None
40
+ __properties: ClassVar[List[str]] = ["created_at", "updated_at", "id", "name", "strategy_id", "api_key_id", "allocation", "enabled", "deleted", "user_id", "current_allocation"]
41
+
42
+ model_config = ConfigDict(
43
+ populate_by_name=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of BotModel from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([
74
+ ])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # set to None if id (nullable) is None
82
+ # and model_fields_set contains the field
83
+ if self.id is None and "id" in self.model_fields_set:
84
+ _dict['id'] = None
85
+
86
+ # set to None if user_id (nullable) is None
87
+ # and model_fields_set contains the field
88
+ if self.user_id is None and "user_id" in self.model_fields_set:
89
+ _dict['user_id'] = None
90
+
91
+ # set to None if current_allocation (nullable) is None
92
+ # and model_fields_set contains the field
93
+ if self.current_allocation is None and "current_allocation" in self.model_fields_set:
94
+ _dict['current_allocation'] = None
95
+
96
+ return _dict
97
+
98
+ @classmethod
99
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
100
+ """Create an instance of BotModel from a dict"""
101
+ if obj is None:
102
+ return None
103
+
104
+ if not isinstance(obj, dict):
105
+ return cls.model_validate(obj)
106
+
107
+ _obj = cls.model_validate({
108
+ "created_at": obj.get("created_at") if obj.get("created_at") is not None else 1742340838,
109
+ "updated_at": obj.get("updated_at") if obj.get("updated_at") is not None else 1742340838,
110
+ "id": obj.get("id"),
111
+ "name": obj.get("name"),
112
+ "strategy_id": obj.get("strategy_id"),
113
+ "api_key_id": obj.get("api_key_id"),
114
+ "allocation": obj.get("allocation"),
115
+ "enabled": obj.get("enabled"),
116
+ "deleted": obj.get("deleted") if obj.get("deleted") is not None else False,
117
+ "user_id": obj.get("user_id"),
118
+ "current_allocation": obj.get("current_allocation")
119
+ })
120
+ return _obj
121
+
122
+
@@ -0,0 +1,37 @@
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 Exchange(str, Enum):
22
+ """
23
+ Supported exchanges
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ KUCOIN = 'kucoin'
30
+ BINGX = 'bingx'
31
+
32
+ @classmethod
33
+ def from_json(cls, json_str: str) -> Self:
34
+ """Create an instance of Exchange from a JSON string"""
35
+ return cls(json.loads(json_str))
36
+
37
+
@@ -0,0 +1,91 @@
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, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class ExecutionIds(BaseModel):
26
+ """
27
+ ExecutionIds
28
+ """ # noqa: E501
29
+ main: List[StrictStr] = Field(description="Main execution ID. List with one item.")
30
+ sl: List[StrictStr] = Field(description="Stop loss execution IDs. List with multiple items ordered by the next stop loss.")
31
+ tp: List[StrictStr] = Field(description="Take profit execution IDs. List with multiple items ordered by the next take profit.")
32
+ __properties: ClassVar[List[str]] = ["main", "sl", "tp"]
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 ExecutionIds 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 ExecutionIds 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
+ "main": obj.get("main"),
86
+ "sl": obj.get("sl"),
87
+ "tp": obj.get("tp")
88
+ })
89
+ return _obj
90
+
91
+
@@ -0,0 +1,109 @@
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, StrictFloat, StrictInt, StrictStr
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 FuturesBalance(BaseModel):
26
+ """
27
+ Model for futures balance
28
+ """ # noqa: E501
29
+ api_key_id: StrictStr = Field(description="API key ID", alias="apiKeyId")
30
+ asset: StrictStr = Field(description="Asset/Currency code")
31
+ balance: Union[StrictFloat, StrictInt] = Field(description="Total balance/equity")
32
+ available: Union[StrictFloat, StrictInt] = Field(description="Available balance for trading/withdrawal")
33
+ unrealized_pnl: Union[StrictFloat, StrictInt] = Field(description="Unrealized profit and loss", alias="unrealizedPnl")
34
+ used_margin: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="usedMargin")
35
+ frozen_amount: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="frozenAmount")
36
+ __properties: ClassVar[List[str]] = ["apiKeyId", "asset", "balance", "available", "unrealizedPnl", "usedMargin", "frozenAmount"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of FuturesBalance from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ """
69
+ excluded_fields: Set[str] = set([
70
+ ])
71
+
72
+ _dict = self.model_dump(
73
+ by_alias=True,
74
+ exclude=excluded_fields,
75
+ exclude_none=True,
76
+ )
77
+ # set to None if used_margin (nullable) is None
78
+ # and model_fields_set contains the field
79
+ if self.used_margin is None and "used_margin" in self.model_fields_set:
80
+ _dict['usedMargin'] = None
81
+
82
+ # set to None if frozen_amount (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.frozen_amount is None and "frozen_amount" in self.model_fields_set:
85
+ _dict['frozenAmount'] = None
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of FuturesBalance from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "apiKeyId": obj.get("apiKeyId"),
100
+ "asset": obj.get("asset"),
101
+ "balance": obj.get("balance"),
102
+ "available": obj.get("available"),
103
+ "unrealizedPnl": obj.get("unrealizedPnl"),
104
+ "usedMargin": obj.get("usedMargin"),
105
+ "frozenAmount": obj.get("frozenAmount")
106
+ })
107
+ return _obj
108
+
109
+
@@ -0,0 +1,198 @@
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 FuturesTradingAction(BaseModel):
31
+ """
32
+ Model for futures trading actions
33
+ """ # noqa: E501
34
+ id: Optional[StrictStr] = None
35
+ execution_id: Optional[StrictStr] = None
36
+ open_order_execution_id: Optional[StrictStr] = None
37
+ client_order_id: Optional[StrictStr] = None
38
+ action_type: TradingActionType = Field(description="The type of action.")
39
+ market_type: MarketType = Field(description="The type of market the action is for.")
40
+ strategy_id: StrictStr = Field(description="UID for the strategy.")
41
+ symbol: StrictStr = Field(description="Trading symbol or asset pair in format: 'symbol/quote_currency' (see market service for valid symbols)")
42
+ is_limit: Optional[StrictBool] = None
43
+ limit_price: Optional[Union[StrictFloat, StrictInt]] = None
44
+ 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%.")
45
+ take_profit: Optional[List[TPSL]] = None
46
+ stop_loss: Optional[List[TPSL]] = None
47
+ expiry_timestamp: Optional[StrictInt] = None
48
+ position_id: Optional[StrictStr] = None
49
+ leverage: Optional[Annotated[int, Field(strict=True, ge=1)]]
50
+ margin_mode: Optional[MarginMode] = None
51
+ __properties: ClassVar[List[str]] = ["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"]
52
+
53
+ model_config = ConfigDict(
54
+ populate_by_name=True,
55
+ validate_assignment=True,
56
+ protected_namespaces=(),
57
+ )
58
+
59
+
60
+ def to_str(self) -> str:
61
+ """Returns the string representation of the model using alias"""
62
+ return pprint.pformat(self.model_dump(by_alias=True))
63
+
64
+ def to_json(self) -> str:
65
+ """Returns the JSON representation of the model using alias"""
66
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
67
+ return json.dumps(self.to_dict())
68
+
69
+ @classmethod
70
+ def from_json(cls, json_str: str) -> Optional[Self]:
71
+ """Create an instance of FuturesTradingAction from a JSON string"""
72
+ return cls.from_dict(json.loads(json_str))
73
+
74
+ def to_dict(self) -> Dict[str, Any]:
75
+ """Return the dictionary representation of the model using alias.
76
+
77
+ This has the following differences from calling pydantic's
78
+ `self.model_dump(by_alias=True)`:
79
+
80
+ * `None` is only added to the output dict for nullable fields that
81
+ were set at model initialization. Other fields with value `None`
82
+ are ignored.
83
+ """
84
+ excluded_fields: Set[str] = set([
85
+ ])
86
+
87
+ _dict = self.model_dump(
88
+ by_alias=True,
89
+ exclude=excluded_fields,
90
+ exclude_none=True,
91
+ )
92
+ # override the default output from pydantic by calling `to_dict()` of each item in take_profit (list)
93
+ _items = []
94
+ if self.take_profit:
95
+ for _item_take_profit in self.take_profit:
96
+ if _item_take_profit:
97
+ _items.append(_item_take_profit.to_dict())
98
+ _dict['take_profit'] = _items
99
+ # override the default output from pydantic by calling `to_dict()` of each item in stop_loss (list)
100
+ _items = []
101
+ if self.stop_loss:
102
+ for _item_stop_loss in self.stop_loss:
103
+ if _item_stop_loss:
104
+ _items.append(_item_stop_loss.to_dict())
105
+ _dict['stop_loss'] = _items
106
+ # set to None if id (nullable) is None
107
+ # and model_fields_set contains the field
108
+ if self.id is None and "id" in self.model_fields_set:
109
+ _dict['id'] = None
110
+
111
+ # set to None if execution_id (nullable) is None
112
+ # and model_fields_set contains the field
113
+ if self.execution_id is None and "execution_id" in self.model_fields_set:
114
+ _dict['execution_id'] = None
115
+
116
+ # set to None if open_order_execution_id (nullable) is None
117
+ # and model_fields_set contains the field
118
+ if self.open_order_execution_id is None and "open_order_execution_id" in self.model_fields_set:
119
+ _dict['open_order_execution_id'] = None
120
+
121
+ # set to None if client_order_id (nullable) is None
122
+ # and model_fields_set contains the field
123
+ if self.client_order_id is None and "client_order_id" in self.model_fields_set:
124
+ _dict['client_order_id'] = None
125
+
126
+ # set to None if is_limit (nullable) is None
127
+ # and model_fields_set contains the field
128
+ if self.is_limit is None and "is_limit" in self.model_fields_set:
129
+ _dict['is_limit'] = None
130
+
131
+ # set to None if limit_price (nullable) is None
132
+ # and model_fields_set contains the field
133
+ if self.limit_price is None and "limit_price" in self.model_fields_set:
134
+ _dict['limit_price'] = None
135
+
136
+ # set to None if take_profit (nullable) is None
137
+ # and model_fields_set contains the field
138
+ if self.take_profit is None and "take_profit" in self.model_fields_set:
139
+ _dict['take_profit'] = None
140
+
141
+ # set to None if stop_loss (nullable) is None
142
+ # and model_fields_set contains the field
143
+ if self.stop_loss is None and "stop_loss" in self.model_fields_set:
144
+ _dict['stop_loss'] = None
145
+
146
+ # set to None if expiry_timestamp (nullable) is None
147
+ # and model_fields_set contains the field
148
+ if self.expiry_timestamp is None and "expiry_timestamp" in self.model_fields_set:
149
+ _dict['expiry_timestamp'] = None
150
+
151
+ # set to None if position_id (nullable) is None
152
+ # and model_fields_set contains the field
153
+ if self.position_id is None and "position_id" in self.model_fields_set:
154
+ _dict['position_id'] = None
155
+
156
+ # set to None if leverage (nullable) is None
157
+ # and model_fields_set contains the field
158
+ if self.leverage is None and "leverage" in self.model_fields_set:
159
+ _dict['leverage'] = None
160
+
161
+ # set to None if margin_mode (nullable) is None
162
+ # and model_fields_set contains the field
163
+ if self.margin_mode is None and "margin_mode" in self.model_fields_set:
164
+ _dict['margin_mode'] = None
165
+
166
+ return _dict
167
+
168
+ @classmethod
169
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
170
+ """Create an instance of FuturesTradingAction from a dict"""
171
+ if obj is None:
172
+ return None
173
+
174
+ if not isinstance(obj, dict):
175
+ return cls.model_validate(obj)
176
+
177
+ _obj = cls.model_validate({
178
+ "id": obj.get("id"),
179
+ "execution_id": obj.get("execution_id"),
180
+ "open_order_execution_id": obj.get("open_order_execution_id"),
181
+ "client_order_id": obj.get("client_order_id"),
182
+ "action_type": obj.get("action_type"),
183
+ "market_type": obj.get("market_type"),
184
+ "strategy_id": obj.get("strategy_id"),
185
+ "symbol": obj.get("symbol"),
186
+ "is_limit": obj.get("is_limit"),
187
+ "limit_price": obj.get("limit_price"),
188
+ "allocation": obj.get("allocation"),
189
+ "take_profit": [TPSL.from_dict(_item) for _item in obj["take_profit"]] if obj.get("take_profit") is not None else None,
190
+ "stop_loss": [TPSL.from_dict(_item) for _item in obj["stop_loss"]] if obj.get("stop_loss") is not None else None,
191
+ "expiry_timestamp": obj.get("expiry_timestamp"),
192
+ "position_id": obj.get("position_id"),
193
+ "leverage": obj.get("leverage") if obj.get("leverage") is not None else 1,
194
+ "margin_mode": obj.get("margin_mode")
195
+ })
196
+ return _obj
197
+
198
+
@@ -0,0 +1,95 @@
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
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from crypticorn.trade.client.models.validation_error import ValidationError
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class HTTPValidationError(BaseModel):
27
+ """
28
+ HTTPValidationError
29
+ """ # noqa: E501
30
+ detail: Optional[List[ValidationError]] = None
31
+ __properties: ClassVar[List[str]] = ["detail"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of HTTPValidationError from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ # override the default output from pydantic by calling `to_dict()` of each item in detail (list)
73
+ _items = []
74
+ if self.detail:
75
+ for _item_detail in self.detail:
76
+ if _item_detail:
77
+ _items.append(_item_detail.to_dict())
78
+ _dict['detail'] = _items
79
+ return _dict
80
+
81
+ @classmethod
82
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83
+ """Create an instance of HTTPValidationError from a dict"""
84
+ if obj is None:
85
+ return None
86
+
87
+ if not isinstance(obj, dict):
88
+ return cls.model_validate(obj)
89
+
90
+ _obj = cls.model_validate({
91
+ "detail": [ValidationError.from_dict(_item) for _item in obj["detail"]] if obj.get("detail") is not None else None
92
+ })
93
+ return _obj
94
+
95
+
@@ -0,0 +1,37 @@
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 MarginMode(str, Enum):
22
+ """
23
+ Margin mode for futures trades
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ ISOLATED = 'isolated'
30
+ CROSS = 'cross'
31
+
32
+ @classmethod
33
+ def from_json(cls, json_str: str) -> Self:
34
+ """Create an instance of MarginMode from a JSON string"""
35
+ return cls(json.loads(json_str))
36
+
37
+