crypticorn 2.7.3__py3-none-any.whl → 2.7.5__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.
@@ -0,0 +1,33 @@
1
+ FROM python:3.11.5
2
+
3
+ # This line is used to allow the cache to be busted (only busts in CI)
4
+ ARG CACHEBUST=1
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ WORKDIR /code
8
+ # set API_ENV in .env
9
+ # API_ENV=local
10
+ # add to compose file
11
+ # build:
12
+ # context: .
13
+ # dockerfile: src/api/Dockerfile
14
+ # args:
15
+ # - API_ENV=${API_ENV}
16
+ # environment:
17
+ # - API_ENV=${API_ENV}
18
+ #
19
+ # and to the workflow:
20
+ # env:
21
+ # API_ENV: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}
22
+ ARG API_ENV
23
+
24
+ RUN pip install --no-cache-dir -r requirements.txt
25
+
26
+ RUN if [ "$API_ENV" != "prod" ]; then \
27
+ pip install --pre crypticorn; \
28
+ fi
29
+
30
+
31
+ COPY ./src /code/src
32
+
33
+ CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "3000"]
@@ -0,0 +1,26 @@
1
+ # Please see the documentation for all configuration options:
2
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3
+
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: "pip"
7
+ directory: "/" # root folder, or change if your requirements.txt is elsewhere
8
+ schedule:
9
+ interval: "weekly" # options: "daily", "weekly", "monthly"
10
+ open-pull-requests-limit: 3
11
+ labels:
12
+ - "dependencies"
13
+ rebase-strategy: "auto" # will rebase PRs if needed
14
+ ignore:
15
+ - dependency-name: "*"
16
+ update-types: ["version-update:semver-major"] # avoids risky major bumps
17
+ commit-message:
18
+ prefix: "deps"
19
+ target-branch: "dev" # ! merge to main after pr is merged
20
+ groups:
21
+ pip-dependencies:
22
+ patterns:
23
+ - "*"
24
+ update-types:
25
+ - "minor"
26
+ - "patch"
@@ -0,0 +1,12 @@
1
+ # https://docs.astral.sh/ruff/integrations/#github-actions
2
+ name: Ruff
3
+ on: [ push, pull_request ]
4
+ jobs:
5
+ ruff:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v4
9
+ - uses: astral-sh/ruff-action@v3
10
+ with:
11
+ args: check --ignore E402 --output-format=github .
12
+ src: "./src"
@@ -264,11 +264,6 @@ class ApiError(ExcludeEnumMixin, Enum, metaclass=ApiErrorFallback):
264
264
  ApiErrorType.USER_ERROR,
265
265
  ApiErrorLevel.ERROR,
266
266
  )
267
- INVALID_MODEL_NAME = (
268
- ApiErrorIdentifier.INVALID_MODEL_NAME,
269
- ApiErrorType.USER_ERROR,
270
- ApiErrorLevel.ERROR,
271
- )
272
267
  INSUFFICIENT_SCOPES = (
273
268
  ApiErrorIdentifier.INSUFFICIENT_SCOPES,
274
269
  ApiErrorType.USER_ERROR,
@@ -304,6 +299,11 @@ class ApiError(ExcludeEnumMixin, Enum, metaclass=ApiErrorFallback):
304
299
  ApiErrorType.SERVER_ERROR,
305
300
  ApiErrorLevel.ERROR,
306
301
  )
302
+ INVALID_MODEL_NAME = (
303
+ ApiErrorIdentifier.INVALID_MODEL_NAME,
304
+ ApiErrorType.USER_ERROR,
305
+ ApiErrorLevel.ERROR,
306
+ )
307
307
  INVALID_PARAMETER = (
308
308
  ApiErrorIdentifier.INVALID_PARAMETER,
309
309
  ApiErrorType.SERVER_ERROR,
@@ -5,7 +5,9 @@ from fastapi import HTTPException as FastAPIHTTPException, Request, FastAPI
5
5
  from fastapi.exceptions import RequestValidationError, ResponseValidationError
6
6
  from fastapi.responses import JSONResponse
7
7
  from crypticorn.common import ApiError, ApiErrorIdentifier, ApiErrorType, ApiErrorLevel
8
+ import logging
8
9
 
10
+ logger = logging.getLogger(__name__)
9
11
 
10
12
  class ExceptionType(StrEnum):
11
13
  HTTP = "http"
@@ -91,35 +93,39 @@ class WebSocketException(HTTPException):
91
93
 
92
94
  async def general_handler(request: Request, exc: Exception):
93
95
  """This is the default exception handler for all exceptions."""
94
- body = ExceptionContent(message=str(exc), error=ApiError.UNKNOWN_ERROR)
96
+ body = ExceptionContent(message=str(exc), error=ApiError.UNKNOWN_ERROR).enrich()
97
+ logger.error(f"Unknown error: {body.detail}")
95
98
  return JSONResponse(
96
- status_code=body.enrich().status_code, content=HTTPException(content=body).detail
99
+ status_code=body.status_code, content=HTTPException(content=body).detail
97
100
  )
98
101
 
99
102
 
100
103
  async def request_validation_handler(request: Request, exc: RequestValidationError):
101
104
  """This is the exception handler for all request validation errors."""
102
- body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_REQUEST)
105
+ body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_REQUEST).enrich()
106
+ logger.error(f"Request validation error: {body.detail}")
103
107
  return JSONResponse(
104
- status_code=body.enrich().status_code, content=HTTPException(content=body).detail
108
+ status_code=body.status_code, content=HTTPException(content=body).detail
105
109
  )
