Example #1
0
    def test_YW_ETFSS_SZSH_005(self):
        # -----------ETF赎回-------------
        title = '深圳ETF赎回--禁止现金替代:T日ETF拥股量1unit→T日赎回ETF'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-204-05',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '169905',  # etf代码
            'etf_unit': 1,  # etf赎回单位数
            'etf_unit_buy': 1,  # etf买入单位数
            'etf_unit_sell': 1,  # etf卖出单位数
            'component_unit_sell': 1  # 成分股卖出单位数
        }

        # -----------二级市场买入etf-----------
        etf_add(Api, Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                unit_info['ticker'], unit_info['etf_unit_buy'])
        time.sleep(3)

        # -----------ETF赎回-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '2', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)

        # -----------查询ETF赎回前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_REDEMPTION'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # --------二级市场,卖出etf-----------
        case_goal['期望状态'] = '废单'
        case_goal['errorID'] = 11010121
        case_goal['errorMSG'] = queryOrderErrorMsg(11010121)
        quantity = int(unit_info['etf_unit_sell'] *
                       stkparm['最小申赎单位'])  # 二级市场卖出的etf数量
        quantity_list = split_etf_quantity(quantity)
        # 查询涨停价
        limitup_px = getUpPrice(stkparm['证券代码'])
        rs = {}
        for etf_quantity in quantity_list:
            wt_reqs_etf = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                etf_quantity,
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = serviceTest(Api, case_goal, wt_reqs_etf)
            if rs['用例测试结果'] is False:
                etf_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
                return
        etf_sell_log(case_goal, rs)

        # ------------二级市场卖出成份股-----------
        case_goal['期望状态'] = '全成'
        case_goal['errorID'] = 0
        case_goal['errorMSG'] = ''
        etf_component_info = QueryEtfComponentsInfoDB(stkparm['证券代码'],
                                                      wt_reqs['market'])
        rs = {}
        for stk_info in etf_component_info:
            stk_code = stk_info[0]
            components_share = QueryEtfComponentsDB(stkparm['证券代码'], stk_code)
            components_total = int(components_share *
                                   unit_info['component_unit_sell'])
            quantity = get_valid_amount(components_total)
            limitup_px = getUpPrice(stk_code)
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                'ticker':
                stk_code,
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                quantity,
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            rs = serviceTest(Api, case_goal, wt_reqs)
            if rs['用例测试结果'] is False:
                etf_components_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
        etf_components_sell_log(case_goal, rs)
        self.assertEqual(rs['用例测试结果'], True)
Example #2
0
    def test_YW_ETFSS_SZSH_066(self):
        # -----------ETF赎回-------------
        title = '深圳:当日买入的基金份额,当日可以赎回并检查持仓'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-204-065',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '179880',  # etf代码
            'etf_unit': 1,  # etf赎回单位数
            'etf_unit_buy': 1,  # etf买入单位数
            'component_unit_sell': 1  # 成分股卖出单位数
        }

        # -----------二级市场买入etf-----------
        etf_add(Api, Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                unit_info['ticker'], unit_info['etf_unit_buy'])
        time.sleep(3)

        # -----------ETF赎回-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '2', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)

        # -----------查询ETF赎回前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_REDEMPTION'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)
