crypticorn 2.16.0__py3-none-any.whl → 2.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. crypticorn/__init__.py +2 -2
  2. crypticorn/auth/client/api/admin_api.py +397 -13
  3. crypticorn/auth/client/api/auth_api.py +3610 -341
  4. crypticorn/auth/client/api/service_api.py +249 -7
  5. crypticorn/auth/client/api/user_api.py +2295 -179
  6. crypticorn/auth/client/api/wallet_api.py +1468 -81
  7. crypticorn/auth/client/configuration.py +2 -2
  8. crypticorn/auth/client/models/create_api_key_request.py +2 -1
  9. crypticorn/auth/client/models/get_api_keys200_response_inner.py +2 -1
  10. crypticorn/auth/client/rest.py +23 -4
  11. crypticorn/auth/main.py +8 -5
  12. crypticorn/cli/init.py +1 -1
  13. crypticorn/cli/templates/.env.docker.temp +3 -0
  14. crypticorn/cli/templates/.env.example.temp +4 -0
  15. crypticorn/cli/templates/Dockerfile +5 -2
  16. crypticorn/client.py +226 -59
  17. crypticorn/common/__init__.py +1 -0
  18. crypticorn/common/auth.py +45 -14
  19. crypticorn/common/decorators.py +1 -2
  20. crypticorn/common/enums.py +0 -2
  21. crypticorn/common/errors.py +10 -0
  22. crypticorn/common/metrics.py +30 -0
  23. crypticorn/common/middleware.py +94 -1
  24. crypticorn/common/pagination.py +252 -20
  25. crypticorn/common/router/admin_router.py +2 -2
  26. crypticorn/common/router/status_router.py +40 -2
  27. crypticorn/common/scopes.py +2 -2
  28. crypticorn/common/warnings.py +7 -0
  29. crypticorn/dex/__init__.py +6 -0
  30. crypticorn/dex/client/__init__.py +49 -0
  31. crypticorn/dex/client/api/__init__.py +6 -0
  32. crypticorn/dex/client/api/admin_api.py +2986 -0
  33. crypticorn/dex/client/api/signals_api.py +1798 -0
  34. crypticorn/dex/client/api/status_api.py +892 -0
  35. crypticorn/dex/client/api_client.py +758 -0
  36. crypticorn/dex/client/api_response.py +20 -0
  37. crypticorn/dex/client/configuration.py +620 -0
  38. crypticorn/dex/client/exceptions.py +220 -0
  39. crypticorn/dex/client/models/__init__.py +30 -0
  40. crypticorn/dex/client/models/api_error_identifier.py +121 -0
  41. crypticorn/dex/client/models/api_error_level.py +37 -0
  42. crypticorn/dex/client/models/api_error_type.py +37 -0
  43. crypticorn/dex/client/models/exception_detail.py +117 -0
  44. crypticorn/dex/client/models/log_level.py +38 -0
  45. crypticorn/dex/client/models/paginated_response_signal_with_token.py +134 -0
  46. crypticorn/dex/client/models/risk.py +86 -0
  47. crypticorn/dex/client/models/signal_overview_stats.py +158 -0
  48. crypticorn/dex/client/models/signal_volume.py +84 -0
  49. crypticorn/dex/client/models/signal_with_token.py +163 -0
  50. crypticorn/dex/client/models/token_data.py +127 -0
  51. crypticorn/dex/client/models/token_detail.py +116 -0
  52. crypticorn/dex/client/py.typed +0 -0
  53. crypticorn/dex/client/rest.py +217 -0
  54. crypticorn/dex/main.py +1 -0
  55. crypticorn/hive/client/api/admin_api.py +1173 -47
  56. crypticorn/hive/client/api/data_api.py +499 -17
  57. crypticorn/hive/client/api/models_api.py +1595 -87
  58. crypticorn/hive/client/api/status_api.py +397 -16
  59. crypticorn/hive/client/api_client.py +0 -5
  60. crypticorn/hive/client/models/api_error_identifier.py +1 -1
  61. crypticorn/hive/client/models/coin_info.py +1 -1
  62. crypticorn/hive/client/models/exception_detail.py +1 -1
  63. crypticorn/hive/client/models/target_info.py +1 -1
  64. crypticorn/hive/client/rest.py +23 -4
  65. crypticorn/hive/main.py +99 -25
  66. crypticorn/hive/utils.py +2 -2
  67. crypticorn/klines/client/api/admin_api.py +1173 -47
  68. crypticorn/klines/client/api/change_in_timeframe_api.py +269 -11
  69. crypticorn/klines/client/api/funding_rates_api.py +315 -11
  70. crypticorn/klines/client/api/ohlcv_data_api.py +390 -11
  71. crypticorn/klines/client/api/status_api.py +397 -16
  72. crypticorn/klines/client/api/symbols_api.py +216 -11
  73. crypticorn/klines/client/api/udf_api.py +1268 -51
  74. crypticorn/klines/client/api_client.py +0 -5
  75. crypticorn/klines/client/models/api_error_identifier.py +3 -1
  76. crypticorn/klines/client/models/exception_detail.py +1 -1
  77. crypticorn/klines/client/models/ohlcv.py +1 -1
  78. crypticorn/klines/client/models/symbol_group.py +1 -1
  79. crypticorn/klines/client/models/udf_config.py +1 -1
  80. crypticorn/klines/client/rest.py +23 -4
  81. crypticorn/klines/main.py +89 -12
  82. crypticorn/metrics/client/api/admin_api.py +1173 -47
  83. crypticorn/metrics/client/api/exchanges_api.py +1370 -145
  84. crypticorn/metrics/client/api/indicators_api.py +622 -17
  85. crypticorn/metrics/client/api/logs_api.py +296 -11
  86. crypticorn/metrics/client/api/marketcap_api.py +1207 -67
  87. crypticorn/metrics/client/api/markets_api.py +343 -11
  88. crypticorn/metrics/client/api/quote_currencies_api.py +228 -11
  89. crypticorn/metrics/client/api/status_api.py +397 -16
  90. crypticorn/metrics/client/api/tokens_api.py +382 -15
  91. crypticorn/metrics/client/api_client.py +0 -5
  92. crypticorn/metrics/client/configuration.py +4 -2
  93. crypticorn/metrics/client/models/exception_detail.py +1 -1
  94. crypticorn/metrics/client/models/exchange_mapping.py +1 -1
  95. crypticorn/metrics/client/models/marketcap_ranking.py +1 -1
  96. crypticorn/metrics/client/models/marketcap_symbol_ranking.py +1 -1
  97. crypticorn/metrics/client/models/ohlcv.py +1 -1
  98. crypticorn/metrics/client/rest.py +23 -4
  99. crypticorn/metrics/main.py +113 -19
  100. crypticorn/pay/client/api/admin_api.py +1585 -57
  101. crypticorn/pay/client/api/now_payments_api.py +961 -39
  102. crypticorn/pay/client/api/payments_api.py +562 -17
  103. crypticorn/pay/client/api/products_api.py +880 -30
  104. crypticorn/pay/client/api/status_api.py +397 -16
  105. crypticorn/pay/client/api_client.py +0 -5
  106. crypticorn/pay/client/configuration.py +2 -2
  107. crypticorn/pay/client/models/api_error_identifier.py +7 -7
  108. crypticorn/pay/client/models/exception_detail.py +1 -1
  109. crypticorn/pay/client/models/now_create_invoice_req.py +1 -1
  110. crypticorn/pay/client/models/now_create_invoice_res.py +1 -1
  111. crypticorn/pay/client/models/product.py +1 -1
  112. crypticorn/pay/client/models/product_create.py +1 -1
  113. crypticorn/pay/client/models/product_update.py +1 -1
  114. crypticorn/pay/client/models/scope.py +1 -0
  115. crypticorn/pay/client/rest.py +23 -4
  116. crypticorn/pay/main.py +10 -6
  117. crypticorn/trade/client/__init__.py +11 -1
  118. crypticorn/trade/client/api/__init__.py +0 -1
  119. crypticorn/trade/client/api/admin_api.py +1184 -55
  120. crypticorn/trade/client/api/api_keys_api.py +1678 -162
  121. crypticorn/trade/client/api/bots_api.py +7563 -187
  122. crypticorn/trade/client/api/exchanges_api.py +565 -19
  123. crypticorn/trade/client/api/notifications_api.py +1290 -116
  124. crypticorn/trade/client/api/orders_api.py +393 -55
  125. crypticorn/trade/client/api/status_api.py +397 -13
  126. crypticorn/trade/client/api/strategies_api.py +1133 -77
  127. crypticorn/trade/client/api/trading_actions_api.py +786 -65
  128. crypticorn/trade/client/models/__init__.py +11 -0
  129. crypticorn/trade/client/models/actions_count.py +88 -0
  130. crypticorn/trade/client/models/api_error_identifier.py +1 -0
  131. crypticorn/trade/client/models/bot.py +7 -18
  132. crypticorn/trade/client/models/bot_create.py +17 -1
  133. crypticorn/trade/client/models/bot_update.py +17 -1
  134. crypticorn/trade/client/models/exchange.py +6 -1
  135. crypticorn/trade/client/models/exchange_key.py +1 -1
  136. crypticorn/trade/client/models/exchange_key_balance.py +111 -0
  137. crypticorn/trade/client/models/exchange_key_create.py +17 -1
  138. crypticorn/trade/client/models/exchange_key_update.py +17 -1
  139. crypticorn/trade/client/models/execution_ids.py +1 -1
  140. crypticorn/trade/client/models/futures_balance.py +27 -25
  141. crypticorn/trade/client/models/notification.py +17 -1
  142. crypticorn/trade/client/models/notification_create.py +18 -2
  143. crypticorn/trade/client/models/notification_update.py +17 -1
  144. crypticorn/trade/client/models/orders_count.py +88 -0
  145. crypticorn/trade/client/models/paginated_response_futures_trading_action.py +134 -0
  146. crypticorn/trade/client/models/paginated_response_order.py +134 -0
  147. crypticorn/trade/client/models/pn_l.py +95 -0
  148. crypticorn/trade/client/models/post_futures_action.py +1 -1
  149. crypticorn/trade/client/models/spot_balance.py +109 -0
  150. crypticorn/trade/client/models/strategy.py +22 -4
  151. crypticorn/trade/client/models/strategy_create.py +23 -5
  152. crypticorn/trade/client/models/strategy_exchange_info.py +16 -4
  153. crypticorn/trade/client/models/strategy_update.py +19 -3
  154. crypticorn/trade/client/models/tpsl.py +4 -19
  155. crypticorn/trade/client/models/tpsl_create.py +6 -19
  156. crypticorn/trade/client/rest.py +23 -4
  157. crypticorn/trade/main.py +15 -12
  158. {crypticorn-2.16.0.dist-info → crypticorn-2.17.0.dist-info}/METADATA +65 -20
  159. {crypticorn-2.16.0.dist-info → crypticorn-2.17.0.dist-info}/RECORD +163 -128
  160. crypticorn/trade/client/api/futures_trading_panel_api.py +0 -1285
  161. {crypticorn-2.16.0.dist-info → crypticorn-2.17.0.dist-info}/WHEEL +0 -0
  162. {crypticorn-2.16.0.dist-info → crypticorn-2.17.0.dist-info}/entry_points.txt +0 -0
  163. {crypticorn-2.16.0.dist-info → crypticorn-2.17.0.dist-info}/licenses/LICENSE +0 -0
  164. {crypticorn-2.16.0.dist-info → crypticorn-2.17.0.dist-info}/top_level.txt +0 -0
