ticker = ticker["original"]
rate = Computation.compute_value(ticker, self.order_action(inverted), compute_value=compute_value)
+ #TODO: store when the order is considered filled
# FIXME: Dust amount should be removed from there if they werent
# honored in other sales
delta_in_base = abs(self.value_from - self.value_to)
print(self)
for order in self.orders:
print("\t", order, sep="")
+ for mouvement in order.mouvements:
+ print("\t\t", mouvement, sep="")
class Order:
def __init__(self, action, amount, rate, base_currency, trade_type, market,
# rate * total = total_in_base
self.total_in_base = Amount(base_currency, hash_.get("total", 0))
+ def __repr__(self):
+ if self.fee_rate > 0:
+ fee_rate = " fee: {}%".format(self.fee_rate * 100)
+ else:
+ fee_rate = ""
+ if self.date is None:
+ date = "No date"
+ else:
+ date = self.date
+ return "Mouvement({} ; {} {} ({}){})".format(
+ date, self.action, self.total, self.total_in_base,
+ fee_rate)
+
if __name__ == '__main__': # pragma: no cover
from market import market
h.print_orders(market)
order_mock2 = mock.Mock()
order_mock2.__repr__ = mock.Mock()
order_mock2.__repr__.return_value = "Mock 2"
+ order_mock1.mouvements = []
+ mouvement_mock1 = mock.Mock()
+ mouvement_mock1.__repr__ = mock.Mock()
+ mouvement_mock1.__repr__.return_value = "Mouvement 1"
+ mouvement_mock2 = mock.Mock()
+ mouvement_mock2.__repr__ = mock.Mock()
+ mouvement_mock2.__repr__.return_value = "Mouvement 2"
+ order_mock2.mouvements = [
+ mouvement_mock1, mouvement_mock2
+ ]
trade.orders.append(order_mock1)
trade.orders.append(order_mock2)
self.assertEqual("Trade(0.50000000 BTC [10.00000000 ETH] -> 1.00000000 BTC in ETH, acquire)", out[0])
self.assertEqual("\tMock 1", out[1])
self.assertEqual("\tMock 2", out[2])
+ self.assertEqual("\t\tMouvement 1", out[3])
+ self.assertEqual("\t\tMouvement 2", out[4])
def test__repr(self):
value_from = portfolio.Amount("BTC", "0.5")
self.assertEqual(portfolio.Amount("ETH", 0), mouvement.total)
self.assertEqual(portfolio.Amount("BTC", 0), mouvement.total_in_base)
+ def test__repr(self):
+ mouvement = portfolio.Mouvement("ETH", "BTC", {
+ "tradeID": 42, "type": "buy", "fee": "0.0015",
+ "date": "2017-12-30 12:00:12", "rate": "0.1",
+ "amount": "10", "total": "1"
+ })
+ self.assertEqual("Mouvement(2017-12-30 12:00:12 ; buy 10.00000000 ETH (1.00000000 BTC) fee: 0.1500%)", repr(mouvement))
+ mouvement = portfolio.Mouvement("ETH", "BTC", {
+ "tradeID": 42, "type": "buy",
+ "date": "garbage", "rate": "0.1",
+ "amount": "10", "total": "1"
+ })
+ self.assertEqual("Mouvement(No date ; buy 10.00000000 ETH (1.00000000 BTC))", repr(mouvement))
+
@unittest.skipUnless("acceptance" in limits, "Acceptance skipped")
class AcceptanceTest(WebMockTestCase):
@unittest.expectedFailure