aboutsummaryrefslogtreecommitdiff
path: root/script.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-01-12 00:39:27 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-01-12 00:39:35 +0100
commit73e777420f63616e883393c50f0684243ac19bed (patch)
tree1da9a2aa99930adb9d79bfb95673b77e72cce887 /script.py
parent4c51aa716c2940b006430cad70739ddb965f5068 (diff)
downloadTrader-73e777420f63616e883393c50f0684243ac19bed.tar.gz
Trader-73e777420f63616e883393c50f0684243ac19bed.tar.zst
Trader-73e777420f63616e883393c50f0684243ac19bed.zip
Fetch assets from market
Diffstat (limited to 'script.py')
-rw-r--r--script.py15
1 files changed, 9 insertions, 6 deletions
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):
9 return decorate 9 return decorate
10 10
11max_digits = 18 11max_digits = 18
12current_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
19repartition_pertenthousand = { 13repartition_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
47def 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
53def assets_value(assets, market, base_currency="BTC"): 55def 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
112current_assets = fetch_balances(market)
110give_orders(current_assets, repartition_pertenthousand, market) 113give_orders(current_assets, repartition_pertenthousand, market)