Ejemplo n.º 1
0
def QA_fetch_financial_report_adv(code, start, end=None, ltype='EN'):
    """高级财务查询接口
    Arguments:
        code {[type]} -- [description]
        start {[type]} -- [description]
    Keyword Arguments:
        end {[type]} -- [description] (default: {None})
    """

    if end is None:

        return QA_DataStruct_Financial(
            QA_fetch_financial_report(code,
                                      start,
                                      ltype=ltype)
        )
    else:
        series = pd.Series(
            data=month_data,
            index=pd.to_datetime(month_data, utc=False),
            name='date'
        )
        timerange = series.loc[start:end].tolist()
        return QA_DataStruct_Financial(
            QA_fetch_financial_report(code,
                                      timerange,
                                      ltype=ltype)
        )
Ejemplo n.º 2
0
def QA_fetch_stock_divyield_adv(code,
                                start="all",
                                end=None,
                                format='pd',
                                collections=DATABASE.report_calendar):
    '获取股票日线'
    #code= [code] if isinstance(code,str) else code
    end = start if end is None else end
    start = str(start)[0:10]
    end = str(end)[0:10]

    # code checking
    if start == 'all':
        start = '1990-01-01'
        end = str(datetime.date.today())

    if end is None:

        return QA_DataStruct_Financial(
            QA_fetch_stock_divyield(code, start, str(datetime.date.today())))
    else:
        series = pd.Series(data=month_data,
                           index=pd.to_datetime(month_data),
                           name='date')
        timerange = series.loc[start:end].tolist()
        return QA_DataStruct_Financial(
            QA_fetch_stock_divyield(code, start, end))
Ejemplo n.º 3
0
def QA_fetch_financial_TTM_adv(code,
                               start="all",
                               end=None,
                               format='pd',
                               collections=DATABASE.financial_TTM):
    '获取财报TTM'
    #code= [code] if isinstance(code,str) else code
    end = start if end is None else end
    start = str(start)[0:10]
    end = str(end)[0:10]

    # code checking
    if start == 'all':
        start = '2001-01-01'
        end = QA_util_today_str()

    if end is None:
        return QA_DataStruct_Financial(
            QA_fetch_financial_TTM(code, start, str(datetime.date.today())))
    else:
        series = pd.Series(data=month_data,
                           index=pd.to_datetime(month_data),
                           name='date')
        timerange = series.loc[start:end].tolist()
        return QA_DataStruct_Financial(QA_fetch_financial_TTM(
            code, start, end))
Ejemplo n.º 4
0
def QA_fetch_financial_report_adv(code, start='all', type='report', end=None):
    """高级财务查询接口

    Arguments:
        code {[type]} -- [description]
        start {[type]} -- [description]

    Keyword Arguments:
        end {[type]} -- [description] (default: {None})
    """
    end = start if end is None else end
    start = str(start)[0:10]
    end = str(end)[0:10]

    if start == 'all':
        start = '1990-01-01'
        end = str(datetime.date.today())

    if end is None:
        end = str(datetime.date.today())
        date_list = list(
            pd.DataFrame.from_dict(
                QA_util_getBetweenQuarter(
                    start,
                    QA_util_datetime_to_strdate(QA_util_add_months(
                        end, -3)))).T.iloc[:, 1])
        if type == 'report':
            return QA_DataStruct_Financial(
                QA_fetch_financial_report(code, date_list))
        elif type == 'date':
            return QA_DataStruct_Financial(
                QA_fetch_financial_report(code, date_list, type='date'))
    else:
        daterange = pd.date_range(start, end)
        timerange = [item.strftime('%Y-%m-%d') for item in list(daterange)]
        if type == 'report':
            return QA_DataStruct_Financial(
                QA_fetch_financial_report(code, timerange))
        elif type == 'date':
            return QA_DataStruct_Financial(
                QA_fetch_financial_report(code, timerange, type='date'))
Ejemplo n.º 5
0
def QA_fetch_financial_report_adv(code=None,
                                  start=None,
                                  end=None,
                                  type='report',
                                  ltype='EN'):
    """高级财务查询接口
    Arguments:
        code {[type]} -- [description]
        start {[type]} -- [description]
    Keyword Arguments:
        end {[type]} -- [description] (default: {None})
    """
    return QA_DataStruct_Financial(
        QA_fetch_financial_report(code, start, end, type=type, ltype=ltype))
Ejemplo n.º 6
0
def QA_fetch_stock_divyield_adv(code,
                                start="all",
                                end=None,
                                format='pd',
                                type='crawl',
                                collections=DATABASE.stock_divyield):
    '获取股票日线'
    #code= [code] if isinstance(code,str) else code
    end = start if end is None else end
    start = str(start)[0:10]
    end = str(end)[0:10]

    # code checking
    if start == 'all':
        start = '2007-01-01'
        end = QA_util_today_str()
    if end is None:
        end = QA_util_today_str()
    return QA_DataStruct_Financial(
        QA_fetch_stock_divyield(code, start, end, type=type))
Ejemplo n.º 7
0
def QA_fetch_stock_financial_calendar_adv(
        code,
        start="all",
        end=None,
        type='day',
        format='pd',
        collections=DATABASE.report_calendar):
    '获取股票财报日历'
    #code= [code] if isinstance(code,str) else code
    # code checking
    if start == 'all':
        start = '2007-01-01'
        end = QA_util_today_str()
    if end is None:
        end = QA_util_today_str()

    end = start if end is None else end
    start = str(start)[0:10]
    end = str(end)[0:10]

    return QA_DataStruct_Financial(
        QA_fetch_stock_financial_calendar(code, start, end, type=type))