def QA_quotation(code, start, end, frequence, market, source=DATASOURCE.TDX, output=OUTPUT_FORMAT.DATAFRAME):
    """一个统一的获取k线的方法
    如果使用mongo,从本地数据库获取,失败则在线获取

    Arguments:
        code {str/list} -- 期货/股票的代码
        start {str} -- 开始日期
        end {str} -- 结束日期
        frequence {enum} -- 频率 QA.FREQUENCE
        market {enum} -- 市场 QA.MARKET_TYPE
        source {enum} -- 来源 QA.DATASOURCE
        output {enum} -- 输出类型 QA.OUTPUT_FORMAT
    """
    res = None
    if market == MARKET_TYPE.STOCK_CN:
        if frequence == FREQUENCE.DAY:
            if source == DATASOURCE.MONGO:
                try:
                    res = QAQueryAdv.QA_fetch_stock_day_adv(code, start, end)
                except:
                    res = None
            if source == DATASOURCE.TDX or res == None:
                res = QATdx.QA_fetch_get_stock_day(code, start, end, '00')
                res = QA_DataStruct_Stock_day(res.set_index(['date', 'code']))
            elif source == DATASOURCE.TUSHARE:
                res = QATushare.QA_fetch_get_stock_day(code, start, end, '00')
        elif frequence in [FREQUENCE.ONE_MIN, FREQUENCE.FIVE_MIN, FREQUENCE.FIFTEEN_MIN, FREQUENCE.THIRTY_MIN, FREQUENCE.SIXTY_MIN]:
            if source == DATASOURCE.MONGO:
                try:
                    res = QAQueryAdv.QA_fetch_stock_min_adv(
                        code, start, end, frequence=frequence)
                except:
                    res = None
            if source == DATASOURCE.TDX or res == None:
                res = QATdx.QA_fetch_get_stock_min(
                    code, start, end, frequence=frequence)
                res = QA_DataStruct_Stock_min(
                    res.set_index(['datetime', 'code']))

    elif market == MARKET_TYPE.FUTURE_CN:
        if frequence == FREQUENCE.DAY:
            if source == DATASOURCE.MONGO:
                try:
                    res = QAQueryAdv.QA_fetch_future_day_adv(code, start, end)
                except:
                    res = None
            if source == DATASOURCE.TDX or res == None:
                res = QATdx.QA_fetch_get_future_day(code, start, end)
                res = QA_DataStruct_Future_day(res.set_index(['date', 'code']))
        elif frequence in [FREQUENCE.ONE_MIN, FREQUENCE.FIVE_MIN, FREQUENCE.FIFTEEN_MIN, FREQUENCE.THIRTY_MIN, FREQUENCE.SIXTY_MIN]:
            if source == DATASOURCE.MONGO:
                try:
                    res = QAQueryAdv.QA_fetch_future_min_adv(
                        code, start, end, frequence=frequence)
                except:
                    res = None
            if source == DATASOURCE.TDX or res == None:
                res = QATdx.QA_fetch_get_future_min(
                    code, start, end, frequence=frequence)
                res = QA_DataStruct_Future_min(
                    res.set_index(['datetime', 'code']))

    # 指数代码和股票代码是冲突重复的，  sh000001 上证指数  000001 是不同的
    elif market == MARKET_TYPE.INDEX_CN:
        if frequence == FREQUENCE.DAY:
            if source == DATASOURCE.MONGO:
                res = QAQueryAdv.QA_fetch_index_day_adv(code, start, end)

    elif market == MARKET_TYPE.OPTION_CN:
        if source == DATASOURCE.MONGO:
            #res = QAQueryAdv.QA_fetch_option_day_adv(code, start, end)
            raise NotImplementedError('CURRENT NOT FINISH THIS METHOD')
    # print(type(res))

    if output is OUTPUT_FORMAT.DATAFRAME:
        return res.data
    elif output is OUTPUT_FORMAT.DATASTRUCT:
        return res
    elif output is OUTPUT_FORMAT.NDARRAY:
        return res.to_numpy()
    elif output is OUTPUT_FORMAT.JSON:
        return res.to_json()
    elif output is OUTPUT_FORMAT.LIST:
        return res.to_list()