crypticorn/hive/main.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
  import os
3
3
  import asyncio
4
4
  from pathlib import Path
5
- from typing import TYPE_CHECKING, Optional
5
+ from typing import TYPE_CHECKING, Optional, Union, Coroutine, Any
6
6
  from crypticorn.hive import (
7
7
  ApiClient,
8
8
  Configuration,
@@ -20,12 +20,38 @@ if TYPE_CHECKING:
20
20
  from aiohttp import ClientSession
21
21
 
22
22
 
23
+ class HiveClient:
24
+ """
25
+ A client for interacting with the Crypticorn Hive API.
26
+ """
27
+
28
+ config_class = Configuration
29
+
30
+ def __init__(
31
+ self,
32
+ config: Configuration,
33
+ http_client: Optional[ClientSession] = None,
34
+ is_sync: bool = False,
35
+ ):
36
+ self.config = config
37
+ self.base_client = ApiClient(configuration=self.config)
38
+ if http_client is not None:
39
+ self.base_client.rest_client.pool_manager = http_client
40
+ # Pass sync context to REST client for proper session management
41
+ self.base_client.rest_client.is_sync = is_sync
42
+ # Instantiate all the endpoint clients
43
+ self.models = ModelsApi(self.base_client, is_sync=is_sync)
44
+ self.data = DataApiWrapper(self.base_client, is_sync=is_sync)
45
+ self.status = StatusApi(self.base_client, is_sync=is_sync)
46
+ self.admin = AdminApi(self.base_client, is_sync=is_sync)
47
+
48
+
23
49
  class DataApiWrapper(DataApi):
24
50
  """
25
51
  A wrapper for the DataApi class.
26
52
  """
27
53
 
28
- async def download_data(
54
+ def download_data(
29
55
  self,
30
56
  model_id: StrictInt,
31
57
  folder: Path = Path("data"),
@@ -33,17 +59,86 @@ class DataApiWrapper(DataApi):
33
59
  feature_size: Optional[FeatureSize] = None,
34
60
  *args,
35
61
  **kwargs,
36
- ) -> list[Path]:
62
+ ) -> Union[list[Path], Coroutine[Any, Any, list[Path]]]:
37
63
  """
38
64
  Download data for model training. All three files (y_train, x_test, x_train) are downloaded and saved under e.g. FOLDER/v1/coin_1/*.feather.
39
65
  The folder will be created if it doesn't exist.
66
+ Works in both sync and async contexts.
40
67
 
41
68
  :param model_id: Model ID (required) (type: int)
42
69
  :param version: Data version. Default is the latest public version. (optional) (type: DataVersion)
43
70
  :param feature_size: The number of features in the data. Default is LARGE. (optional) (type: FeatureSize)
44
71
  :return: A list of paths to the downloaded files.
45
72
  """
46
- response = await super().download_data(
73
+ if self.is_sync:
74
+ return self._download_data_wrapper_sync(
75
+ model_id=model_id,
76
+ folder=folder,
77
+ version=version,
78
+ feature_size=feature_size,
79
+ *args,
80
+ **kwargs,
81
+ )
82
+ else:
83
+ return self._download_data_wrapper_async(
84
+ model_id=model_id,
85
+ folder=folder,
86
+ version=version,
87
+ feature_size=feature_size,
88
+ *args,
89
+ **kwargs,
90
+ )
91
+
92
+ def _download_data_wrapper_sync(
93
+ self,
94
+ model_id: StrictInt,
95
+ folder: Path = Path("data"),
96
+ version: Optional[DataVersion] = None,
97
+ feature_size: Optional[FeatureSize] = None,
98
+ *args,
99
+ **kwargs,
100
+ ) -> list[Path]:
101
+ """
102
+ Download data for model training (sync version).
103
+ """
104
+ response = self._download_data_sync(
105
+ model_id=model_id,
106
+ version=version,
107
+ feature_size=feature_size,
108
+ *args,
109
+ **kwargs,
110
+ )
111
+ base_path = f"{folder}/v{response.version.value}/coin_{response.coin.value}/"
112
+ os.makedirs(base_path, exist_ok=True)
113
+
114
+ return [
115
+ download_file(
116
+ url=response.links.y_train,
117
+ dest_path=base_path + "y_train_" + response.target + ".feather",
118
+ ),
119
+ download_file(
120
+ url=response.links.x_test,
121
+ dest_path=base_path + "x_test_" + response.feature_size + ".feather",
122
+ ),
123
+ download_file(
124
+ url=response.links.x_train,
125
+ dest_path=base_path + "x_train_" + response.feature_size + ".feather",
126
+ ),
127
+ ]
128
+
129
+ async def _download_data_wrapper_async(
130
+ self,
131
+ model_id: StrictInt,
132
+ folder: Path = Path("data"),
133
+ version: Optional[DataVersion] = None,
134
+ feature_size: Optional[FeatureSize] = None,
135
+ *args,
136
+ **kwargs,
137
+ ) -> list[Path]:
138
+ """
139
+ Download data for model training (async version).
140
+ """
141
+ response = await self._download_data_async(
47
142
  model_id=model_id,
48
143
  version=version,
49
144
  feature_size=feature_size,
@@ -75,24 +170,3 @@ class DataApiWrapper(DataApi):
75
170
  ),
76
171
  ]
77
172
  )
