crypticorn 2.17.0rc1__py3-none-any.whl → 2.17.0rc2__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 (86) hide show
  1. crypticorn/__init__.py +2 -2
  2. crypticorn/auth/client/api/admin_api.py +415 -13
  3. crypticorn/auth/client/api/auth_api.py +2622 -113
  4. crypticorn/auth/client/api/service_api.py +258 -7
  5. crypticorn/auth/client/api/user_api.py +2485 -270
  6. crypticorn/auth/client/api/wallet_api.py +1518 -77
  7. crypticorn/auth/client/models/create_api_key_request.py +2 -1
  8. crypticorn/auth/client/models/get_api_keys200_response_inner.py +2 -1
  9. crypticorn/auth/client/rest.py +23 -4
  10. crypticorn/auth/main.py +8 -5
  11. crypticorn/client.py +227 -59
  12. crypticorn/common/__init__.py +0 -1
  13. crypticorn/common/metrics.py +4 -6
  14. crypticorn/common/middleware.py +10 -5
  15. crypticorn/common/pagination.py +137 -18
  16. crypticorn/common/router/admin_router.py +1 -1
  17. crypticorn/common/utils.py +2 -1
  18. crypticorn/common/warnings.py +1 -0
  19. crypticorn/hive/client/api/admin_api.py +1234 -51
  20. crypticorn/hive/client/api/data_api.py +517 -13
  21. crypticorn/hive/client/api/models_api.py +1657 -83
  22. crypticorn/hive/client/api/status_api.py +415 -13
  23. crypticorn/hive/client/models/api_error_identifier.py +1 -1
  24. crypticorn/hive/client/rest.py +23 -4
  25. crypticorn/hive/main.py +99 -25
  26. crypticorn/klines/client/api/admin_api.py +1234 -51
  27. crypticorn/klines/client/api/change_in_timeframe_api.py +278 -7
  28. crypticorn/klines/client/api/funding_rates_api.py +324 -7
  29. crypticorn/klines/client/api/ohlcv_data_api.py +399 -7
  30. crypticorn/klines/client/api/status_api.py +415 -13
  31. crypticorn/klines/client/api/symbols_api.py +225 -7
  32. crypticorn/klines/client/api/udf_api.py +1393 -120
  33. crypticorn/klines/client/models/api_error_identifier.py +3 -1
  34. crypticorn/klines/client/rest.py +23 -4
  35. crypticorn/klines/main.py +89 -12
  36. crypticorn/metrics/client/api/admin_api.py +1234 -51
  37. crypticorn/metrics/client/api/exchanges_api.py +1405 -140
  38. crypticorn/metrics/client/api/indicators_api.py +640 -13
  39. crypticorn/metrics/client/api/logs_api.py +305 -7
  40. crypticorn/metrics/client/api/marketcap_api.py +1240 -60
  41. crypticorn/metrics/client/api/markets_api.py +352 -7
  42. crypticorn/metrics/client/api/quote_currencies_api.py +237 -7
  43. crypticorn/metrics/client/api/status_api.py +415 -13
  44. crypticorn/metrics/client/api/tokens_api.py +400 -13
  45. crypticorn/metrics/client/configuration.py +4 -2
  46. crypticorn/metrics/client/rest.py +23 -4
  47. crypticorn/metrics/main.py +113 -19
  48. crypticorn/pay/client/api/admin_api.py +1720 -126
  49. crypticorn/pay/client/api/now_payments_api.py +1013 -42
  50. crypticorn/pay/client/api/payments_api.py +580 -13
  51. crypticorn/pay/client/api/products_api.py +915 -25
  52. crypticorn/pay/client/api/status_api.py +415 -13
  53. crypticorn/pay/client/configuration.py +2 -2
  54. crypticorn/pay/client/models/api_error_identifier.py +7 -7
  55. crypticorn/pay/client/models/scope.py +1 -0
  56. crypticorn/pay/client/rest.py +23 -4
  57. crypticorn/pay/main.py +10 -6
  58. crypticorn/trade/client/__init__.py +2 -1
  59. crypticorn/trade/client/api/__init__.py +0 -1
  60. crypticorn/trade/client/api/admin_api.py +1718 -123
  61. crypticorn/trade/client/api/api_keys_api.py +1596 -103
  62. crypticorn/trade/client/api/bots_api.py +1106 -47
  63. crypticorn/trade/client/api/exchanges_api.py +592 -19
  64. crypticorn/trade/client/api/notifications_api.py +1340 -112
  65. crypticorn/trade/client/api/orders_api.py +240 -7
  66. crypticorn/trade/client/api/status_api.py +415 -13
  67. crypticorn/trade/client/api/strategies_api.py +1170 -69
  68. crypticorn/trade/client/api/trading_actions_api.py +650 -19
  69. crypticorn/trade/client/models/__init__.py +2 -0
  70. crypticorn/trade/client/models/exchange.py +6 -1
  71. crypticorn/trade/client/models/exchange_key_balance.py +111 -0
  72. crypticorn/trade/client/models/futures_balance.py +27 -25
  73. crypticorn/trade/client/models/spot_balance.py +110 -0
  74. crypticorn/trade/client/models/strategy.py +5 -3
  75. crypticorn/trade/client/models/strategy_create.py +6 -4
  76. crypticorn/trade/client/models/strategy_exchange_info.py +16 -4
  77. crypticorn/trade/client/models/strategy_update.py +2 -2
  78. crypticorn/trade/client/rest.py +23 -4
  79. crypticorn/trade/main.py +15 -12
  80. {crypticorn-2.17.0rc1.dist-info → crypticorn-2.17.0rc2.dist-info}/METADATA +64 -20
  81. {crypticorn-2.17.0rc1.dist-info → crypticorn-2.17.0rc2.dist-info}/RECORD +85 -84
  82. crypticorn/trade/client/api/futures_trading_panel_api.py +0 -1285
  83. {crypticorn-2.17.0rc1.dist-info → crypticorn-2.17.0rc2.dist-info}/WHEEL +0 -0
  84. {crypticorn-2.17.0rc1.dist-info → crypticorn-2.17.0rc2.dist-info}/entry_points.txt +0 -0
  85. {crypticorn-2.17.0rc1.dist-info → crypticorn-2.17.0rc2.dist-info}/licenses/LICENSE +0 -0
  86. {crypticorn-2.17.0rc1.dist-info → crypticorn-2.17.0rc2.dist-info}/top_level.txt +0 -0
