def QA_data_stock_to_fq(__data, type_='01'):

    def __QA_fetch_stock_xdxr(
            code,
            format_='pd',
            collections=DATABASE.stock_xdxr
    ):
        '获取股票除权信息/数据库'
        try:
            data = pd.DataFrame(
                [item for item in collections.find({'code': code})]
            ).drop(['_id'],
                   axis=1)
            data['date'] = pd.to_datetime(data['date'])
            return data.set_index(['date', 'code'], drop=False)
        except:
            return pd.DataFrame(
                data=[],
                columns=[
                    'category',
                    'category_meaning',
                    'code',
                    'date',
                    'fenhong',
                    'fenshu',
                    'liquidity_after',
                    'liquidity_before',
                    'name',
                    'peigu',
                    'peigujia',
                    'shares_after',
                    'shares_before',
                    'songzhuangu',
                    'suogu',
                    'xingquanjia'
                ]
            )

    '股票 日线/分钟线 动态复权接口'

    code = __data.index.remove_unused_levels().levels[1][0] if isinstance(
        __data.index,
        pd.core.indexes.multi.MultiIndex
    ) else __data['code'][0]

    return _QA_data_stock_to_fq(
        bfq_data=__data,
        xdxr_data=__QA_fetch_stock_xdxr(code),
        fqtype=type_
    )
def QA_data_stock_to_fq ( __data , type_ = '01' ) : def __QA_fetch_stock_xdxr ( code , format_ = 'pd' , collections = DATABASE . stock_xdxr ) : try : data = pd . DataFrame ( [ item for item in collections . find ( { 'code' : code } ) ] ) . drop ( [ '_id' ] , axis = 1 ) data [ 'date' ] = pd . to_datetime ( data [ 'date' ] ) return data . set_index ( [ 'date' , 'code' ] , drop = False ) except : return pd . DataFrame ( data = [ ] , columns = [ 'category' , 'category_meaning' , 'code' , 'date' , 'fenhong' , 'fenshu' , 'liquidity_after' , 'liquidity_before' , 'name' , 'peigu' , 'peigujia' , 'shares_after' , 'shares_before' , 'songzhuangu' , 'suogu' , 'xingquanjia' ] ) '股票 日线/分钟线 动态复权接口' code = __data . index . remove_unused_levels ( ) . levels [ 1 ] [ 0 ] if isinstance ( __data . index , pd . core . indexes . multi . MultiIndex ) else __data [ 'code' ] [ 0 ] return _QA_data_stock_to_fq ( bfq_data = __data , xdxr_data = __QA_fetch_stock_xdxr ( code ) , fqtype = type_ )
股票 日线/分钟线 动态复权接口