<commit_before>"""
https://c-cex.com/?id=api
"""

# Import Built-Ins
import logging

# Import Third-Party

# Import Homebrew
from bitex.api.rest import CCEXRest
from bitex.utils import return_api_response
from bitex.formatters.ccex import CcexFormatter as fmt

# Init Logging Facilities
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)


class CCEX(CCEXRest):
    def __init__(self, key='', secret='', key_file=''):
        super(CCEX, self).__init__(key, secret)
        if key_file:
            self.load_key(key_file)
        print(self.uri)

    def public_query(self, endpoint, **kwargs):
        return self.query('GET', 'api_pub.html?a=' + endpoint, **kwargs)

    def private_query(self, endpoint, **kwargs):
        return self.query('POST', 'api.html?a=' + endpoint, authenticate=True, **kwargs)

    """
    BitEx Standardized Methods
    """

    @return_api_response(fmt.ticker)
    def ticker(self, pair, **kwargs):
        return self.public_query('%s.json' % pair, params=kwargs)

    @return_api_response(fmt.order_book)
    def order_book(self, pair, type='both', **kwargs):
        q = {'market': pair, 'type': type}
        q.update(kwargs)
        return self.public_query('getorderbook', params=q)

    @return_api_response(fmt.trades)
    def trades(self, pair, **kwargs):
        q = {'market': pair}
        q.update(kwargs)
        return self.public_query('getmarkethistory',
                                 params=q)

    @return_api_response(fmt.order)
    def bid(self, pair, price, size, **kwargs):
        q = {'market': pair, 'rate': price, 'quantity': size}
        q.update(kwargs)
        return self.private_query('buylimit', params=q)

    @return_api_response(fmt.order)
    def ask(self, pair, price, size, **kwargs):
        q = {'market': pair, 'rate': price, 'quantity': size}
        q.update(kwargs)
        return self.private_query('buylimit', params=q)

    @return_api_response(fmt.cancel)
    def cancel_order(self, order_id, **kwargs):
        q = {'uuid': order_id}
        q.update(kwargs)
        return self.private_query('cancel', params=q)

    @return_api_response(fmt.order_status)
    def order(self, order_id, **kwargs):
        q = {'uuid': order_id}
        q.update(kwargs)
        return self.private_query('getorder', params=q)

    @return_api_response(fmt.balance)
    def balance(self, **kwargs):
        return self.private_query('getbalance', params=kwargs)

    @return_api_response(fmt.withdraw)
    def withdraw(self, _type, source_wallet, amount, tar_addr, **kwargs):
        raise NotImplementedError()

    @return_api_response(fmt.deposit)
    def deposit_address(self, **kwargs):
        raise NotImplementedError()

    """
    Exchange Specific Methods
    """

    @return_api_response(None)
    def pairs(self, names_only=True):
        if names_only:
            return self.public_query('api_pub.html?a=getmarkets')
        else:
            return self.public_query('pairs.json')

    @return_api_response(None)
    def prices(self):
        return self.public_query('prices.json')

    @return_api_response(None)
    def coin_names(self):
        return self.public_query('coinnames.json')<commit_msg>change 'amount' to 'size' in ccex.py #35<commit_after>"""
https://c-cex.com/?id=api
"""

# Import Built-Ins
import logging

# Import Third-Party

# Import Homebrew
from bitex.api.rest import CCEXRest
from bitex.utils import return_api_response
from bitex.formatters.ccex import CcexFormatter as fmt

# Init Logging Facilities
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)


class CCEX(CCEXRest):
    def __init__(self, key='', secret='', key_file=''):
        super(CCEX, self).__init__(key, secret)
        if key_file:
            self.load_key(key_file)
        print(self.uri)

    def public_query(self, endpoint, **kwargs):
        return self.query('GET', 'api_pub.html?a=' + endpoint, **kwargs)

    def private_query(self, endpoint, **kwargs):
        return self.query('POST', 'api.html?a=' + endpoint, authenticate=True, **kwargs)

    """
    BitEx Standardized Methods
    """

    @return_api_response(fmt.ticker)
    def ticker(self, pair, **kwargs):
        return self.public_query('%s.json' % pair, params=kwargs)

    @return_api_response(fmt.order_book)
    def order_book(self, pair, type='both', **kwargs):
        q = {'market': pair, 'type': type}
        q.update(kwargs)
        return self.public_query('getorderbook', params=q)

    @return_api_response(fmt.trades)
    def trades(self, pair, **kwargs):
        q = {'market': pair}
        q.update(kwargs)
        return self.public_query('getmarkethistory',
                                 params=q)

    @return_api_response(fmt.order)
    def bid(self, pair, price, size, **kwargs):
        q = {'market': pair, 'rate': price, 'quantity': size}
        q.update(kwargs)
        return self.private_query('buylimit', params=q)

    @return_api_response(fmt.order)
    def ask(self, pair, price, size, **kwargs):
        q = {'market': pair, 'rate': price, 'quantity': size}
        q.update(kwargs)
        return self.private_query('buylimit', params=q)

    @return_api_response(fmt.cancel)
    def cancel_order(self, order_id, **kwargs):
        q = {'uuid': order_id}
        q.update(kwargs)
        return self.private_query('cancel', params=q)

    @return_api_response(fmt.order_status)
    def order(self, order_id, **kwargs):
        q = {'uuid': order_id}
        q.update(kwargs)
        return self.private_query('getorder', params=q)

    @return_api_response(fmt.balance)
    def balance(self, **kwargs):
        return self.private_query('getbalance', params=kwargs)

    @return_api_response(fmt.withdraw)
    def withdraw(self, _type, source_wallet, size, tar_addr, **kwargs):
        raise NotImplementedError()

    @return_api_response(fmt.deposit)
    def deposit_address(self, **kwargs):
        raise NotImplementedError()

    """
    Exchange Specific Methods
    """

    @return_api_response(None)
    def pairs(self, names_only=True):
        if names_only:
            return self.public_query('api_pub.html?a=getmarkets')
        else:
            return self.public_query('pairs.json')

    @return_api_response(None)
    def prices(self):
        return self.public_query('prices.json')

    @return_api_response(None)
    def coin_names(self):
        return self.public_query('coinnames.json')
{'fraction_non_alphanumeric': 0.13446940356312936, 'fraction_numerical': 0.00030983733539891554, 'mean_word_length': 3.2140992167101827, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3066223', 'n_tokens_mistral': 2085, 'n_tokens_neox': 2020, 'n_words': 423}