@@ -68,17 +68,19 @@ class ApiErrorIdentifier(str, Enum):
68
68
  INVALID_EXCHANGE_KEY = "invalid_exchange_key"
69
69
  INVALID_MARGIN_MODE = "invalid_margin_mode"
70
70
  INVALID_MODEL_NAME = "invalid_model_name"
71
- INVALID_PARAMETER_PROVIDED = "exchange_invalid_parameter"
71
+ INVALID_PARAMETER_PROVIDED = "invalid_parameter_provided"
72
72
  LEVERAGE_LIMIT_EXCEEDED = "leverage_limit_exceeded"
73
73
  ORDER_VIOLATES_LIQUIDATION_PRICE_CONSTRAINTS = (
74
74
  "order_violates_liquidation_price_constraints"
75
75
  )
76
+ MARGIN_MODE_CLASH = "margin_mode_clash"
76
77
  MODEL_NAME_NOT_UNIQUE = "model_name_not_unique"
77
78
  NO_CREDENTIALS = "no_credentials"
78
79
  NOW_API_DOWN = "now_api_down"
79
80
  OBJECT_ALREADY_EXISTS = "object_already_exists"
80
81
  OBJECT_CREATED = "object_created"
81
82
  OBJECT_DELETED = "object_deleted"
83
+ OBJECT_LOCKED = "object_locked"
82
84
  OBJECT_NOT_FOUND = "object_not_found"
83
85
  OBJECT_UPDATED = "object_updated"
84
86
  ORDER_IS_ALREADY_FILLED = "order_is_already_filled"
@@ -77,6 +77,7 @@ class RESTClientObject:
77
77
 
78
78
  self.pool_manager: Optional[aiohttp.ClientSession] = None
79
79
  self.retry_client: Optional[aiohttp_retry.RetryClient] = None
80
+ self.is_sync: bool = False # Track whether this is sync or async mode
80
81
 
81
82
  async def close(self) -> None:
82
83
  if self.pool_manager:
@@ -170,7 +171,9 @@ class RESTClientObject:
170
171
 
