diff options
-rw-r--r-- | script.py | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -9,12 +9,6 @@ def static_var(varname, value): | |||
9 | return decorate | 9 | return decorate |
10 | 10 | ||
11 | max_digits = 18 | 11 | max_digits = 18 |
12 | current_assets = { | ||
13 | "ETH": int(2.00000000 * 10**max_digits), | ||
14 | "BTC": int(1.23000000 * 10**max_digits), | ||
15 | "ZEC": int(2.00000000 * 10**max_digits), | ||
16 | "SC" : int(2.000000000 * 10**max_digits), | ||
17 | } | ||
18 | 12 | ||
19 | repartition_pertenthousand = { | 13 | repartition_pertenthousand = { |
20 | "BTC": 2857, | 14 | "BTC": 2857, |
@@ -50,6 +44,14 @@ def get_ticker(c1, c2, market): | |||
50 | get_ticker.cache[(c1, c2, market.__class__)] = None | 44 | get_ticker.cache[(c1, c2, market.__class__)] = None |
51 | return get_ticker(c1, c2, market) | 45 | return get_ticker(c1, c2, market) |
52 | 46 | ||
47 | def fetch_balances(market): | ||
48 | balances = {} | ||
49 | fetched_balance = market.fetch_balance() | ||
50 | for key, value in fetched_balance["total"].items(): | ||
51 | if value > 0: | ||
52 | balances[key] = int(value * 10**max_digits) | ||
53 | return balances | ||
54 | |||
53 | def assets_value(assets, market, base_currency="BTC"): | 55 | def assets_value(assets, market, base_currency="BTC"): |
54 | repartition_in_base_currency = {} | 56 | repartition_in_base_currency = {} |
55 | for currency, asset_value in assets.items(): | 57 | for currency, asset_value in assets.items(): |
@@ -107,4 +109,5 @@ def give_orders(current_assets, repartition_pertenthousand, market, base_currenc | |||
107 | for currency, value in new_repartition.items(): | 109 | for currency, value in new_repartition.items(): |
108 | print("holding {} {}".format(formatted_price(value), currency)) | 110 | print("holding {} {}".format(formatted_price(value), currency)) |
109 | 111 | ||
112 | current_assets = fetch_balances(market) | ||
110 | give_orders(current_assets, repartition_pertenthousand, market) | 113 | give_orders(current_assets, repartition_pertenthousand, market) |