crypticorn 2.8.0rc4__py3-none-any.whl → 2.8.0rc6__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.
crypticorn/__init__.py CHANGED
@@ -1,6 +1,9 @@
1
1
  """
2
2
  .. include:: ../README.md
3
- .. include:: ../CHANGELOG.md
3
+
4
+ ## Versioning
5
+ We adhere to [Semantic Versioning](https://semver.org/).
6
+ You can find the full Changelog [below](#changelog).
4
7
  """
5
8
 
6
9
  from crypticorn.common.logging import configure_logging
crypticorn/client.py CHANGED
@@ -13,7 +13,7 @@ SubClient = TypeVar("SubClient")
13
13
 
14
14
  class ApiClient:
15
15
  """
16
- The official client for interacting with the Crypticorn API.
16
+ The official Python client for interacting with the Crypticorn API.
17
17
 
18
18
  It is consisting of multiple microservices covering the whole stack of the Crypticorn project.
19
19
  """
@@ -27,11 +27,11 @@ class ApiClient:
27
27
  self.base_url = base_url
28
28
  """The base URL the client will use to connect to the API."""
29
29
  self.api_key = api_key
30
- """The API key to use for authentication."""
30
+ """The API key to use for authentication (recommended)."""
31
31
  self.jwt = jwt
32
- """The JWT to use for authentication."""
32
+ """The JWT to use for authentication (not recommended)."""
33
33
 
