diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-02-11 13:36:54 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-02-11 13:36:54 +0100 |
commit | 1aa7d4fa2ec3c2b3268bef31a666ca6e1aaa6563 (patch) | |
tree | f47f804070e935bf8fdf621cc59f4320606cf46f /store.py | |
parent | 6ca5a1ec669593fa915a2824efca068c975f9caa (diff) | |
download | Trader-1aa7d4fa2ec3c2b3268bef31a666ca6e1aaa6563.tar.gz Trader-1aa7d4fa2ec3c2b3268bef31a666ca6e1aaa6563.tar.zst Trader-1aa7d4fa2ec3c2b3268bef31a666ca6e1aaa6563.zip |
Add Makefile and test coverage
Fix order preparation and add tests for the step
Separate tests between acceptance and unit
Add more tests
Diffstat (limited to 'store.py')
-rw-r--r-- | store.py | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -53,22 +53,27 @@ class TradeStore: | |||
53 | continue | 53 | continue |
54 | value_from = values_in_base.get(currency, portfolio.Amount(base_currency, 0)) | 54 | value_from = values_in_base.get(currency, portfolio.Amount(base_currency, 0)) |
55 | value_to = new_repartition.get(currency, portfolio.Amount(base_currency, 0)) | 55 | value_to = new_repartition.get(currency, portfolio.Amount(base_currency, 0)) |
56 | |||
56 | if value_from.value * value_to.value < 0: | 57 | if value_from.value * value_to.value < 0: |
57 | trade_1 = portfolio.Trade(value_from, portfolio.Amount(base_currency, 0), currency, market=market) | 58 | cls.add_trade_if_matching( |
58 | if only is None or trade_1.action == only: | 59 | value_from, portfolio.Amount(base_currency, 0), |
59 | cls.all.append(trade_1) | 60 | currency, only=only, market=market) |
60 | trade_2 = portfolio.Trade(portfolio.Amount(base_currency, 0), value_to, currency, market=market) | 61 | cls.add_trade_if_matching( |
61 | if only is None or trade_2.action == only: | 62 | portfolio.Amount(base_currency, 0), value_to, |
62 | cls.all.append(trade_2) | 63 | currency, only=only, market=market) |
63 | else: | 64 | else: |
64 | trade = portfolio.Trade( | 65 | cls.add_trade_if_matching(value_from, value_to, |
65 | value_from, | 66 | currency, only=only, market=market) |
66 | value_to, | 67 | |
67 | currency, | 68 | @classmethod |
68 | market=market | 69 | def add_trade_if_matching(cls, value_from, value_to, currency, |
69 | ) | 70 | only=None, market=None): |
70 | if only is None or trade.action == only: | 71 | trade = portfolio.Trade(value_from, value_to, currency, |
71 | cls.all.append(trade) | 72 | market=market) |
73 | if only is None or trade.action == only: | ||
74 | cls.all.append(trade) | ||
75 | return True | ||
76 | return False | ||
72 | 77 | ||
73 | @classmethod | 78 | @classmethod |
74 | def prepare_orders(cls, only=None, compute_value="default"): | 79 | def prepare_orders(cls, only=None, compute_value="default"): |