Esempio n. 1
0
    def test_is_done(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        self.assertFalse(order.is_done)

        for status in ["FILLED", "CANCELED", "PARTIALLY_CANCELED"]:
            order.last_state = status
            self.assertTrue(order.is_done)
Esempio n. 2
0
    def test_create_from_json(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        self.assertEqual("C1", order.client_order_id)
        self.assertEqual("1", order.exchange_order_id)
        self.assertEqual("BTC-USDT", order.trading_pair)
        self.assertEqual(OrderType.LIMIT, order.order_type)
        self.assertEqual(TradeType.BUY, order.trade_type)
        self.assertEqual(Decimal("35000"), order.price)
        self.assertEqual(Decimal("1.1"), order.amount)
        self.assertEqual(Decimal("0.5"), order.executed_amount_base)
        self.assertEqual(Decimal("15000"), order.executed_amount_quote)
        self.assertEqual(order.base_asset, order.fee_asset)
        self.assertEqual(Decimal("0"), order.fee_paid)
        self.assertEqual("Working", order.last_state)
Esempio n. 3
0
 def restore_tracking_states(self, saved_states: Dict[str, Any]):
     self._in_flight_orders.update({
         key: MexcInFlightOrder.from_json(value)
         for key, value in saved_states.items()
     })
Esempio n. 4
0
    def test_to_json(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        self.assertEqual(self._example_json(), order.to_json())
Esempio n. 5
0
    def test_mark_as_filled(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        order.mark_as_filled()
        self.assertEqual("FILLED", order.last_state)
Esempio n. 6
0
    def test_is_cancelled(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        for status in ["Working", "FullyExecuted", "Rejected"]:
            order.last_state = status
            self.assertFalse(order.is_cancelled)
Esempio n. 7
0
    def test_is_failure(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        for status in ["NEW", "PARTIALLY_FILLED"]:
            order.last_state = status
            self.assertFalse(order.is_failure)