aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-02-19 14:06:45 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-02-19 14:06:45 +0100
commit7eb9cb36c2ef01097fe8e99d40dd17308abdfe37 (patch)
tree193f00e62178dd7da3c2442af4a5aee8783f6051
parent9f1408a3c5d6f42ae709ca16fa27e01db192fd05 (diff)
downloadTrader-7eb9cb36c2ef01097fe8e99d40dd17308abdfe37.tar.gz
Trader-7eb9cb36c2ef01097fe8e99d40dd17308abdfe37.tar.zst
Trader-7eb9cb36c2ef01097fe8e99d40dd17308abdfe37.zip
Allow dispatch assets to receive liquidity
-rw-r--r--store.py4
-rw-r--r--test.py1
2 files changed, 3 insertions, 2 deletions
diff --git a/store.py b/store.py
index 841a0fc..abbe5ee 100644
--- a/store.py
+++ b/store.py
@@ -27,9 +27,9 @@ class BalanceStore:
27 cls.all[currency] = portfolio.Balance(currency, balance) 27 cls.all[currency] = portfolio.Balance(currency, balance)
28 28
29 @classmethod 29 @classmethod
30 def dispatch_assets(cls, amount, repartition=None): 30 def dispatch_assets(cls, amount, liquidity="medium", repartition=None):
31 if repartition is None: 31 if repartition is None:
32 repartition = portfolio.Portfolio.repartition() 32 repartition = portfolio.Portfolio.repartition(liquidity=liquidity)
33 sum_ratio = sum([v[0] for k, v in repartition.items()]) 33 sum_ratio = sum([v[0] for k, v in repartition.items()])
34 amounts = {} 34 amounts = {}
35 for currency, (ptt, trade_type) in repartition.items(): 35 for currency, (ptt, trade_type) in repartition.items():
diff --git a/test.py b/test.py
index 8641130..d58b203 100644
--- a/test.py
+++ b/test.py
@@ -1247,6 +1247,7 @@ class BalanceStoreTest(WebMockTestCase):
1247 } 1247 }
1248 1248
1249 amounts = portfolio.BalanceStore.dispatch_assets(portfolio.Amount("BTC", "11.1")) 1249 amounts = portfolio.BalanceStore.dispatch_assets(portfolio.Amount("BTC", "11.1"))
1250 repartition.assert_called_with(liquidity="medium")
1250 self.assertIn("XEM", portfolio.BalanceStore.currencies()) 1251 self.assertIn("XEM", portfolio.BalanceStore.currencies())
1251 self.assertEqual(D("2.6"), amounts["BTC"].value) 1252 self.assertEqual(D("2.6"), amounts["BTC"].value)
1252 self.assertEqual(D("7.5"), amounts["XEM"].value) 1253 self.assertEqual(D("7.5"), amounts["XEM"].value)