171
172
  pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient]
172
173
 
173
- # https pool manager
174
+ # For sync operations, always use a fresh session
175
+ should_close_session = False
176
+
174
177
  if self.pool_manager is None:
175
178
  self.pool_manager = aiohttp.ClientSession(
176
179
  connector=aiohttp.TCPConnector(
@@ -178,6 +181,9 @@ class RESTClientObject:
178
181
  ),
179
182
  trust_env=True,
180
183
  )
184
+ # Only close session automatically in sync mode
185
+ should_close_session = self.is_sync
186
+
181
187
  pool_manager = self.pool_manager
182
188
 
183
189
  if self.retries is not None and method in ALLOW_RETRY_METHODS:
@@ -193,6 +199,19 @@ class RESTClientObject:
193
199
  )
194
200
  pool_manager = self.retry_client
195
201
 
196
- r = await pool_manager.request(**args)
197
-
198
- return RESTResponse(r)
202
+ try:
203
+ r = await pool_manager.request(**args)
204
+ # For sessions we're about to close, read the data immediately
205
+ if should_close_session:
206
+ response = RESTResponse(r)
207
+ await response.read() # Read data before closing session
208
+ return response
209
+ else:
210
+ return RESTResponse(r)
211
+ finally:
212
+ if should_close_session:
213
+ if self.retry_client is not None:
214
+ await self.retry_client.close()
215
+ self.retry_client = None
216
+ await self.pool_manager.close()
217
+ self.pool_manager = None
crypticorn/klines/main.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from __future__ import annotations
2
- from typing import TYPE_CHECKING, Optional
2
+ from typing import TYPE_CHECKING, Optional, Union, Coroutine, Any
3
3
  from crypticorn.klines import (
4
4
  ApiClient,
5
5
  Configuration,
@@ -26,17 +26,20 @@ class KlinesClient:
26
26
  self,
27
27
  config: Configuration,
28
28
  http_client: Optional[ClientSession] = None,
29
+ is_sync: bool = False,
29
30
  ):
30
31
  self.config = config
31
32
  self.base_client = ApiClient(configuration=self.config)
32
33
  if http_client is not None:
33
34
  self.base_client.rest_client.pool_manager = http_client
35
+ # Pass sync context to REST client for proper session management
36
+ self.base_client.rest_client.is_sync = is_sync
34
37
  # Instantiate all the endpoint clients
35
- self.funding = FundingRatesApiWrapper(self.base_client)
36
- self.ohlcv = OHLCVDataApiWrapper(self.base_client)
37
- self.symbols = SymbolsApiWrapper(self.base_client)
38
- self.udf = UDFApi(self.base_client)
39
- self.status = StatusApi(self.base_client)
38
+ self.funding = FundingRatesApiWrapper(self.base_client, is_sync=is_sync)
39
+ self.ohlcv = OHLCVDataApiWrapper(self.base_client, is_sync=is_sync)
40
+ self.symbols = SymbolsApiWrapper(self.base_client, is_sync=is_sync)
41
+ self.udf = UDFApi(self.base_client, is_sync=is_sync)
42
+ self.status = StatusApi(self.base_client, is_sync=is_sync)
40
43
 
41
44
 
42
45
  class FundingRatesApiWrapper(FundingRatesApi):
@@ -44,12 +47,38 @@ class FundingRatesApiWrapper(FundingRatesApi):
44
47
  A wrapper for the FundingRatesApi class.
45
48
  """
46
49
 
47
- async def get_funding_rates_fmt(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
50
+ def get_funding_rates_fmt(self, *args, **kwargs) -> Union[pd.DataFrame, Coroutine[Any, Any, pd.DataFrame]]: # type: ignore
48
51
  """
49
52
  Get the funding rates in a pandas DataFrame.
