コード例 #1
0
    def orderList(self,
                  from_number=None,
                  count_number=None,
                  from_id=None,
                  end_id=None,
                  order=None,
                  since=None,
                  end=None,
                  pair=None,
                  active=None,
                  connection=None):

        warnings.warn("OrderList will be removed from the server on "
                      "December 1, 2013.")

        params = {"method": "OrderList"}

        setHistoryParams(params, from_number, count_number, from_id, end_id,
                         order, since, end)

        if pair is not None:
            common.validatePair(pair)
            params["pair"] = pair
        if active is not None:
            if active not in (0, 1, True, False):
                raise Exception("Unexpected active parameter: %r" % active)
            params["active"] = int(active)

        orders = self._post(params, connection)
        result = []
        for k, v in orders.items():
            result.append(OrderItem(k, v))

        return result
コード例 #2
0
ファイル: trade.py プロジェクト: Queeq/btce-api
    def tradeHistory(self,
                     from_number=None,
                     count_number=None,
                     from_id=None,
                     end_id=None,
                     order=None,
                     since=None,
                     end=None,
                     pair=None,
                     connection=None):

        params = {"method": "TradeHistory"}

        setHistoryParams(params, from_number, count_number, from_id, end_id,
                         order, since, end)

        if pair is not None:
            common.validatePair(pair)
            params["pair"] = pair

        orders = self._post(params, connection)
        result = []
        for k, v in orders.items():
            result.append(TradeHistoryItem(k, v))

        return result
コード例 #3
0
ファイル: public.py プロジェクト: chuckatkins/btce-api
def getTradeHistory(pair, connection=None, count=None):
    '''Retrieve the trade history for the given pair.  Returns a list of
    Trade instances.  If count is not None, it should be an integer, and
    specifies the number of items from the trade history that will be
    processed and returned.'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    history = connection.makeJSONRequest("/api/2/%s/trades" % pair)

    if type(history) is not list:
        raise Exception("The response is a %r, not a list." % type(history))

    result = []

    # Limit the number of items returned if requested.
    if count is not None:
        history = history[:count]

    for h in history:
        h["pair"] = pair
        t = Trade(**h)
        result.append(t)
    return result
コード例 #4
0
ファイル: trade.py プロジェクト: Ademan/btce-api
    def orderList(self, from_number=None, count_number=None,
                  from_id=None, end_id=None, order=None,
                  since=None, end=None, pair=None, active=None,
                  connection=None):

        warnings.warn("OrderList will be removed from the server on "
                      "December 1, 2013.")

        params = {"method": "OrderList"}

        setHistoryParams(params, from_number, count_number, from_id, end_id,
                         order, since, end)

        if pair is not None:
            common.validatePair(pair)
            params["pair"] = pair
        if active is not None:
            if active not in (0, 1, True, False):
                raise Exception("Unexpected active parameter: %r" % active)
            params["active"] = int(active)

        orders = self._post(params, connection)
        result = []
        for k, v in orders.items():
            result.append(OrderItem(k, v))

        return result
コード例 #5
0
ファイル: public.py プロジェクト: afansky/btce-api
def getTradeHistory(pair, connection=None, count=None):
    '''Retrieve the trade history for the given pair.  Returns a list of
    Trade instances.  If count is not None, it should be an integer, and
    specifies the number of items from the trade history that will be
    processed and returned.'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    history = connection.makeJSONRequest("/api/2/%s/trades" % pair)

    if type(history) is not list:
        raise Exception("The response is a %r, not a list." % type(history))

    result = []

    # Limit the number of items returned if requested.
    if count is not None:
        history = history[:count]

    for h in history:
        h["pair"] = pair
        t = Trade(**h)
        result.append(t)
    return result
