示例#1
0
    da_yr, da_qtr = WS_retrieve_custom(da_item['Item'], da_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Price
    mc_samp = WS_currVal(seq_DT_long,
                         Item=mc_item['Item'],
                         Table=mc_item['Table'],
                         Name=mc_item.name,
                         Code=Code_lst)
    mc_samp = find_n_mod_error(mc_samp)

    # <<Year>>
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    eb_yr_samp = WS_resample(seq_DT_long, eb_yr, fill_cols=fill_cols)
    da_yr_samp = WS_resample(seq_DT_long, da_yr, fill_cols=fill_cols)
    eba_yr_samp = align_add(eb_yr_samp, da_yr_samp)
    ebitda2p_yr_samp = simple_div(eba_yr_samp, mc_samp)

    ebitda2p_yr_samp = Conv_Historical_Val3(ebitda2p_yr_samp,
                                            freq=freq,
                                            bkfil=bkfil)

    # <<Qtr>>
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    eb_qtr_samp = WS_resample(seq_DT_long, eb_qtr, fill_cols=fill_cols)
    da_qtr_samp = WS_resample(seq_DT_long, da_qtr, fill_cols=fill_cols)
    eba_qtr_samp = align_add(eb_qtr_samp, da_qtr_samp)
    ebitda2p_qtr_samp = simple_div(eba_qtr_samp, mc_samp)
                                       **add_lback_kwarg)
    # Minority Interest
    mi_yr, mi_qtr = WS_retrieve_custom(mi_item['Item'], mi_item['Table'],
                                       Code_lst, 'avg', bkfil,
                                       **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    cf_yr_samp = WS_resample(seq_DT, cf_yr, fill_cols=fill_cols)
    cx_yr_samp = WS_resample(seq_DT, cx_yr, fill_cols=fill_cols)
    db_yr_samp = WS_resample(seq_DT, db_yr, fill_cols=fill_cols)
    eq_yr_samp = WS_resample(seq_DT, eq_yr, fill_cols=fill_cols)
    mi_yr_samp = WS_resample(seq_DT, mi_yr, fill_cols=fill_cols)

    fcf_yr_samp = align_subtract(cf_yr_samp, cx_yr_samp)
    ic_yr_samp = align_add(db_yr_samp, eq_yr_samp, mi_yr_samp)

    fcfroic_yr_samp = align_div(fcf_yr_samp, ic_yr_samp)
    cfroic_yr_samp = align_div(cf_yr_samp, ic_yr_samp)

    DF_fcfroic_yr = DF_fcfroic_yr.append(fcfroic_yr_samp, sort=False)
    DF_cfroic_yr = DF_cfroic_yr.append(cfroic_yr_samp, sort=False)

    # Quarter
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    cf_qtr_samp = WS_resample(seq_DT, cf_qtr, fill_cols=fill_cols)
    cx_qtr_samp = WS_resample(seq_DT, cx_qtr, fill_cols=fill_cols)
    db_qtr_samp = WS_resample(seq_DT, db_qtr, fill_cols=fill_cols)
    eq_qtr_samp = WS_resample(seq_DT, eq_qtr, fill_cols=fill_cols)
    # Revenue
    b_yr, b_qtr = WS_retrieve_custom(rev_item['Item'], rev_item['Table'],
                                     Code_lst, 'sum', bkfil, **add_lback_kwarg)

    # <<Year>>
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    a_yr_samp = WS_resample(seq_DT_long, a_yr, fill_cols=fill_cols)
    a1_yr_samp = WS_resample(seq_DT_long, a1_yr, fill_cols=fill_cols)
    a2_yr_samp = WS_resample(seq_DT_long, a2_yr, fill_cols=fill_cols)
    b_yr_samp = WS_resample(seq_DT_long, b_yr, fill_cols=fill_cols)

    # Margin
    nm_yr_samp = align_div(a_yr_samp, b_yr_samp)
    nm_yr_samp['Value_'] = 100 * nm_yr_samp['Value_']

    ebitda_yr_samp = align_add(a1_yr_samp, a2_yr_samp)
    tmp_col = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    ebitdam_yr_samp = align_div(ebitda_yr_samp[tmp_col], b_yr_samp)
    ebitdam_yr_samp['Value_'] = 100 * ebitdam_yr_samp['Value_']

    opm_yr_samp = align_div(a1_yr_samp, b_yr_samp)
    opm_yr_samp['Value_'] = 100 * opm_yr_samp['Value_']

    # Margin Chg
    nm_yr_chg_samp = get_HistChgAvg(nm_yr_samp, 2, 1, buffer=2 / 3)
    opm_yr_chg_samp = get_HistChgAvg(opm_yr_samp, 2, 1, buffer=2 / 3)
    ebitdam_yr_chg_samp = get_HistChgAvg(ebitdam_yr_samp, 2, 1, buffer=2 / 3)

    # <<Quarter>>
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    dv_yr, dv_qtr = WS_retrieve_custom(dv_item['Item'], dv_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Capex
    cx_yr, cx_qtr = WS_retrieve_custom(cx_item['Item'], cx_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    cf_yr_samp = WS_resample(seq_DT, cf_yr, fill_cols=fill_cols)
    dv_yr_samp = WS_resample(seq_DT, dv_yr, fill_cols=fill_cols)
    cx_yr_samp = WS_resample(seq_DT, cx_yr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    cc_yr_samp = align_add(cf_yr_samp, dv_yr_samp)
    cacqr_yr_samp = align_div(cc_yr_samp[cols], cx_yr_samp)

    DF_CAcqR_yr = DF_CAcqR_yr.append(cacqr_yr_samp, sort=False)

    # Quarter
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    cf_qtr_samp = WS_resample(seq_DT, cf_qtr, fill_cols=fill_cols)
    dv_qtr_samp = WS_resample(seq_DT, dv_qtr, fill_cols=fill_cols)
    cx_qtr_samp = WS_resample(seq_DT, cx_qtr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    cc_qtr_samp = align_add(cf_qtr_samp, dv_qtr_samp)
    cacqr_qtr_samp = align_div(cc_qtr_samp[cols], cx_qtr_samp)