Example #3
0
    def test_YW_ETFSS_SHSG_034(self):
        # -----------ETF申购-------------
        title = '上海ETF申购--可现金替代:(T-1日+T日)部分成分股&' \
                '资金足额&计算现金比例=最大现金比例→T日申购ETF'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-34',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '590470',  # etf代码
            'component_unit_buy': 100,  # 成分股买入数量或单位,大于等于100为数量,否则为份数
            'etf_unit': 1,  # etf申购单位数
            'component_unit_sell': 0.5  # 成分股卖出数量或单位,大于等于100为数量,否则为份数
        }

        # -----------T日买入成分股-------------
        etf_basket_add(Api,
                       Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                       unit_info['ticker'],
                       unit_info['component_unit_buy'])

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0',
                              'B', case_goal['期望状态'], Api)

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                    Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'order_client_id':
                    2,
                'market':
                    Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                    stkparm['证券代码'],
                'side':
                    Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                    Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                    int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # --------二级市场,卖出etf-----------
        quantity = int(unit_info['etf_unit'] *
                       stkparm['最小申赎单位'])  # 二级市场卖出的etf数量
        quantity_list = split_etf_quantity(quantity)
        # 查询涨停价
        limitup_px = getUpPrice(stkparm['证券代码'])
        rs = {}
        for etf_quantity in quantity_list:
            wt_reqs_etf = {
                'business_type':
                    Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'order_client_id':
                    2,
                'market':
                    Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                    stkparm['证券代码'],
                'side':
                    Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                    Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                    limitup_px,
                'quantity':
                    etf_quantity,
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = serviceTest(Api, case_goal, wt_reqs_etf)
            if rs['用例测试结果'] is False:
                etf_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
                return
        etf_sell_log(case_goal, rs)

        # ------------二级市场卖出成份股-----------
        case_goal['期望状态'] = '废单'
        case_goal['errorID'] = 11010121
        case_goal['errorMSG'] = 'Failed to check security quantity.'
        etf_component_info = QueryEtfComponentsInfoDB(stkparm['证券代码'],wt_reqs['market'])
        rs = {}
        for stk_info in etf_component_info:
            stk_code = stk_info[0]
            components_share = QueryEtfComponentsDB(stkparm['证券代码'], stk_code)
            components_total = unit_info['component_unit_sell'] \
                                 if unit_info['component_unit_sell'] >= 100 \
                                  else int(components_share * unit_info['component_unit_sell'])
            quantity = get_valid_amount(components_total)
            limitup_px = getUpPrice(stk_code)
            wt_reqs = {
                'business_type':
                    Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'market':
                    Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                    stk_code,
                'side':
                    Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                    Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                    limitup_px,
                'quantity':
                    quantity,
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            rs = serviceTest(Api, case_goal, wt_reqs)
            if rs['用例测试结果'] is False:
                etf_components_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
        etf_components_sell_log(case_goal, rs)
        self.assertEqual(rs['用例测试结果'], True)
Example #4
0
    def test_YW_ETFSS_SZSG_080(self):
        # -----------ETF申购-------------
        title = '深圳:当日买入的股票,当日可以申购并检查持仓'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-79',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '169159',  # etf代码
            'optional_unit': 1,  # 买入允许现金替代成分股份数
            'forbidden_unit': 1,  # 买入禁止现金替代成分股份数
            'etf_unit': 1,  # etf申购单位数
        }

        # -----------T日买入成分股-------------
        etf_basket_add_real(
            Api,
            Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
            'B',
            unit_info,
            case_goal,
        )

        time.sleep(15)

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '2', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)
        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SZ_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)
    def test_S_REDEMPTION_HA_ETF_510260(self):
        # -----------ETF赎回-------------
        title = '赎回真实的ETF-可赎回的证券数足量,资金足额'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-204-026',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '510260',  # etf代码
            'etf_unit': 1,  # etf赎回单位数
            'component_unit_sell': 1  # 成分股卖出单位数
        }

        # -----------ETF赎回-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)

        # -----------查询ETF赎回前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_REDEMPTION'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # ------------二级市场卖出成份股-----------
        etf_component_info = QueryEtfComponentsInfoDB(stkparm['证券代码'],
                                                      wt_reqs['market'])
        rs = {}
        for stk_info in etf_component_info:
            if stk_info[1] != 2:  #非全部现金替代
                stk_code = stk_info[0]
                components_share = QueryEtfComponentsDB(
                    stkparm['证券代码'], stk_code)
                components_total = int(components_share *
                                       unit_info['component_unit_sell'])
                quantity = get_valid_amount(components_total)
                limitup_px = getUpPrice(stk_code)
                wt_reqs = {
                    'business_type':
                    Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                    'market':
                    Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                    'ticker':
                    stk_code,
                    'side':
                    Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                    'price_type':
                    Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                    'price':
                    limitup_px,
                    'quantity':
                    quantity,
                }
                ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
                rs = serviceTest(Api, case_goal, wt_reqs)
                if rs['用例测试结果'] is False:
                    etf_components_sell_log(case_goal, rs)
                    self.assertEqual(rs['用例测试结果'], True)
        etf_components_sell_log(case_goal, rs)
        self.assertEqual(rs['用例测试结果'], True)
