コード例 #1
0
    def place_order(self, order: Order) -> Order:
        assert order.market_name == self.name

        logging.info('Placing order: {}'.format(order))
        market = self._format_market_pair(order.pair)
        self._validate_minimal_order(order)

        if order.type == ORDER_TYPE_MARKET:
            raise NotImplementedError(
                'Bittrex does not support MARKET orders.')

        elif order.type == ORDER_TYPE_LIMIT:
            if order.is_sell():
                result = self._client_v1.sell_limit(market,
                                                    float(order.quantity),
                                                    float(order.rate))
            elif order.is_buy():
                result = self._client_v1.buy_limit(market,
                                                   float(order.quantity),
                                                   float(order.rate))
            else:
                raise ValueError('Unknown order direction: {}'.format(
                    order._direction))

            self._validate_result(result)
            order.set_id_on_market(result['result']['uuid'])
            return order

        else:
            raise ValueError('Unknown order type: {}'.format(order.type))
コード例 #2
0
    def place_order(self, order: Order) -> Order:
        fee = self._calculate_fee(order)
        self._initialize_balances(order.pair)

        if order.is_sell():
            self._process_sell(fee, order)
        elif order.is_buy():
            self._process_buy(fee, order)

        order.close(order.created_at)

        return order