diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-02-19 14:06:45 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-02-19 14:06:45 +0100 |
commit | 7eb9cb36c2ef01097fe8e99d40dd17308abdfe37 (patch) | |
tree | 193f00e62178dd7da3c2442af4a5aee8783f6051 | |
parent | 9f1408a3c5d6f42ae709ca16fa27e01db192fd05 (diff) | |
download | Trader-7eb9cb36c2ef01097fe8e99d40dd17308abdfe37.tar.gz Trader-7eb9cb36c2ef01097fe8e99d40dd17308abdfe37.tar.zst Trader-7eb9cb36c2ef01097fe8e99d40dd17308abdfe37.zip |
Allow dispatch assets to receive liquidity
-rw-r--r-- | store.py | 4 | ||||
-rw-r--r-- | test.py | 1 |
2 files changed, 3 insertions, 2 deletions
@@ -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(): |
@@ -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) |