X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=portfolio.py;h=1d8bfd5f122775df881bcbbdd3a76e8422740896;hb=f2da658998b6e6605c6ae27ff338ef23b96dce25;hp=a4fbf9485ad67b7ed1b0a582c5be8de6284107d1;hpb=183a53e3be74fabf501eaff19a39a47f1a6c9af5;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/portfolio.py b/portfolio.py index a4fbf94..1d8bfd5 100644 --- a/portfolio.py +++ b/portfolio.py @@ -220,6 +220,10 @@ class Balance: self.free = Amount(currency, free_value) self.used = Amount(currency, used_value) + @classmethod + def from_hash(cls, currency, hash_): + return cls(currency, hash_["total"], hash_["free"], hash_["used"]) + @classmethod def in_currency(cls, other_currency, market, action="average", type="total"): amounts = {} @@ -234,10 +238,6 @@ class Balance: def currencies(cls): return cls.known_balances.keys() - @classmethod - def from_hash(cls, currency, hash_): - return cls(currency, hash_["total"], hash_["free"], hash_["used"]) - @classmethod def _fill_balances(cls, hash_): for key in hash_: @@ -270,9 +270,6 @@ class Balance: new_repartition = cls.dispatch_assets(total_base_value) Trade.compute_trades(values_in_base, new_repartition, market=market) - def __int__(self): - return int(self.total) - def __repr__(self): return "Balance({} [{}/{}/{}])".format(self.currency, str(self.free), str(self.used), str(self.total))