cryptobin 1.0.2__tar.gz → 1.0.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptobin
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Binance Crypto Comparison Lib
5
5
  Home-page: https://github.com/asinerum/cryptobin
6
6
  Author: Asinerum Conlang Project
@@ -19,11 +19,22 @@ Requires-Dist: python-dotenv>=1.2.1
19
19
  Requires-Dist: python-multipart>=0.0.29
20
20
  Requires-Dist: starlette>=0.50.0
21
21
  Requires-Dist: uvicorn>=0.38.0
22
- Requires-Dist: tagrepo
22
+ Requires-Dist: tagrepo>=1.0.19
23
23
  Dynamic: license-file
24
24
 
25
25
  # Binance Crypto Comparison Lib
26
26
 
27
+ ## Installation
28
+ ```bash
29
+ pip install uvia vapp cryptobin
30
+ ```
31
+
32
+ ## Sample Usage (CLI Web Daemon)
33
+ ```bash
34
+ export SYMBOLS_LIST="btc,eth,bnb,sol"
35
+ uvia -a vapp -m cryptobin [-H <host>] [-p <port>]
36
+ ```
37
+
27
38
  Detailed tips, tricks, and examples, can be found at project's repository
28
39
  https://github.com/asinerum/cryptobin
29
40
 
@@ -0,0 +1,17 @@
1
+ # Binance Crypto Comparison Lib
2
+
3
+ ## Installation
4
+ ```bash
5
+ pip install uvia vapp cryptobin
6
+ ```
7
+
8
+ ## Sample Usage (CLI Web Daemon)
9
+ ```bash
10
+ export SYMBOLS_LIST="btc,eth,bnb,sol"
11
+ uvia -a vapp -m cryptobin [-H <host>] [-p <port>]
12
+ ```
13
+
14
+ Detailed tips, tricks, and examples, can be found at project's repository
15
+ https://github.com/asinerum/cryptobin
16
+
17
+ (C) 2026 Asinerum Conlang Project
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = cryptobin
3
- version = 1.0.2
3
+ version = 1.0.4
4
4
  author = Asinerum Conlang Project
5
5
  author_email = asinerum.com@gmail.com
6
6
  description = Binance Crypto Comparison Lib
@@ -26,7 +26,7 @@ install_requires =
26
26
  python-multipart >= 0.0.29
27
27
  starlette >= 0.50.0
28
28
  uvicorn >= 0.38.0
29
- tagrepo
29
+ tagrepo >= 1.0.19
30
30
 
31
31
  [options.packages.find]
32
32
  where = src
@@ -0,0 +1,3 @@
1
+ from .core import *
2
+
3
+ __version__ = "1.0.4"
@@ -1,3 +1,10 @@
1
+ """
2
+ Sample Usage:
3
+ - CLI web daemon:
4
+ export SYMBOLS_LIST="btc,eth,bnb,sol"
5
+ uvia -a vapp -m cryptobin [-H <host>] [-p <port>]
6
+ """
7
+
1
8
  import os
2
9
  import io
3
10
  import tempfile
@@ -5,7 +12,7 @@ import uvicorn ## for <uvia>
5
12
  import matplotlib.pyplot as plt
6
13
  import base64
7
14
 
8
- from datetime import date, datetime
15
+ from datetime import date, datetime, timedelta
9
16
  from dotenv import load_dotenv
10
17
  from binance.client import Client
11
18
 
@@ -54,24 +61,38 @@ KLINE_VOLUME_INDEX = 7
54
61
 
55
62
  client = Client(BINANCE_API_KEY, BINANCE_API_SECRET)
56
63
 
64
+ def plotter_output_html(savefig_instance, caption: str, format: str='png') -> str:
65
+ buf = io.BytesIO()
66
+ savefig_instance(buf, format=format)
67
+ buf.seek(0)
68
+ img_b64 = base64.b64encode(buf.read()).decode('utf-8')
69
+ return f'''<h3>{caption.capitalize()}</h3><img src="data:image/png;base64,{img_b64}"><br>'''
70
+
71
+ def binance_core_data(symbols: list, start: date, end: date, client: Client, proportions: list=[]):
72
+ if not proportions: proportions = [1 for _ in symbols]
73
+ data = {}
74
+ for i in range(len(symbols)):
75
+ symbol = symbols[i]
76
+ proportion = float(proportions[i])
77
+ klines = binance_get_klines(symbol, start=start, end=end, client=client)
78
+ if proportion == 0: proportion = float(klines[0][KLINE_RATE_INDEX]) #comet
79
+ dates = [datetime.fromtimestamp(k[KLINE_DATE_INDEX]/1000) for k in klines]
80
+ rates = [float(k[KLINE_RATE_INDEX])/proportion for k in klines]
81
+ volumes = [float(k[KLINE_VOLUME_INDEX]) for k in klines]
82
+ caps = [c*v for c,v in zip(rates, volumes)]
83
+ data[symbol] = {"dates": dates, "rates": rates, "volumes": volumes, "caps": caps}
84
+ return data
85
+
57
86
  def binance_klines_plot(symbols: list, proportions: list, start: date, end: date, client: Client):
58
87
  def plot(metric: str):
