Exemple #1
0
    # Revenue
    re_yr, re_qtr = WS_retrieve_custom(re_item['Item'], re_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # COGS
    co_yr, co_qtr = WS_retrieve_custom(co_item['Item'], co_item['Table'],
                                       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)
Exemple #2
0
    # NetIncome
    ni_yr, ni_qtr = WS_retrieve_custom(ni_item['Item'], ni_item['Table'],
                                       Code_lst, 'sum', 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)
    # 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'
Exemple #3
0
# Bring needed items
gi_item = Item_lst.loc['GrossIncome']
aa_item = Item_lst.loc['TotAsset_st']

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
Exemple #4
0
                        bkfil,
                        add_lback=34)
    payout_qtr = WS_qtr_currToHist(poc_item['Item'],
                                   poc_item['Table'],
                                   Code_lst,
                                   bkfil,
                                   add_lback=48)

    # Qtr
    roe_qtr_ = get_HistAvg(roe_qtr, k=8)
    payout_qtr_ = get_HistAvg(payout_qtr, k=8)
    epsg_qtr = get_HistChgAvg(eps_qtr, k=5, k2=4, growth=True)

    fill_cols = ['FiscalPrd', 'FiscalPrd2', 'CalPrdEndDate', 'Value_']
    roe_qtr_samp = WS_resample(seq_DT,
                               roe_qtr_,
                               fill_cols=fill_cols + ['FILLyr'])
    payout_qtr_samp = WS_resample(seq_DT, payout_qtr_, fill_cols=fill_cols)
    epsg_qtr_samp = WS_resample(seq_DT,
                                epsg_qtr,
                                fill_cols=fill_cols + ['Ratio'])

    DF_ROE_qtr = DF_ROE_qtr.append(roe_qtr_samp)
    DF_Payout_qtr = DF_Payout_qtr.append(payout_qtr_samp)
    DF_epsg_qtr = DF_epsg_qtr.append(epsg_qtr_samp)

    # Year
    roe_yr_ = get_HistAvg(roe_yr, k=2)
    payout_yr_ = get_HistAvg(payout_yr, k=2)
    epsg_yr = get_HistChgAvg(eps_yr, k=2, k2=1, growth=True)
