]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - portfolio.py
Add Balance class tests
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / portfolio.py
index a4fbf9485ad67b7ed1b0a582c5be8de6284107d1..1d8bfd5f122775df881bcbbdd3a76e8422740896 100644 (file)
@@ -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))