Example #1
0
def query_etherscan_for_transactions(accounts):
    transactions = list()
    for account in accounts:
        transactions.extend(
            retry_calls(5, 'etherscan', 'query_txlist', query_txlist, account,
                        False))
        transactions.extend(
            retry_calls(5, 'etherscan', 'query_txlist_internal', query_txlist,
                        account, True))

    transactions.sort(key=lambda tx: tx.timestamp)
    return transactions
Example #2
0
    def find_usd_price(self, asset, asset_btc_price=None):
        if self.kraken and self.kraken.first_connection_made and asset_btc_price is not None:
            return self.query_kraken_for_price(asset, asset_btc_price)

        # Adjust some ETH tokens to how cryptocompare knows them
        if asset == 'RDN':
            asset = 'RDN*'  # temporary
        if asset == 'DATAcoin':
            asset = 'DATA'
        resp = retry_calls(
            5,
            'find_usd_price',
            'urllib2.urlopen',
            urlopen,
            Request(
                u'https://min-api.cryptocompare.com/data/price?fsym={}&tsyms=USD'.format(
                    asset
                ))
        )

        resp = rlk_jsonloads(resp.read())

        # If there is an error in the response skip this token
        if 'USD' not in resp:
            if resp['Response'] == 'Error':
                print('Could not query USD price for {}. Error: "{}"'.format(
                    asset,
                    resp['Message']),
                )
            else:
                print('Could not query USD price for {}'.format(asset))
            return FVal(0)

        return FVal(resp['USD'])
Example #3
0
 def api_query(self, command, req={}):
     result = retry_calls(5, 'poloniex', command, self._api_query, command,
                          req)
     if 'error' in result:
         raise ValueError(
             'Poloniex query for "{}" returned error: {}'.format(
                 command, result['error']))
     return result
Example #4
0
 def query_private(self, method, req={}):
     return retry_calls(5, 'kraken', method, self._query_private, method,
                        req)
Example #5
0
 def query_public(self, method, req={}):
     return retry_calls(5, 'kraken', method, self._query_public, method,
                        req)