106
110
 
107
111
 
108
112
  async def response_validation_handler(request: Request, exc: ResponseValidationError):
109
113
  """This is the exception handler for all response validation errors."""
110
- body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_RESPONSE)
114
+ body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_RESPONSE).enrich()
115
+ logger.error(f"Response validation error: {body.detail}")
111
116
  return JSONResponse(
112
- status_code=body.enrich().status_code, content=HTTPException(content=body).detail
117
+ status_code=body.status_code, content=HTTPException(content=body).detail
113
118
  )
114
119
 
115
120
 
116
121
  async def http_handler(request: Request, exc: HTTPException):
117
122
  """This is the exception handler for HTTPExceptions. It unwraps the HTTPException and returns the detail in a flat JSON response."""
123
+ logger.error(f"HTTP error: {exc.detail}")
118
124
  return JSONResponse(status_code=exc.status_code, content=exc.detail)
119
125
 
120
126
 
121
127
  def register_exception_handlers(app: FastAPI):
122
- """Utility to register serveral exception handlers in one go. Catches Exception, HTTPException and Data Validation errors and responds with a unified json body."""
128
+ """Utility to register serveral exception handlers in one go. Catches Exception, HTTPException and Data Validation errors, logs them and responds with a unified json body."""
123
129
  app.add_exception_handler(Exception, general_handler)
124
130
  app.add_exception_handler(FastAPIHTTPException, http_handler)
125
131
  app.add_exception_handler(RequestValidationError, request_validation_handler)
@@ -1,8 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crypticorn
3
- Version: 2.7.3
3
+ Version: 2.7.5
4
4
  Summary: Maximise Your Crypto Trading Profits with Machine Learning
5
5
  Author-email: Crypticorn <timon@crypticorn.com>
6
+ License: MIT
6
7
  Project-URL: Homepage, https://crypticorn.com
7
8
  Keywords: machine learning,data science,crypto,modelling
8
9
  Classifier: Topic :: Scientific/Engineering
@@ -24,6 +25,8 @@ Requires-Dist: typing-extensions<5.0.0,>=4.7.1
24
25
  Requires-Dist: requests<3.0.0,>=2.32.0
25
26
  Requires-Dist: tqdm<5.0.0,>=4.67.0
26
27
  Provides-Extra: dev
28
+ Requires-Dist: build; extra == "dev"
29
+ Requires-Dist: twine; extra == "dev"
27
30
  Requires-Dist: streamlit; extra == "dev"
28
31
  Requires-Dist: httpx; extra == "dev"
29
32
  Requires-Dist: black; extra == "dev"
@@ -40,17 +43,12 @@ Requires-Dist: PyJWT==2.10.0; extra == "test"
40
43
  Provides-Extra: extra
41
44
  Requires-Dist: pandas<3.0.0,>=2.2.0; extra == "extra"
42
45
 
43
- # What is Crypticorn?
46
+ ## What is Crypticorn?
44
47
 
45
- Crypticorn is at the forefront of cutting-edge artificial intelligence cryptocurrency trading.
46
- Crypticorn offers AI-based solutions for both active and passive investors, including:
47
- - Prediction Dashboard with trading terminal,
48
- - AI Agents with different strategies,
49
- - DEX AI Signals for newly launched tokens,
50
- - DEX AI Bots
48
+ Crypticorn is at the forefront of cutting-edge crypto trading with Machine Learning.
51
49
 
52
- Use this API Client to contribute to the so-called Hive AI, a community driven AI Meta Model for predicting the
53
- cryptocurrency market.
50
+ Use this API Client to access valuable data sources, contribute to the Hive AI - a community driven AI Meta Model for predicting the
51
+ crypto market - and programmatically interact with the entire Crypticorn ecosystem.
54
52
 
55
53
  ## Installation
56
54
 
