Пример #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)
Пример #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)
Пример #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()
     })
Пример #4
0
    def test_to_json(self):
        order = MexcInFlightOrder.from_json(self._example_json())

        self.assertEqual(self._example_json(), order.to_json())
Пример #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)
Пример #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)
Пример #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)