コード例 #6
0
ファイル: trade.py プロジェクト: Queeq/btce-api
    def activeOrders(self, pair=None, connection=None):

        params = {"method": "ActiveOrders"}

        if pair is not None:
            common.validatePair(pair)
            params["pair"] = pair

        orders = self._post(params, connection)
        result = []
        for k, v in orders.items():
            result.append(OrderItem(k, v))

        return result
コード例 #7
0
ファイル: trade.py プロジェクト: simlmx/btce-api
    def activeOrders(self, pair=None, connection=None):

        params = {"method": "ActiveOrders"}

        if pair is not None:
            common.validatePair(pair)
            params["pair"] = pair

        orders = self._post(params, connection)
        result = []
        for k, v in orders.items():
            result.append(OrderItem(k, v))

        return result
コード例 #8
0
ファイル: public.py プロジェクト: zm801/btce-api
def getTicker(pair, connection=None):
    '''Retrieve the ticker for the given pair.  Returns a Ticker instance.'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    response = connection.makeJSONRequest("/api/2/%s/ticker" % pair)

    if type(response) is not dict:
        raise TypeError("The response is a %r, not a dict." % type(response))

    return Ticker(**response[u'ticker'])
コード例 #9
0
ファイル: public.py プロジェクト: afansky/btce-api
def getTicker(pair, connection=None):
    '''Retrieve the ticker for the given pair.  Returns a Ticker instance.'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    response = connection.makeJSONRequest("/api/2/%s/ticker" % pair)

    if type(response) is not dict:
        raise Exception("The response is a %r, not a dict." % type(response))

    return Ticker(**response[u'ticker'])
コード例 #10
0
ファイル: public.py プロジェクト: chuckatkins/btce-api
def getTradeFee(pair, connection=None):
    '''Retrieve the fee associated with trades for a given pair'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    fees = connection.makeJSONRequest("/api/2/%s/fee" % pair)
    if type(fees) is not dict:
        raise Exception("The response is not a dict.")

    trade_fee = fees.get(u'trade')
    if type(trade_fee) is not decimal.Decimal:
        raise Exception("The response does not contain a trade fee")

    return trade_fee
コード例 #11
0
ファイル: public.py プロジェクト: chuckatkins/BTCeArbitrage
def getTradeFee(pair, connection=None):
    '''Retrieve the fee associated with trades for a given pair'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    fees = connection.makeJSONRequest("/api/2/%s/fee" % pair)
    if type(fees) is not dict:
        raise Exception("The response is not a dict.")

    trade_fee = fees.get(u'trade')
    if type(trade_fee) is not decimal.Decimal:
        raise Exception("The response does not contain a trade fee")

    return trade_fee
コード例 #12
0
ファイル: trade.py プロジェクト: hknust/btce-api
    def tradeHistory(self, from_number=None, count_number=None,
                     from_id=None, end_id=None, order=None,
                     since=None, end=None, pair=None, connection=None):

        params = {"method": "TradeHistory"}

        setHistoryParams(params, from_number, count_number, from_id, end_id,
                         order, since, end)

        if pair is not None:
            common.validatePair(pair)
            params["pair"] = pair

        orders = self._post(params, connection)
        result = []
        for k, v in orders.items():
            result.append(TradeHistoryItem(k, v))

        return result
コード例 #13
0
def getTicker(pair, connection=None):
    """Retrieve the ticker for the given pair.  Returns a Ticker instance."""

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    response = connection.makeJSONRequest("/api/2/%s/ticker" % pair)

    if type(response) is not dict:
        raise TypeError("The response is a %r, not a dict." % type(response))
    elif 'error' in response:
        print(("There is a error \"%s\" while obtaining ticker %s" % (response['error'], pair))) 
        ticker = None
    else:
        ticker = Ticker(**response['ticker'])

    return ticker