@@ -66,17 +64,19 @@ If you want the latest version, which could be a pre release, run:
66
64
  pip install --pre crypticorn
67
65
  ```
68
66
 
67
+ 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.
68
+
69
69
  ## Structure
70
70
 
71
71
  Our API is available as an asynchronous Python SDK. The main entry point you need is the `ApiClient` class, which you would import like this:
72
72
  ```python
73
73
  from crypticorn import ApiClient
74
74
  ```
75
- The ApiClient serves as the central interface for API operations. It instantiates multiple API wrappers corresponding to our microservices.
75
+ The ApiClient serves as the central interface for API operations. It instantiates multiple API wrappers corresponding to our micro services.
76
76
 
77
- Specific imports, such as request models, should be accessed through the appropriate submodules.
77
+ Request and response models for API operations should be accessed through the appropriate sub package.
78
78
 
79
- Note: All symbols are re-exported at the first submodule layer for convenience.
79
+ Note: All symbols are re-exported at the sub package level for convenience.
80
80
 
81
81
  ```python
82
82
  from crypticorn.trade import BotStatus
@@ -87,6 +87,10 @@ The `common` submodule contains shared classes not bound to a specific API.
87
87
  from crypticorn.common import Scope, Exchange
88
88
  ```
89
89
 
90
+ ## Authentication
91
+
92
+ To get started, [create an API key in your dashboard](https://app.crypticorn.com/account/developer). Then instantiate the `ApiClient` class with your copied key.
93
+
90
94
  ## Basic Usage
91
95
 
92
96
  ### With Async Context Protocol
@@ -131,16 +135,16 @@ print(res)
131
135
  ```
132
136
  The output would look like this:
133
137
  ```python
134
- status_code=200 headers={'Date': 'Wed, 09 Apr 2025 19:15:19 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Alt-Svc': 'h3=":443"; ma=86400', 'Server': 'cloudflare', 'Cf-Cache-Status': 'DYNAMIC', 'Content-Encoding': 'gzip', 'CF-RAY': '92dc551a687bbe5e-ZRH'} data=[ProductModel(id='67e8146e7bae32f3838fe36a', name='Awesome Product', price=5.0, scopes=None, duration=30, description='You need to buy this', is_active=True)] raw_data=b'[{"id":"67e8146e7bae32f3838fe36a","name":"Awesome Product","price":5.0,"duration":30,"description":"You need to buy this","is_active":true}]'
138
+ status_code=200 headers={'Date': 'Wed, 09 Apr 2025 19:15:19 GMT', 'Content-Type': 'application/json'} data=[ProductModel(id='67e8146e7bae32f3838fe36a', name='Awesome Product', price=5.0, scopes=None, duration=30, description='You need to buy this', is_active=True)] raw_data=b'[{"id":"67e8146e7bae32f3838fe36a","name":"Awesome Product","price":5.0,"duration":30,"description":"You need to buy this","is_active":true}]'
135
139
  ```
136
- You can then access the data of the response (as serialized output) with:
140
+ You can then access the data of the response (as serialized output (1) or as JSON string in bytes (2)) with:
137
141
  ```python
138
142
  print(res.data)
143
+ print(res.raw_data)
139
144
  ```
140
145
  On top of that you get some information about the request:
141
146
  ```python
142
147
  print(res.status_code)
143
- print(res.raw_data)
144
148
  print(res.headers)
145
149
  ```
146
150
 
@@ -163,6 +167,7 @@ This might be of use if you are testing a specific API locally.
163
167
  To override e.g. the host for the Hive client to connect to http://localhost:8000 instead of the default proxy, you would do:
164
168
  ```python
165
169
  from crypticorn.hive import Configuration as Hiveconfig
170
+ from crypticorn.common import Service
166
171
  async with ApiClient(base_url=BaseUrl.DEV) as client:
167
- client.configure(config=HiveConfig(host="http://localhost:8000"), client=client.hive)
172
+ client.configure(config=HiveConfig(host="http://localhost:8000"), client=Service.HIVE)
168
173
  ```
@@ -58,14 +58,17 @@ crypticorn/auth/client/models/whoami200_response.py,sha256=-Kj3fB4lgNaa8v_LTertj
58
58
  crypticorn/cli/__init__.py,sha256=bgMmlpRThjYcxXJ1U3UmLE8ODVT5olmFY1u69VOjthQ,69
59
59
  crypticorn/cli/__main__.py,sha256=x9T4xS3U-qokGEzad7rTujmq4yjV5xcYSXgNsDFkvyo,253
60
60
  crypticorn/cli/init.py,sha256=xefvOCjXOiSUPWHFDDv7DWDC0Ggs1JKxk7KPCXyMZnU,3729
