Пример #1
0
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Operating Income
    oi_yr, oi_qtr = WS_retrieve_custom(oi_item['Item'], oi_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    re_yr_samp = WS_resample(seq_DT, re_yr, fill_cols=fill_cols)
    co_yr_samp = WS_resample(seq_DT, co_yr, fill_cols=fill_cols)
    oi_yr_samp = WS_resample(seq_DT, oi_yr, fill_cols=fill_cols)

    cm_yr_samp = align_subtract(re_yr_samp, co_yr_samp)

    ol_yr_samp = align_div(cm_yr_samp, oi_yr_samp)

    DF_ol_yr = DF_ol_yr.append(ol_yr_samp, sort=False)

    # Quarter
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    re_qtr_samp = WS_resample(seq_DT, re_qtr, fill_cols=fill_cols)
    co_qtr_samp = WS_resample(seq_DT, co_qtr, fill_cols=fill_cols)
    oi_qtr_samp = WS_resample(seq_DT, oi_qtr, fill_cols=fill_cols)

    cm_qtr_samp = align_subtract(re_qtr_samp, co_qtr_samp)

    ol_qtr_samp = align_div(cm_qtr_samp, oi_qtr_samp)
Пример #2
0
                                         **add_lback_kwarg)
    # Total Asset
    aa_yr, aa_qtr = WS_retrieve_custom(aa_item['Item'], aa_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)
    ni_yr_samp = WS_resample(seq_DT, ni_yr, fill_cols=fill_cols)
    rev_yr_samp = WS_resample(seq_DT, rev_yr, fill_cols=fill_cols)
    aa_yr_samp = WS_resample(seq_DT, aa_yr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    _acc_yr_samp = align_subtract(cf_yr_samp, ni_yr_samp)
    accruals_yr_samp = align_div(_acc_yr_samp[cols], aa_yr_samp)
    accrualsS_yr_samp = align_div(_acc_yr_samp[cols], rev_yr_samp)

    DF_accruals_yr = DF_accruals_yr.append(accruals_yr_samp, sort=False)
    DF_accrualsS_yr = DF_accrualsS_yr.append(accrualsS_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)
    ni_qtr_samp = WS_resample(seq_DT, ni_qtr, fill_cols=fill_cols)
    rev_qtr_samp = WS_resample(seq_DT, rev_qtr, fill_cols=fill_cols)
    aa_qtr_samp = WS_resample(seq_DT, aa_qtr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
Пример #3
0
    aa_yr_samp = WS_resample(seq_DT, aa_yr, fill_cols=fill_cols)
    cs_yr_samp = WS_resample(seq_DT, cs_yr, fill_cols=fill_cols)
    pp_yr_samp = WS_resample(seq_DT, pp_yr, fill_cols=fill_cols)
    in_yr_samp = WS_resample(seq_DT, in_yr, fill_cols=fill_cols)
    tax_yr_samp = WS_resample(seq_DT, tax_yr, fill_cols=fill_cols)

    c_yr_samp = agg_add(cs_yr_samp, pp_yr_samp, in_yr_samp)
    c_yr_samp = pd.merge(c_yr_samp, cs_yr_samp[
        ['Code', 'BASE_DT', 'FiscalPrd', 'CalPrdEndDate'
         ]].drop_duplicates(), on=['Code', 'BASE_DT', 'FiscalPrd'], how='left')

    ro_yr_samp = simple_mult(oi_yr_samp, tax_yr_samp).rename(columns={'FiscalPrd_0': 'FiscalPrd'})
    ic_yr_samp = simple_subtract(aa_yr_samp, c_yr_samp).rename(columns={'FiscalPrd_0': 'FiscalPrd'})
    ic_yr_samp = ic_yr_samp[ic_yr_samp['Value_'] > 0]

    roic_yr_samp = align_div(ro_yr_samp, ic_yr_samp)
    roic_yr_samp['Value_'] = roic_yr_samp['Value_'] * 100

    DF_roic_yr = DF_roic_yr.append(roic_yr_samp, sort=False)
    

    # Quarter
    fill_cols = ['FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr']
    oi_qtr_samp = WS_resample(seq_DT, oi_qtr, fill_cols=fill_cols)
    aa_qtr_samp = WS_resample(seq_DT, aa_qtr, fill_cols=fill_cols)
    cs_qtr_samp = WS_resample(seq_DT, cs_qtr, fill_cols=fill_cols)
    pp_qtr_samp = WS_resample(seq_DT, pp_qtr, fill_cols=fill_cols)
    in_qtr_samp = WS_resample(seq_DT, in_qtr, fill_cols=fill_cols)
    tax_qtr_samp = WS_resample(seq_DT, tax_qtr, fill_cols=fill_cols)

    c_qtr_samp = agg_add(cs_qtr_samp, pp_qtr_samp, in_qtr_samp)
Пример #4
0
st_time = time.time()
for i, Code_lst in enumerate(Code_lst_tot):
    # GrossIncome
    gi_yr, gi_qtr = WS_retrieve_custom(
        gi_item['Item'], gi_item['Table'], Code_lst, 'sum', bkfil, **add_lback_kwarg)
    # Total Asset
    aa_yr, aa_qtr = WS_retrieve_custom(
        aa_item['Item'], aa_item['Table'], Code_lst, 'avg', bkfil, **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    gi_yr_samp = WS_resample(seq_DT, gi_yr, fill_cols=fill_cols)
    aa_yr_samp = WS_resample(seq_DT, aa_yr, fill_cols=fill_cols)

    gpoa_yr_samp = align_div(gi_yr_samp, aa_yr_samp)
    gpoa_yr_samp['Value_'] = gpoa_yr_samp['Value_'] * 100

    DF_gpoa_yr = DF_gpoa_yr.append(gpoa_yr_samp, sort=False)
    

    # Quarter
    fill_cols = ['FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr']
    gi_qtr_samp = WS_resample(seq_DT, gi_qtr, fill_cols=fill_cols)
    aa_qtr_samp = WS_resample(seq_DT, aa_qtr, fill_cols=fill_cols)

    gpoa_qtr_samp = align_div(gi_qtr_samp, aa_qtr_samp)
    gpoa_qtr_samp['Value_'] = gpoa_qtr_samp['Value_'] * 100

    DF_gpoa_qtr = DF_gpoa_qtr.append(gpoa_qtr_samp, sort=False)
    
    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)
    ev_yr_samp = WS_resample(seq_DT, ev_yr, fill_cols=fill_cols)
    eb_yr_samp = WS_resample(seq_DT, eb_yr, fill_cols=fill_cols)
    da_yr_samp = WS_resample(seq_DT, da_yr, fill_cols=fill_cols)
    cx_yr_samp = WS_resample(seq_DT, cx_yr, fill_cols=fill_cols)

    eba_yr_samp = align_add(eb_yr_samp, da_yr_samp)
    fcf_yr_samp = align_subtract(cf_yr_samp, cx_yr_samp)

    evebitda_yr_samp = align_div(ev_yr_samp, eba_yr_samp)
    cfoev_yr_samp = align_div(cf_yr_samp, ev_yr_samp)
    fcfev_yr_samp = align_div(fcf_yr_samp, ev_yr_samp)

    DF_evebitda_yr = DF_evebitda_yr.append(evebitda_yr_samp, sort=False)
    DF_cfoev_yr = DF_cfoev_yr.append(cfoev_yr_samp, sort=False)
    DF_fcfev_yr = DF_fcfev_yr.append(fcfev_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)
    ev_qtr_samp = WS_resample(seq_DT, ev_qtr, fill_cols=fill_cols)
    eb_qtr_samp = WS_resample(seq_DT, eb_qtr, fill_cols=fill_cols)
    da_qtr_samp = WS_resample(seq_DT, da_qtr, fill_cols=fill_cols)
Пример #6
0
    a2_yr, a2_qtr = WS_retrieve_custom(da_item['Item'], da_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # 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)
Пример #7
0
    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)
    mi_qtr_samp = WS_resample(seq_DT, mi_qtr, fill_cols=fill_cols)
Пример #8
0
st_time = time.time()
for i, Code_lst in enumerate(Code_lst_tot):
    # Long-term Debt
    d_yr, d_qtr = WS_retrieve_custom(d_item['Item'], d_item['Table'], Code_lst,
                                     'avg', bkfil, **add_lback_kwarg)
    # Total Equity
    e_yr, e_qtr = WS_retrieve_custom(e_item['Item'], e_item['Table'], Code_lst,
                                     'avg', bkfil, **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    d_yr_samp = WS_resample(seq_DT, d_yr, fill_cols=fill_cols)
    e_yr_samp = WS_resample(seq_DT, e_yr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    de_yr_samp = align_div(d_yr_samp, e_yr_samp)
    de_yr_samp = de_yr_samp[de_yr_samp['Value_'] >= 0]

    DF_de_yr = DF_de_yr.append(de_yr_samp, sort=False)

    # Quarter
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    d_qtr_samp = WS_resample(seq_DT, d_qtr, fill_cols=fill_cols)
    e_qtr_samp = WS_resample(seq_DT, e_qtr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    de_qtr_samp = align_div(d_qtr_samp, e_qtr_samp)
    de_qtr_samp = de_qtr_samp[de_qtr_samp['Value_'] >= 0]
Пример #9
0
                                       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)
Пример #10
0
    # Accounts Receivable
    ac_yr, ac_qtr = WS_retrieve_custom(ac_item['Item'], ac_item['Table'],
                                       Code_lst, 'avg', bkfil,
                                       **add_lback_kwarg)
    # Revenue
    rev_yr, rev_qtr = WS_retrieve_custom(rev_item['Item'], rev_item['Table'],
                                         Code_lst, 'sum', bkfil,
                                         **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    ac_yr_samp = WS_resample(seq_DT, ac_yr, fill_cols=fill_cols)
    rev_yr_samp = WS_resample(seq_DT, rev_yr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    ardays_yr_samp = align_div(ac_yr_samp, rev_yr_samp)
    ardays_yr_samp['Value_'] = -1 * ardays_yr_samp['Value_'] * 365

    DF_ardays_yr = DF_ardays_yr.append(ardays_yr_samp, sort=False)

    # Quarter
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    ac_qtr_samp = WS_resample(seq_DT, ac_qtr, fill_cols=fill_cols)
    rev_qtr_samp = WS_resample(seq_DT, rev_qtr, fill_cols=fill_cols)

    cols = ['BASE_DT', 'Code', 'FiscalPrd', 'Value_']
    ardays_qtr_samp = align_div(ac_qtr_samp, rev_qtr_samp)
    ardays_qtr_samp['Value_'] = -1 * ardays_qtr_samp['Value_'] * 365
for i, Code_lst in enumerate(Code_lst_tot):
    # Operating CashFlow
    cf_yr, cf_qtr = WS_retrieve_custom(cf_item['Item'], cf_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Enterprise Value
    ev_yr, ev_qtr = WS_retrieve_custom(ev_item['Item'], ev_item['Table'],
                                       Code_lst, 'avg', bkfil,
                                       **add_lback_kwarg)

    # <<Year>>
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    cf_yr_samp = WS_resample(seq_DT_long, cf_yr, fill_cols=fill_cols)
    ev_yr_samp = WS_resample(seq_DT_long, ev_yr, fill_cols=fill_cols)

    cfo2ev_yr_samp = align_div(cf_yr_samp, ev_yr_samp)
    cfo2ev_yr_samp = Conv_Historical_Val2_speed(cfo2ev_yr_samp, back=5)

    # <<Qtr>>
    fill_cols = [
        'FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_', 'FILLyr'
    ]
    cf_qtr_samp = WS_resample(seq_DT_long, cf_qtr, fill_cols=fill_cols)
    ev_qtr_samp = WS_resample(seq_DT_long, ev_qtr, fill_cols=fill_cols)

    cfo2ev_qtr_samp = align_div(cf_qtr_samp, ev_qtr_samp)
    cfo2ev_qtr_samp = Conv_Historical_Val2_speed(cfo2ev_qtr_samp, back=20)

    # <<< Trim Date >>>
    (cfo2ev_yr_samp,
     cfo2ev_qtr_samp) = (trimDateSeq(seq_DT, DF)