Esempio n. 1
0
    def trade(self, pair, trade_type, rate, amount, connection=None):
        common.validateOrder(pair, trade_type, rate, amount)
        params = {"method": "Trade",
                  "pair": pair,
                  "type": trade_type,
                  "rate": common.formatCurrency(rate, pair),
                  "amount": common.formatCurrency(amount, pair)}

        return TradeResult(self._post(params, connection))
Esempio n. 2
0
    def trade(self, pair, trade_type, rate, amount, connection=None):
        common.validateOrder(pair, trade_type, rate, amount)
        params = {
            "method": "Trade",
            "pair": pair,
            "type": trade_type,
            "rate": common.formatCurrency(rate, pair),
            "amount": common.formatCurrency(amount, pair)
        }

        return TradeResult(self._post(params, connection))
Esempio n. 3
0
 def trade(self, pair, trade_type, rate, amount):
     common.validatePair(pair)
     if trade_type not in ("buy", "sell"):
         raise Exception("Unrecognized trade type: %r" % trade_type)
    
     params = {"method":"Trade",
               "pair":pair,
               "type":trade_type,
               "rate":common.formatCurrency(rate, pair),
               "amount":common.formatCurrency(amount, pair)}
     
     return TradeResult(self._post(params))
Esempio n. 4
0
 def trade(self, pair, trade_type, rate, amount):
     common.validatePair(pair)
     if trade_type not in ("buy", "sell"):
         raise Exception("Unrecognized trade type: %r" % trade_type)
    
     maxdigits = common.max_digits.get(pair)
     
     params = {"method":"Trade",
               "pair":pair,
               "type":trade_type,
               "rate":common.formatCurrency(rate, maxdigits),
               "amount":common.formatCurrency(amount, maxdigits)}
     
     return TradeResult(self._post(params))
Esempio n. 5
0
    def trade(self, pair, trade_type, rate, amount, connection=None):
        common.validatePair(pair)
        if trade_type not in ("buy", "sell"):
            raise Exception("Unrecognized trade type: %r" % trade_type)

        params = {
            "method": "Trade",
            "pair": pair,
            "type": trade_type,
            "rate": common.formatCurrency(rate, pair),
            "amount": common.formatCurrency(amount, pair)
        }

        return TradeResult(self._post(params, connection))
Esempio n. 6
0
    def placeOrder(self, pair, trade_type, rate, amount, connection=None, update_delay=None, error_handler=None):
        common.validatePair(pair)
        if trade_type.lower() not in ("buy", "sell"):
            if trade_type.lower() == 'bid':
                trade_type = 'buy'
            elif trade_type.lower() == 'ask':
                trade_type = 'sell'
            else:
                raise Exception("Unrecognized trade type: %r" % trade_type)
       
        params = {"pair": pair,
                  "type": trade_type.upper(),
                  "rate": common.formatCurrency(rate, pair, 'price'),
                  "amount": common.formatCurrency(amount, pair, 'amount')}

        order = OrderItem(self._post('placeorder', params=params, connection=connection,
                                     error_handler=error_handler).get(u'order_id'), initial_params=params, date=now())

        if update_delay is not None:
            time.sleep(update_delay)
            order = self.getOrderStatus(order.order_id, connection=None)

        return order
    def placeOrder(self,
                   pair,
                   trade_type,
                   rate,
                   amount,
                   connection=None,
                   update_delay=None,
                   error_handler=None):
        common.validatePair(pair)
        if trade_type.lower() not in ("buy", "sell"):
            if trade_type.lower() == 'bid':
                trade_type = 'buy'
            elif trade_type.lower() == 'ask':
                trade_type = 'sell'
            else:
                raise Exception("Unrecognized trade type: %r" % trade_type)

        params = {
            "pair": pair,
            "type": trade_type.upper(),
            "rate": common.formatCurrency(rate, pair, 'price'),
            "amount": common.formatCurrency(amount, pair, 'amount')
        }

        order = OrderItem(self._post(
            'placeorder',
            params=params,
            connection=connection,
            error_handler=error_handler).get(u'order_id'),
                          initial_params=params,
                          date=now())

        if update_delay is not None:
            time.sleep(update_delay)
            order = self.getOrderStatus(order.order_id, connection=None)

        return order