crypticorn 2.12.1__tar.gz → 2.13.1__tar.gz

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 (310) hide show
  1. {crypticorn-2.12.1 → crypticorn-2.13.1}/CHANGELOG.md +28 -0
  2. {crypticorn-2.12.1/crypticorn.egg-info → crypticorn-2.13.1}/PKG-INFO +30 -3
  3. {crypticorn-2.12.1 → crypticorn-2.13.1}/README.md +29 -2
  4. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/create_user_request.py +4 -16
  5. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/main.py +8 -0
  6. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/client.py +26 -22
  7. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/auth.py +44 -12
  8. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/errors.py +79 -76
  9. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/configuration.py +2 -2
  10. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/api_error_identifier.py +2 -2
  11. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/main.py +9 -5
  12. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/api_error_identifier.py +1 -1
  13. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/main.py +7 -0
  14. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/exchanges_api.py +343 -0
  15. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/configuration.py +4 -2
  16. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/api_error_identifier.py +9 -3
  17. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/main.py +8 -3
  18. crypticorn-2.12.1/crypticorn/trade/client/api/strategies_api.py → crypticorn-2.13.1/crypticorn/pay/client/api/products_api.py +189 -167
  19. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/configuration.py +2 -2
  20. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/api_error_identifier.py +7 -3
  21. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/main.py +7 -0
  22. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/__init__.py +1 -0
  23. crypticorn-2.13.1/crypticorn/trade/client/api/strategies_api.py +1326 -0
  24. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/trading_actions_api.py +4 -4
  25. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/__init__.py +1 -0
  26. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/api_error_identifier.py +6 -2
  27. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/futures_trading_action.py +23 -37
  28. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/futures_trading_action_create.py +28 -42
  29. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/order.py +40 -34
  30. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/spot_trading_action_create.py +10 -25
  31. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/strategy_exchange_info.py +3 -3
  32. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/tpsl.py +7 -16
  33. crypticorn-2.13.1/crypticorn/trade/client/models/tpsl_create.py +103 -0
  34. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/main.py +8 -2
  35. {crypticorn-2.12.1 → crypticorn-2.13.1/crypticorn.egg-info}/PKG-INFO +30 -3
  36. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn.egg-info/SOURCES.txt +4 -1
  37. {crypticorn-2.12.1 → crypticorn-2.13.1}/pyproject.toml +2 -2
  38. {crypticorn-2.12.1 → crypticorn-2.13.1}/tests/test_auth_client.py +0 -9
  39. crypticorn-2.13.1/tests/test_basic_client.py +39 -0
  40. {crypticorn-2.12.1 → crypticorn-2.13.1}/tests/test_config.py +2 -3
  41. crypticorn-2.13.1/tests/test_shared_aiohttp_client.py +28 -0
  42. crypticorn-2.12.1/crypticorn/pay/client/api/products_api.py +0 -851
  43. {crypticorn-2.12.1 → crypticorn-2.13.1}/LICENSE +0 -0
  44. {crypticorn-2.12.1 → crypticorn-2.13.1}/MANIFEST.in +0 -0
  45. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/__init__.py +0 -0
  46. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/__init__.py +0 -0
  47. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/__init__.py +0 -0
  48. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api/__init__.py +0 -0
  49. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api/admin_api.py +0 -0
  50. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api/auth_api.py +0 -0
  51. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api/service_api.py +0 -0
  52. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api/user_api.py +0 -0
  53. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api/wallet_api.py +0 -0
  54. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api_client.py +0 -0
  55. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/api_response.py +0 -0
  56. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/configuration.py +0 -0
  57. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/exceptions.py +0 -0
  58. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/__init__.py +0 -0
  59. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/add_wallet200_response.py +0 -0
  60. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/add_wallet_request.py +0 -0
  61. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/authorize_user200_response.py +0 -0
  62. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/authorize_user200_response_auth.py +0 -0
  63. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/authorize_user_request.py +0 -0
  64. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/create_api_key200_response.py +0 -0
  65. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/create_api_key_request.py +0 -0
  66. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/get_api_keys200_response_inner.py +0 -0
  67. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response.py +0 -0
  68. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response_balances_inner.py +0 -0
  69. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response_balances_inner_sale_round.py +0 -0
  70. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet.py +0 -0
  71. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet_vesting_wallets_inner.py +0 -0
  72. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response_data_inner.py +0 -0
  73. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/list_wallets200_response_user_value.py +0 -0
  74. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/logout_default_response.py +0 -0
  75. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/logout_default_response_issues_inner.py +0 -0
  76. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/oauth_callback200_response.py +0 -0
  77. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/oauth_callback200_response_user.py +0 -0
  78. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/refresh_token_info200_response.py +0 -0
  79. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/refresh_token_info200_response_user_session.py +0 -0
  80. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/resend_verification_email_request.py +0 -0
  81. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/revoke_user_tokens_request.py +0 -0
  82. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/rotate_tokens200_response.py +0 -0
  83. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/token_info200_response.py +0 -0
  84. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/unlink_wallet_request.py +0 -0
  85. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/update_user_request.py +0 -0
  86. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/user_by_username200_response.py +0 -0
  87. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/user_reset_password_request.py +0 -0
  88. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/user_set_password_request.py +0 -0
  89. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/verify200_response.py +0 -0
  90. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/verify_email200_response.py +0 -0
  91. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/verify_email200_response_auth.py +0 -0
  92. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/verify_email200_response_auth_auth.py +0 -0
  93. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/verify_email_request.py +0 -0
  94. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/verify_wallet_request.py +0 -0
  95. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/wallet_verified200_response.py +0 -0
  96. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/models/whoami200_response.py +0 -0
  97. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/py.typed +0 -0
  98. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/auth/client/rest.py +0 -0
  99. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/__init__.py +0 -0
  100. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/__main__.py +0 -0
  101. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/init.py +0 -0
  102. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/templates/Dockerfile +0 -0
  103. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/templates/__init__.py +0 -0
  104. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/templates/auth.py +0 -0
  105. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/templates/dependabot.yml +0 -0
  106. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/templates/merge-env.sh +0 -0
  107. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/templates/ruff.yml +0 -0
  108. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/cli/version.py +0 -0
  109. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/__init__.py +0 -0
  110. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/ansi_colors.py +0 -0
  111. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/decorators.py +0 -0
  112. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/enums.py +0 -0
  113. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/exceptions.py +0 -0
  114. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/logging.py +0 -0
  115. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/middleware.py +0 -0
  116. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/mixins.py +0 -0
  117. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/openapi.py +0 -0
  118. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/pagination.py +0 -0
  119. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/router/admin_router.py +0 -0
  120. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/router/status_router.py +0 -0
  121. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/scopes.py +0 -0
  122. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/urls.py +0 -0
  123. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/utils.py +0 -0
  124. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/common/warnings.py +0 -0
  125. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/__init__.py +0 -0
  126. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/__init__.py +0 -0
  127. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api/__init__.py +0 -0
  128. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api/admin_api.py +0 -0
  129. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api/data_api.py +0 -0
  130. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api/models_api.py +0 -0
  131. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api/status_api.py +0 -0
  132. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api_client.py +0 -0
  133. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/api_response.py +0 -0
  134. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/exceptions.py +0 -0
  135. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/__init__.py +0 -0
  136. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/api_error_level.py +0 -0
  137. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/api_error_type.py +0 -0
  138. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/coin_info.py +0 -0
  139. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/coins.py +0 -0
  140. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/data_download_response.py +0 -0
  141. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/data_info.py +0 -0
  142. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/data_options.py +0 -0
  143. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/data_version.py +0 -0
  144. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/data_version_info.py +0 -0
  145. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/download_links.py +0 -0
  146. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/evaluation.py +0 -0
  147. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/evaluation_response.py +0 -0
  148. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/exception_detail.py +0 -0
  149. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/feature_size.py +0 -0
  150. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/log_level.py +0 -0
  151. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/model_create.py +0 -0
  152. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/model_read.py +0 -0
  153. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/model_status.py +0 -0
  154. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/model_update.py +0 -0
  155. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/target.py +0 -0
  156. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/target_info.py +0 -0
  157. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/models/target_type.py +0 -0
  158. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/py.typed +0 -0
  159. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/client/rest.py +0 -0
  160. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/hive/utils.py +0 -0
  161. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/__init__.py +0 -0
  162. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/__init__.py +0 -0
  163. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/__init__.py +0 -0
  164. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/admin_api.py +0 -0
  165. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/change_in_timeframe_api.py +0 -0
  166. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/funding_rates_api.py +0 -0
  167. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/ohlcv_data_api.py +0 -0
  168. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/status_api.py +0 -0
  169. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/symbols_api.py +0 -0
  170. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api/udf_api.py +0 -0
  171. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api_client.py +0 -0
  172. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/api_response.py +0 -0
  173. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/configuration.py +0 -0
  174. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/exceptions.py +0 -0
  175. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/__init__.py +0 -0
  176. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/api_error_level.py +0 -0
  177. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/api_error_type.py +0 -0
  178. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/change_in_timeframe.py +0 -0
  179. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/exception_detail.py +0 -0
  180. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/funding_rate.py +0 -0
  181. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/funding_rate_response.py +0 -0
  182. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/internal_exchange.py +0 -0
  183. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/log_level.py +0 -0
  184. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/market_type.py +0 -0
  185. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/ohlcv.py +0 -0
  186. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/resolution.py +0 -0
  187. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/search_symbol.py +0 -0
  188. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/sort_direction.py +0 -0
  189. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/symbol_group.py +0 -0
  190. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/symbol_info.py +0 -0
  191. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/symbol_type.py +0 -0
  192. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/timeframe.py +0 -0
  193. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/models/udf_config.py +0 -0
  194. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/py.typed +0 -0
  195. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/klines/client/rest.py +0 -0
  196. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/__init__.py +0 -0
  197. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/__init__.py +0 -0
  198. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/__init__.py +0 -0
  199. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/admin_api.py +0 -0
  200. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/indicators_api.py +0 -0
  201. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/logs_api.py +0 -0
  202. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/marketcap_api.py +0 -0
  203. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/markets_api.py +0 -0
  204. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/quote_currencies_api.py +0 -0
  205. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/status_api.py +0 -0
  206. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api/tokens_api.py +0 -0
  207. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api_client.py +0 -0
  208. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/api_response.py +0 -0
  209. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/exceptions.py +0 -0
  210. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/__init__.py +0 -0
  211. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/api_error_level.py +0 -0
  212. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/api_error_type.py +0 -0
  213. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/exception_detail.py +0 -0
  214. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/exchange_availability.py +0 -0
  215. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/exchange_mapping.py +0 -0
  216. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/internal_exchange.py +0 -0
  217. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/log_level.py +0 -0
  218. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/market_type.py +0 -0
  219. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/marketcap_ranking.py +0 -0
  220. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/marketcap_symbol_ranking.py +0 -0
  221. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/ohlcv.py +0 -0
  222. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/severity.py +0 -0
  223. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/time_interval.py +0 -0
  224. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/models/trading_status.py +0 -0
  225. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/py.typed +0 -0
  226. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/metrics/client/rest.py +0 -0
  227. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/__init__.py +0 -0
  228. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/__init__.py +0 -0
  229. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api/__init__.py +0 -0
  230. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api/admin_api.py +0 -0
  231. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api/now_payments_api.py +0 -0
  232. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api/payments_api.py +0 -0
  233. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api/status_api.py +0 -0
  234. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api_client.py +0 -0
  235. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/api_response.py +0 -0
  236. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/exceptions.py +0 -0
  237. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/__init__.py +0 -0
  238. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/api_error_level.py +0 -0
  239. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/api_error_type.py +0 -0
  240. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/exception_detail.py +0 -0
  241. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/log_level.py +0 -0
  242. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/now_create_invoice_req.py +0 -0
  243. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/now_create_invoice_res.py +0 -0
  244. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/payment.py +0 -0
  245. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/payment_status.py +0 -0
  246. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/product.py +0 -0
  247. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/product_create.py +0 -0
  248. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/product_update.py +0 -0
  249. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/provider.py +0 -0
  250. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/scope.py +0 -0
  251. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/models/subscription.py +0 -0
  252. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/py.typed +0 -0
  253. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/pay/client/rest.py +0 -0
  254. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/__init__.py +0 -0
  255. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/__init__.py +0 -0
  256. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/admin_api.py +0 -0
  257. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/api_keys_api.py +0 -0
  258. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/bots_api.py +0 -0
  259. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/exchanges_api.py +0 -0
  260. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/futures_trading_panel_api.py +0 -0
  261. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/notifications_api.py +0 -0
  262. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/orders_api.py +0 -0
  263. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api/status_api.py +0 -0
  264. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api_client.py +0 -0
  265. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/api_response.py +0 -0
  266. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/configuration.py +0 -0
  267. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/exceptions.py +0 -0
  268. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/api_error_level.py +0 -0
  269. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/api_error_type.py +0 -0
  270. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/bot.py +0 -0
  271. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/bot_create.py +0 -0
  272. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/bot_status.py +0 -0
  273. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/bot_update.py +0 -0
  274. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/exception_detail.py +0 -0
  275. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/exchange.py +0 -0
  276. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/exchange_key.py +0 -0
  277. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/exchange_key_create.py +0 -0
  278. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/exchange_key_update.py +0 -0
  279. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/execution_ids.py +0 -0
  280. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/futures_balance.py +0 -0
  281. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/log_level.py +0 -0
  282. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/margin_mode.py +0 -0
  283. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/market_type.py +0 -0
  284. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/notification.py +0 -0
  285. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/notification_create.py +0 -0
  286. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/notification_update.py +0 -0
  287. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/order_status.py +0 -0
  288. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/post_futures_action.py +0 -0
  289. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/strategy.py +0 -0
  290. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/strategy_create.py +0 -0
  291. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/strategy_update.py +0 -0
  292. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/models/trading_action_type.py +0 -0
  293. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/py.typed +0 -0
  294. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn/trade/client/rest.py +0 -0
  295. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn.egg-info/dependency_links.txt +0 -0
  296. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn.egg-info/entry_points.txt +0 -0
  297. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn.egg-info/requires.txt +0 -0
  298. {crypticorn-2.12.1 → crypticorn-2.13.1}/crypticorn.egg-info/top_level.txt +0 -0
  299. {crypticorn-2.12.1 → crypticorn-2.13.1}/requirements/dev.txt +0 -0
  300. {crypticorn-2.12.1 → crypticorn-2.13.1}/requirements/extra.txt +0 -0
  301. {crypticorn-2.12.1 → crypticorn-2.13.1}/requirements/main.txt +0 -0
  302. {crypticorn-2.12.1 → crypticorn-2.13.1}/requirements/test.txt +0 -0
  303. {crypticorn-2.12.1 → crypticorn-2.13.1}/setup.cfg +0 -0
  304. {crypticorn-2.12.1 → crypticorn-2.13.1}/static/favicon.svg +0 -0
  305. {crypticorn-2.12.1 → crypticorn-2.13.1}/static/logo.svg +0 -0
  306. {crypticorn-2.12.1 → crypticorn-2.13.1}/static/pip-structure.drawio +0 -0
  307. {crypticorn-2.12.1 → crypticorn-2.13.1}/static/pip-structure.svg +0 -0
  308. {crypticorn-2.12.1 → crypticorn-2.13.1}/tests/test_enums.py +0 -0
  309. {crypticorn-2.12.1 → crypticorn-2.13.1}/tests/test_errors.py +0 -0
  310. {crypticorn-2.12.1 → crypticorn-2.13.1}/tests/test_pagination.py +0 -0
