cryptobin 1.0.0__tar.gz → 1.0.2__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,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptobin
3
- Version: 1.0.0
4
- Summary: Binance Crypto Comparison Library
3
+ Version: 1.0.2
4
+ Summary: Binance Crypto Comparison Lib
5
5
  Home-page: https://github.com/asinerum/cryptobin
6
6
  Author: Asinerum Conlang Project
7
7
  Author-email: asinerum.com@gmail.com
@@ -12,14 +12,18 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.7
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
+ Requires-Dist: pillow>=12.3.0
15
16
  Requires-Dist: matplotlib>=3.10.7
16
17
  Requires-Dist: python-binance>=1.0.36
17
18
  Requires-Dist: python-dotenv>=1.2.1
18
19
  Requires-Dist: python-multipart>=0.0.29
19
20
  Requires-Dist: starlette>=0.50.0
20
21
  Requires-Dist: uvicorn>=0.38.0
22
+ Requires-Dist: tagrepo
21
23
  Dynamic: license-file
22
24
 
25
+ # Binance Crypto Comparison Lib
26
+
23
27
  Detailed tips, tricks, and examples, can be found at project's repository
24
28
  https://github.com/asinerum/cryptobin
25
29
 
@@ -1,3 +1,5 @@
1
+ # Binance Crypto Comparison Lib
2
+
1
3
  Detailed tips, tricks, and examples, can be found at project's repository
2
4
  https://github.com/asinerum/cryptobin
3
5
 
@@ -1,9 +1,9 @@
1
1
  [metadata]
2
2
  name = cryptobin
3
- version = 1.0.0
3
+ version = 1.0.2
4
4
  author = Asinerum Conlang Project
5
5
  author_email = asinerum.com@gmail.com
6
- description = Binance Crypto Comparison Library
6
+ description = Binance Crypto Comparison Lib
7
7
  long_description = file: README.md
8
8
  long_description_content_type = text/markdown
9
9
  url = https://github.com/asinerum/cryptobin
@@ -19,12 +19,14 @@ package_dir =
19
19
  packages = find:
20
20
  python_requires = >=3.7
21
21
  install_requires =
22
+ pillow >= 12.3.0
22
23
  matplotlib >= 3.10.7
23
24
  python-binance >= 1.0.36
24
25
  python-dotenv >= 1.2.1
25
26
  python-multipart >= 0.0.29
26
27
  starlette >= 0.50.0
27
28
  uvicorn >= 0.38.0
29
+ tagrepo
28
30
 
29
31
  [options.packages.find]
30
32
  where = src
@@ -0,0 +1,3 @@
1
+ from .core import *
2
+
3
+ __version__ = "1.0.2"
@@ -1,16 +1,21 @@
1
1
  import os
2
2
  import io
3
+ import tempfile
3
4
  import uvicorn ## for <uvia>
4
5
  import matplotlib.pyplot as plt
5
6
  import base64
7
+
6
8
  from datetime import date, datetime
7
9
  from dotenv import load_dotenv
8
10
  from binance.client import Client
11
+
9
12
  from starlette.applications import Starlette
10
13
  from starlette.responses import HTMLResponse
11
14
  from starlette.routing import Route
12
15
  from starlette.requests import Request
13
16
 
17
+ from tagrepo import *
18
+
14
19
  APP_PORT = 8081
15
20
  APP_DESC = 'Binance Crypto Comparison Toolkit'
16
21
 
@@ -18,9 +23,6 @@ METRIC_RATE = 'rate'
18
23
  METRIC_VOL = 'volume'
19
24
  METRIC_CAP = 'cap'
20
25
 
21
- APP_CHARSET = '<meta charset="utf-8">'
22
- APP_VIEWPORT = '<meta name="viewport" content="width=device-width,initial-scale=1.0">'
23
-
24
26
  load_dotenv()
25
27
 
26
28
  symbols_list = ['BTC', 'ETH', 'BNB']
@@ -42,8 +44,8 @@ LABEL_START_DATE = os.getenv('LABEL_START_DATE') or 'Starting date'
42
44
  LABEL_END_DATE = os.getenv('LABEL_END_DATE') or 'Ending date'
43
45
  LABEL_SUBMIT_BUTTON = os.getenv('LABEL_SUBMIT_BUTTON') or 'Compare'
44
46
  LABEL_COMPARISON = os.getenv('LABEL_COMPARISON') or 'Comparison'
45
- CAPTION_PROPORTION = os.getenv('CAPTION_PROPORTION') or 'Proportion (default 1)'
46
- STYLE_SUBMIT_BUTTON = os.getenv('STYLE_SUBMIT_BUTTON') or 'cursor:pointer;border-radius:3px;background-color:#04AA6D;color:white;font-size:18px;padding:20px;border:none;width:100%'
47
+ CAPTION_PROPORTION = os.getenv('CAPTION_PROPORTION', 'Proportion (default 1)')
48
+ STYLE_SUBMIT_BUTTON = os.getenv('STYLE_SUBMIT_BUTTON', APP_SUBMIT_BUTTON_STYLE)
47
49
 
48
50
  BINANCE_DATE_FORMAT = '%d %b %Y'
49
51
  KLINE_DATE_INDEX = 0
