def account_balance(self, types, currency):
        """
        查询账户资产
        :return:
        """
        p = {"api_key": api_key, "time": Con().now_time()}
        request_path = '/open/api/user/v2/account'
        # request_path = '/open/api/user/account'
        try:
            result = wbf_signature.Signature(secret_key).get_sign(
                types, p, request_path, host)
            # print('查询资产响应:{}'.format(result))
            if result['code'] == '0':
                coin = result['data']['coin_list']
                for i in range(0, len(coin)):
                    if coin[i]['coin'] == currency:
                        Con().info_log(currency, coin[i]['normal'],
                                       coin[i]['locked'])
                        # print('查询资产:{},{}'.format(coin[i]['normal'], coin[i]['locked']))
                        if coin[i]['normal'] is None and coin[i][
                                'locked'] is not None:
                            return 0, coin[i]['locked']
                        elif coin[i]['normal'] is not None and coin[i][
                                'locked'] is None:
                            return coin[i]['normal'], 0
                        elif coin[i]['normal'] is None and coin[i][
                                'locked'] is None:
                            return 0, 0
                        else:
                            return coin[i]['normal'], coin[i]['locked']

        except Exception as e:
            Con().error_log(currency, result, e)
 def order_detail(self, types, p):
     """
     订单详情
     :return:
     """
     request_path = '/open/api/order_info'
     result = wbf_signature.Signature(secret_key).get_sign(
         types, p, request_path, host)
     print('查询订单详情:{}'.format(result))
 def all_record_order(self, types, p):
     """
     查询全部成交记录
     :param types:
     :return:
     """
     request_path = '/open/api/all_trade'
     result = wbf_signature.Signature(secret_key).get_sign(
         types, p, request_path, host)
     print('查询全部成交记录:{}'.format(result))
 def order_place_all_v2(self, types, p):
     """
     批量创建订单
     :param p:
     :return:
     """
     request_path = '/open/api/mass_replaceV2'
     result = wbf_signature.Signature(secret_key).post_sign(
         types, p, request_path, host)
     print('批量创建订单:{}'.format(result))
 def order_place(self, types, p):
     """
     创建订单
     :param p:
     :return:
     """
     request_path = '/open/api/create_order'
     result = wbf_signature.Signature(secret_key).post_sign(
         types, p, request_path, host)
     print('创建订单:{}'.format(result))
 def order_cancel(self, types, p):
     """
     撤销订单
     :param p:
     :return:
     """
     request_path = '/open/api/cancel_order'
     result = wbf_signature.Signature(secret_key).post_sign(
         types, p, request_path, host)
     print('撤销订单:{}'.format(result))
 def unfilled_order(self, types, p):
     """
     查询全部委托单
     :param types:
     :return:
     """
     # print(p)
     request_path = '/open/api/v2/all_order'
     result = wbf_signature.Signature(secret_key).get_sign(
         types, p, request_path, host)
     print('查询全部委托单:{}'.format(result))
 def order_detail(self, p, data):
     """
     订单详情
     :return:
     """
     api_key = environment(config.env_name, data)[0]
     secret_key = environment(config.env_name, data)[1]
     host = environment(config.env_name, data)[-2]
     # print(host)
     tie = int(time.time())
     request_path = '/open/api/order_info'
     result = wbf_signature.Signature(api_key, secret_key,
                                      tie).get(request_path, host, p)
     return result
 def unfilled_order_v2(self, types):
     """
     查询当前委托单
     :param types:
     :return:
     """
     params = {
         "api_key": api_key,
         "time": Con().now_time(),
         "symbol": config.symbol
     }
     request_path = '/open/api/v2/new_order'
     result = wbf_signature.Signature(secret_key).get_sign(
         types, params, request_path, host)
     print('查询当前委托单:{}'.format(result))
 def cancel_all(self, types):
     """
     撤销全部订单
     :param p:
     :return:
     """
     request_path = '/open/api/cancel_order_all'
     params = {
         "api_key": api_key,
         "time": Con().now_time(),
         "symbol": config.symbol
     }
     result = wbf_signature.Signature(secret_key).post_sign(
         types, params, request_path, host)
     print('撤销全部订单:{}'.format(result))
 def order_cancel(self, p, data):
     """
     撤销订单
     :param p:
     :return:
     """
     api_key = environment(config.env_name, data)[0]
     secret_key = environment(config.env_name, data)[1]
     host = environment(config.env_name, data)[-2]
     # print(host)
     tie = int(time.time())
     request_path = '/open/api/cancel_order'
     result = wbf_signature.Signature(api_key, secret_key,
                                      tie).post_sign(p, request_path, host)
     print(result)
     return result
 def account_balance(self, data, currency):
     """
     查询账户资产
     :return:
     """
     api_key = environment(data)[0]
     secret_key = environment(data)[1]
     host = environment(data)[-2]
     # print(host)
     tie = int(time.time())
     request_path = '/open/api/user/account'
     result = wbf_signature.Signature(api_key, secret_key,
                                      tie).get_sign(request_path, host)
     # print(result)
     coin = result['data']['coin_list']
     # print(coin)
     for i in range(0, len(coin)):
         if coin[i]['coin'] == currency:
             # print(coin[i]['normal'], coin[i]['locked'])
             wirte_log.return_log(currency, coin[i]['normal'],
                                  coin[i]['locked'])
             # print(coin[i]['normal'], coin[i]['locked'])
             return coin[i]['normal'], coin[i]['locked']