crypticorn 2.8.0rc7__py3-none-any.whl → 2.8.1__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 +1 -1
- crypticorn/cli/init.py +2 -2
- crypticorn/common/exceptions.py +5 -4
- crypticorn/common/logging.py +13 -4
- crypticorn/common/middleware.py +2 -3
- crypticorn/common/router/admin_router.py +10 -12
- crypticorn/common/router/status_router.py +2 -2
- crypticorn/hive/utils.py +1 -2
- crypticorn/klines/client/__init__.py +9 -1
- crypticorn/klines/client/api/__init__.py +1 -0
- crypticorn/klines/client/api/admin_api.py +1455 -0
- crypticorn/klines/client/api/change_in_timeframe_api.py +24 -20
- crypticorn/klines/client/api/funding_rates_api.py +12 -10
- crypticorn/klines/client/api/ohlcv_data_api.py +37 -24
- crypticorn/klines/client/api/status_api.py +8 -235
- crypticorn/klines/client/api/symbols_api.py +12 -9
- crypticorn/klines/client/api/udf_api.py +6 -6
- crypticorn/klines/client/models/__init__.py +8 -1
- crypticorn/klines/client/models/api_error_identifier.py +115 -0
- crypticorn/klines/client/models/api_error_level.py +37 -0
- crypticorn/klines/client/models/api_error_type.py +37 -0
- crypticorn/klines/client/models/exception_detail.py +6 -3
- crypticorn/klines/client/models/funding_rate.py +6 -12
- crypticorn/klines/client/models/funding_rate_response.py +103 -0
- crypticorn/klines/client/models/internal_exchange.py +39 -0
- crypticorn/klines/client/models/log_level.py +38 -0
- crypticorn/klines/client/models/market_type.py +35 -0
- crypticorn/klines/client/models/{ohlcv_history.py → ohlcv.py} +12 -13
- crypticorn/klines/client/models/search_symbol.py +3 -4
- crypticorn/klines/client/models/udf_config.py +2 -1
- crypticorn/klines/main.py +1 -13
- crypticorn/metrics/client/__init__.py +11 -0
- crypticorn/metrics/client/api/__init__.py +2 -0
- crypticorn/metrics/client/api/admin_api.py +1452 -0
- crypticorn/metrics/client/api/exchanges_api.py +51 -40
- crypticorn/metrics/client/api/indicators_api.py +49 -32
- crypticorn/metrics/client/api/logs_api.py +7 -7
- crypticorn/metrics/client/api/marketcap_api.py +28 -25
- crypticorn/metrics/client/api/markets_api.py +50 -278
- crypticorn/metrics/client/api/quote_currencies_api.py +289 -0
- crypticorn/metrics/client/api/status_api.py +4 -231
- crypticorn/metrics/client/api/tokens_api.py +241 -37
- crypticorn/metrics/client/models/__init__.py +9 -0
- crypticorn/metrics/client/models/api_error_identifier.py +115 -0
- crypticorn/metrics/client/models/api_error_level.py +37 -0
- crypticorn/metrics/client/models/api_error_type.py +37 -0
- crypticorn/metrics/client/models/exception_detail.py +6 -3
- crypticorn/metrics/client/models/exchange_mapping.py +121 -0
- crypticorn/metrics/client/models/internal_exchange.py +39 -0
- crypticorn/metrics/client/models/log_level.py +38 -0
- crypticorn/metrics/client/models/market_type.py +35 -0
- crypticorn/metrics/client/models/marketcap_ranking.py +87 -0
- crypticorn/metrics/client/models/ohlcv.py +113 -0
- crypticorn/metrics/main.py +14 -2
- {crypticorn-2.8.0rc7.dist-info → crypticorn-2.8.1.dist-info}/METADATA +3 -2
- {crypticorn-2.8.0rc7.dist-info → crypticorn-2.8.1.dist-info}/RECORD +59 -40
- {crypticorn-2.8.0rc7.dist-info → crypticorn-2.8.1.dist-info}/WHEEL +0 -0
- {crypticorn-2.8.0rc7.dist-info → crypticorn-2.8.1.dist-info}/entry_points.txt +0 -0
- {crypticorn-2.8.0rc7.dist-info → crypticorn-2.8.1.dist-info}/top_level.txt +0 -0
crypticorn/__init__.py
CHANGED
crypticorn/cli/init.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import click
|
2
2
|
from pathlib import Path
|
3
3
|
import subprocess
|
4
|
-
import importlib.resources
|
4
|
+
import importlib.resources
|
5
5
|
import crypticorn.cli.templates as templates
|
6
6
|
|
7
7
|
|
@@ -19,7 +19,7 @@ def get_git_root() -> Path:
|
|
19
19
|
|
20
20
|
def copy_template(template_name: str, target_path: Path):
|
21
21
|
"""Copy a template file to the target path."""
|
22
|
-
with
|
22
|
+
with importlib.resources.files(templates).joinpath(template_name).open(
|
23
23
|
"r"
|
24
24
|
) as template_file:
|
25
25
|
content = template_file.read()
|
crypticorn/common/exceptions.py
CHANGED
@@ -6,8 +6,9 @@ from fastapi.exceptions import RequestValidationError, ResponseValidationError
|
|
6
6
|
from fastapi.responses import JSONResponse
|
7
7
|
from crypticorn.common import ApiError, ApiErrorIdentifier, ApiErrorType, ApiErrorLevel
|
8
8
|
import logging
|
9
|
+
import json
|
9
10
|
|
10
|
-
logger = logging.getLogger(
|
11
|
+
logger = logging.getLogger("crypticorn")
|
11
12
|
|
12
13
|
|
13
14
|
class ExceptionType(StrEnum):
|
@@ -99,7 +100,7 @@ async def general_handler(request: Request, exc: Exception) -> JSONResponse:
|
|
99
100
|
status_code=body.enrich().status_code,
|
100
101
|
content=HTTPException(content=body).detail,
|
101
102
|
)
|
102
|
-
logger.error(f"Response validation error: {res}")
|
103
|
+
logger.error(f"Response validation error: {json.loads(res.__dict__.get('body'))}")
|
103
104
|
return res
|
104
105
|
|
105
106
|
|
@@ -112,7 +113,7 @@ async def request_validation_handler(
|
|
112
113
|
status_code=body.enrich().status_code,
|
113
114
|
content=HTTPException(content=body).detail,
|
114
115
|
)
|
115
|
-
logger.error(f"Response validation error: {res}")
|
116
|
+
logger.error(f"Response validation error: {json.loads(res.__dict__.get('body'))}")
|
116
117
|
return res
|
117
118
|
|
118
119
|
|
@@ -125,7 +126,7 @@ async def response_validation_handler(
|
|
125
126
|
status_code=body.enrich().status_code,
|
126
127
|
content=HTTPException(content=body).detail,
|
127
128
|
)
|
128
|
-
logger.error(f"Response validation error: {res}")
|
129
|
+
logger.error(f"Response validation error: {json.loads(res.__dict__.get('body'))}")
|
129
130
|
return res
|
130
131
|
|
131
132
|
|
crypticorn/common/logging.py
CHANGED
@@ -51,7 +51,6 @@ _LOGFORMAT = (
|
|
51
51
|
f"%(levelcolor)s%(levelname)s{C.RESET} - "
|
52
52
|
f"%(message)s"
|
53
53
|
)
|
54
|
-
_PLAIN_LOGFORMAT = "%(asctime)s - " "%(name)s - " "%(levelname)s - " "%(message)s"
|
55
54
|
_DATEFMT = "%Y-%m-%d %H:%M:%S.%f:"
|
56
55
|
|
57
56
|
|
@@ -71,7 +70,7 @@ class CustomFormatter(logging.Formatter):
|
|
71
70
|
|
72
71
|
|
73
72
|
def configure_logging(
|
74
|
-
name: str,
|
73
|
+
name: str = None,
|
75
74
|
fmt: str = _LOGFORMAT,
|
76
75
|
datefmt: str = _DATEFMT,
|
77
76
|
stdout_level: int = logging.INFO,
|
@@ -81,9 +80,16 @@ def configure_logging(
|
|
81
80
|
) -> None:
|
82
81
|
"""Configures the logging for the application.
|
83
82
|
Run this function as early as possible in the application (for example using the `lifespan` parameter in FastAPI).
|
84
|
-
Then use can use the default `logging.getLogger(__name__)` method to get the logger.
|
83
|
+
Then use can use the default `logging.getLogger(__name__)` method to get the logger (or <name> if you set the name parameter).
|
84
|
+
:param name: The name of the logger. If not provided, the root logger will be used. Use a name if you use multiple loggers in the same application.
|
85
|
+
:param fmt: The format of the log message.
|
86
|
+
:param datefmt: The date format of the log message.
|
87
|
+
:param stdout_level: The level of the log message to be printed to the console.
|
88
|
+
:param file_level: The level of the log message to be written to the file. Only used if `log_file` is provided.
|
89
|
+
:param log_file: The file to write the log messages to.
|
90
|
+
:param filters: A list of filters to apply to the log handlers.
|
85
91
|
"""
|
86
|
-
logger = logging.getLogger(name)
|
92
|
+
logger = logging.getLogger(name) if name else logging.getLogger()
|
87
93
|
|
88
94
|
if logger.handlers: # clear existing handlers to avoid duplicates
|
89
95
|
logger.handlers.clear()
|
@@ -110,6 +116,9 @@ def configure_logging(
|
|
110
116
|
file_handler.addFilter(filter)
|
111
117
|
logger.addHandler(file_handler)
|
112
118
|
|
119
|
+
if name:
|
120
|
+
logger.propagate = False
|
121
|
+
|
113
122
|
|
114
123
|
def disable_logging():
|
115
124
|
"""Disable logging for the crypticorn logger."""
|
crypticorn/common/middleware.py
CHANGED
@@ -11,7 +11,7 @@ def add_cors_middleware(app: "FastAPI"):
|
|
11
11
|
"http://localhost:5173", # vite dev server
|
12
12
|
"http://localhost:4173", # vite preview server
|
13
13
|
],
|
14
|
-
allow_origin_regex="^https
|
14
|
+
allow_origin_regex="^https://([a-zA-Z0-9-]+.)*crypticorn.(dev|com)/?$", # matches (multiple or no) subdomains of crypticorn.dev and crypticorn.com
|
15
15
|
allow_credentials=True,
|
16
16
|
allow_methods=["*"],
|
17
17
|
allow_headers=["*"],
|
@@ -23,6 +23,5 @@ async def default_lifespan(app: FastAPI):
|
|
23
23
|
This is used to configure the logging for the application.
|
24
24
|
To override this, pass a different lifespan to the FastAPI constructor or call this lifespan within a custom lifespan.
|
25
25
|
"""
|
26
|
-
configure_logging(
|
27
|
-
logger = logging.getLogger(__name__)
|
26
|
+
configure_logging()
|
28
27
|
yield
|
@@ -6,7 +6,7 @@ ONLY ALLOW ACCESS TO THIS ROUTER WITH ADMIN SCOPES.
|
|
6
6
|
"""
|
7
7
|
|
8
8
|
import os
|
9
|
-
import
|
9
|
+
import importlib.metadata
|
10
10
|
import threading
|
11
11
|
import time
|
12
12
|
import psutil
|
@@ -20,10 +20,10 @@ router = APIRouter(tags=["Admin"], prefix="/admin")
|
|
20
20
|
START_TIME = time.time()
|
21
21
|
|
22
22
|
|
23
|
-
@router.get("/log-level", status_code=200, operation_id="getLogLevel")
|
23
|
+
@router.get("/log-level", status_code=200, operation_id="getLogLevel", deprecated=True)
|
24
24
|
async def get_logging_level() -> LogLevel:
|
25
25
|
"""
|
26
|
-
Get the log level of the server logger.
|
26
|
+
Get the log level of the server logger. Will be removed in a future release.
|
27
27
|
"""
|
28
28
|
return LogLevel.get_name(logging.getLogger().level)
|
29
29
|
|
@@ -39,7 +39,7 @@ def get_uptime(type: Literal["seconds", "human"] = "seconds") -> str:
|
|
39
39
|
|
40
40
|
|
41
41
|
@router.get("/memory", operation_id="getMemoryUsage", status_code=200)
|
42
|
-
def get_memory_usage() ->
|
42
|
+
def get_memory_usage() -> float:
|
43
43
|
"""
|
44
44
|
Resident Set Size (RSS) in MB — the actual memory used by the process in RAM.
|
45
45
|
Represents the physical memory footprint. Important for monitoring real usage.
|
@@ -90,11 +90,9 @@ def list_installed_packages(
|
|
90
90
|
)
|
91
91
|
) -> list:
|
92
92
|
"""Return a list of installed packages and versions."""
|
93
|
-
|
94
|
-
[
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
key=lambda x: next(iter(x)),
|
100
|
-
)
|
93
|
+
packages = {
|
94
|
+
dist.metadata["Name"]: dist.version
|
95
|
+
for dist in importlib.metadata.distributions()
|
96
|
+
if include is None or dist.metadata["Name"] in include
|
97
|
+
}
|
98
|
+
return dict(sorted(packages.items()))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
from datetime import datetime
|
2
2
|
from typing import Literal
|
3
|
-
from fastapi import APIRouter
|
3
|
+
from fastapi import APIRouter, Request
|
4
4
|
|
5
5
|
router = APIRouter(tags=["Status"], prefix="")
|
6
6
|
|
7
7
|
|
8
8
|
@router.get("/", operation_id="ping")
|
9
|
-
async def ping() ->
|
9
|
+
async def ping(request: Request) -> dict:
|
10
10
|
"""
|
11
11
|
Returns 'OK' if the API is running.
|
12
12
|
"""
|
crypticorn/hive/utils.py
CHANGED
@@ -17,6 +17,7 @@ Do not edit the class manually.
|
|
17
17
|
__version__ = "1.0.0"
|
18
18
|
|
19
19
|
# import apis into sdk package
|
20
|
+
from crypticorn.klines.client.api.admin_api import AdminApi
|
20
21
|
from crypticorn.klines.client.api.change_in_timeframe_api import ChangeInTimeframeApi
|
21
22
|
from crypticorn.klines.client.api.funding_rates_api import FundingRatesApi
|
22
23
|
from crypticorn.klines.client.api.ohlcv_data_api import OHLCVDataApi
|
@@ -36,10 +37,17 @@ from crypticorn.klines.client.exceptions import ApiAttributeError
|
|
36
37
|
from crypticorn.klines.client.exceptions import ApiException
|
37
38
|
|
38
39
|
# import models into sdk package
|
40
|
+
from crypticorn.klines.client.models.api_error_identifier import ApiErrorIdentifier
|
41
|
+
from crypticorn.klines.client.models.api_error_level import ApiErrorLevel
|
42
|
+
from crypticorn.klines.client.models.api_error_type import ApiErrorType
|
39
43
|
from crypticorn.klines.client.models.change_in_timeframe import ChangeInTimeframe
|
40
44
|
from crypticorn.klines.client.models.exception_detail import ExceptionDetail
|
41
45
|
from crypticorn.klines.client.models.funding_rate import FundingRate
|
42
|
-
from crypticorn.klines.client.models.
|
46
|
+
from crypticorn.klines.client.models.funding_rate_response import FundingRateResponse
|
47
|
+
from crypticorn.klines.client.models.internal_exchange import InternalExchange
|
48
|
+
from crypticorn.klines.client.models.log_level import LogLevel
|
49
|
+
from crypticorn.klines.client.models.market_type import MarketType
|
50
|
+
from crypticorn.klines.client.models.ohlcv import OHLCV
|
43
51
|
from crypticorn.klines.client.models.resolution import Resolution
|
44
52
|
from crypticorn.klines.client.models.search_symbol import SearchSymbol
|
45
53
|
from crypticorn.klines.client.models.sort_direction import SortDirection
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# flake8: noqa
|
2
2
|
|
3
3
|
# import apis into api package
|
4
|
+
from crypticorn.klines.client.api.admin_api import AdminApi
|
4
5
|
from crypticorn.klines.client.api.change_in_timeframe_api import ChangeInTimeframeApi
|
5
6
|
from crypticorn.klines.client.api.funding_rates_api import FundingRatesApi
|
6
7
|
from crypticorn.klines.client.api.ohlcv_data_api import OHLCVDataApi
|