78
-
79
-
80
- class HiveClient:
81
- """
82
- A client for interacting with the Crypticorn Hive API.
83
- """
84
-
85
- config_class = Configuration
86
-
87
- def __init__(
88
- self, config: Configuration, http_client: Optional[ClientSession] = None
89
- ):
90
- self.config = config
91
- self.base_client = ApiClient(configuration=self.config)
92
- if http_client is not None:
93
- self.base_client.rest_client.pool_manager = http_client
94
- # Instantiate all the endpoint clients
95
- self.models = ModelsApi(self.base_client)
96
- self.data = DataApiWrapper(self.base_client)
97
- self.status = StatusApi(self.base_client)
98
- self.admin = AdminApi(self.base_client)
crypticorn/hive/utils.py CHANGED
@@ -28,7 +28,7 @@ async def download_file(
28
28
 
29
29
  if file_size < total_size:
30
30
  # Download incomplete
31
- logger.info(f" resuming download")
31
+ logger.info(" resuming download")
32
32
  resume_header = {"Range": f"bytes={file_size}-"}
33
33
  req = requests.get(
34
34
  url,
@@ -45,7 +45,7 @@ async def download_file(
45
45
  file_size = 0
46
46
  else:
47
47
  # File does not exist, starting download
48
- logger.info(f" starting download")
48
+ logger.info(" starting download")
49
49
 
50
50
  # write dataset to file and show progress bar
51
51
  pbar = tqdm.tqdm(