34
- self.service_classes: dict[Service, type[SubClient]] = {
34
+ self._service_classes: dict[Service, type[SubClient]] = {
35
35
  Service.HIVE: HiveClient,
36
36
  Service.TRADE: TradeClient,
37
37
  Service.KLINES: KlinesClient,
@@ -40,38 +40,56 @@ class ApiClient:
40
40
  Service.AUTH: AuthClient,
41
41
  }
42
42
 
43
- self.services: dict[Service, SubClient] = {
43
+ self._services: dict[Service, SubClient] = {
44
44
  service: client_class(self._get_default_config(service))
45
- for service, client_class in self.service_classes.items()
45
+ for service, client_class in self._service_classes.items()
46
46
  }
47
47
 
48
48
  @property
49
49
  def hive(self) -> HiveClient:
50
- return self.services[Service.HIVE]
50
+ """
51
+ Entry point for the Hive AI API ([Docs](https://docs.crypticorn.com/api/?api=hive-ai-api)).
52
+ """
53
+ return self._services[Service.HIVE]
51
54
 
52
55
  @property
53
56
  def trade(self) -> TradeClient:
54
- return self.services[Service.TRADE]
57
+ """
58
+ Entry point for the Trading API ([Docs](https://docs.crypticorn.com/api/?api=trading-api)).
59
+ """
60
+ return self._services[Service.TRADE]
55
61
 
56
62
  @property
57
63
  def klines(self) -> KlinesClient:
58
- return self.services[Service.KLINES]
64
+ """
65
+ Entry point for the Klines API ([Docs](https://docs.crypticorn.com/api/?api=klines-api)).
66
+ """
67
+ return self._services[Service.KLINES]
59
68
 
60
69
  @property
61
70
  def metrics(self) -> MetricsClient:
62
- return self.services[Service.METRICS]
71
+ """
72
+ Entry point for the Metrics API ([Docs](https://docs.crypticorn.com/api/?api=metrics-api)).
73
+ """
74
+ return self._services[Service.METRICS]
63
75
 
64
76
  @property
65
77
  def pay(self) -> PayClient:
66
- return self.services[Service.PAY]
78
+ """
79
+ Entry point for the Payment API ([Docs](https://docs.crypticorn.com/api/?api=payment-api)).
80
+ """
81
+ return self._services[Service.PAY]
67
82
 
68
83
  @property
69
84
  def auth(self) -> AuthClient:
70
- return self.services[Service.AUTH]
85
+ """
86
+ Entry point for the Auth API ([Docs](https://docs.crypticorn.com/api/?api=auth-api)).
87
+ """
88
+ return self._services[Service.AUTH]
71
89
 
72
90
  async def close(self):
73
91
  """Close all client sessions."""
74
- for service in self.services.values():
92
+ for service in self._services.values():
75
93
  if hasattr(service.base_client, "close"):
76
94
  await service.base_client.close()
77
95
 
@@ -81,7 +99,7 @@ class ApiClient:
81
99
  """
82
100
  Get the default configuration for a given service.
83
101
  """
84
- config_class = self.service_classes[service].config_class
102
+ config_class = self._service_classes[service].config_class
85
103
  return config_class(
86
104
  host=f"{self.base_url}/{version}/{service}",
87
105
  access_token=self.jwt,
@@ -105,7 +123,7 @@ class ApiClient:
105
123
  >>> client.configure(config=HiveConfig(host="http://localhost:8000"), client=client.hive)
106
124
  """
107
125
  assert Service.validate(service), f"Invalid service: {service}"
108
- client = self.services[service]
126
+ client = self._services[service]
109
127
  new_config = client.config
110
128
 
111
129
  for attr in vars(config):
@@ -113,7 +131,7 @@ class ApiClient:
113
131
  if new_value:
114
132
  setattr(new_config, attr, new_value)
115
133
 
116
- self.services[service] = type(client)(new_config)
134
+ self._services[service] = type(client)(new_config)
117
135
 
118
136
  async def __aenter__(self):
119
137
  return self
@@ -11,6 +11,7 @@ from enum import StrEnum
11
11
  from crypticorn.common.mixins import ValidateEnumMixin
12
12
  from crypticorn.common.ansi_colors import AnsiColors as C
13
13
  from datetime import datetime
14
+ import os
14
15
 
15
16
 
16
17
  class LogLevel(ValidateEnumMixin, StrEnum):
@@ -100,7 +101,7 @@ def configure_logging(
100
101
  # Configure file handler
101
102
  if log_file:
102
103
  os.makedirs(os.path.dirname(log_file), exist_ok=True)
103
- file_handler = logging.RotatingFileHandler(
104
+ file_handler = logging.handlers.RotatingFileHandler(
104
105
  log_file, maxBytes=10 * 1024 * 1024, backupCount=5
105
106
  )
106
107
  file_handler.setLevel(file_level)
@@ -1,22 +1,28 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crypticorn
3
- Version: 2.8.0rc4
3
+ Version: 2.8.0rc6
4
4
  Summary: Maximise Your Crypto Trading Profits with Machine Learning
5
5
  Author-email: Crypticorn <timon@crypticorn.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://crypticorn.com
8
+ Project-URL: Documentation, https://docs.crypticorn.com
9
+ Project-URL: Dashboard, https://app.crypticorn.com
8
10
  Keywords: machine learning,data science,crypto,modelling
9
11
  Classifier: Topic :: Scientific/Engineering
10
12
  Classifier: Development Status :: 4 - Beta
11
13
  Classifier: Intended Audience :: Science/Research
12
14
  Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
14
19
  Classifier: Typing :: Typed
15
20
  Requires-Python: >=3.10
16
21
  Description-Content-Type: text/markdown
17
22
  Requires-Dist: fastapi<1.0.0,>=0.115.0
18
23
  Requires-Dist: click<9.0.0,>=8.0.0
19
24
  Requires-Dist: psutil<8.0.0,>=7.0.0
25
+ Requires-Dist: setuptools<81.0.0,>=80.0.0
20
26
  Requires-Dist: urllib3<3.0.0,>=1.25.3
21
27
  Requires-Dist: python_dateutil<3.0.0,>=2.8.2
22
28
  Requires-Dist: aiohttp<4.0.0,>=3.8.4
@@ -35,6 +41,7 @@ Requires-Dist: ruff; extra == "dev"
35
41
  Requires-Dist: isort; extra == "dev"
36
42
  Requires-Dist: mypy; extra == "dev"
37
43
  Requires-Dist: openapi-generator-cli<8.0.0,>=7.12.0; extra == "dev"
44
+ Requires-Dist: pdoc==15.0.3; extra == "dev"
38
45
  Provides-Extra: test
39
46
  Requires-Dist: pytest==8.3.5; extra == "test"
40
47
  Requires-Dist: pytest-asyncio==0.26.0; extra == "test"
@@ -53,9 +60,9 @@ crypto market - and programmatically interact with the entire Crypticorn ecosyst
53
60
 
54
61
  ## Installation
55
62
 
56
- >Python 3.10+ required
63
+ You need Python 3.10+ installed to be able to use this library.
57
64
 
58
- You can install the latest stable version from PyPi:
65
+ You can install the latest stable version from [PyPi](https://pypi.org/project/crypticorn/):
59
66
  ```bash
60
67
  pip install crypticorn
61
68
  ```
@@ -65,7 +72,7 @@ If you want the latest version, which could be a pre release, run:
65
72
  pip install --pre crypticorn
66
73
  ```
67
74
 
68
- You can install extra dependencies grouped in the extras `extra` (heavy dependencies that do not come with the default version) `dev` (development) and `test` (testing). The `extra` dependencies include heavy libraries like `pandas`, which is only used in a few custom API operations (suffixed with `_fmt`), which preprocess the response data as a pandas Dataframe for convenience.
75
+ You can install extra dependencies grouped in the extras `extra`, `dev` (development) and `test` (testing). The `extra` dependencies include heavy libraries like `pandas`, which is only used in a few custom API operations (see [data processing](#data-preprocessing)), which preprocess the response data as a pandas Dataframe for convenience.
69
76
 
70
77
  ## Structure
71
78
 
@@ -73,11 +80,13 @@ Our API is available as an asynchronous Python SDK. The main entry point you nee
73
80
  ```python
74
81
  from crypticorn import ApiClient
75
82
  ```
76
- The ApiClient serves as the central interface for API operations. It instantiates multiple API wrappers corresponding to our micro services.
83
+ The ApiClient serves as the central interface for API operations. It instantiates multiple API wrappers corresponding to our micro services. These are structured the following:
77
84
 
78
- Request and response models for API operations should be accessed through the appropriate sub package.
85
+ <img src="../static/pip-structure.svg" alt="pip package structure" />
79
86
 
80
- Note: All symbols are re-exported at the sub package level for convenience.
87
+ You can either explore each API by clicking through the library or checkout the [API Documentation](https://docs.crypticorn.dev/api).
88
+
89
+ Request and response models for API operations should be accessed through the sub package you are using for an operation. All symbols are re-exported at the sub package level for convenience.
81
90
 
82
91
  ```python
83
92
  from crypticorn.trade import BotStatus
@@ -94,25 +103,27 @@ To get started, [create an API key in your dashboard](https://app.crypticorn.com
94
103
 
95
104
  ## Basic Usage
96
105
 
97
- ### With Async Context Protocol
106
+ You can use the client with the async context protocol...
98
107
  ```python
99
- async with ApiClient(base_url=BaseUrl.Prod, api_key="your-api-key") as client:
108
+ async with ApiClient(api_key="your-api-key") as client:
100
109
  await client.pay.products.get_products()
101
110
  ```
102
-
103
- ### Without Async Context Protocol
104
- Without the context you need to close the session manually.
111
+ ...or without it like this...
105
112
  ```python
106
- client = ApiClient(base_url=BaseUrl.Prod, api_key="your-api-key")
113
+ client = ApiClient(api_key="your-api-key")
107
114
  asyncio.run(client.pay.models.get_products())
108
115
  asyncio.run(client.close())
109
116
  ```
110
- ...or wrapped in a function
117
+ ...or this.
118
+ ```python
119
+ client = ApiClient(api_key="your-api-key")
120
+
111
121
  async def main():
112
122
  await client.pay.products.get_products()
113
123
 
114
124
  asyncio.run(main())
115
125
  asyncio.run(client.close())
126
+ ```
116
127
 
117
128
  ## Response Types
118
129
 
@@ -121,8 +132,8 @@ There are three different available output formats you can choose from:
121
132
  ### Serialized Response
122
133
  You can get fully serialized responses as pydantic models. Using this, you get the full benefits of pydantic's type checking.
123
134
  ```python
124
- response = await client.pay.products.get_products()
125
- print(response)
135
+ res = await client.pay.products.get_products()
136
+ print(res)
126
137
  ```
127
138
  The output would look like this:
128
139
  ```python
@@ -131,7 +142,7 @@ The output would look like this:
131
142
 
132
143
  ### Serialized Response with HTTP Info
133
144
  ```python
134
- await client.pay.products.get_products_with_http_info()
145
+ res = await client.pay.products.get_products_with_http_info()
135
146
  print(res)
136
147
  ```
137
148
  The output would look like this:
@@ -160,15 +171,27 @@ The output would look like this:
160
171
  [{'id': '67e8146e7bae32f3838fe36a', 'name': 'Awesome Product', 'price': 5.0, 'duration': 30, 'description': 'You need to buy this', 'is_active': True}]
161
172
  ```
162
173
 
174
+ ## Wrapper Utilities
175
+
176
+ Our SDK provides a collection of wrapper utilities designed to make interacting with the API more efficient and user-friendly.
177
+
178
+ ### Data Preprocessing
179
+ Some API operations allow to get the returned data formatted as a pandas Dataframe. These operations are suffixed with `_fmt` and take the same inputs as the non-formatted function. They live alongside the other functions with the default [response types](#response-types). To use this functionality you have to install `pandas`, which is available in the [`extra` dependency group](#installation).
180
+
181
+ ### Data Downloads
182
+ This utility allows direct data streaming to your local disk, instead of only returning download links. It is being used in the following functions:
183
+ - `client.hive.data.download_data()` (overrides the [default response](https://docs.crypticorn.dev/api/?api=hive-ai-api#tag/data/GET/data))
184
+
163
185
  ## Advanced Usage
164
186
 
165
187
  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.
166
188
  This might be of use if you are testing a specific API locally.
167
189
 
168
- To override e.g. the host for the Hive client to connect to http://localhost:8000 instead of the default proxy, you would do:
190
+ To override e.g. the host for the Hive client to connect to localhost:8000 instead of the default proxy, you would do:
169
191
  ```python
170
192
  from crypticorn.hive import Configuration as Hiveconfig
171
193
  from crypticorn.common import Service
172
- async with ApiClient(base_url=BaseUrl.DEV) as client:
194
+
195
+ async with ApiClient() as client:
173
196
  client.configure(config=HiveConfig(host="http://localhost:8000"), client=Service.HIVE)
174
197
  ```
@@ -1,5 +1,5 @@
1
- crypticorn/__init__.py,sha256=AyaDwO9NVhoQzNUNwqM_4o5saE3vbVcJZ9RNpXEYKxw,219
2
- crypticorn/client.py,sha256=jMdF4mZuqB8YMZZOwJkTcvpHluGqw6Q-taSF6vQS5WM,3912
1
+ crypticorn/__init__.py,sha256=qQ2C8ZhrVX5b157tfdqyWeZMZBvZDl6pSOLxSvTqNAo,315
2
+ crypticorn/client.py,sha256=sARrNfvh9Hw_J9GoXUnB_6B2hueVF_0dNo8Aliq5sA8,4701
3
3
  crypticorn/auth/__init__.py,sha256=JAl1tBLK9pYLr_-YKaj581c-c94PWLoqnatTIVAVvMM,81
4
4
  crypticorn/auth/main.py,sha256=j8eRGN2gUWyeOCnWnUPe3mCAfaidGnOMnZRiSQy-yzM,720
5
5
  crypticorn/auth/client/__init__.py,sha256=do16xS84uXvVoJuWERjb9RwlOaLy4UF4uKBZWczFC3c,5291
@@ -70,7 +70,7 @@ crypticorn/common/decorators.py,sha256=pmnGYCIrLv59wZkDbvPyK9NJmgPJWW74LXTdIWSjO
70
70
  crypticorn/common/enums.py,sha256=RitDVqlG_HTe6tHT6bWusZNFCeYk1eQvJVH-7x3_Zlg,668
71
71
  crypticorn/common/errors.py,sha256=8jxZ2lLn_NoFKKq6n2JwKPsR0dA2vkGnbXDfEK6ndH0,27851
72
72
  crypticorn/common/exceptions.py,sha256=BuRLQIg2_pwsaQAhPKP3lY9q2GNp0SlRdXlvp1O2USo,6088
73
- crypticorn/common/logging.py,sha256=aLZ4d1SN1E9GDA78_OSLfnIQ9KguVbrNxWcJWM3rX-4,3647
73
+ crypticorn/common/logging.py,sha256=DYP9mNElewhXQxkBtjvAM05tKIbqeDiE9YRH92whMLc,3666
74
74
  crypticorn/common/middleware.py,sha256=PnzYHvB653JfQmwbpoDiHTAjMhH599cQebU0UOyGI2k,1041
75
75
  crypticorn/common/mixins.py,sha256=o2x1aId-mSjLZ2BbDCVRvRH78d7EiDhQn5COwZAkkQs,1719
76
76
  crypticorn/common/pagination.py,sha256=c07jrMNrBaNTmgx4sppdP7ND4RNT7NBqBXWvofazIlE,2251
@@ -234,8 +234,8 @@ crypticorn/trade/client/models/strategy_model_input.py,sha256=ala19jARyfA5ysys5D
234
234
  crypticorn/trade/client/models/strategy_model_output.py,sha256=2o2lhbgUSTznowpMLEHF1Ex9TG9oRmzlCIb-gXqo7_s,5643
235
235
  crypticorn/trade/client/models/tpsl.py,sha256=C2KgTIZs-a8W4msdaXgBKJcwtA-o5wR4rBauRP-iQxU,4317
236
236
  crypticorn/trade/client/models/trading_action_type.py,sha256=pGq_TFLMPfYFizYP-xKgEC1ZF4U3lGdJYoGa_ZH2x-Q,769
237
- crypticorn-2.8.0rc4.dist-info/METADATA,sha256=PBWk-nODkor_054gxc-xrFEGYzBfjpK0fXMnGw1890s,6646
238
- crypticorn-2.8.0rc4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
239
- crypticorn-2.8.0rc4.dist-info/entry_points.txt,sha256=d_xHsGvUTebPveVUK0SrpDFQ5ZRSjlI7lNCc11sn2PM,59
240
- crypticorn-2.8.0rc4.dist-info/top_level.txt,sha256=EP3NY216qIBYfmvGl0L2Zc9ItP0DjGSkiYqd9xJwGcM,11
241
- crypticorn-2.8.0rc4.dist-info/RECORD,,
237
+ crypticorn-2.8.0rc6.dist-info/METADATA,sha256=Xn-v6YnY9-0fIoMjAMUc-dcDXyXOhCB5HrRpHyVQ8Qs,8098
238
+ crypticorn-2.8.0rc6.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
239
+ crypticorn-2.8.0rc6.dist-info/entry_points.txt,sha256=d_xHsGvUTebPveVUK0SrpDFQ5ZRSjlI7lNCc11sn2PM,59
240
+ crypticorn-2.8.0rc6.dist-info/top_level.txt,sha256=EP3NY216qIBYfmvGl0L2Zc9ItP0DjGSkiYqd9xJwGcM,11
241
+ crypticorn-2.8.0rc6.dist-info/RECORD,,