<commit_before>"""
ABC for Exchange APIs
"""
# Import Built-Ins
import logging
import time
from abc import ABCMeta, abstractmethod

# Import Third-Party
import requests

# Import Homebrew
from bitex.api.REST.response import APIResponse

log = logging.getLogger(__name__)


class APIClient(metaclass=ABCMeta):
    """
    Base Class for API ojects. Provides basic methods to interact
    with exchange APIs, such as sending queries and signing messages to pass
    authentication.
    """

    def __init__(self, uri, api_version=None, key=None, secret=None, timeout=5):
        """
        Create API Client object.
        :param uri: string address for api (i.e. https://api.kraken.com/
        :param api_version: version, as required to query an endpoint
        :param key: API access key
        :param secret: API secret
        """
        self.key = key
        self.secret = secret
        self.uri = uri
        self.version = api_version if api_version else ''
        self.timeout = timeout
        log.debug("Initialized API Client for URI: %s; "
                  "Will request on API version: %s" %
                  (self.uri, self.version))

    def load_key(self, path):
        """
        Load key and secret from file.
        :param path: path to file with first two lines are key, secret respectively
        """
        with open(path, 'r') as f:
            self.key = f.readline().strip()
            self.secret = f.readline().strip()

    def nonce(self):
        """
        Creates a Nonce value for signature generation
        :return:
        """
        return str(int(1000 * time.time()))

    @staticmethod
    def api_request(*args, **kwargs):
        """
        Wrapper which converts a requests.Response into our custom APIResponse
        object
        :param args:
        :param kwargs:
        :return:
        """
        r = requests.request(*args, **kwargs)
        return APIResponse(r)
<commit_msg>Use round instead of int for correct rounding<commit_after>"""
ABC for Exchange APIs
"""
# Import Built-Ins
import logging
import time
from abc import ABCMeta, abstractmethod

# Import Third-Party
import requests

# Import Homebrew
from bitex.api.REST.response import APIResponse

log = logging.getLogger(__name__)


class APIClient(metaclass=ABCMeta):
    """
    Base Class for API ojects. Provides basic methods to interact
    with exchange APIs, such as sending queries and signing messages to pass
    authentication.
    """

    def __init__(self, uri, api_version=None, key=None, secret=None, timeout=5):
        """
        Create API Client object.
        :param uri: string address for api (i.e. https://api.kraken.com/
        :param api_version: version, as required to query an endpoint
        :param key: API access key
        :param secret: API secret
        """
        self.key = key
        self.secret = secret
        self.uri = uri
        self.version = api_version if api_version else ''
        self.timeout = timeout
        log.debug("Initialized API Client for URI: %s; "
                  "Will request on API version: %s" %
                  (self.uri, self.version))

    def load_key(self, path):
        """
        Load key and secret from file.
        :param path: path to file with first two lines are key, secret respectively
        """
        with open(path, 'r') as f:
            self.key = f.readline().strip()
            self.secret = f.readline().strip()

    def nonce(self):
        """
        Creates a Nonce value for signature generation
        :return:
        """
        return str(round(1000 * time.time())) 

    @staticmethod
    def api_request(*args, **kwargs):
        """
        Wrapper which converts a requests.Response into our custom APIResponse
        object
        :param args:
        :param kwargs:
        :return:
        """
        r = requests.request(*args, **kwargs)
        return APIResponse(r)

{'fraction_non_alphanumeric': 0.09560132214594458, 'fraction_numerical': 0.0025425883549453345, 'mean_word_length': 2.195775792038993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1031769', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1057, 'n_words': 377}