コード例 #14
0
ファイル: public.py プロジェクト: alkutin/btce-api
def getTicker(pair, connection=None):
    """Retrieve the ticker for the given pair.  Returns a Ticker instance."""

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    response = connection.makeJSONRequest("/api/2/%s/ticker" % pair)

    if type(response) is not dict:
        raise TypeError("The response is a %r, not a dict." % type(response))
    elif u'error' in response:
        print ("There is a error \"%s\" while obtaining ticker %s" % (response['error'], pair)) 
        ticker = None
    else:
        ticker = Ticker(**response[u'ticker'])

    return ticker
コード例 #15
0
ファイル: public.py プロジェクト: chuckatkins/btce-api
def getDepth(pair, connection=None):
    '''Retrieve the depth for the given pair.  Returns a tuple (asks, bids);
    each of these is a list of (price, volume) tuples.'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    depth = connection.makeJSONRequest("/api/2/%s/depth" % pair)
    if type(depth) is not dict:
        raise Exception("The response is not a dict.")

    asks = depth.get(u'asks')
    if type(asks) is not list:
        raise Exception("The response does not contain an asks list.")

    bids = depth.get(u'bids')
    if type(bids) is not list:
        raise Exception("The response does not contain a bids list.")

    return asks, bids
コード例 #16
0
ファイル: public.py プロジェクト: afansky/btce-api
def getDepth(pair, connection=None):
    '''Retrieve the depth for the given pair.  Returns a tuple (asks, bids);
    each of these is a list of (price, volume) tuples.'''

    common.validatePair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    depth = connection.makeJSONRequest("/api/2/%s/depth" % pair)
    if type(depth) is not dict:
        raise Exception("The response is not a dict.")

    asks = depth.get(u'asks')
    if type(asks) is not list:
        raise Exception("The response does not contain an asks list.")

    bids = depth.get(u'bids')
    if type(bids) is not list:
        raise Exception("The response does not contain a bids list.")

    return asks, bids
コード例 #17
0
ファイル: bot.py プロジェクト: afansky/trade-bot
    def addTickerHandler(self, handler, pairs=btceapi.all_pairs):
        for p in pairs:
            validatePair(p)

        self.tickerHandlers.append((handler, pairs))
コード例 #18
0
ファイル: test_common.py プロジェクト: huer0625/btce-api
 def test_validatePair(self):
     for pair in all_pairs:
         validatePair(pair)
     self.assertRaises(Exception, validatePair, "not_a_real_pair")
コード例 #19
0
ファイル: bot.py プロジェクト: deamoon/meteopt
 def addDepthHandler(self, handler, pairs=btceapi.all_pairs):
     for p in pairs:
         validatePair(p)
       
     self.depthHandlers.append((handler, pairs))
コード例 #20
0
ファイル: bot.py プロジェクト: deamoon/meteopt
    def addTradeHistoryHandler(self, handler, pairs=btceapi.all_pairs):
        for p in pairs:
            validatePair(p)

        self.tradeHistoryHandlers.append((handler, pairs))
コード例 #21
0
ファイル: bot.py プロジェクト: afansky/trade-bot
    def addDepthHandler(self, handler, pairs=btceapi.all_pairs):
        for p in pairs:
            validatePair(p)

        self.depthHandlers.append((handler, pairs))
コード例 #22
0
ファイル: test_common.py プロジェクト: chuckatkins/btce-api
 def test_validatePair(self):
     for pair in all_pairs:
         validatePair(pair)
     self.assertRaises(Exception, validatePair, "not_a_real_pair")
コード例 #23
0
ファイル: bot.py プロジェクト: afansky/trade-bot
    def addTradeHistoryHandler(self, handler, pairs=btceapi.all_pairs):
        for p in pairs:
            validatePair(p)

        self.tradeHistoryHandlers.append((handler, pairs))
コード例 #24
0
ファイル: bot.py プロジェクト: afansky/btce-bot
    def addTickerHandler(self, handler, pairs=btceapi.all_pairs):
        for p in pairs:
            validatePair(p)

        self.tickerHandlers.append((handler, pairs))