Пример #1
0
    def peg(self):
        # PEG = PE / 过去12个月的EPS增长率
        pe_daily = self.pe_daily
        basicepsyoy = self.basicepsyoy
        basicepsyoy = adjust_months(basicepsyoy)
        epsyoy = append_df(basicepsyoy, target_feq='D', fill_type='preceding')

        pe_daily = CALFUNC.del_dat_early_than(pe_daily, START_YEAR)
        epsyoy = CALFUNC.del_dat_early_than(epsyoy, START_YEAR)

        [pe_daily, epsyoy] = align(pe_daily, epsyoy)

        [h, l] = pe_daily.shape
        pe_ar = pe_daily.values
        eps_ar = epsyoy.values

        res = np.zeros([h, l])
        for i in range(0, h):
            for j in range(0, l):
                if pd.isna(eps_ar[i, j]) or eps_ar[i, j] == 0:
                    res[i, j] = np.nan
                else:
                    res[i, j] = pe_ar[i, j] / eps_ar[i, j]

        res_df = pd.DataFrame(data=res,
                              index=pe_daily.index,
                              columns=pe_daily.columns)

        return res_df
Пример #2
0
 def ROE_G_q(self):  # 单季度.ROE同比增长率
     roe = self.roe
     sig_season_roe = get_signal_season_value(roe)
     roe_g = CALFUNC.generate_yoygr(sig_season_roe)
     roe_g = adjust_months(roe_g)
     roe_g = append_df(roe_g)
     roe_g_q = CALFUNC.del_dat_early_than(roe_g, START_YEAR)
     return roe_g_q
Пример #3
0
 def Sales_G_q(self):  # qfa_yoysales:单季度.营业收入同比增长率
     operatingrevenue = self.operatingrevenue
     sig_season_operatingrevenue = get_signal_season_value(operatingrevenue)
     sales_g = CALFUNC.generate_yoygr(sig_season_operatingrevenue)
     sales_g = adjust_months(sales_g)
     sales_g = append_df(sales_g)
     sales_g = CALFUNC.del_dat_early_than(sales_g, START_YEAR)
     return sales_g
Пример #4
0
    def grossprofitmargin_ttm(self):

        gir = self.grossincomeratiottm
        gir = adjust_months(gir)
        # 用来扩展月度数据
        gir = append_df(gir)
        res = CALFUNC.del_dat_early_than(gir, START_YEAR)
        return res
Пример #5
0
    def totalassetturnover(self):

        totalassettrate = self.totalassettrate
        tmp0 = adjust_months(totalassettrate)
        tmp1 = append_df(tmp0)
        res = CALFUNC.del_dat_early_than(tmp1, START_YEAR)

        return res
Пример #6
0
 def Profit_G_q(self):  # qfa_yoyprofit:单季度.净利润同比增长率
     netprofit = self.netprofitcut  # 扣除非经常损益后的净利润
     sig_season_netprofit = get_signal_season_value(netprofit)
     p_g = CALFUNC.generate_yoygr(sig_season_netprofit)
     p_g = adjust_months(p_g)
     p_g = append_df(p_g)
     profit_g_q = CALFUNC.del_dat_early_than(p_g, START_YEAR)
     return profit_g_q
Пример #7
0
    def ROE_q(self):
        totalshareholderequity = self.totalshareholderequity
        netprofit = self.netprofit
        # 得到单季度 净利润
        sig_season_netprofit = get_signal_season_value(netprofit)
        # 得到季度平均总资产
        s_mean_equity = get_season_mean_value(totalshareholderequity)

        roe_q = (sig_season_netprofit / s_mean_equity) * 100
        roe_q = adjust_months(roe_q)
        roe_q = append_df(roe_q)
        roe_q = CALFUNC.del_dat_early_than(roe_q, START_YEAR)
        return roe_q
Пример #8
0
    def ROA_q(self):
        totalassets = self.totalassets
        netprofit = self.netprofit
        # 得到单季度 净利润
        sig_season_netprofit = get_signal_season_value(netprofit)
        # 得到季度平均总资产
        s_mean_totalassets = get_season_mean_value(totalassets)

        roa_q = (sig_season_netprofit / s_mean_totalassets) * 100
        roa_q = adjust_months(roa_q)
        roa_q = append_df(roa_q)
        roa_q = CALFUNC.del_dat_early_than(roa_q, START_YEAR)
        return roa_q
Пример #9
0
    def assetturnover_q(self):
        totalassets = self.totalassets
        revenue = self.operatingrevenue
        # 得到单季度 净利润
        sig_season_revenue = get_signal_season_value(revenue)
        # 得到季度平均总资产
        s_mean_totalassets = get_season_mean_value(totalassets)

        turnover_q = (sig_season_revenue / s_mean_totalassets) * 100
        turnover_q = adjust_months(turnover_q)
        turnover_q = append_df(turnover_q)
        turnover_q = CALFUNC.del_dat_early_than(turnover_q, START_YEAR)

        return turnover_q
Пример #10
0
    def grossprofitmargin_diff(self):
        revenue = self.operatingrevenue  # 营业收入
        cost = self.operatingcost  # 营业成本
        # 财务指标常规处理,移动月份,改月末日期
        revenue_q = get_signal_season_value(revenue)
        cost_q = get_signal_season_value(cost)
        gross_q = (revenue_q - cost_q) / revenue_q

        gir_d = CALFUNC.generate_diff(gross_q)
        gir_d = adjust_months(gir_d)
        # 用来扩展月度数据
        gir_d = append_df(gir_d)
        res = CALFUNC.del_dat_early_than(gir_d, START_YEAR)
        return res