61
+ crypticorn/cli/templates/Dockerfile,sha256=89KlphaXJH51L7Vs4B928WmwYcMtpvLmKGyoDAhOcMw,726
61
62
  crypticorn/cli/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
63
  crypticorn/cli/templates/auth.py,sha256=Q1TxlA7qzhjvrqp1xz1aV2vGnj3DKFNN-VSl3o0B-dI,983
64
+ crypticorn/cli/templates/dependabot.yml,sha256=ct5ieB8KAV1KLzoYKUNm6dZ9wKG_P_JQHgRjZUfT54w,861
65
+ crypticorn/cli/templates/ruff.yml,sha256=gWicFFTzC4nToSmRkIIGipos8CZ447YG0kebBCJhtJE,319
63
66
  crypticorn/common/__init__.py,sha256=42ajAXlz0LDBb1AFyX8xvwpp1MB_YrvqutFDkLthUQM,464
64
67
  crypticorn/common/auth.py,sha256=60SRXlW72VJO8rGzCiemWmzGu8tXDqWr0wt9EM6p8aI,8631
65
68
  crypticorn/common/decorators.py,sha256=pmnGYCIrLv59wZkDbvPyK9NJmgPJWW74LXTdIWSjOkY,1063
66
69
  crypticorn/common/enums.py,sha256=RitDVqlG_HTe6tHT6bWusZNFCeYk1eQvJVH-7x3_Zlg,668
67
- crypticorn/common/errors.py,sha256=K1VSEKZro1I4cmi-sOhx24pTrvhbbD4RBRRqKodWpA8,27851
68
- crypticorn/common/exceptions.py,sha256=2gsYU0AMiLga4D99PBprQX59k12jJJMlUZ0uEk9rQxs,5671
70
+ crypticorn/common/errors.py,sha256=8jxZ2lLn_NoFKKq6n2JwKPsR0dA2vkGnbXDfEK6ndH0,27851
71
+ crypticorn/common/exceptions.py,sha256=FOxScGTnAoiBkpC5lccQ6_b1jIPcWxawZvR_H2KBCNY,5953
69
72
  crypticorn/common/mixins.py,sha256=LKPcNTR8uREeDGWTlWozNx7rS1mYdQVx1RllLhxIAsE,1640
70
73
  crypticorn/common/pagination.py,sha256=c07jrMNrBaNTmgx4sppdP7ND4RNT7NBqBXWvofazIlE,2251
71
74
  crypticorn/common/scopes.py,sha256=gbxrzME18ASQS18IHg96TvFZxh5-O8ffD2caGpfs0lc,2333
@@ -221,8 +224,8 @@ crypticorn/trade/client/models/strategy_model_input.py,sha256=ala19jARyfA5ysys5D
221
224
  crypticorn/trade/client/models/strategy_model_output.py,sha256=2o2lhbgUSTznowpMLEHF1Ex9TG9oRmzlCIb-gXqo7_s,5643
222
225
  crypticorn/trade/client/models/tpsl.py,sha256=C2KgTIZs-a8W4msdaXgBKJcwtA-o5wR4rBauRP-iQxU,4317
223
226
  crypticorn/trade/client/models/trading_action_type.py,sha256=pGq_TFLMPfYFizYP-xKgEC1ZF4U3lGdJYoGa_ZH2x-Q,769
224
- crypticorn-2.7.3.dist-info/METADATA,sha256=t3vla6kYBXY_bkb-HZrZN5EOagTwHt7KLRYcgCFHc50,6249
225
- crypticorn-2.7.3.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
226
- crypticorn-2.7.3.dist-info/entry_points.txt,sha256=d_xHsGvUTebPveVUK0SrpDFQ5ZRSjlI7lNCc11sn2PM,59
227
- crypticorn-2.7.3.dist-info/top_level.txt,sha256=EP3NY216qIBYfmvGl0L2Zc9ItP0DjGSkiYqd9xJwGcM,11
228
- crypticorn-2.7.3.dist-info/RECORD,,
227
+ crypticorn-2.7.5.dist-info/METADATA,sha256=5E_LCIIfd_O0t6Q8HBqaVLQVSvq_xgvVmMiCgPW_AZU,6607
228
+ crypticorn-2.7.5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
229
+ crypticorn-2.7.5.dist-info/entry_points.txt,sha256=d_xHsGvUTebPveVUK0SrpDFQ5ZRSjlI7lNCc11sn2PM,59
230
+ crypticorn-2.7.5.dist-info/top_level.txt,sha256=EP3NY216qIBYfmvGl0L2Zc9ItP0DjGSkiYqd9xJwGcM,11
231
+ crypticorn-2.7.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5