@@ -77,58 +79,30 @@ def binance_get_klines(symbol: str, start: date, end: date, client: Client, inte
77
79
 
78
80
  def html_metrics_plot(label: str, metrics: list, plot_func, response_func=HTMLResponse):
79
81
  charts_html = ''
82
+ plot_files = []
80
83
  for metric in metrics:
81
84
  plt.figure(figsize=(8,5))
82
85
  plot_func(metric)
83
86
  plt.title(f'{metric} {label}'.title())
84
87
  plt.legend()
85
88
  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
86
94
  buf = io.BytesIO()
87
95
  plt.savefig(buf, format='png')
88
96
  buf.seek(0)
89
97
  img_b64 = base64.b64encode(buf.read()).decode('utf-8')
90
98
  charts_html += f'''<h3>{metric.capitalize()}</h3><img src="data:image/png;base64,{img_b64}"><br>'''
91
99
  plt.close()
92
- return response_func(f'<html><body>{charts_html}</body></html>')
93
-
94
- def html_text_checkbox(input_id: str, param_name: str, text_name: str, defvalue: str, labelfunc=str) -> str:
95
- return f'''<label>\n<input type="checkbox" name="{param_name}" id="{input_id}" value="{input_id}">\n<input type="text" size="10" name="{text_name}" value="{defvalue}">\n{labelfunc(input_id)}\n</label><br>'''
96
-
97
- def html_text_checkboxes(param_name: str, text_name: str, input_ids: list, defvalue: str, labelfunc=str) -> str:
98
- html_str = ''
99
- for input_id in input_ids:
100
- html_str += html_text_checkbox(input_id=input_id, param_name=param_name, text_name=text_name, defvalue=defvalue, labelfunc=labelfunc) + '\n'
101
- return html_str
102
-
103
- def html_input_date(input_id: str, param_name: str, label: str) -> str:
104
- return f'''<input type="date" id="{input_id}" name="{param_name}">\n<label for="{input_id}">{label}</label><br>'''
105
-
106
- def html_input_dates(param_names: list, labels: list, insert: str='\n') -> str:
107
- html_strs = []
108
- for i in range(len(param_names)):
109
- html_strs.append(html_input_date(input_id=param_names[i], param_name=param_names[i], label=labels[i]))
110
- return insert.join(html_strs)
111
-
112
- def html_fieldset(legend: str, settings: str) -> str:
113
- return f'''<fieldset>\n<legend>{legend}</legend>\n{settings}</fieldset>'''
114
-
115
- def html_checkbox(input_id: str, param_name: str, labelfunc=str) -> str:
116
- return f'''<input type="checkbox" id="{input_id}" name="{param_name}" value="{input_id}">\n<label for="{input_id}">{labelfunc(input_id)}</label><br>'''
117
-
118
- def html_checkboxes(param_name: str, input_ids: list, labelfunc=str) -> str:
119
- html_str = ''
120
- for input_id in input_ids:
121
- html_str += html_checkbox(input_id=input_id, param_name=param_name, labelfunc=labelfunc) + '\n'
122
- return html_str
123
-
124
- def html_hidden_checkbox(input_id: str, param_name: str, text_name: str, defvalue: str, labelfunc=str) -> str:
125
- return f'''<label>\n<input type="checkbox" name="{param_name}" id="{input_id}" value="{input_id}">\n<input type="hidden" name="{text_name}" value="{defvalue}">\n{labelfunc(input_id)}\n</label><br>'''
126
-
127
- def html_hidden_checkboxes(param_name: str, text_name: str, input_ids: list, defvalue: str, labelfunc=str) -> str:
128
- html_str = ''
129
- for input_id in input_ids:
130
- html_str += html_hidden_checkbox(input_id=input_id, param_name=param_name, text_name=text_name, defvalue=defvalue, labelfunc=labelfunc) + '\n'
131
- return html_str
100
+ return response_func(f'<html><body>{charts_html}</body></html>') if response_func else plot_files
101
+
102
+ def plotter_save_temp(savefig_instance) -> str:
103
+ tmp_file = tempfile.NamedTemporaryFile(suffix=".png", delete=False)
104
+ savefig_instance(tmp_file.name, format="png")
105
+ return tmp_file.name
132
106
 
133
107
  def form_page():
134
108
  return f'''
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptobin
3
- Version: 1.0.0
4
- Summary: Binance Crypto Comparison Library
3
+ Version: 1.0.2
4
+ Summary: Binance Crypto Comparison Lib
5
5
  Home-page: https://github.com/asinerum/cryptobin
6
6
  Author: Asinerum Conlang Project
7
7
  Author-email: asinerum.com@gmail.com
@@ -12,14 +12,18 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.7
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
+ Requires-Dist: pillow>=12.3.0
15
16
  Requires-Dist: matplotlib>=3.10.7
16
17
  Requires-Dist: python-binance>=1.0.36
17
18
  Requires-Dist: python-dotenv>=1.2.1
18
19
  Requires-Dist: python-multipart>=0.0.29
19
20
  Requires-Dist: starlette>=0.50.0
20
21
  Requires-Dist: uvicorn>=0.38.0
22
+ Requires-Dist: tagrepo
21
23
  Dynamic: license-file
22
24
 
25
+ # Binance Crypto Comparison Lib
26
+
23
27
  Detailed tips, tricks, and examples, can be found at project's repository
24
28
  https://github.com/asinerum/cryptobin
25
29
 
@@ -1,6 +1,8 @@
1
+ pillow>=12.3.0
1
2
  matplotlib>=3.10.7
2
3
  python-binance>=1.0.36
3
4
  python-dotenv>=1.2.1
4
5
  python-multipart>=0.0.29
5
6
  starlette>=0.50.0
6
7
  uvicorn>=0.38.0
8
+ tagrepo
@@ -1,3 +0,0 @@
1
- from .core import *
2
-
3
- __version__ = "1.0.0"
File without changes
File without changes