Beispiel #1
0
    def sell(self, amount=None, price=None, book=None):
        """Places a sell order (both limit and market orders are available)

        Args:
          amount (str):
            Amount of major currency to buy. 
          price (str, optional):
            If supplied, this will place a limit order to sell at the specified price.
            If not supplied, this will place a market order to sell the amount of major
            currency specified in amount at the market rate
          book (str, optional):
            Specifies which book to use. Default is btc_mxn

        Returns:
          A bitso.Order instance.        
        """
        if amount is None:
            raise ApiClientError({u'message': u'amount not specified.'})
        url = '%s/sell' % self.base_url
        parameters = self._build_auth_payload()
        parameters['amount'] = str(amount).encode('utf-8')
        if price is not None:
            parameters['price'] = str(price).encode('utf-8')
        parameters['book'] = book
        resp = self._request_url(url, 'POST', params=parameters)
        return Order._NewFromJsonDict(resp) 
Beispiel #2
0
    def buy(self, amount=None, price=None, book=None):
        """Places a buy limit order.

        Args:
          amount (str):
            Amount of major currency to buy. 
          price (str):
            Specified price for the limit order.
          book (str, optional):
            Specifies which book to use. Default is btc_mxn

        Returns:
          A bitso.Order instance.        
        """

        if amount is None:
            raise ApiClientError({u'message': u'amount not specified.'})
        url = '%s/buy' % self.base_url
        parameters = self._build_auth_payload()
        parameters['amount'] = str(amount).encode('utf-8')
        if price is None:
            raise ApiClientError({u'message': u'price not specified.'})
        if price is not None:
            parameters['price'] = str(price).encode('utf-8')
        parameters['book'] = book
        resp = self._request_url(url, 'POST', params=parameters)
        return Order._NewFromJsonDict(resp) 
Beispiel #3
0
    def open_orders(self, book=None):
        """Get a list of the user's open orders

        Args:
          book (str):
            Specifies which book to use. Default is btc_mxn
            
        Returns:
          A list of bitso.Order instances.        
        """
        url = '%s/open_orders/' % self.base_url
        url+='?book=%s' % book
        parameters = {}
        resp = self._request_url(url, 'GET', params=parameters, private=True)
        return [Order._NewFromJsonDict(x) for x in resp['payload']]
Beispiel #4
0
    def open_orders(self, book=None):
        """Get a list of the user's open orders

        Args:
          book (str):
            Specifies which book to use. Default is btc_mxn
            
        Returns:
          A list of bitso.Order instances.        
        """
        url = '%s/open_orders/' % self.base_url
        url+='?book=%s' % book
        parameters = {}
        resp = self._request_url(url, 'GET', params=parameters, private=True)
        return [Order._NewFromJsonDict(x) for x in resp['payload']]
Beispiel #5
0
    def open_orders(self, book=None):
        """Get a list of the user's open orders

        Args:
          book (str, optional):
            Specifies which book to use. Default is btc_mxn
            
        Returns:
          A list of bitso.Order instances.        
        """
        url = '%s/open_orders' % self.base_url
        parameters = self._build_auth_payload()
        if book:
            parameters['book'] = book
        resp = self._request_url(url, 'POST', params=parameters)
        return [Order._NewFromJsonDict(x) for x in resp]
Beispiel #6
0
    def lookup_order(self, oids):
        """Get a list of details for one or more orders

        Args:
          order_ids (list):
            A list of Bitso Order IDs
            
        Returns:
          A list of bitso.Order instances.        
        """
        if isinstance(oids, basestring):
            oids = [oids]
        url = '%s/orders/' % self.base_url
        if oids:
            url+='%s/' % ('-'.join(oids))
        resp = self._request_url(url, 'GET', private=True)
        return [Order._NewFromJsonDict(x) for x in resp['payload']]
Beispiel #7
0
    def lookup_order(self, order_ids):
        """Get a list of details for one or more orders

        Args:
          order_ids (list):
            A list of Bitso Order IDs
            
        Returns:
          A list of bitso.Order instances.        
        """
        url = '%s/lookup_order' % self.base_url
        if isinstance(order_ids, basestring):
            order_ids = [order_ids]
        parameters = self._build_auth_payload()
        parameters['id[]'] = order_ids
        resp = self._request_url(url, 'POST', params=parameters)
        return [Order._NewFromJsonDict(x) for x in resp]
Beispiel #8
0
    def lookup_order(self, oids):
        """Get a list of details for one or more orders

        Args:
          order_ids (list):
            A list of Bitso Order IDs
            
        Returns:
          A list of bitso.Order instances.        
        """
        if isinstance(oids, basestring):
            oids = [oids]
        url = '%s/orders/' % self.base_url
        if oids:
            url+='%s/' % ('-'.join(oids))
        resp = self._request_url(url, 'GET', private=True)
        return [Order._NewFromJsonDict(x) for x in resp['payload']]