59
- for i in range(len(symbols)):
60
- symbol = symbols[i]
61
- proportion = float(proportions[i])
62
- klines = binance_get_klines(symbol, start=start, end=end, client=client)
63
- if proportion == 0: proportion = float(klines[0][KLINE_RATE_INDEX]) #comet
64
- dates = [datetime.fromtimestamp(k[KLINE_DATE_INDEX]/1000) for k in klines]
65
- rates = [float(k[KLINE_RATE_INDEX])/proportion for k in klines]
66
- volumes = [float(k[KLINE_VOLUME_INDEX]) for k in klines]
67
- # Market cap approximation is [rate * volume]
68
- caps = [c*v for c,v in zip(rates, volumes)]
88
+ data = binance_core_data(symbols=symbols, start=start, end=end, client=client, proportions=proportions)
89
+ for symbol, coindata in data.items():
69
90
  if metric == METRIC_RATE:
70
- plt.plot(dates, rates, label=symbol)
91
+ plt.plot(coindata["dates"], coindata["rates"], label=symbol)
71
92
  elif metric == METRIC_VOL:
72
- plt.plot(dates, volumes, label=symbol)
93
+ plt.plot(coindata["dates"], coindata["volumes"], label=symbol)
73
94
  elif metric == METRIC_CAP:
74
- plt.plot(dates, caps, label=symbol)
95
+ plt.plot(coindata["dates"], coindata["caps"], label=symbol)
75
96
  return plot
76
97
 
77
98
  def binance_get_klines(symbol: str, start: date, end: date, client: Client, interval=Client.KLINE_INTERVAL_1DAY):
@@ -86,16 +107,10 @@ def html_metrics_plot(label: str, metrics: list, plot_func, response_func=HTMLRe
86
107
  plt.title(f'{metric} {label}'.title())
87
108
  plt.legend()
88
109
  plt.tight_layout()
89
- if not response_func:
90
- plot_file = plotter_save_temp(plt.savefig)
91
- plot_files.append(plot_file)
92
- plt.close()
93
- continue
94
- buf = io.BytesIO()
95
- plt.savefig(buf, format='png')
96
- buf.seek(0)
97
- img_b64 = base64.b64encode(buf.read()).decode('utf-8')
98
- charts_html += f'''<h3>{metric.capitalize()}</h3><img src="data:image/png;base64,{img_b64}"><br>'''
110
+ if response_func:
111
+ charts_html += plotter_output_html(plt.savefig, caption=metric)
112
+ else:
113
+ plot_files += [plotter_save_temp(plt.savefig)]
99
114
  plt.close()
100
115
  return response_func(f'<html><body>{charts_html}</body></html>') if response_func else plot_files
101
116
 
@@ -142,8 +157,8 @@ def homepage(formpage=form_page):
142
157
  form = await request.form()
143
158
  symbols = form.getlist('symbols')
144
159
  proportions = form.getlist('proportions')
145
- start = date.fromisoformat(form['start'])
146
- end = date.fromisoformat(form['end'])
160
+ start = date.fromisoformat(form.get('start') or (date.today() - timedelta(days=30)).isoformat())
161
+ end = date.fromisoformat(form.get('end') or date.today().isoformat())
147
162
  metrics = [METRIC_RATE, METRIC_VOL, METRIC_CAP]
148
163
  return html_metrics_plot(label=LABEL_COMPARISON, metrics=metrics, plot_func=binance_klines_plot(symbols, proportions, start=start, end=end, client=client))
149
164
  return submit
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptobin
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Binance Crypto Comparison Lib
5
5
  Home-page: https://github.com/asinerum/cryptobin
6
6
  Author: Asinerum Conlang Project
@@ -19,11 +19,22 @@ Requires-Dist: python-dotenv>=1.2.1
19
19
  Requires-Dist: python-multipart>=0.0.29
20
20
  Requires-Dist: starlette>=0.50.0
21
21
  Requires-Dist: uvicorn>=0.38.0
22
- Requires-Dist: tagrepo
22
+ Requires-Dist: tagrepo>=1.0.19
23
23
  Dynamic: license-file
24
24
 
25
25
  # Binance Crypto Comparison Lib
26
26
 
27
+ ## Installation
28
+ ```bash
29
+ pip install uvia vapp cryptobin
30
+ ```
31
+
32
+ ## Sample Usage (CLI Web Daemon)
33
+ ```bash
34
+ export SYMBOLS_LIST="btc,eth,bnb,sol"
35
+ uvia -a vapp -m cryptobin [-H <host>] [-p <port>]
36
+ ```
37
+
27
38
  Detailed tips, tricks, and examples, can be found at project's repository
28
39
  https://github.com/asinerum/cryptobin
29
40
 
@@ -5,4 +5,4 @@ python-dotenv>=1.2.1
5
5
  python-multipart>=0.0.29
6
6
  starlette>=0.50.0
7
7
  uvicorn>=0.38.0
8
- tagrepo
8
+ tagrepo>=1.0.19
cryptobin-1.0.2/README.md DELETED
@@ -1,6 +0,0 @@
1
- # Binance Crypto Comparison Lib
2
-
3
- Detailed tips, tricks, and examples, can be found at project's repository
4
- https://github.com/asinerum/cryptobin
5
-
6
- (C) 2026 Asinerum Conlang Project
@@ -1,3 +0,0 @@
1
- from .core import *
2
-
3
- __version__ = "1.0.2"
File without changes
File without changes