cryptotab 1.0.0__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.
cryptotab/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .bin import *
2
+
3
+ __version__ = "1.0.0"
cryptotab/bin.py ADDED
@@ -0,0 +1,46 @@
1
+ from jinja2 import Template
2
+
3
+ from .task import *
4
+
5
+ APP_PORT = 8087
6
+ APP_DESC = "Crypto Comparison Toolkit"
7
+
8
+ METRICS = [
9
+ PRICE_FLUCTUATION,
10
+ VOLUME_FLUCTUATION,
11
+ MARTKETCAP_FLUCTUATION,
12
+ SURPLUS_FLUCTUATION,
13
+ ]
14
+
15
+ def form_content():
16
+ return f'''
17
+ <form method="post">
18
+ <p>{html_coin_checkboxes()}</p>
19
+ <p>{html_form_date_range()}</p>
20
+ <p>{html_submit_button()}</p>
21
+ </form>
22
+ '''
23
+
24
+ def form_page():
25
+ return Template(APP_TMP_SIMPLE_PAGE).render(
26
+ APP_CHARSET=APP_CHARSET,
27
+ APP_VIEWPORT=APP_VIEWPORT,
28
+ APP_TITLE=APP_DESC,
29
+ FORM_TITLE=FORM_TITLE,
30
+ FORM_BODY=form_content())
31
+
32
+ def homepage(formpage=form_page):
33
+ async def submit(request: Request):
34
+ if request.method == "GET":
35
+ return HTMLResponse(formpage())
36
+ else:
37
+ form = await request.form()
38
+ symbols = form.getlist("symbols")
39
+ start, end = get_form_date_range(form)
40
+ plotter = html_metrics_plot(
41
+ label=LABEL_COMPARISON,
42
+ metrics=METRICS,
43
+ plot_func=binance_fluctuation_plot(symbols, start=start, end=end, client=client))
44
+ clear_binance_data()
45
+ return plotter
46
+ return submit
cryptotab/cli.py ADDED
@@ -0,0 +1,53 @@
1
+ """
2
+ Usage:
3
+ cryptotab (-h|--help)
4
+ cryptotab [-s <starting_date>] [-e <ending_date>] [-l <symbols_list>] [-c <stable_coin>] [-f <symbols_file>]
5
+
6
+ Arguments:
7
+ -s, --start Starting date of chart
8
+ -e, --end Ending date of chart
9
+ -l, --list Crypto symbols list for chart
10
+ -c, --coin Stable coin for crypto evaluation
11
+ -f, --file YAML file containing symbols list
12
+ <starting_date> A date string in UK format d/m/yyyy
13
+ <ending_date> A date string in UK format d/m/yyyy
14
+ <symbols_list> A list of charting coins, eg. "BTC,ETH", or "?" for manual input
15
+ <stable_coin> A big Binance stable coin, eg. "USDT" or "USDC"
16
+ <symbols_file> Standard YAML file with a list of symbols
17
+ """
18
+
19
+ from cometaz.cli import main as bin_main, input_data, show_chart
20
+
21
+ from .bin import *
22
+
23
+ def build_chart_images(
24
+ symbols: list,
25
+ start: date,
26
+ end: date,
27
+ metrics: list=METRICS) -> list:
28
+ plotter = html_metrics_plot(
29
+ label=LABEL_COMPARISON,
30
+ metrics=metrics,
31
+ plot_func=binance_fluctuation_plot(
32
+ symbols=symbols,
33
+ start=start,
34
+ end=end,
35
+ client=client),
36
+ response_func=None)
37
+ clear_binance_data()
38
+ return plotter
39
+
40
+ def run(args):
41
+ try:
42
+ bisymbols, start, end = input_data(args)
43
+ print("Adjusted ISO starting:", start)
44
+ print("Adjusted ISO ending:", end)
45
+ show_chart(build_chart_images(bisymbols, start, end))
46
+ except Exception as e:
47
+ print(f"Error: {e}")
48
+
49
+ def main():
50
+ bin_main(run, APP_DESC)
51
+
52
+ if __name__ == "__main__":
53
+ main()
cryptotab/environ.py ADDED
@@ -0,0 +1,52 @@
1
+ from tagrepo.environ import set_environ
2
+ from cometaz.cli import read_yaml
3
+
4
+ from cryptobin import *
5
+
6
+ SYMB = "symb"
7
+ NAME = "name"
8
+
9
+ DEF_COINS = {"Defaults": [
10
+ {SYMB: "BTC", NAME: "Bitcoin"},
11
+ {SYMB: "ETH", NAME: "Ethereum"},
12
+ {SYMB: "BNB", NAME: "BNB"},
13
+ {SYMB: "SOL", NAME: "Solana"},
14
+ ]
15
+ }
16
+
17
+ if SYMBOLS_LIST: DEF_COINS = {"Favorites": [{SYMB: x.strip().upper(), NAME: x.strip()} for x in SYMBOLS_LIST.split(",")]}
18
+
19
+ coin_data_adjust = lambda data: {k: [{SYMB: x, NAME: y} for x, y in v.items()] for k, v in data.items()}
20
+ add_suffix = lambda var, *args: str(var) + "".join(list(map(str, args)))
21
+
22
+ def coin_data_load(file: str) -> dict:
23
+ coins = read_yaml(file)
24
+ if coins and type(coins[next(iter(coins))]) is dict:
25
+ coins = coin_data_adjust(coins)
26
+ if not coins:
27
+ coins = DEF_COINS.copy()
28
+ return coins
29
+
30
+ COINS = coin_data_load("list.yaml")
31
+
32
+ def html_coin_checkbox(symbol: dict, list_name: str="symbols", stuff: str=STABLE_COIN, symb=SYMB, name=NAME, symb_func=add_suffix) -> str:
33
+ return html_checkbox(symb_func(symbol[symb], stuff), list_name, labelfunc=lambda arg: symbol[name])
34
+
35
+ def html_coin_group_checkboxes(group: list[dict], list_name: str="symbols", stuff: str=STABLE_COIN, symb=SYMB, name=NAME, symb_func=add_suffix) -> str:
36
+ content_html = ""
37
+ for symbol in group:
38
+ content_html += html_coin_checkbox(symbol, list_name=list_name, stuff=stuff, symb=symb, name=name, symb_func=symb_func)
39
+ return content_html
40
+
41
+ def html_coin_checkboxes(coins: dict=COINS, list_name: str="symbols", stuff: str=STABLE_COIN, symb=SYMB, name=NAME, symb_func=add_suffix) -> str:
42
+ content_html = ""
43
+ for key, group in coins.items():
44
+ content_html += html_fieldset(key.title(), html_coin_group_checkboxes(group, list_name=list_name, stuff=stuff, symb=symb, name=name, symb_func=symb_func))
45
+ return content_html
46
+
47
+ set_environ("PRICE_FLUCTUATION", "Price Fluctuation")
48
+ set_environ("VOLUME_FLUCTUATION", "Volume Fluctuation")
49
+ set_environ("MARTKETCAP_FLUCTUATION", "Martketcap Fluctuation")
50
+ set_environ("SURPLUS_FLUCTUATION", "Profit Fluctuation")
51
+
52
+ set_environ("FORM_TITLE", "Crypto Comparison")
cryptotab/ping.py ADDED
@@ -0,0 +1,47 @@
1
+ import random
2
+ import pandas as pd
3
+ import pingouin as pg
4
+
5
+ from .tab import *
6
+
7
+ RANDOM_SEED = 1234
8
+ SAMPLE_SIZE = 100
9
+
10
+ are_lists = lambda *args: all([type(x) is list for x in args])
11
+ same_size = lambda *args: are_lists(*args) and len(args) and all(len(lst) == len(args[0]) for lst in args)
12
+
13
+ def multivariate(x: list[float], y: list[float], size: int=SAMPLE_SIZE):
14
+ if not same_size(x, y): return None
15
+ t = Tab([x, y])
16
+ np.random.seed(RANDOM_SEED)
17
+ mean, cov = t.mean(), t.cov()
18
+ return np.random.multivariate_normal(mean, cov, size).T.tolist()
19
+
20
+ def t_test(x: list[float], y: list[float], size: int=SAMPLE_SIZE):
21
+ r = multivariate(x, y, size=size)
22
+ return pg.ttest(r[0], r[1]) if are_lists(r) else None
23
+
24
+ def pearson_corr(x: list[float], y: list[float], size: int=SAMPLE_SIZE):
25
+ r = multivariate(x, y, size=size)
26
+ return pg.corr(r[0], r[1]) if are_lists(r) else None
27
+
28
+ def robust_corr(x: list[float], y: list[float], size: int=SAMPLE_SIZE):
29
+ r = multivariate(x, y, size=size)
30
+ if are_lists(r):
31
+ r[0][0] = random.uniform(0, 10**6)
32
+ return pg.corr(r[0], r[1], method="bicor")
33
+ return None
34
+
35
+ def pairwise_corr(x: list[float], y: list[float], size: int=SAMPLE_SIZE):
36
+ r = multivariate(x, y, size=size)
37
+ if are_lists(r):
38
+ data = pd.DataFrame({'X': r[0], 'Y': r[1]})
39
+ return pg.pairwise_corr(data, columns=['X', 'Y'], method='pearson')
40
+ return None
41
+
42
+ def pairwise_t_test(x: list[float], y: list[float], size: int=SAMPLE_SIZE):
43
+ r = multivariate(x, y, size=size)
44
+ if are_lists(r):
45
+ data = pd.DataFrame({'X': r[0], 'Y': r[1]})
46
+ return data.ptests(paired=True, stars=False)
47
+ return None
cryptotab/tab.py ADDED
@@ -0,0 +1,54 @@
1
+ import numpy as np
2
+
3
+ ## tabular data: rows:=variables, cols:=observations
4
+ ## for example: [A_daily_prices[], B_daily_prices[]]
5
+
6
+ class Tab:
7
+ def __init__(self, data: list[list], decimals: int=5):
8
+ self.data = data.copy()
9
+ self.decimals = decimals
10
+ def cov0(self, bias: bool=False) -> list: ## pure python with no number adjustment
11
+ data = self.data
12
+ n_vars = len(data) ## data.rows
13
+ n_obs = len(data[0]) ## data.cols
14
+ means = [sum(var) / n_obs for var in data]
15
+ matrix = [[0.0] * n_vars for _ in range(n_vars)]
16
+ for i in range(n_vars):
17
+ for j in range(i, n_vars):
18
+ cov = sum((data[i][k] - means[i]) * (data[j][k] - means[j]) for k in range(n_obs)) / (n_obs - (1 if not bias else 0))
19
+ matrix[i][j] = cov
20
+ matrix[j][i] = cov ## symmetric cov
21
+ return matrix
22
+ def cov(self, bias: bool=False) -> list: ## using numpy
23
+ return np.cov(np.array(self.data), bias=bias).tolist()
24
+ def mean(self, axis: int=1) -> list: ## default mean on rows
25
+ return np.mean(self.data, axis=axis).tolist() ## axis=0 for mean on columns
26
+ def round(self, data=None, decimals: int=-1) -> list: ## for data printing
27
+ if data is None: data = self.data
28
+ if decimals < 0: decimals = self.decimals
29
+ return np.round(data, decimals=decimals).tolist()
30
+
31
+ class Frame:
32
+ import pandas as pd
33
+ def __init__(self, data: list[list]):
34
+ self.df = self.pd.DataFrame(list(row) for row in zip(*data))
35
+ def diff(self, fillna: any=None, colabs: str="abs_change", colpct: str="pct_change"):
36
+ df = self.df.copy()
37
+ for i in range(len(df.columns)):
38
+ df[f"{colabs}_{i}"] = df[i].diff()
39
+ df[f"{colpct}_{i}"] = df[i].pct_change() * 100
40
+ if fillna is not None: df = df.fillna(fillna)
41
+ return df
42
+ def getdiff(self, fillna: any=None): ## income
43
+ df = self.diff(fillna=fillna)
44
+ df = df.drop(columns=df.columns[:len(self.df.columns)])
45
+ return df
46
+ def avgdiff(self, skip: int=1) -> tuple: ## skip first row at default
47
+ df = self.getdiff(fillna=0)
48
+ return df, df.iloc[skip:].mean()
49
+ def diffdev(self, skip: int=1): ## income surplus
50
+ df, means = self.avgdiff(skip=skip)
51
+ for col in df.columns:
52
+ df[f"dev_{col}"] = df[col] - means[col]
53
+ df = df.drop(columns=df.columns[:len(self.df.columns) * 2])
54
+ return df.iloc[skip:]
cryptotab/task.py ADDED
@@ -0,0 +1,25 @@
1
+ from .environ import *
2
+ from .tab import *
3
+
4
+ def clear_binance_data():
5
+ global binance_data
6
+ binance_data = {}
7
+
8
+ def binance_fluctuation_plot(symbols: list, start: date, end: date, client: Client, valfield="pct_change_0", devprefix="dev_"):
9
+ global binance_data
10
+ if not binance_data: binance_data = binance_core_data(symbols=symbols, start=start, end=end, client=client)
11
+ def plot(metric: str):
12
+ if metric in [VOLUME_FLUCTUATION]:
13
+ key = "volumes"
14
+ elif metric in [MARTKETCAP_FLUCTUATION]:
15
+ key = "caps"
16
+ else:
17
+ key = "rates"
18
+ for symbol, data in binance_data.items():
19
+ frame = Frame([data[key]])
20
+ if metric in [SURPLUS_FLUCTUATION]:
21
+ data["chart"] = frame.diffdev(0)[devprefix + valfield].tolist()
22
+ else:
23
+ data["chart"] = frame.getdiff(0)[valfield].tolist()
24
+ plt.plot(data["dates"], data["chart"], label=symbol)
25
+ return plot
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: cryptotab
3
+ Version: 1.0.0
4
+ Summary: Crypto Comparison Universal Toolkit
5
+ Home-page: https://github.com/asinerum/cryptotab
6
+ Author: Asinerum Conlang Project
7
+ Author-email: asinerum.com@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: jinja2>=3.1.6
16
+ Requires-Dist: pingouin>=0.5.5
17
+ Requires-Dist: tagrepo>=1.0.19
18
+ Requires-Dist: cometaz>=1.0.4
19
+ Requires-Dist: vapp>=1.0.5
20
+ Requires-Dist: uvia>=1.0.2
21
+ Dynamic: license-file
22
+
23
+ # Crypto Comparison Universal Toolkit
24
+
25
+ ## Installation
26
+ ```bash
27
+ pip install uvia vapp cryptotab
28
+ ```
29
+
30
+ ## Data Prerequisites
31
+ A valid YAML data file should be created in working folder.
32
+ Sample well-formatted files (with real cryptocurrency lists) are included in the package.
33
+
34
+ ## Web Daemon Usage
35
+ ```bash
36
+ uvia -a vapp -m cryptotab --host 127.0.0.1 --port 7890
37
+ ```
38
+
39
+ ## CLI Usage
40
+ ```bash
41
+ cryptotab --help
42
+ ```
43
+
44
+ Detailed tips, tricks, and examples, can be found at project's repository
45
+ https://github.com/asinerum/cryptotab
46
+
47
+ (C)2026 Asinerum Conlang Project
@@ -0,0 +1,13 @@
1
+ cryptotab/__init__.py,sha256=HgwMrmclqXTs8lX_SHSH2I9LJllLtKc7m83-QSX8lcA,45
2
+ cryptotab/bin.py,sha256=hcVWGzAb_A7HsZXKcMV91ABpco5Wyut1bPhkWqwEIBo,1122
3
+ cryptotab/cli.py,sha256=5iSl4ntLYcIvXn0Rr6xC5wUoUFWjG4LWCliEw-g4iJA,1508
4
+ cryptotab/environ.py,sha256=CpwAGbtUQidyi9BQ2phwL-jT1vyrt8wpfdGYNIOh0ik,2097
5
+ cryptotab/ping.py,sha256=A1SPC0eRXLWjAQAIskKiRHHSkGjL0B4qU_Vidapet4E,1604
6
+ cryptotab/tab.py,sha256=kP2L5XLU7_-QaXOPO9bNQYyUBr06Vu4yq1flpVske-U,2285
7
+ cryptotab/task.py,sha256=QfDeAT78uKAxWEGrS-csInplI51-4hNeXBw2T98IUIc,890
8
+ cryptotab-1.0.0.dist-info/licenses/LICENSE,sha256=4npUbkrpgB6lqMiYYeUxZAP4SOkjVSwK8-7jW60mxvw,1081
9
+ cryptotab-1.0.0.dist-info/METADATA,sha256=uV6OHnDoZu1pmDbIpt4_jk_Rp9blUn0iA58mCLTASSE,1258
10
+ cryptotab-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
11
+ cryptotab-1.0.0.dist-info/entry_points.txt,sha256=6SteWGa16lmpByho1MdgOES-WVUNmsEq8ugTmLVIgRA,49
12
+ cryptotab-1.0.0.dist-info/top_level.txt,sha256=T9As8HVM81zuQBZ2Wv9ZaB9q8BaZXs1XnpMCiN6YF3w,10
13
+ cryptotab-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cryptotab = cryptotab.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Asinerum Conlang Project
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ cryptotab