예제 #1
0
def get_accounts():
    """
    :return: 
    """
    path = "/v1/account/accounts"
    params = {}
    return hbu.api_key_get(params, path)
예제 #2
0
def orders_matchresults(symbol,
                        types=None,
                        start_date=None,
                        end_date=None,
                        _from=None,
                        direct=None,
                        size=None):
    """
    :param symbol: 
    :param types: 可选值 {buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖}
    :param start_date: 
    :param end_date: 
    :param _from: 
    :param direct: 可选值{prev 向前,next 向后}
    :param size: 
    :return: 
    """
    params = {'symbol': symbol}

    if types:
        params[types] = types
    if start_date:
        params['start-date'] = start_date
    if end_date:
        params['end-date'] = end_date
    if _from:
        params['from'] = _from
    if direct:
        params['direct'] = direct
    if size:
        params['size'] = size
    url = '/v1/order/matchresults'
    return hbu.api_key_get(params, url)
예제 #3
0
def orders_list(symbol,
                states,
                types=None,
                start_date=None,
                end_date=None,
                _from=None,
                direct=None,
                size=None):
    """
    :param symbol: 
    :param states: 可选值 {pre-submitted 准备提交, submitted 已提交, partial-filled 部分成交, partial-canceled 部分成交撤销, filled 完全成交, canceled 已撤销}
    :param types: 可选值 {buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖}
    :param start_date: 
    :param end_date: 
    :param _from: 
    :param direct: 可选值{prev 向前,next 向后}
    :param size: 
    :return: 
    """
    params = {'symbol': symbol, 'states': states}

    if types:
        params[types] = types
    if start_date:
        params['start-date'] = start_date
    if end_date:
        params['end-date'] = end_date
    if _from:
        params['from'] = _from
    if direct:
        params['direct'] = direct
    if size:
        params['size'] = size
    url = '/v1/order/orders'
    return hbu.api_key_get(params, url)
예제 #4
0
def order_matchresults(order_id):
    """
    
    :param order_id: 
    :return: 
    """
    params = {}
    url = "/v1/order/orders/{0}/matchresults".format(order_id)
    return hbu.api_key_get(params, url)
예제 #5
0
def order_info(order_id):
    """
    
    :param order_id: 
    :return: 
    """
    params = {}
    url = "/v1/order/orders/{0}".format(order_id)
    return hbu.api_key_get(params, url)
예제 #6
0
def get_balance(acct_id=None):
    """
    :param acct_id
    :return:
    """

    if not acct_id:
        try:
            accounts = get_accounts()
            acct_id = ACCOUNT_ID = accounts['data'][0]['id']
        except BaseException as e:
            #xie begin ,print 'get acct_id error.%s'%e
            Logger.error("HuobiService", "Unrecognised message:\n" % e)
            #xie end
            acct_id = ACCOUNT_ID

    url = "/v1/account/accounts/{0}/balance".format(acct_id)
    params = {"account-id": acct_id}
    return hbu.api_key_get(params, url)