Пример #1
0
    def get_order_status(self, order_number):
        method = 'order_status/' + str(order_number) + '/'
        result = dotdict(self._query_private(method))

        if result.status == 'success':
            return dotdict(result.data['order'])
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return None
Пример #2
0
    def get_ticker(self, market_code=''):
        method = 'ticker/' + market_code + '/'
        result = dotdict(self._query_public(method))

        if result.status == 'success':
            return dotdict(result.data['ticker'])
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return None
Пример #3
0
    def get_balance(self, account_name=''):
        method = 'balance/' + str(account_name) + '/'
        result = dotdict(self._query_private(method))

        if result.status == 'success':
            return dotdict(result.data['balances'])
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return None
Пример #4
0
 def get_market_info(self, market_code=''):
     method = 'market_info/' + market_code + '/'
     result = dotdict(self._query_public(method))
     if result.status == 'success' and market_code == '':
         markets = []
         for market in result.data['markets']:
             markets.append(dotdict(market))
         return markets
     elif result.status == 'success':
         return dotdict(result.data['markets'])
     elif result.status == 'error':
         raise APIException(result.status_code, result.reason)
     else:
         return None
Пример #5
0
    def _get_orders(self, account_name='Main', status='', market_code=''):
        method = 'orders/' + str(
            account_name) + '/' + status + '/' + market_code + '/'
        result = dotdict(self._query_private(method))

        if result.status == 'success':
            orders = []
            for order in result.data['orders']:
                orders.append(dotdict(order))
            return orders
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return None
Пример #6
0
    def create_order(self,
                     market_code,
                     order_type,
                     buy_sell,
                     volume,
                     price='0',
                     client_id=0,
                     post_only=False,
                     account_name='Main'):
        method = 'orders/'
        data = {
            'order_type': order_type,
            'market_code': market_code,
            'volume': str(volume),
            'buy_sell': buy_sell,
            'price': str(price),
            'client_id': client_id,
            'post_only': post_only,
            'account_name': account_name
        }

        result = dotdict(self._query_private(method, data))

        if result.status == 'success':
            return result.data['order_number']
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return None
Пример #7
0
    def cancel_order(self, order_number):
        method = 'cancel_order/' + str(order_number) + '/'
        result = dotdict(
            self._query_private(method, {'order_number': order_number}))

        if result.status == 'success':
            return True
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return False
Пример #8
0
    def withdraw_request(self, currency_code, amount, alias):
        method = 'withdrawal/request/'
        data = {
            'currency_code': currency_code,
            'amount': str(amount),
            'alias': alias
        }

        result = dotdict(
            self._query_private(method, data, timeout=self.timeout))

        if result.status == 'success':
            return True
        elif result.status == 'error':
            raise APIException(result.status_code, result.reason)
        else:
            return None
Пример #9
0
from __future__ import absolute_import

import importlib
import os
import sys

from bitexen_client.utils.dotdict import dotdict

def import_path(fullpath):
    """
    Import a file with full path specification. Allows one to
    import from anywhere, something __import__ does not do.
    """
    path, filename = os.path.split(fullpath)
    filename, ext = os.path.splitext(filename)
    sys.path.insert(0, path)
    module = importlib.import_module(filename, path)
    importlib.reload(module)  # Might be out of date
    del sys.path[0]
    return module

settings = {}
try:
    userSettings = import_path(os.path.join('bitexen_client', 'bitexen_client_settings'))
    settings.update(vars(userSettings))
except ImportError:
    #ToDo: add loggings
    pass

settings = dotdict(settings)