Example #6
0
    def test_YW_ETFSS_SHSH_050(self):
        # -----------ETF赎回-------------
        title = 'T日申购ETF-T日赎回当天申购的ETF-T日卖出T日的ETF'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-204-050',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '580470',  # etf代码
            'etf_unit': 1,  # etf赎回单位数
            'component_unit_buy': 1,  # 成分股买入单位数
            'etf_unit_sell': 1,  # etf卖出单位数
        }

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)
        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # -----------ETF赎回-------------

        case_goal['期望状态'] = '废单'
        case_goal['errorID'] = 11010121
        case_goal['errorMSG'] = 'Failed to check security quantity.'
        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        wt_reqs = {
            'business_type':
            Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
            'market': Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
            'ticker': stkparm['证券代码'],
            'side': Api.const.XTP_SIDE_TYPE['XTP_SIDE_REDEMPTION'],
            'price_type': Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
            'quantity': int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
        }
        EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
        CaseParmInsertMysql(case_goal, wt_reqs)
        rs = etfServiceTest(Api, case_goal, wt_reqs)
        etf_creation_log(case_goal, rs)

        # -----------ETF申购-------------
        wt_reqs = {
            'business_type':
            Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
            'market': Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
            'ticker': stkparm['证券代码'],
            'side': Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
            'price_type': Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
            'quantity': int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
        }
        EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
        CaseParmInsertMysql(case_goal, wt_reqs)
        rs = etfServiceTest(Api, case_goal, wt_reqs)
        etf_creation_log(case_goal, rs)

        # --------二级市场,卖出etf-----------
        case_goal['期望状态'] = '全成'
        case_goal['errorID'] = 0
        case_goal['errorMSG'] = ''
        quantity = int(unit_info['etf_unit'] *
                       stkparm['最小申赎单位'])  # 二级市场卖出的etf数量
        quantity_list = split_etf_quantity(quantity)
        # 查询涨停价
        limitup_px = getUpPrice(stkparm['证券代码'])
        rs = {}
        for etf_quantity in quantity_list:
            wt_reqs_etf = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                etf_quantity,
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = serviceTest(Api, case_goal, wt_reqs_etf)
            if rs['用例测试结果'] is False:
                etf_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
                return
        etf_sell_log(case_goal, rs)
    def test_YW_ETFSS_SHSH_046_2(self):
        # -----------ETF赎回-------------
        title = '上海ETF赎回--交易时间对状态为“全成”进行撤单'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-204-046',
            '期望状态': '全成',
            'errorID': 11000343,
            'errorMSG': 'Target order already finished!',
            '是否生成报单': '是',
            '是否是撤废': '是',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '580440',  # etf代码
            'etf_unit': 1,  # etf赎回单位数
        }

        # -----------ETF赎回-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)

        # -----------查询ETF赎回前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_REDEMPTION'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info,
                                self.py_name)
            etf_creation_log(case_goal, rs)