Exemple #5
0
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    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)
Exemple #6
0
        cs_item['Item'], cs_item['Table'], Code_lst, 'avg', bkfil, **add_lback_kwarg)
    # PPE
    pp_yr, pp_qtr = WS_retrieve_custom(
        pp_item['Item'], pp_item['Table'], Code_lst, 'avg', bkfil, **add_lback_kwarg)
    # Invest AssoComp
    in_yr, in_qtr = WS_retrieve_custom(
        in_item['Item'], in_item['Table'], Code_lst, 'avg', bkfil, **add_lback_kwarg)
    # Effective Tax
    tax_yr = WS_year(tax_item['Item'], tax_item['Table'], Code_lst, bkfil)
    tax_qtr = WS_qtr_avg(tax_item['Item'], tax_item['Table'], Code_lst, bkfil, maxMonths=13)
    tax_yr['Value_'] = 1 - tax_yr['Value_'] / 100
    tax_qtr['Value_'] = 1 - tax_qtr['Value_'] / 100

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    oi_yr_samp = WS_resample(seq_DT, oi_yr, fill_cols=fill_cols)
    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]
    # Operating Income
    eb_yr, eb_qtr = WS_retrieve_custom(eb_item['Item'], eb_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Depreciation & Amortization
    da_yr, da_qtr = WS_retrieve_custom(da_item['Item'], da_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)
    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)
                                     Code_lst, 'sum', bkfil, **add_lback_kwarg)
    # Operating Income
    a1_yr, a1_qtr = WS_retrieve_custom(oi_item['Item'], oi_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Dep & Amort
    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_']
    # Long-term Debt
    db_yr, db_qtr = WS_retrieve_custom(db_item['Item'], db_item['Table'],
                                       Code_lst, 'avg', bkfil,
                                       **add_lback_kwarg)
    # Total Equity
    eq_yr, eq_qtr = WS_retrieve_custom(eq_item['Item'], eq_item['Table'],
                                       Code_lst, 'avg', bkfil,
                                       **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
Exemple #10
0
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)
    # 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']
    cf_yr_samp = WS_resample(seq_DT_long, cf_yr, fill_cols=fill_cols)
    cfo2p_yr_samp = simple_div(cf_yr_samp, mc_samp)

    cfo2p_yr_samp = Conv_Historical_Val3(cfo2p_yr_samp, freq=freq, bkfil=bkfil)

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

    cfo2p_qtr_samp = Conv_Historical_Val3(cfo2p_qtr_samp,
                                          freq=freq,
                                          bkfil=bkfil)
Exemple #11
0
                           Code_lst,
                           Name=mktcap_item.name)
    mktcap_DF = mktcap_DF[mktcap_DF['Value_'] != 0]
    # mktcap_DF = mktcap_DF.groupby('Code').apply(MkCap_debug)
    # mktcap_DF.index = mktcap_DF.index.droplevel(level=1)
    # mktcap_DF.index.rename(None, inplace=True)
    # mktcap_DF.reset_index(drop=True, inplace=True)

    hist_DF_yr, hist_DF_qtr = WS_retrieve_custom(hist_item['Item'],
                                                 hist_item['Table'].iloc[0],
                                                 Code_lst, 'sum', bkfil,
                                                 **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    hist_yr_samp = WS_resample(seq_DT, hist_DF_yr, fill_cols=fill_cols)
    # Yr-P2Sales
    ps_DF_yr = pd.merge(
        mktcap_DF.rename(columns={'Value_': 'mktcap'})[[
            'BASE_DT', 'Code', 'mktcap'
        ]],
        hist_yr_samp[hist_yr_samp['Item'] == '1001'].rename(
            columns={'Value_': 'sales'})[['BASE_DT', 'Code', 'sales']],
        on=['BASE_DT', 'Code'])
    ps_DF_yr['Value_'], ps_DF_yr[
        'freq'] = ps_DF_yr['mktcap'] / ps_DF_yr['sales'], 'Y'
    # Yr-P2FCF
    pfcf_DF_yr = align_subtract(
        hist_yr_samp[hist_yr_samp['Item'] == '4860'][[
            'BASE_DT', 'Code', 'FiscalPrd', 'Value_'
        ]], hist_yr_samp[hist_yr_samp['Item'] == '4601'][[
Exemple #12
0
# Bring needed items
d_item = Item_lst.loc['LT_Debt']
e_item = Item_lst.loc['TotEquity_st']

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)
Exemple #13
0
    # REVg_l1yr_ws
    REVgr_yr, REVgr_qtr = WS_retrieve_custom(rv1_item['Item'],
                                             rv1_item['Table'], Code_lst, None,
                                             bkfil, **add_lback_kwarg)
    # NIg_l1yr_ws
    NIgr_yr, NIgr_qtr = WS_retrieve_custom(ni1_item['Item'], ni1_item['Table'],
                                           Code_lst, None, bkfil,
                                           **add_lback_kwarg)
    # LTDtCE_ws
    DtE_yr, DtE_qtr = WS_retrieve_custom(de_item['Item'], de_item['Table'],
                                         Code_lst, None, bkfil,
                                         **add_lback_kwarg)

    # Year
    fill_cols = ['FiscalPrd', 'CalPrdEndDate', 'Value_', 'FILLyr']
    roe_yr_samp = WS_resample(seq_DT, roe_yr, fill_cols=fill_cols)
    roa_yr_samp = WS_resample(seq_DT, roa_yr, fill_cols=fill_cols)
    opm_yr_samp = WS_resample(seq_DT, opm_yr, fill_cols=fill_cols)
    nm_yr_samp = WS_resample(seq_DT, nm_yr, fill_cols=fill_cols)
    gpm_yr_samp = WS_resample(seq_DT, gpm_yr, fill_cols=fill_cols)
    REVgr_yr_samp = WS_resample(seq_DT, REVgr_yr, fill_cols=fill_cols)
    NIgr_yr_samp = WS_resample(seq_DT, NIgr_yr, fill_cols=fill_cols)
    DtE_yr_samp = WS_resample(seq_DT, DtE_yr, fill_cols=fill_cols)

    DF_ROE_yr = DF_ROE_yr.append(roe_yr_samp, sort=False)
    DF_ROA_yr = DF_ROA_yr.append(roa_yr_samp, sort=False)
    DF_OPM_yr = DF_OPM_yr.append(opm_yr_samp, sort=False)
    DF_NM_yr = DF_NM_yr.append(nm_yr_samp, sort=False)
    DF_GPM_yr = DF_GPM_yr.append(gpm_yr_samp, sort=False)
    DF_RevGr_yr = DF_RevGr_yr.append(REVgr_yr_samp, sort=False)
    DF_NIGr_yr = DF_NIGr_yr.append(NIgr_yr_samp, sort=False)
    # Operating CashFlow
    cf_yr, cf_qtr = WS_retrieve_custom(cf_item['Item'], cf_item['Table'],
                                       Code_lst, 'sum', bkfil,
                                       **add_lback_kwarg)
    # Cash Dividend
    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)
Exemple #15
0
rev_item = Item_lst.loc['NetSales_Revenue']

st_time = time.time()
for i, Code_lst in enumerate(Code_lst_tot):
    # 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)