コード例 #1
0
    def test_time_in_force_parser_given_invalid_value_raises_value_error(self):
        # Arrange
        # Act
        # Assert
        with pytest.raises(ValueError):
            TimeInForceParser.to_str_py(0)

        with pytest.raises(ValueError):
            TimeInForceParser.from_str_py("")
コード例 #2
0
    def test_time_in_force_from_str(self, string, expected):
        # Arrange
        # Act
        result = TimeInForceParser.from_str_py(string)

        # Assert
        self.assertEqual(expected, result)
コード例 #3
0
    def test_time_in_force_to_str(self, enum, expected):
        # Arrange
        # Act
        result = TimeInForceParser.to_str_py(enum)

        # Assert
        self.assertEqual(expected, result)
コード例 #4
0
    def test_time_in_force_to_str(self, enum, expected):
        # Arrange
        # Act
        result = TimeInForceParser.to_str_py(enum)

        # Assert
        assert expected == result
コード例 #5
0
    async def _submit_limit_order(self, order: LimitOrder):
        if order.is_post_only:
            time_in_force = None
        else:
            time_in_force = TimeInForceParser.to_str_py(order.time_in_force)

        await self._account_spot.new_order(
            symbol=order.instrument_id.symbol.value,
            side=OrderSideParser.to_str_py(order.side),
            type=binance_order_type(order=order),
            time_in_force=time_in_force,
            quantity=str(order.quantity),
            price=str(order.price),
            iceberg_qty=str(order.display_qty)
            if order.display_qty is not None else None,
            new_client_order_id=order.client_order_id.value,
            recv_window=5000,
        )
コード例 #6
0
    async def _submit_stop_limit_order(self, order: StopLimitOrder):
        # Get current market price
        response: Dict[str, Any] = await self._market_spot.ticker_price(
            order.instrument_id.symbol.value)
        market_price = Decimal(response["price"])

        await self._account_spot.new_order(
            symbol=order.instrument_id.symbol.value,
            side=OrderSideParser.to_str_py(order.side),
            type=binance_order_type(order=order, market_price=market_price),
            time_in_force=TimeInForceParser.to_str_py(order.time_in_force),
            quantity=str(order.quantity),
            price=str(order.price),
            stop_price=str(order.trigger),
            iceberg_qty=str(order.display_qty)
            if order.display_qty is not None else None,
            new_client_order_id=order.client_order_id.value,
            recv_window=5000,
        )