53
+ Works in both sync and async contexts.
54
+ """
55
+ if self.is_sync:
56
+ return self._get_funding_rates_fmt_sync(*args, **kwargs)
57
+ else:
58
+ return self._get_funding_rates_fmt_async(*args, **kwargs)
59
+
60
+ def _get_funding_rates_fmt_sync(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
61
+ """
62
+ Get the funding rates in a pandas DataFrame (sync version).
63
+ """
64
+ pd = optional_import("pandas", "extra")
65
+ response = self._get_funding_rates_sync(*args, **kwargs)
66
+ response = [
67
+ {
68
+ "timestamp": int(m.timestamp.timestamp()),
69
+ "symbol": m.symbol,
70
+ "funding_rate": m.funding_rate,
71
+ }
72
+ for m in response
73
+ ]
74
+ return pd.DataFrame(response)
75
+
76
+ async def _get_funding_rates_fmt_async(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
77
+ """
78
+ Get the funding rates in a pandas DataFrame (async version).
50
79
  """
51
80
  pd = optional_import("pandas", "extra")
52
- response = await self.get_funding_rates(*args, **kwargs)
81
+ response = await self._get_funding_rates_async(*args, **kwargs)
53
82
  response = [
54
83
  {
55
84
  "timestamp": int(m.timestamp.timestamp()),
@@ -66,12 +95,42 @@ class OHLCVDataApiWrapper(OHLCVDataApi):
66
95
  A wrapper for the OHLCVDataApi class.
67
96
  """
68
97
 
69
- async def get_ohlcv_data_fmt(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
98
+ def get_ohlcv_data_fmt(self, *args, **kwargs) -> Union[pd.DataFrame, Coroutine[Any, Any, pd.DataFrame]]: # type: ignore
70
99
  """
71
100
  Get the OHLCV data in a pandas DataFrame.
101
+ Works in both sync and async contexts.
102
+ """
103
+ if self.is_sync:
104
+ return self._get_ohlcv_data_fmt_sync(*args, **kwargs)
105
+ else:
106
+ return self._get_ohlcv_data_fmt_async(*args, **kwargs)
107
+
108
+ def _get_ohlcv_data_fmt_sync(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
109
+ """
110
+ Get the OHLCV data in a pandas DataFrame (sync version).
111
+ """
112
+ pd = optional_import("pandas", "extra")
113
+ response = self._get_ohlcv_sync(*args, **kwargs)
114
+ rows = []
115
+ for item in response:
116
+ row = {
117
+ "timestamp": item.timestamp,
118
+ "open": item.open,
119
+ "high": item.high,
120
+ "low": item.low,
121
+ "close": item.close,
122
+ "volume": item.volume,
123
+ }
124
+ rows.append(row)
125
+ df = pd.DataFrame(rows)
126
+ return df
127
+
128
+ async def _get_ohlcv_data_fmt_async(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
129
+ """
130
+ Get the OHLCV data in a pandas DataFrame (async version).
72
131
  """
73
132
  pd = optional_import("pandas", "extra")
74
- response = await self.get_ohlcv(*args, **kwargs)
133
+ response = await self._get_ohlcv_async(*args, **kwargs)
75
134
  rows = []
76
135
  for item in response:
77
136
  row = {
@@ -92,10 +151,28 @@ class SymbolsApiWrapper(SymbolsApi):
92
151
  A wrapper for the SymbolsApi class.
93
152
  """
94
153
 
95
- async def get_symbols_fmt(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
154
+ def get_symbols_fmt(self, *args, **kwargs) -> Union[pd.DataFrame, Coroutine[Any, Any, pd.DataFrame]]: # type: ignore
96
155
  """
97
156
  Get the symbols in a pandas DataFrame.
157
+ Works in both sync and async contexts.
158
+ """
159
+ if self.is_sync:
160
+ return self._get_symbols_fmt_sync(*args, **kwargs)
161
+ else:
162
+ return self._get_symbols_fmt_async(*args, **kwargs)
163
+
164
+ def _get_symbols_fmt_sync(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
165
+ """
166
+ Get the symbols in a pandas DataFrame (sync version).
167
+ """
168
+ pd = optional_import("pandas", "extra")
169
+ response = self._get_klines_symbols_sync(*args, **kwargs)
170
+ return pd.DataFrame(response, columns=["symbol"])
171
+
172
+ async def _get_symbols_fmt_async(self, *args, **kwargs) -> pd.DataFrame: # type: ignore
173
+ """
174
+ Get the symbols in a pandas DataFrame (async version).
98
175
  """
99
176
  pd = optional_import("pandas", "extra")
100
- response = await self.get_klines_symbols(*args, **kwargs)
177
+ response = await self._get_klines_symbols_async(*args, **kwargs)
101
178
  return pd.DataFrame(response, columns=["symbol"])