def QA_quotation ( code , start , end , frequence , market , source = DATASOURCE . TDX , output = OUTPUT_FORMAT . DATAFRAME ) : res = None if market == MARKET_TYPE . STOCK_CN : if frequence == FREQUENCE . DAY : if source == DATASOURCE . MONGO : try : res = QAQueryAdv . QA_fetch_stock_day_adv ( code , start , end ) except : res = None if source == DATASOURCE . TDX or res == None : res = QATdx . QA_fetch_get_stock_day ( code , start , end , '00' ) res = QA_DataStruct_Stock_day ( res . set_index ( [ 'date' , 'code' ] ) ) elif source == DATASOURCE . TUSHARE : res = QATushare . QA_fetch_get_stock_day ( code , start , end , '00' ) elif frequence in [ FREQUENCE . ONE_MIN , FREQUENCE . FIVE_MIN , FREQUENCE . FIFTEEN_MIN , FREQUENCE . THIRTY_MIN , FREQUENCE . SIXTY_MIN ] : if source == DATASOURCE . MONGO : try : res = QAQueryAdv . QA_fetch_stock_min_adv ( code , start , end , frequence = frequence ) except : res = None if source == DATASOURCE . TDX or res == None : res = QATdx . QA_fetch_get_stock_min ( code , start , end , frequence = frequence ) res = QA_DataStruct_Stock_min ( res . set_index ( [ 'datetime' , 'code' ] ) ) elif market == MARKET_TYPE . FUTURE_CN : if frequence == FREQUENCE . DAY : if source == DATASOURCE . MONGO : try : res = QAQueryAdv . QA_fetch_future_day_adv ( code , start , end ) except : res = None if source == DATASOURCE . TDX or res == None : res = QATdx . QA_fetch_get_future_day ( code , start , end ) res = QA_DataStruct_Future_day ( res . set_index ( [ 'date' , 'code' ] ) ) elif frequence in [ FREQUENCE . ONE_MIN , FREQUENCE . FIVE_MIN , FREQUENCE . FIFTEEN_MIN , FREQUENCE . THIRTY_MIN , FREQUENCE . SIXTY_MIN ] : if source == DATASOURCE . MONGO : try : res = QAQueryAdv . QA_fetch_future_min_adv ( code , start , end , frequence = frequence ) except : res = None if source == DATASOURCE . TDX or res == None : res = QATdx . QA_fetch_get_future_min ( code , start , end , frequence = frequence ) res = QA_DataStruct_Future_min ( res . set_index ( [ 'datetime' , 'code' ] ) ) elif market == MARKET_TYPE . INDEX_CN : if frequence == FREQUENCE . DAY : if source == DATASOURCE . MONGO : res = QAQueryAdv . QA_fetch_index_day_adv ( code , start , end ) elif market == MARKET_TYPE . OPTION_CN : if source == DATASOURCE . MONGO : raise NotImplementedError ( 'CURRENT NOT FINISH THIS METHOD' ) if output is OUTPUT_FORMAT . DATAFRAME : return res . data elif output is OUTPUT_FORMAT . DATASTRUCT : return res elif output is OUTPUT_FORMAT . NDARRAY : return res . to_numpy ( ) elif output is OUTPUT_FORMAT . JSON : return res . to_json ( ) elif output is OUTPUT_FORMAT . LIST : return res . to_list ( )
一个统一的获取k线的方法
    如果使用mongo,从本地数据库获取,失败则在线获取

    Arguments:
        code {str/list} -- 期货/股票的代码
        start {str} -- 开始日期
        end {str} -- 结束日期
        frequence {enum} -- 频率 QA.FREQUENCE
        market {enum} -- 市场 QA.MARKET_TYPE
        source {enum} -- 来源 QA.DATASOURCE
        output {enum} -- 输出类型 QA.OUTPUT_FORMAT