Example #8
0
    def test_YW_ETFSS_SHSG_086(self):
        # -----------ETF申购-------------
        title = '上海:ETF卖出优先使用当天申购的ETF,其次使用昨日持仓的ETF'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-86',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '570260',  # etf代码
            'optional_unit': 1,  # 买入允许现金替代成分股份数
            'forbidden_unit': 1,  # 买入禁止现金替代成分股份数
            'etf_unit': 1,  # etf申购单位数
        }

        # -----------T日买入成分股-------------
        etf_basket_add_real(Api,
                            Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                            'B',
                            unit_info,
                            case_goal,
                            )
        time.sleep(15)

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0',
                              'B', case_goal['期望状态'], Api)
        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                    Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'order_client_id':
                    2,
                'market':
                    Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                    stkparm['证券代码'],
                'side':
                    Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                    Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                    int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
				'position_effect': 
				    Api.const.XTP_POSITION_EFFECT_TYPE['XTP_POSITION_EFFECT_INIT']
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # --------二级市场,卖出etf-----------
        quantity = int(unit_info['etf_unit'] *
                       stkparm['最小申赎单位'])  # 二级市场卖出的etf数量
        quantity_list = split_etf_quantity(quantity)
        # 查询涨停价
        limitup_px = getUpPrice(stkparm['证券代码'])
        rs = {}
        for etf_quantity in quantity_list:
            wt_reqs_etf = {
                'business_type':
                    Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'order_client_id':
                    2,
                'market':
                    Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                    stkparm['证券代码'],
                'side':
                    Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                    Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                    limitup_px,
                'quantity':
                    etf_quantity,
				'position_effect': 
				    Api.const.XTP_POSITION_EFFECT_TYPE['XTP_POSITION_EFFECT_INIT']
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = serviceTest(Api, case_goal, wt_reqs_etf)
            if rs['用例测试结果'] is False:
                etf_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
                return
        etf_sell_log(case_goal, rs)
Example #9
0
    def test_YW_ETFSS_SHSG_004(self):
        # -----------ETF申购-------------
        title = '上海A股ETF申购禁止现金替代全成测试'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-04',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '590140',  # etf代码
            'etf_unit': 1,  # etf申购单位数
            'component_unit_sell': 1  # 成分股卖出单位数
        }

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)
        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                unit_info['etf_unit'] * stkparm['最小申赎单位'],
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # --------二级市场,卖出etf-----------
        quantity = unit_info['etf_unit'] * stkparm['最小申赎单位']  # 二级市场卖出的etf数量
        quantity_list = split_etf_quantity(quantity)
        # 查询涨停价
        limitup_px = getUpPrice(stkparm['证券代码'])
        rs = {}
        for etf_quantity in quantity_list:
            wt_reqs_etf = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                etf_quantity,
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = serviceTest(Api, case_goal, wt_reqs_etf)
            if rs['用例测试结果'] is False:
                etf_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
                return
        etf_sell_log(case_goal, rs)

        # ------------二级市场卖出成份股-----------
        etf_component_info = QueryEtfComponentsInfoDB(stkparm['证券代码'],
                                                      wt_reqs['market'])
        rs = {}
        for stk_info in etf_component_info:
            stk_code = stk_info[0]
            components_share = QueryEtfComponentsDB(stkparm['证券代码'], stk_code)
            limitup_px = getUpPrice(stk_code)
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stk_code,
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                components_share * unit_info['component_unit_sell'],
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            rs = serviceTest(Api, case_goal, wt_reqs)
            if rs['用例测试结果'] is False:
                etf_components_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
        etf_components_sell_log(case_goal, rs)
        self.assertEqual(rs['用例测试结果'], True)
