crypticorn 1.0.0__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.
- crypticorn-1.0.0/LICENSE.md +19 -0
- crypticorn-1.0.0/PKG-INFO +34 -0
- crypticorn-1.0.0/README.md +12 -0
- crypticorn-1.0.0/crypticorn/__init__.py +8 -0
- crypticorn-1.0.0/crypticorn/api.py +107 -0
- crypticorn-1.0.0/crypticorn/utils.py +109 -0
- crypticorn-1.0.0/crypticorn.egg-info/PKG-INFO +34 -0
- crypticorn-1.0.0/crypticorn.egg-info/SOURCES.txt +11 -0
- crypticorn-1.0.0/crypticorn.egg-info/dependency_links.txt +1 -0
- crypticorn-1.0.0/crypticorn.egg-info/requires.txt +2 -0
- crypticorn-1.0.0/crypticorn.egg-info/top_level.txt +1 -0
- crypticorn-1.0.0/pyproject.toml +33 -0
- crypticorn-1.0.0/setup.cfg +4 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2024 Crypticorn
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: crypticorn
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: Maximise Your Crypto Trading Profits with AI Predictions
|
5
|
+
Author-email: Crypticorn <timon@crypticorn.com>
|
6
|
+
License: MIT License
|
7
|
+
Project-URL: homepage, https://crypticorn.com
|
8
|
+
Project-URL: documentation, https://docs.crypticorn.com
|
9
|
+
Keywords: machine learning,data science,crypto,modelling
|
10
|
+
Classifier: Topic :: Scientific/Engineering
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
14
|
+
Classifier: Operating System :: OS Independent
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
16
|
+
Classifier: Typing :: Typed
|
17
|
+
Requires-Python: >=3.10
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
License-File: LICENSE.md
|
20
|
+
Requires-Dist: pandas<3.0.0,>=2.2.0
|
21
|
+
Requires-Dist: requests<3.0.0,>=2.32.0
|
22
|
+
|
23
|
+
# What is Crypticorn?
|
24
|
+
|
25
|
+
Crypticorn is at the forefront of cutting-edge artificial intelligence cryptocurrency trading.
|
26
|
+
Crypticorn offers AI-based solutions for both active and passive investors, including:
|
27
|
+
- Prediction Dashboard with trading terminal,
|
28
|
+
- AI Trading Bots with different strategies,
|
29
|
+
- DEX AI Signals for newly launched tokens,
|
30
|
+
- DEX AI Bots
|
31
|
+
|
32
|
+
Use this API Client to contribute to the so-called Hive AI, a community driven AI Meta Model for predicting the
|
33
|
+
cryptocurrency market.
|
34
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# What is Crypticorn?
|
2
|
+
|
3
|
+
Crypticorn is at the forefront of cutting-edge artificial intelligence cryptocurrency trading.
|
4
|
+
Crypticorn offers AI-based solutions for both active and passive investors, including:
|
5
|
+
- Prediction Dashboard with trading terminal,
|
6
|
+
- AI Trading Bots with different strategies,
|
7
|
+
- DEX AI Signals for newly launched tokens,
|
8
|
+
- DEX AI Bots
|
9
|
+
|
10
|
+
Use this API Client to contribute to the so-called Hive AI, a community driven AI Meta Model for predicting the
|
11
|
+
cryptocurrency market.
|
12
|
+
|
@@ -0,0 +1,107 @@
|
|
1
|
+
from typing import Any
|
2
|
+
import pandas as pd
|
3
|
+
import requests
|
4
|
+
import os
|
5
|
+
from .utils import download_file, SingleModel, ModelEvaluation, DataInfo
|
6
|
+
|
7
|
+
|
8
|
+
class Crypticorn:
|
9
|
+
"""
|
10
|
+
A client for interacting with the crypticorn API, offering functionality to create and evaluate models,
|
11
|
+
download data, and retrieve information about available coins, targets, and features.
|
12
|
+
"""
|
13
|
+
|
14
|
+
def __init__(self, api_key: str, headers: dict = None, base_url='https://api.crypticorn.com'):
|
15
|
+
"""@private
|
16
|
+
Initializes the crypticorn API client with an API key.
|
17
|
+
|
18
|
+
:param api_key: The API key required for authenticating requests.
|
19
|
+
"""
|
20
|
+
self._base_url = base_url + "/v1/hive"
|
21
|
+
self._headers = headers if headers else {"Authorization": f"ApiKey {api_key}"}
|
22
|
+
|
23
|
+
def create_model(self, coin_id: int, target: str) -> SingleModel:
|
24
|
+
"""
|
25
|
+
Creates a new model based on the specified coin_id and target.
|
26
|
+
|
27
|
+
:param coin_id: The id of the coin to be used for the model.
|
28
|
+
:param target: The target variable for the model.
|
29
|
+
"""
|
30
|
+
endpoint = "/model/creation"
|
31
|
+
response = requests.post(
|
32
|
+
url=self._base_url + endpoint,
|
33
|
+
params={"coin_id": coin_id, "target": target},
|
34
|
+
headers=self._headers
|
35
|
+
)
|
36
|
+
return response.json()
|
37
|
+
|
38
|
+
def evaluate_model(self, model_id: int, data: Any, version: float = None) -> ModelEvaluation:
|
39
|
+
"""
|
40
|
+
Evaluates an existing model using the provided data.
|
41
|
+
|
42
|
+
:param model_id: The id of the model to evaluate.
|
43
|
+
:param data: The data to use for evaluation, which can be a pandas DataFrame or a file path with
|
44
|
+
extensions `.feather` or `.parquet`.
|
45
|
+
:param version: (optional) Specifies the data version for evaluation. Defaults to the latest version.
|
46
|
+
If a different version than the latest is specified, the evaluation will not be stored
|
47
|
+
or counted on the leaderboard. This is useful for testing your model with different versions.
|
48
|
+
Ensure to specify a `version` if your model was trained on older data versions; otherwise,
|
49
|
+
it will be evaluated against the latest data, potentially affecting the results.
|
50
|
+
"""
|
51
|
+
if isinstance(data, pd.DataFrame):
|
52
|
+
json_data = data.to_json(orient='records')
|
53
|
+
elif isinstance(data, str):
|
54
|
+
if data.endswith('.feather'):
|
55
|
+
json_data = pd.read_feather(data).to_json(orient="records")
|
56
|
+
elif data.endswith('.parquet'):
|
57
|
+
json_data = pd.read_parquet(data).to_json(orient="records")
|
58
|
+
else:
|
59
|
+
raise ValueError("Unsupported file format. Use .feather, .parquet, or pd.Dataframe.")
|
60
|
+
else:
|
61
|
+
raise ValueError("Unsupported data format. Pass a pd.DataFrame or a valid file path.")
|
62
|
+
|
63
|
+
endpoint = "/model/evaluation"
|
64
|
+
response = requests.post(
|
65
|
+
url=self._base_url + endpoint,
|
66
|
+
params={"model_id": model_id, "version": version},
|
67
|
+
json=json_data,
|
68
|
+
headers=self._headers
|
69
|
+
)
|
70
|
+
return response.json()
|
71
|
+
|
72
|
+
def download_data(self, model_id: int, version: float = None,
|
73
|
+
feature_size: str = None) -> int:
|
74
|
+
"""
|
75
|
+
Downloads training data for models.
|
76
|
+
Either pass a model_id or coin_id. For more details about available data, use `data_info()`.
|
77
|
+
|
78
|
+
:param model_id: id of the model to download data for.
|
79
|
+
:param version: (optional) Data version to download. Defaults to the latest version if not specified.
|
80
|
+
:param feature_size: (optional) Size of the feature set to download. Default is "large".
|
81
|
+
"""
|
82
|
+
endpoint = "/data"
|
83
|
+
response = requests.get(
|
84
|
+
url=self._base_url + endpoint,
|
85
|
+
params={"feature_size": feature_size, "version": version, "model_id": model_id},
|
86
|
+
headers=self._headers
|
87
|
+
)
|
88
|
+
if response.status_code != 200:
|
89
|
+
return response.json()
|
90
|
+
data = response.json()
|
91
|
+
base_path = f"v{data['version']}/coin_{data['coin']}/"
|
92
|
+
os.makedirs(base_path, exist_ok=True)
|
93
|
+
download_file(url=data["y_train"], dest_path=f"{base_path}y_train_{data['target']}.feather")
|
94
|
+
download_file(url=data["X_test"], dest_path=f"{base_path}X_test_{data['feature_size']}.feather")
|
95
|
+
download_file(url=data["X_train"], dest_path=f"{base_path}X_train_{data['feature_size']}.feather")
|
96
|
+
return 200
|
97
|
+
|
98
|
+
def data_info(self) -> DataInfo:
|
99
|
+
"""
|
100
|
+
Returns information about the training data.
|
101
|
+
Useful in combination with `download_data()` and `create_model()`.
|
102
|
+
"""
|
103
|
+
endpoint = "/data/info"
|
104
|
+
response = requests.get(
|
105
|
+
url=self._base_url + endpoint,
|
106
|
+
headers=self._headers)
|
107
|
+
return response.json()
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import requests
|
2
|
+
import os
|
3
|
+
import tqdm
|
4
|
+
import logging
|
5
|
+
from pydantic import BaseModel
|
6
|
+
from typing import List, Dict, Any
|
7
|
+
|
8
|
+
logger = logging.getLogger(__name__)
|
9
|
+
logger.setLevel(logging.INFO)
|
10
|
+
|
11
|
+
if not logger.handlers:
|
12
|
+
console_handler = logging.StreamHandler()
|
13
|
+
console_handler.setLevel(logging.INFO)
|
14
|
+
|
15
|
+
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
16
|
+
console_handler.setFormatter(formatter)
|
17
|
+
|
18
|
+
logger.addHandler(console_handler)
|
19
|
+
|
20
|
+
def download_file(url: str, dest_path: str, show_progress_bars: bool = True):
|
21
|
+
"""downloads a file and shows a progress bar. allow resuming a download"""
|
22
|
+
file_size = 0
|
23
|
+
req = requests.get(url, stream=True, timeout=600)
|
24
|
+
req.raise_for_status()
|
25
|
+
|
26
|
+
total_size = int(req.headers.get('content-length', 0))
|
27
|
+
temp_path = dest_path + ".temp"
|
28
|
+
|
29
|
+
if os.path.exists(dest_path):
|
30
|
+
logger.info(f" file already exists: {dest_path}")
|
31
|
+
file_size = os.stat(dest_path).st_size
|
32
|
+
if file_size == total_size:
|
33
|
+
return dest_path
|
34
|
+
|
35
|
+
if os.path.exists(temp_path):
|
36
|
+
file_size = os.stat(temp_path).st_size
|
37
|
+
|
38
|
+
if file_size < total_size:
|
39
|
+
# Download incomplete
|
40
|
+
logger.info(f" resuming download")
|
41
|
+
resume_header = {'Range': f'bytes={file_size}-'}
|
42
|
+
req = requests.get(url, headers=resume_header, stream=True,
|
43
|
+
verify=False, allow_redirects=True, timeout=600)
|
44
|
+
else:
|
45
|
+
# Error, delete file and restart download
|
46
|
+
logger.error(f" deleting file {dest_path} and restarting")
|
47
|
+
os.remove(temp_path)
|
48
|
+
file_size = 0
|
49
|
+
else:
|
50
|
+
# File does not exist, starting download
|
51
|
+
logger.info(f" starting download")
|
52
|
+
|
53
|
+
# write dataset to file and show progress bar
|
54
|
+
pbar = tqdm.tqdm(total=total_size, unit='B', unit_scale=True,
|
55
|
+
desc=dest_path, disable=not show_progress_bars)
|
56
|
+
# Update progress bar to reflect how much of the file is already downloaded
|
57
|
+
pbar.update(file_size)
|
58
|
+
with open(temp_path, "ab") as dest_file:
|
59
|
+
for chunk in req.iter_content(1024):
|
60
|
+
dest_file.write(chunk)
|
61
|
+
pbar.update(1024)
|
62
|
+
# move temp file to target destination
|
63
|
+
os.replace(temp_path, dest_path)
|
64
|
+
return dest_path
|
65
|
+
|
66
|
+
|
67
|
+
class SingleModel(BaseModel):
|
68
|
+
coin_id: int
|
69
|
+
evaluations: List[Dict[str, Any]]
|
70
|
+
created: str
|
71
|
+
model_id: int
|
72
|
+
name: str
|
73
|
+
status: str
|
74
|
+
target: str
|
75
|
+
updated: str
|
76
|
+
dev_id: str
|
77
|
+
target_type: str
|
78
|
+
class Config:
|
79
|
+
protected_namespaces = ()
|
80
|
+
|
81
|
+
|
82
|
+
class AllModels(BaseModel):
|
83
|
+
models: List[SingleModel]
|
84
|
+
|
85
|
+
|
86
|
+
class AccountInfo(BaseModel):
|
87
|
+
api_key: bool
|
88
|
+
models: List[SingleModel]
|
89
|
+
user_id: str
|
90
|
+
username: str
|
91
|
+
updated: str
|
92
|
+
created: str
|
93
|
+
|
94
|
+
|
95
|
+
class ModelEvaluation(BaseModel):
|
96
|
+
benchmarks: Dict[str, Dict[str, Any]]
|
97
|
+
metrics: Dict[str, Any]
|
98
|
+
|
99
|
+
|
100
|
+
class ApiKeyGeneration(BaseModel):
|
101
|
+
api_key: str
|
102
|
+
|
103
|
+
|
104
|
+
class DataInfo(BaseModel):
|
105
|
+
data: Dict[str, Dict[str, Dict[str, List[str]]]]
|
106
|
+
coins: List[str]
|
107
|
+
feature_sizes: List[str]
|
108
|
+
targets: Dict[str, str]
|
109
|
+
versions: Dict[str, float]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: crypticorn
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: Maximise Your Crypto Trading Profits with AI Predictions
|
5
|
+
Author-email: Crypticorn <timon@crypticorn.com>
|
6
|
+
License: MIT License
|
7
|
+
Project-URL: homepage, https://crypticorn.com
|
8
|
+
Project-URL: documentation, https://docs.crypticorn.com
|
9
|
+
Keywords: machine learning,data science,crypto,modelling
|
10
|
+
Classifier: Topic :: Scientific/Engineering
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
14
|
+
Classifier: Operating System :: OS Independent
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
16
|
+
Classifier: Typing :: Typed
|
17
|
+
Requires-Python: >=3.10
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
License-File: LICENSE.md
|
20
|
+
Requires-Dist: pandas<3.0.0,>=2.2.0
|
21
|
+
Requires-Dist: requests<3.0.0,>=2.32.0
|
22
|
+
|
23
|
+
# What is Crypticorn?
|
24
|
+
|
25
|
+
Crypticorn is at the forefront of cutting-edge artificial intelligence cryptocurrency trading.
|
26
|
+
Crypticorn offers AI-based solutions for both active and passive investors, including:
|
27
|
+
- Prediction Dashboard with trading terminal,
|
28
|
+
- AI Trading Bots with different strategies,
|
29
|
+
- DEX AI Signals for newly launched tokens,
|
30
|
+
- DEX AI Bots
|
31
|
+
|
32
|
+
Use this API Client to contribute to the so-called Hive AI, a community driven AI Meta Model for predicting the
|
33
|
+
cryptocurrency market.
|
34
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
LICENSE.md
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
crypticorn/__init__.py
|
5
|
+
crypticorn/api.py
|
6
|
+
crypticorn/utils.py
|
7
|
+
crypticorn.egg-info/PKG-INFO
|
8
|
+
crypticorn.egg-info/SOURCES.txt
|
9
|
+
crypticorn.egg-info/dependency_links.txt
|
10
|
+
crypticorn.egg-info/requires.txt
|
11
|
+
crypticorn.egg-info/top_level.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
crypticorn
|
@@ -0,0 +1,33 @@
|
|
1
|
+
[project]
|
2
|
+
name = "crypticorn"
|
3
|
+
description = "Maximise Your Crypto Trading Profits with AI Predictions"
|
4
|
+
readme = "README.md"
|
5
|
+
requires-python = ">=3.10"
|
6
|
+
license = {text = "MIT License"}
|
7
|
+
authors = [{name = "Crypticorn", email = "timon@crypticorn.com"}]
|
8
|
+
version = "1.0.0"
|
9
|
+
keywords = ["machine learning", "data science", "crypto", "modelling"]
|
10
|
+
|
11
|
+
dependencies = [
|
12
|
+
"pandas >= 2.2.0, < 3.0.0",
|
13
|
+
"requests >= 2.32.0, < 3.0.0",
|
14
|
+
]
|
15
|
+
|
16
|
+
classifiers = [
|
17
|
+
"Topic :: Scientific/Engineering",
|
18
|
+
"License :: OSI Approved :: MIT License",
|
19
|
+
"Development Status :: 4 - Beta",
|
20
|
+
"Intended Audience :: Science/Research",
|
21
|
+
"Operating System :: OS Independent",
|
22
|
+
"Programming Language :: Python :: 3",
|
23
|
+
"Typing :: Typed",
|
24
|
+
]
|
25
|
+
|
26
|
+
[project.urls]
|
27
|
+
homepage = "https://crypticorn.com"
|
28
|
+
documentation = "https://docs.crypticorn.com"
|
29
|
+
|
30
|
+
|
31
|
+
[build-system]
|
32
|
+
requires = ["setuptools>=61.0"]
|
33
|
+
build-backend = "setuptools.build_meta"
|