From: Ismaƫl Bouya Date: Thu, 11 Jan 2018 23:39:27 +0000 (+0100) Subject: Fetch assets from market X-Git-Tag: v0.1~48 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=commitdiff_plain;h=73e777420f63616e883393c50f0684243ac19bed Fetch assets from market --- diff --git a/script.py b/script.py index 9bc2fe6..b31fd61 100644 --- a/script.py +++ b/script.py @@ -9,12 +9,6 @@ def static_var(varname, value): return decorate max_digits = 18 -current_assets = { - "ETH": int(2.00000000 * 10**max_digits), - "BTC": int(1.23000000 * 10**max_digits), - "ZEC": int(2.00000000 * 10**max_digits), - "SC" : int(2.000000000 * 10**max_digits), - } repartition_pertenthousand = { "BTC": 2857, @@ -50,6 +44,14 @@ def get_ticker(c1, c2, market): get_ticker.cache[(c1, c2, market.__class__)] = None return get_ticker(c1, c2, market) +def fetch_balances(market): + balances = {} + fetched_balance = market.fetch_balance() + for key, value in fetched_balance["total"].items(): + if value > 0: + balances[key] = int(value * 10**max_digits) + return balances + def assets_value(assets, market, base_currency="BTC"): repartition_in_base_currency = {} for currency, asset_value in assets.items(): @@ -107,4 +109,5 @@ def give_orders(current_assets, repartition_pertenthousand, market, base_currenc for currency, value in new_repartition.items(): print("holding {} {}".format(formatted_price(value), currency)) +current_assets = fetch_balances(market) give_orders(current_assets, repartition_pertenthousand, market)