def QA_fetch_stock_realtime_adv(code=None,
                                num=1,
                                collections=DATABASE.get_collection('realtime_{}'.format(datetime.date.today()))):
    '''
    返回当日的上下五档, code可以是股票可以是list, num是每个股票获取的数量
    :param code:
    :param num:
    :param collections:  realtime_XXXX-XX-XX 每天实时时间
    :return: DataFrame
    '''
    if code is not None:
        # code 必须转换成list 去查询数据库
        if isinstance(code, str):
            code = [code]
        elif isinstance(code, list):
            pass
        else:
            print(
                "QA Error QA_fetch_stock_realtime_adv parameter code is not List type or String type")

        items_from_collections = [item for item in collections.find(
            {'code': {'$in': code}}, limit=num*len(code), sort=[('datetime', pymongo.DESCENDING)])]
        if items_from_collections is None:
            print("QA Error QA_fetch_stock_realtime_adv find parameter code={} num={} collection={} return NOne".format(
                code, num, collections))
            return

        data = pd.DataFrame(items_from_collections)
        data_set_index = data.set_index(
            ['datetime', 'code'], drop=False).drop(['_id'], axis=1)
        return data_set_index
    else:
        print("QA Error QA_fetch_stock_realtime_adv parameter code is None")
返回当日的上下五档, code可以是股票可以是list, num是每个股票获取的数量
    :param code:
    :param num:
    :param collections:  realtime_XXXX-XX-XX 每天实时时间
    :return: DataFrame