@@ -1,6 +1,34 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v2.13.1 (2025-05-26)
5
+
6
+ ### Bug Fixes
7
+
8
+ - Update error code levels and types
9
+ ([`9266c4b`](https://github.com/crypticorn-ai/api-client/commit/9266c4bc85adb879ab3b978ce7835a192147a825))
10
+
11
+ ### Performance Improvements
12
+
13
+ - Decrease client startup time by using a shared http session across all subclients
14
+ ([`dd41a60`](https://github.com/crypticorn-ai/api-client/commit/dd41a6079bd6568e074cbaebb1d4eda629a9b179))
15
+
16
+ centralize aiohttp.ClientSession in ApiClient
17
+
18
+ ### Refactoring
19
+
20
+ - Return specific exceptions for api key / bearer only endpoints
21
+ ([`52c77ce`](https://github.com/crypticorn-ai/api-client/commit/52c77ce73e880bdc08394a3f754c7f9bf0f81e6d))
22
+
23
+
24
+ ## v2.13.0 (2025-05-23)
25
+
26
+ ### Features
27
+
28
+ - New endpoint in metrics client (get symbol mappings for any pair)
29
+ ([`a1f3b6a`](https://github.com/crypticorn-ai/api-client/commit/a1f3b6a31df3d8e6c148fa087d6ab158842c82dc))
30
+
31
+
4
32
  ## v2.12.1 (2025-05-22)
5
33
 
6
34
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crypticorn
3
- Version: 2.12.1
3
+ Version: 2.13.1
4
4
  Summary: Maximise Your Crypto Trading Profits with Machine Learning
5
5
  Author-email: Crypticorn <timon@crypticorn.com>
6
6
  License-Expression: MIT
@@ -191,14 +191,41 @@ This utility allows direct data streaming to your local disk, instead of only re
191
191
 
192
192
  ## Advanced Usage
193
193
 
194
+ ### Sub Client Configuration
195
+
194
196
  You can override some configuration for specific services. If you just want to use the API as is, you don't need to configure anything.
195
197
  This might be of use if you are testing a specific API locally.
196
198
 
197
199
  To override e.g. the host for the Hive client to connect to localhost:8000 instead of the default proxy, you would do:
198
200
  ```python
199
- from crypticorn.hive import Configuration as Hiveconfig
201
+ from crypticorn.hive import Configuration as HiveConfig
200
202
  from crypticorn.common import Service
201
203
 
202
204
  async with ApiClient() as client:
203
- client.configure(config=HiveConfig(host="http://localhost:8000"), client=Service.HIVE)
205
+ client.configure(config=HiveConfig(host="http://localhost:8000"), service=Service.HIVE)
206
+ ```
207
+
208
+ ### Session Management
209
+
210
+ By default `ApiClient` manages a single shared `aiohttp.ClientSession` for all service wrappers. You can pass your own configured `aiohttp.ClientSession` for advanced use cases (for custom retry, logging, or mocking):
211
+
212
+ ```python
213
+ import aiohttp
214
+ from crypticorn import ApiClient
215
+
216
+ custom_http_client = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10), headers={"X-Test": "1"})
217
+ api = ApiClient(api_key="your-key")
218
+ api._http_client = custom_http_client
219
+
220
+ for service in api._services.values():
221
+ service.base_client.rest_client.pool_manager = custom_http_client
222
+ ```
223
+
224
+ ### Disable Logging
225
+
226
+ In case you don't want any logging statements by the `crypticorn` logger to be logged to stdout, you can disable it with:
227
+
228
+ ```python
229
+ from crypticorn.common import disable_logging
230
+ disable_logging()
204
231
  ```
@@ -136,14 +136,41 @@ This utility allows direct data streaming to your local disk, instead of only re
136
136
 
137
137
  ## Advanced Usage
138
138
 
139
+ ### Sub Client Configuration
140
+
139
141
  You can override some configuration for specific services. If you just want to use the API as is, you don't need to configure anything.
140
142
  This might be of use if you are testing a specific API locally.
141
143
 
142
144
  To override e.g. the host for the Hive client to connect to localhost:8000 instead of the default proxy, you would do:
143
145
  ```python
144
- from crypticorn.hive import Configuration as Hiveconfig
146
+ from crypticorn.hive import Configuration as HiveConfig
145
147
  from crypticorn.common import Service
146
148
 
147
149
  async with ApiClient() as client:
148
- client.configure(config=HiveConfig(host="http://localhost:8000"), client=Service.HIVE)
150
+ client.configure(config=HiveConfig(host="http://localhost:8000"), service=Service.HIVE)
151
+ ```
152
+
153
+ ### Session Management
154
+
155
+ By default `ApiClient` manages a single shared `aiohttp.ClientSession` for all service wrappers. You can pass your own configured `aiohttp.ClientSession` for advanced use cases (for custom retry, logging, or mocking):
156
+
157
+ ```python
158
+ import aiohttp
159
+ from crypticorn import ApiClient
160
+
161
+ custom_http_client = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10), headers={"X-Test": "1"})
162
+ api = ApiClient(api_key="your-key")
163
+ api._http_client = custom_http_client
164
+
165
+ for service in api._services.values():
166
+ service.base_client.rest_client.pool_manager = custom_http_client
167
+ ```
168
+
169
+ ### Disable Logging
170
+
171
+ In case you don't want any logging statements by the `crypticorn` logger to be logged to stdout, you can disable it with:
172
+
173
+ ```python
174
+ from crypticorn.common import disable_logging
175
+ disable_logging()
149
176
  ```
@@ -17,7 +17,7 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
22
  from typing_extensions import Annotated
23
23
  from typing import Optional, Set
@@ -29,12 +29,10 @@ class CreateUserRequest(BaseModel):
29
29
  CreateUserRequest
30
30
  """ # noqa: E501
31
31
 
32
- email: Annotated[str, Field(min_length=1, strict=True)]
32
+ email: StrictStr
33
33
  password: Annotated[str, Field(min_length=8, strict=True)]
34
- username: Optional[
35
- Annotated[str, Field(min_length=3, strict=True, max_length=32)]
36
- ] = None
37
- name: Optional[Annotated[str, Field(min_length=1, strict=True)]] = None
34
+ username: Optional[StrictStr] = None
35
+ name: Optional[StrictStr] = None
38
36
  picture: Optional[StrictStr] = None
39
37
  __properties: ClassVar[List[str]] = [
40
38
  "email",
@@ -44,16 +42,6 @@ class CreateUserRequest(BaseModel):
44
42
  "picture",
45
43
  ]
46
44
 
47
- @field_validator("username")
48
- def username_validate_regular_expression(cls, value):
49
- """Validates the regular expression"""
50
- if value is None:
51
- return value
52
-
53
- if not re.match(r"^[a-zA-Z0-9_]+$", value):
54
- raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_]+$/")
55
- return value
56
-
57
45
  model_config = ConfigDict(
58
46
  populate_by_name=True,
59
47
  validate_assignment=True,
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+ from typing import TYPE_CHECKING, Optional
1
3
  from crypticorn.auth import (
2
4
  ApiClient,
3
5
  Configuration,
@@ -8,6 +10,9 @@ from crypticorn.auth import (
8
10
  AuthApi,
9
11
  )
10
12
 
13
+ if TYPE_CHECKING:
14
+ from aiohttp import ClientSession
15
+
11
16
 
12
17
  class AuthClient:
13
18
  """
@@ -19,9 +24,12 @@ class AuthClient:
19
24
  def __init__(
20
25
  self,
21
26
  config: Configuration,
27
+ http_client: Optional[ClientSession] = None,
22
28
  ):
23
29
  self.config = config
24
30
  self.base_client = ApiClient(configuration=self.config)
31
+ if http_client is not None:
32
+ self.base_client.rest_client.pool_manager = http_client
25
33
  # Instantiate all the endpoint clients
26
34
  self.admin = AdminApi(self.base_client)
27
35
  self.service = ServiceApi(self.base_client)
@@ -1,4 +1,5 @@
1
- from typing import TypeVar
1
+ from typing import TypeVar, Optional
2
+ from aiohttp import ClientSession, ClientTimeout, TCPConnector
2
3
  from crypticorn.hive import HiveClient
3
4
  from crypticorn.klines import KlinesClient
4
5
  from crypticorn.pay import PayClient
@@ -6,6 +7,7 @@ from crypticorn.trade import TradeClient
6
7
  from crypticorn.metrics import MetricsClient
7
8
  from crypticorn.auth import AuthClient
8
9
  from crypticorn.common import BaseUrl, ApiVersion, Service, apikey_header as aph
10
+ from importlib.metadata import version
9
11
 
10
12
  ConfigT = TypeVar("ConfigT")
11
13
  SubClient = TypeVar("SubClient")
@@ -14,14 +16,13 @@ SubClient = TypeVar("SubClient")
14
16
  class ApiClient:
15
17
  """
16
18
  The official Python client for interacting with the Crypticorn API.
17
-
18
19
  It is consisting of multiple microservices covering the whole stack of the Crypticorn project.
19
20
  """
20
21
 
21
22
  def __init__(
22
23
  self,
23
- api_key: str = None,
24
- jwt: str = None,
24
+ api_key: Optional[str] = None,
25
+ jwt: Optional[str] = None,
25
26
  base_url: BaseUrl = BaseUrl.PROD,
26
27
  ):
27
28
  self.base_url = base_url
@@ -30,7 +31,14 @@ class ApiClient:
30
31
  """The API key to use for authentication (recommended)."""
31
32
  self.jwt = jwt
32
33
  """The JWT to use for authentication (not recommended)."""
34
+ self.version = version("crypticorn")
35
+ """The version of the client."""
33
36
 
37
+ self._http_client = ClientSession(
38
+ timeout=ClientTimeout(total=30.0),
39
+ connector=TCPConnector(limit=100, limit_per_host=20),
40
+ headers={"User-Agent": f"crypticorn/python/{self.version}"},
41
+ )
34
42
  self._service_classes: dict[Service, type[SubClient]] = {
35
43
  Service.HIVE: HiveClient,
36
44
  Service.TRADE: TradeClient,
@@ -39,9 +47,10 @@ class ApiClient:
39
47
  Service.METRICS: MetricsClient,
40
48
  Service.AUTH: AuthClient,
41
49
  }
42
-
43
50
  self._services: dict[Service, SubClient] = {
44
- service: client_class(self._get_default_config(service))
51
+ service: client_class(
52
+ self._get_default_config(service), http_client=self._http_client
53
+ )
45
54
  for service, client_class in self._service_classes.items()
46
55
  }
47
56
 
@@ -88,17 +97,16 @@ class ApiClient:
88
97
  return self._services[Service.AUTH]
89
98
 
90
99
  async def close(self):
91
- """Close all client sessions."""
92
100
  for service in self._services.values():
93
- if hasattr(service.base_client, "close"):
101
+ if hasattr(service, "base_client") and hasattr(
102
+ service.base_client, "close"
103
+ ):
94
104
  await service.base_client.close()
105
+ await self._http_client.close()
95
106
 
96
- def _get_default_config(
97
- self, service: Service, version: ApiVersion = ApiVersion.V1
98
- ):
99
- """
100
- Get the default configuration for a given service.
101
- """
107
+ def _get_default_config(self, service, version=None):
108
+ if version is None:
109
+ version = ApiVersion.V1
102
110
  config_class = self._service_classes[service].config_class
103
111
  return config_class(
104
112
  host=f"{self.base_url}/{version}/{service}",
@@ -106,11 +114,7 @@ class ApiClient:
106
114
  api_key={aph.scheme_name: self.api_key} if self.api_key else None,
107
115
  )
108
116
 
109
- def configure(
110
- self,
111
- config: ConfigT,
112
- service: Service,
113
- ):
117
+ def configure(self, config: ConfigT, service: Service) -> None:
114
118
  """
115
119
  Update a sub-client's configuration by overriding with the values set in the new config.
116
120
  Useful for testing a specific service against a local server instead of the default proxy.
@@ -125,13 +129,13 @@ class ApiClient:
125
129
  assert Service.validate(service), f"Invalid service: {service}"
126
130
  client = self._services[service]
127
131
  new_config = client.config
128
-
129
132
  for attr in vars(config):
130
133
  new_value = getattr(config, attr)
131
134
  if new_value:
132
135
  setattr(new_config, attr, new_value)
133
-
134
- self._services[service] = type(client)(new_config)
136
+ self._services[service] = type(client)(
137
+ new_config, http_client=self._http_client
138
+ )
135
139
 
136
140
  async def __aenter__(self):
137
141
  return self
@@ -70,7 +70,7 @@ class AuthHandler:
70
70
  self, api_scopes: list[Scope], user_scopes: list[Scope]
71
71
  ) -> bool:
72
72
  """
73
- Checks if the user scopes are a subset of the API scopes.
73
+ Checks if the required scopes are a subset of the user scopes.
74
74
  """
75
75
  if not set(api_scopes).issubset(user_scopes):
76
76
  raise HTTPException(
@@ -137,10 +137,21 @@ class AuthHandler:
137
137
  sec: SecurityScopes = SecurityScopes(),
138
138
  ) -> Verify200Response:
139
139
  """
140
- Verifies the API key and checks if the user scopes are a subset of the API scopes.
140
+ Verifies the API key and checks the scopes.
141
141
  Use this function if you only want to allow access via the API key.
142
+ This function is used for HTTP connections.
142
143
  """
143
- return await self.combined_auth(bearer=None, api_key=api_key, sec=sec)
144
+ try:
145
+ return await self.combined_auth(bearer=None, api_key=api_key, sec=sec)
146
+ except HTTPException as e:
147
+ if e.detail.get("code") == ApiError.NO_CREDENTIALS.identifier:
148
+ raise HTTPException(
149
+ content=ExceptionContent(
150
+ error=ApiError.NO_API_KEY,
151
+ message="No credentials provided. API key is required",
152
+ ),
153
+ )
154
+ raise e
144
155
 
145
156
  async def bearer_auth(
146
157
  self,
@@ -151,10 +162,21 @@ class AuthHandler:
151
162
  sec: SecurityScopes = SecurityScopes(),
152
163
  ) -> Verify200Response:
153
164
  """
154
- Verifies the bearer token and checks if the user scopes are a subset of the API scopes.
165
+ Verifies the bearer token and checks the scopes.
155
166
  Use this function if you only want to allow access via the bearer token.
167
+ This function is used for HTTP connections.
156
168
  """
157
- return await self.combined_auth(bearer=bearer, api_key=None, sec=sec)
169
+ try:
170
+ return await self.combined_auth(bearer=bearer, api_key=None, sec=sec)
171
+ except HTTPException as e:
172
+ if e.detail.get("code") == ApiError.NO_CREDENTIALS.identifier:
173
+ raise HTTPException(
174
+ content=ExceptionContent(
175
+ error=ApiError.NO_BEARER,
176
+ message="No credentials provided. Bearer token is required",
177
+ ),
178
+ )
179
+ raise e
158
180
 
159
181
  async def combined_auth(
160
182
  self,
@@ -165,9 +187,10 @@ class AuthHandler:
165
187
  sec: SecurityScopes = SecurityScopes(),
166
188
  ) -> Verify200Response:
167
189
  """
168
- Verifies the bearer token and/or API key and checks if the user scopes are a subset of the API scopes.
190
+ Verifies the bearer token and/or API key and checks the scopes.
169
191
  Returns early on the first successful verification, otherwise tries all available tokens.
170
192
  Use this function if you want to allow access via either the bearer token or the API key.
193
+ This function is used for HTTP connections.
171
194
  """
172
195
  tokens = [bearer, api_key]
173
196
 
@@ -197,7 +220,7 @@ class AuthHandler:
197
220
  raise HTTPException(
198
221
  content=ExceptionContent(
199
222
  error=ApiError.NO_CREDENTIALS,
200
- message="No credentials provided",
223
+ message="No credentials provided. Either API key or bearer token is required.",
201
224
  ),
202
225
  )
203
226
 
@@ -207,10 +230,14 @@ class AuthHandler:
207
230
  sec: SecurityScopes = SecurityScopes(),
208
231
  ) -> Verify200Response:
209
232
  """
210
- Verifies the API key and checks if the user scopes are a subset of the API scopes.
233
+ Verifies the API key and checks the scopes.
211
234
  Use this function if you only want to allow access via the API key.
235
+ This function is used for WebSocket connections.
212
236
  """
213
- return await self.ws_combined_auth(bearer=None, api_key=api_key, sec=sec)
237
+ try:
238
+ return await self.api_key_auth(api_key=api_key, sec=sec)
239
+ except HTTPException as e:
240
+ raise WebSocketException.from_http_exception(e)
214
241
 
215
242
  async def ws_bearer_auth(
216
243
  self,
@@ -218,10 +245,14 @@ class AuthHandler:
218
245
  sec: SecurityScopes = SecurityScopes(),
219
246
  ) -> Verify200Response:
220
247
  """
221
- Verifies the bearer token and checks if the user scopes are a subset of the API scopes.
248
+ Verifies the bearer token and checks the scopes.
222
249
  Use this function if you only want to allow access via the bearer token.
250
+ This function is used for WebSocket connections.
223
251
  """
224
- return await self.ws_combined_auth(bearer=bearer, api_key=None, sec=sec)
252
+ try:
253
+ return await self.bearer_auth(bearer=bearer, sec=sec)
254
+ except HTTPException as e:
255
+ raise WebSocketException.from_http_exception(e)
225
256
 
226
257
  async def ws_combined_auth(
227
258
  self,
@@ -230,8 +261,9 @@ class AuthHandler:
230
261
  sec: SecurityScopes = SecurityScopes(),
231
262
  ) -> Verify200Response:
232
263
  """
233
- Verifies the bearer token and/or API key and checks if the user scopes are a subset of the API scopes.
264
+ Verifies the bearer token and/or API key and checks the scopes.
234
265
  Use this function if you want to allow access via either the bearer token or the API key.
266
+ This function is used for WebSocket connections.
235
267
  """
236
268
  credentials = (
237
269
  HTTPAuthorizationCredentials(scheme="Bearer", credentials=bearer)