Example #10
0
    def test_YW_ETFSS_SHSG_048(self):
        # -----------ETF申购-------------
        title = '上海ETF申购真实ETF-资金<现金替代所需的资金,申购所需的成分股不足' \
                '(可现金替代的比例<=最大现金替代比例,且禁止现金替代的成分股充足)'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-48',
            '期望状态': '废单',
            'errorID': 11010120,
            'errorMSG': queryOrderErrorMsg(11010120),
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '570150',  # etf代码
            'optional_unit': 1,  # 买入允许现金替代成分股份数或者数量,大于等于100为买入数量
            'forbidden_unit': 1,  # 买入允许现金替代成分股份数
            'optional_unit_one': -100,  # 取一个允许现金替代成分股的买入数量为:总数-100
            'etf_unit': 1,  # etf申购单位数
        }

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)
Example #11
0
    def test_YW_ETFSS_SHSG_078(self):
        # -----------ETF申购-------------
        title = '上海ETF申购--数量溢出(99000000)实际最大值'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-78',
            '期望状态': '全成',
            'errorID': 0,
            'errorMSG': '',
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '570340',  # etf代码
            'etf_unit': 99,  # etf申购单位数
        }

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)
        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'order_client_id':
                2,
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                99000000,
                'position_effect':
                Api.const.XTP_POSITION_EFFECT_TYPE['XTP_POSITION_EFFECT_INIT']
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)
Example #12
0
    def test_YW_ETFSS_SHSG_015(self):
        # -----------ETF申购-------------
        title = '上海ETF申购--必须全部现金替代:T日有成分股可申购1unitETF&可用资金不足→T日申购ETF'
        # 定义当前测试用例的期待值
        # 期望状态:初始、未成交、部成、全成、部撤已报、部撤、已报待撤、已撤、废单、撤废、内部撤单
        # xtp_ID和cancel_xtpID默认为0,不需要变动
        case_goal = {
            'case_ID': 'ATC-202-15',
            '期望状态': '废单',
            'errorID': 11010120,
            'errorMSG': queryOrderErrorMsg(11010120),
            '是否生成报单': '是',
            '是否是撤废': '否',
            'xtp_ID': 0,
            'cancel_xtpID': 0,
        }
        logger.warning(title + ', case_ID=' + case_goal['case_ID'])
        unit_info = {
            'ticker': '590260',  # etf代码
            'component_unit_buy': 1,  # 成分股买入单位数
            'etf_unit': 1,  # etf申购单位数
            # 成分股卖出单位数, 为方便测试, T-1日买入成分股和T日卖出成分股数量取0.5unit
            'component_unit_sell': 1
        }

        # -----------T日买入成分股-------------
        etf_basket_add(Api, Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                       unit_info['ticker'], unit_info['component_unit_buy'])

        # -----------查询ETF申购前成分股持仓-------------
        component_stk_info = etf_get_all_component_stk(unit_info['ticker'])

        # -----------ETF申购-------------
        # 参数:证券代码、市场、证券类型、证券状态、交易状态、买卖方向(B买S卖)、期望状态、Api
        stkparm = QueryEtfQty(unit_info['ticker'], '1', '14', '2', '0', 'B',
                              case_goal['期望状态'], Api)

        # 定义委托参数信息------------------------------------------
        # 如果下单参数获取失败,则用例失败
        if stkparm['返回结果'] is False:
            rs = {
                '用例测试结果': stkparm['返回结果'],
                '用例错误原因': '获取下单参数失败, ' + stkparm['错误原因'],
            }
            etf_query_log(case_goal, rs)
            self.assertEqual(rs['用例测试结果'], True)
        else:
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_ETF'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_PURCHASE'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_LIMIT'],
                'quantity':
                int(unit_info['etf_unit'] * stkparm['最小申赎单位']),
                'position_effect':
                Api.const.XTP_POSITION_EFFECT_TYPE['XTP_POSITION_EFFECT_INIT']
            }
            EtfParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = etfServiceTest(Api, case_goal, wt_reqs, component_stk_info)
            etf_creation_log(case_goal, rs)

        # --------二级市场,卖出etf-----------
        case_goal['errorID'] = 11010121
        case_goal['errorMSG'] = queryOrderErrorMsg(11010121)
        quantity = int(unit_info['etf_unit'] *
                       stkparm['最小申赎单位'])  # 二级市场卖出的etf数量
        quantity_list = split_etf_quantity(quantity)
        # 查询涨停价
        limitup_px = getUpPrice(stkparm['证券代码'])
        rs = {}
        for etf_quantity in quantity_list:
            wt_reqs_etf = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stkparm['证券代码'],
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                etf_quantity,
                'position_effect':
                Api.const.XTP_POSITION_EFFECT_TYPE['XTP_POSITION_EFFECT_INIT']
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            CaseParmInsertMysql(case_goal, wt_reqs)
            rs = serviceTest(Api, case_goal, wt_reqs_etf)
            if rs['用例测试结果'] is False:
                etf_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
                return
        etf_sell_log(case_goal, rs)

        # ------------二级市场卖出成份股-----------
        etf_component_info = QueryEtfComponentsInfoDB(stkparm['证券代码'],
                                                      wt_reqs['market'])
        rs = {}
        for stk_info in etf_component_info:
            stk_code = stk_info[0]
            components_share = QueryEtfComponentsDB(stkparm['证券代码'], stk_code)
            components_total = int(components_share *
                                   unit_info['component_unit_sell'])
            quantity = get_valid_amount(components_total)
            limitup_px = getUpPrice(stk_code)
            wt_reqs = {
                'business_type':
                Api.const.XTP_BUSINESS_TYPE['XTP_BUSINESS_TYPE_CASH'],
                'market':
                Api.const.XTP_MARKET_TYPE['XTP_MKT_SH_A'],
                'ticker':
                stk_code,
                'side':
                Api.const.XTP_SIDE_TYPE['XTP_SIDE_SELL'],
                'price_type':
                Api.const.XTP_PRICE_TYPE['XTP_PRICE_BEST5_OR_CANCEL'],
                'price':
                limitup_px,
                'quantity':
                quantity,
                'position_effect':
                Api.const.XTP_POSITION_EFFECT_TYPE['XTP_POSITION_EFFECT_INIT']
            }
            ParmIni(Api, case_goal['期望状态'], wt_reqs['price_type'])
            rs = serviceTest(Api, case_goal, wt_reqs)
            if rs['用例测试结果'] is False:
                etf_components_sell_log(case_goal, rs)
                self.assertEqual(rs['用例测试结果'], True)
        etf_components_sell_log(case_goal, rs)
        self.assertEqual(rs['用例测试结果'], True)