aboutsummaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-01-22 01:06:13 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-01-22 01:06:13 +0100
commitb83d489771c1c4f482a711cffc572f23a1599b4d (patch)
tree7290a3b5615721940bcb2bc13f2d93c0170ac255 /test.py
parent7ab23e291602b6ffd54622cffdc76ba0b4437a05 (diff)
downloadTrader-b83d489771c1c4f482a711cffc572f23a1599b4d.tar.gz
Trader-b83d489771c1c4f482a711cffc572f23a1599b4d.tar.zst
Trader-b83d489771c1c4f482a711cffc572f23a1599b4d.zip
Fix bid/ask to sell/buy in orders
Diffstat (limited to 'test.py')
-rw-r--r--test.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/test.py b/test.py
index 2589896..1b8a109 100644
--- a/test.py
+++ b/test.py
@@ -665,11 +665,11 @@ class AcceptanceTest(unittest.TestCase):
665 def create_order(symbol, type, action, amount, price=None): 665 def create_order(symbol, type, action, amount, price=None):
666 self.assertEqual("limit", type) 666 self.assertEqual("limit", type)
667 if symbol == "ETH/BTC": 667 if symbol == "ETH/BTC":
668 self.assertEqual("bid", action) 668 self.assertEqual("sell", action)
669 self.assertEqual(2, 3*amount) 669 self.assertEqual(2, 3*amount)
670 self.assertEqual(D("0.14014"), price) 670 self.assertEqual(D("0.14014"), price)
671 elif symbol == "XVG/BTC": 671 elif symbol == "XVG/BTC":
672 self.assertEqual("bid", action) 672 self.assertEqual("sell", action)
673 self.assertEqual(1000, amount) 673 self.assertEqual(1000, amount)
674 self.assertEqual(D("0.00003003"), price) 674 self.assertEqual(D("0.00003003"), price)
675 else: 675 else:
@@ -755,19 +755,22 @@ class AcceptanceTest(unittest.TestCase):
755 self.assertEqual("sell", trades["XVG"].action) 755 self.assertEqual("sell", trades["XVG"].action)
756 756
757 # Action 6 757 # Action 6
758 portfolio.Trade.prepare_orders(only="buy", compute_value=lambda x, y: x["ask"] * D("0.999")) 758 portfolio.Trade.prepare_orders(only="buy", compute_value=lambda x, y: x["ask"])
759
759 760
760 all_orders = portfolio.Trade.all_orders(state="pending") 761 all_orders = portfolio.Trade.all_orders(state="pending")
761 self.assertEqual(3, len(all_orders)) 762 self.assertEqual(3, len(all_orders))
762 self.assertEqual(portfolio.Amount("ETC", D("15.4")), all_orders[0].amount) 763 self.assertEqual(portfolio.Amount("ETC", D("38.5")/3), all_orders[0].amount)
763 self.assertEqual(D("0.002997"), all_orders[0].rate) 764 self.assertEqual(D("0.003"), all_orders[0].rate)
764 self.assertEqual("ask", all_orders[0].action) 765 self.assertEqual("buy", all_orders[0].action)
765 self.assertEqual(portfolio.Amount("BTD", D("9.7")), all_orders[1].amount) 766
766 self.assertEqual(D("0.0011988"), all_orders[1].rate) 767 self.assertEqual(portfolio.Amount("BTD", D("24.25")/3), all_orders[1].amount)
767 self.assertEqual("ask", all_orders[1].action) 768 self.assertEqual(D("0.0012"), all_orders[1].rate)
769 self.assertEqual("buy", all_orders[1].action)
770
768 self.assertEqual(portfolio.Amount("BTC", D("0.0097")), all_orders[2].amount) 771 self.assertEqual(portfolio.Amount("BTC", D("0.0097")), all_orders[2].amount)
769 self.assertEqual(D("15984"), all_orders[2].rate) 772 self.assertEqual(D("16000"), all_orders[2].rate)
770 self.assertEqual("bid", all_orders[2].action) 773 self.assertEqual("sell", all_orders[2].action)
771 774
772 with mock.patch.object(portfolio.time, "sleep") as sleep: 775 with mock.patch.object(portfolio.time, "sleep") as sleep:
773 # Action 7 776 # Action 7