cryptobin 1.0.2__tar.gz → 1.0.3__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.3
4
4
  Summary: Binance Crypto Comparison Lib
5
5
  Home-page: https://github.com/asinerum/cryptobin
6
6
  Author: Asinerum Conlang Project
@@ -19,7 +19,7 @@ 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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = cryptobin
3
- version = 1.0.2
3
+ version = 1.0.3
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.3"
@@ -54,24 +54,31 @@ KLINE_VOLUME_INDEX = 7
54
54
 
55
55
  client = Client(BINANCE_API_KEY, BINANCE_API_SECRET)
56
56
 
57
+ def binance_core_data(symbols: list, start: date, end: date, client: Client, proportions: list=[]):
58
+ if not proportions: proportions = [1 for _ in symbols]
59
+ data = {}
60
+ for i in range(len(symbols)):
61
+ symbol = symbols[i]
62
+ proportion = float(proportions[i])
63
+ klines = binance_get_klines(symbol, start=start, end=end, client=client)
64
+ if proportion == 0: proportion = float(klines[0][KLINE_RATE_INDEX]) #comet
65
+ dates = [datetime.fromtimestamp(k[KLINE_DATE_INDEX]/1000) for k in klines]
66
+ rates = [float(k[KLINE_RATE_INDEX])/proportion for k in klines]
67
+ volumes = [float(k[KLINE_VOLUME_INDEX]) for k in klines]
68
+ caps = [c*v for c,v in zip(rates, volumes)]
69
+ data[symbol] = {"dates": dates, "rates": rates, "volumes": volumes, "caps": caps}
70
+ return data
71
+
57
72
  def binance_klines_plot(symbols: list, proportions: list, start: date, end: date, client: Client):
58
73
  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)]
74
+ data = binance_core_data(symbols=symbols, start=start, end=end, client=client, proportions=proportions)
75
+ for symbol, coindata in data.items():
69
76
  if metric == METRIC_RATE:
70
- plt.plot(dates, rates, label=symbol)
77
+ plt.plot(coindata["dates"], coindata["rates"], label=symbol)
71
78
  elif metric == METRIC_VOL:
72
- plt.plot(dates, volumes, label=symbol)
79
+ plt.plot(coindata["dates"], coindata["volumes"], label=symbol)
73
80
  elif metric == METRIC_CAP:
74
- plt.plot(dates, caps, label=symbol)
81
+ plt.plot(coindata["dates"], coindata["caps"], label=symbol)
75
82
  return plot
76
83
 
77
84
  def binance_get_klines(symbol: str, start: date, end: date, client: Client, interval=Client.KLINE_INTERVAL_1DAY):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptobin
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Binance Crypto Comparison Lib
5
5
  Home-page: https://github.com/asinerum/cryptobin
6
6
  Author: Asinerum Conlang Project
@@ -19,7 +19,7 @@ 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
@@ -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
@@ -1,3 +0,0 @@
1
- from .core import *
2
-
3
- __version__ = "1.0.2"
File without changes
File without changes
File without changes