Пример #11
0
    def RDtosales(self):
        data = Data()

        rd_exp = data.rd_exp
        revenue = data.operatingrevenue
        rd_exp = CALFUNC.del_dat_early_than(rd_exp, 2018)
        revenue = CALFUNC.del_dat_early_than(revenue, 2018)

        res = rd_exp / revenue
        res = adjust_months(res)
        res = append_df(res)

        to_del = res.columns[res.isna().sum() / len(res) > 0.9]
        res.drop(to_del, axis=1, inplace=True)

        return res
Пример #12
0
 def grossprofitmargin_q(self):
     '''
     计算公示:(营业收入 - 营业成本) / 营业收入 * 100 %
     计算单季度指标,应该先对 营业收入 和 营业成本 分别计算单季度指标,再计算
     '''
     revenue = self.operatingrevenue  # 营业收入
     cost = self.operatingcost  # 营业成本
     # 财务指标常规处理,移动月份,改月末日期
     revenue_q = get_signal_season_value(revenue)
     cost_q = get_signal_season_value(cost)
     gross_q = (revenue_q - cost_q) / revenue_q
     # 调整为公告日期
     tmp = adjust_months(gross_q)
     # 用来扩展月度数据
     tmp = append_df(tmp)
     res = CALFUNC.del_dat_early_than(tmp, START_YEAR)
     return res
Пример #13
0
    def Profitmargin_q(self):  # 单季度净利润率
        '''
        1.qfa_deductedprofit:单季度.扣除非经常损益后的净利润
        2.qfa_oper_rev: 单季度.营业收入
        :return:
        '''

        netprofit = self.netprofitcut  # 扣除非经常损益后的净利润
        operatingrevenue = self.operatingrevenue
        sig_season_netprofit = get_signal_season_value(netprofit)
        sig_season_operatingrevenue = get_signal_season_value(operatingrevenue)
        profitmargin_q = sig_season_netprofit / sig_season_operatingrevenue
        profitmargin_q = adjust_months(profitmargin_q)
        profitmargin_q = append_df(profitmargin_q)

        pq = CALFUNC.del_dat_early_than(profitmargin_q, START_YEAR)

        return pq
Пример #14
0
    def REVSU(self):
        netprofit = self.totaloperatingrevenueps
        # 得到单季度的数据。
        sig_season_va = get_signal_season_value(netprofit)
        cols = pd.DataFrame([i for i in sig_season_va.columns])

        revsu = pd.DataFrame()
        rolling_cols = rolling_windows(cols, 6)
        for roll in rolling_cols:
            res = _calculate_su_simple(sig_season_va[roll])
            res = pd.DataFrame(res.values, index=res.index, columns=[roll[-1]])
            revsu = pd.concat([revsu, res], axis=1)

        revsu.dropna(how='all', axis=0, inplace=True)

        revsu = adjust_months(revsu)
        revsu = append_df(revsu)

        return revsu
Пример #15
0
    def SUE(self):
        # 使用原始的财务数据
        eps = self.basiceps
        # 得到单季度的数据。
        sig_season_va = get_signal_season_value(eps)
        cols = pd.DataFrame([i for i in sig_season_va.columns])

        sue = pd.DataFrame()
        rolling_cols = rolling_windows(cols, 6)
        for roll in rolling_cols:
            res = _calculate_su_simple(sig_season_va[roll])
            res = pd.DataFrame(res.values, index=res.index, columns=[roll[-1]])
            sue = pd.concat([sue, res], axis=1)

        sue.dropna(how='all', axis=0, inplace=True)

        sue = adjust_months(sue)
        sue = append_df(sue)

        return sue
Пример #16
0
    def position_daily(self, stock_pool):
        data = Data()
        main_net_buy_ratio = data.MAIN_NET_BUY_RATIO_SCALERED
        main_net_buy_ratio = main_net_buy_ratio.shift(1, axis=1)
        main_net_buy_ratio = main_net_buy_ratio.drop(
            main_net_buy_ratio.columns[0], axis=1)

        black_cond = float_2_bool_df(main_net_buy_ratio, min_para=5)
        black_cond = cond_append_to_month(black_cond)

        stock_pool_v = bool_2_ones(stock_pool, use_df=True)
        pool = append_df(stock_pool_v, target_feq='D')
        pool = pool.shift(1, axis=1)
        pool.dropna(how='all', axis=1, inplace=True)

        pool_boll = float_2_bool_df(pool, min_para=0.5)
        # ttt = pool_boll.sum()

        mu_col = [c for c in black_cond.columns if c in pool_boll.columns]

        res = pool_boll.loc[:, mu_col] & black_cond.loc[pool.index, mu_col]
        # tt = res.sum()
        return res
Пример #17
0
 def ROA_ttm(self):
     roa_ttm = self.roattm
     roa_ttm = adjust_months(roa_ttm)
     roa_ttm = append_df(roa_ttm)
     roa_ttm = CALFUNC.del_dat_early_than(roa_ttm, START_YEAR)
     return roa_ttm