def _get_data(self): from single_factor import OperationRevenueGrowth, EstimateNetRevenueGrowRateFY1_6M, FreeCashFlowPerShare, GrossIncomeRatio, ROC, EffectiveTaxRate, PS factor_list = [ OperationRevenueGrowth, EstimateNetRevenueGrowRateFY1_6M, FreeCashFlowPerShare, GrossIncomeRatio, ROC, EffectiveTaxRate, PS ] date_one_year = get_trading_date_from_now(self.date, -1, ql.Years) date_two_year = get_trading_date_from_now(self.date, -2, ql.Years) df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) df_Revenue_growth_one_year = get_factor_from_wind_without_cache( self.code_list, [OperationRevenueGrowth], date_one_year) df_Revenue_growth_one_year.rename(columns={'营业收入增长率': '营业收入增长率_去年'}, inplace=True) df_FreeCashFlowPerShare_one_year = get_factor_from_wind_without_cache( self.code_list, [FreeCashFlowPerShare], date_one_year) df_FreeCashFlowPerShare_one_year.rename( columns={'每股企业自由现金流': '每股企业自由现金流_去年'}, inplace=True) df_FreeCashFlowPerShare_two_year = get_factor_from_wind_without_cache( self.code_list, [FreeCashFlowPerShare], date_two_year) df_FreeCashFlowPerShare_two_year.rename( columns={'每股企业自由现金流': '每股企业自由现金流_前年'}, inplace=True) df_temp = df['市销率'] * df['销售毛利率'] * 10.0 # 边际获利乘数即:销售毛利率*10 df = pd.concat([ df, df_Revenue_growth_one_year, df_FreeCashFlowPerShare_one_year, df_FreeCashFlowPerShare_two_year, df_temp ], axis=1) df.rename(columns={0: '高估/低估指数'}, inplace=True) df = df.dropna() return df
def _get_data(self): from single_factor import NetProfitGrowRateV2, NetProfit, Revenue, PE factor_list = [NetProfitGrowRateV2, NetProfit,PE] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) date_temp = get_trading_date_from_now(self.date, -3, ql.Months) df_temp = get_factor_from_wind_without_cache(self.code_list, [NetProfitGrowRateV2, Revenue], date_temp) df_temp.rename(columns={'净利润增长率': '净利润增长率_3个月前'}, inplace=True) df_temp_1 = df['净利润增长率'] - df_temp['净利润增长率_3个月前'] df = pd.concat([df, df_temp, df_temp_1], axis=1) df.rename(columns={0: '差值'}, inplace=True) df = df.dropna() return df
def _get_data(self): from single_factor import PB, PE, DividendYield, PriceFreeCashFlowPerShare, LongTermLiabilityToWorkCapital factor_list = [PB, DividendYield, PriceFreeCashFlowPerShare, LongTermLiabilityToWorkCapital] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) # 五年PE值获取 df_PE = [] for i in range(5): date_temp = get_trading_date_from_now(self.date, -i, ql.Years) df_temp = get_factor_from_wind_without_cache(self.code_list, [PE], date_temp) df_temp.rename(columns={'市盈率PE': '市盈率_'+str(i)}, inplace=True) df_PE.append(df_temp) df = pd.concat([df]+df_PE, axis=1) df = df.dropna() return df
def _get_data(self): from single_factor import LCap, CurrentRatio, ROE, FreeCashFlowPerShare, OperationRevenueGrowth, NetProfitGrowRateV2 factor_list = [LCap, CurrentRatio, ROE, OperationRevenueGrowth, NetProfitGrowRateV2] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) # 五年自由现金流量 df_PE = [] for i in range(5): date_temp = get_trading_date_from_now(self.date, -i, ql.Years) df_temp = get_factor_from_wind_without_cache(self.code_list, [FreeCashFlowPerShare], date_temp) df_temp.rename(columns={'每股企业自由现金流指标': '每股企业自由现金流指标_' + str(i)}, inplace=True) df_PE.append(df_temp) df = pd.concat([df] + df_PE, axis=1) df = df.dropna() return df
def _get_data(self): from single_factor import DebetToAsset, CFPS, MarketValueToFreeCashFlow, NetProfitGrowRateV2, DividendYield, PE, InventoryTurnRatio factor_list = [DebetToAsset, CFPS, MarketValueToFreeCashFlow, NetProfitGrowRateV2, DividendYield, PE] factor_InvTurn_now = [InventoryTurnRatio] factor_InvTurn_one_year = [InventoryTurnRatio] date_one_year = get_trading_date_from_now(self.date, -1, ql.Years) df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) # 存货增长率与营收增长率的比较判断数据,使用存货周转率判断 df_invturn_now = get_factor_from_wind_without_cache(self.code_list, factor_InvTurn_now, self.date) df_invturn_now.rename(columns={'存货周转率': '存货周转率_今年'}, inplace=True) df_invturn_one_year = get_factor_from_wind_without_cache(self.code_list, factor_InvTurn_one_year, date_one_year) df_invturn_one_year.rename(columns={'存货周转率': '存货周转率_去年'}, inplace=True) df = pd.concat([df, df_invturn_now, df_invturn_one_year], axis=1) df = df.dropna() return df
def output(self): from single_factor import InventoryTurnRatio factor_list = [InventoryTurnRatio] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) last_year = self._get_last_year_date(self.date) df_last_year = get_factor_from_wind_without_cache(code, factor_list, last_year) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df_last_year.iloc[:, 0] = pd.to_numeric(df_last_year.iloc[:, 0]) growth = (df.iloc[:, 0].values - df_last_year.iloc[:, 0].values) / df_last_year.iloc[:, 0].values text = '\0\0存货周转率分析(数据截止' + self.date + '):' para_1 = rl_text(text) text = '存货周转率为%.2f次;上年同期为%.2f次;同比增长为%.2f%%。' text = text % (df.iloc[:, 0].values, df_last_year.iloc[:, 0], growth * 100.0) para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def _get_data(self): from single_factor import SteadyProfitAcc, InventoryTurnRatio, PB factor_list = [SteadyProfitAcc, InventoryTurnRatio, PB] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) df = df.dropna() return df
def _get_data(self): from single_factor import DilutedEPS, EstimateNetProfitGrowRateFY1_6M factor_list = [DilutedEPS, EstimateNetProfitGrowRateFY1_6M] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) df = df.dropna() return df
def _get_data(self): from single_factor import DilutedEPS, ForecastEarningGrowth_FY1_3M factor_list = [DilutedEPS, ForecastEarningGrowth_FY1_3M] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) df = df.dropna() return df
def _get_data(self): from single_factor import EstimatePEFY1, EstimateNetProfitGrowRateFY1_6M, PB factor_list = [EstimatePEFY1, EstimateNetProfitGrowRateFY1_6M, PB] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) df = df.dropna() return df
def _get_data(self): # 10日的策略 from single_factor import ForeignCapitalHoldingRatioGrowth_LR_10 factor_list = [ForeignCapitalHoldingRatioGrowth_LR_10] df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) df = df.dropna() return df
def output(self): from single_factor import AccRecTurnRatioV2 factor_list = [AccRecTurnRatioV2] code = [self.code] date = self._get_last_year_end(self.date) df = get_factor_from_wind_without_cache(code, factor_list, date) date_last = self._get_last_year_date(date) df_last_year = get_factor_from_wind_without_cache(code, factor_list, date_last) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df_last_year.iloc[:, 0] = pd.to_numeric(df_last_year.iloc[:, 0]) growth = (df.iloc[:, 0].values - df_last_year.iloc[:, 0].values) / df_last_year.iloc[:, 0].values text = '\0\0应收账款率分析(数据截止' + date + '):' para_1 = rl_text(text) text = '应收账款周转率为%.2f次;上年同期为%.2f次;同比增长为%.2f%%。' text = text % (df.iloc[:, 0].values, df_last_year.iloc[:, 0], growth * 100.0) para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def _get_data(self): from single_factor import ClosePrice, PE, DividendYield, NetTangibleAssetPerShare, NetLiquidAssetPerShare, TotalLiability, NetLiquidAsset, NetTangibleAsset, CurrentRatio, NetProfitGrowRateV2 factor_list = [ClosePrice, PE, DividendYield, NetTangibleAssetPerShare, NetLiquidAssetPerShare, TotalLiability, NetLiquidAsset, NetTangibleAsset, CurrentRatio, NetProfitGrowRateV2] # factor_list = [PE_MAX] # 待添加到上述列表,条件筛选不完整 df = get_factor_from_wind_without_cache(self.code_list, factor_list, self.date) date_temp_1 = get_trading_date_from_now(self.date, -3, ql.Days) # 取3天前国债收益率 yield_data = w.wss("TB" + str(self.N) + "Y.WI", "close", "tradeDate=" + str(date_temp_1) + ";priceAdj=U;cycle=D").Data[0][0] df = df.dropna() return df, yield_data
def output(self): from single_factor import ROE factor_list = [ROE] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) last_year = self._get_last_year_date(self.date) df_last_year = get_factor_from_wind_without_cache(code, factor_list, last_year) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df_last_year.iloc[:, 0] = pd.to_numeric(df_last_year.iloc[:, 0]) growth = (df.iloc[:, 0].values - df_last_year.iloc[:, 0].values) / df_last_year.iloc[:, 0].values text = '\0\0业绩分析(资本回报率ROE)(数据截止' + self.date + '):' para_1 = rl_text(text) text = '资本回报为ROE%.2f%%;上年同期为%.2f%%;同比增长率为%.2f%%;' text = text % (df.iloc[:, 0].values, df_last_year.iloc[:, 0].values, growth * 100.0) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import AssetTurnoverRatio factor_list = [AssetTurnoverRatio] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) last_year = self._get_last_year_date(self.date) df_last_year = get_factor_from_wind_without_cache(code, factor_list, last_year) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df_last_year.iloc[:, 0] = pd.to_numeric(df_last_year.iloc[:, 0]) growth = (df.iloc[:, 0].values - df_last_year.iloc[:, 0].values) / df_last_year.iloc[:, 0].values text = '\0\0管理层面分析_效率分析(数据截止' + self.date + '):' para_1 = rl_text(text) text = '总资产周转率本年为%.2f次;上年同期为%.2f次;同比增长率为%.2f%%;' text = text % (df.iloc[:, 0].values, df_last_year.iloc[:, 0], growth * 100.0) text_summary = self._get_summary(df, growth) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import NonCurrentAssetRatio factor_list = [NonCurrentAssetRatio] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) date_last = self._get_last_year_date(self.date) df_last_year = get_factor_from_wind_without_cache(code, factor_list, date_last) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df_last_year.iloc[:, 0] = pd.to_numeric(df_last_year.iloc[:, 0]) growth = (df.iloc[:, 0].values - df_last_year.iloc[:, 0].values) / df_last_year.iloc[:, 0].values text = '\0\0资产结构分析(数据截止' + date + '):' para_1 = rl_text(text) text = '公司非流动资产占比为%.2f%%;上年同期为%.2f%%;同比增长为%.2f%%;' text = text % (df.iloc[:, 0].values, df_last_year.iloc[:, 0], growth * 100.0) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import DebetToAsset, TotalAsset factor_list = [DebetToAsset, TotalAsset] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) last_year = self._get_last_year_date(self.date) df_last_year = get_factor_from_wind_without_cache(code, factor_list, last_year) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df.iloc[:, 1] = pd.to_numeric(df.iloc[:, 1]) df_last_year.iloc[:, 0] = pd.to_numeric(df_last_year.iloc[:, 0]) growth = (df.iloc[:, 0].values - df_last_year.iloc[:, 0].values) / df_last_year.iloc[:, 0].values text = '\0\0管理层面分析_效率分析(数据截止' + self.date + '):' para_1 = rl_text(text) text = '总资产规模为%.2f亿元;资产负债率为%.2f%%;上年同期为%.2f%%;同比增长为%.2f%%;' text = text % (df.iloc[:, 1].values / 100000000.0, df.iloc[:, 0].values * 100.0, df_last_year.iloc[:, 0].values * 100.0, growth * 100.0) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import RevenueGrowthRate, EstimateNetRevenueGrowRateFY1_6M factor_list = [RevenueGrowthRate, EstimateNetRevenueGrowRateFY1_6M] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) df.iloc[:, 1] = pd.to_numeric(df.iloc[:, 1]) text = '\0\0营业收入分析(数据截止' + self.date + '):' para_1 = rl_text(text) text = '营业收入增长率为%.2f%%;分析师一致预期营业收入增长率为%.2f%%;' text = text % (df.iloc[:, 0].values, df.iloc[:, 1].values) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import OperateCashFlow, CashFlowCoverRatio factor_list = [OperateCashFlow, CashFlowCoverRatio] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df.iloc[:, 1] = pd.to_numeric(df.iloc[:, 1]) text = '\0\0现金流分析(数据截止' + self.date + '):' para_1 = rl_text(text) text = '经营活动现金流为%.2f亿元;' + '利润现金保障倍数为%.2f倍;' text = text % (df.iloc[:, 0].values/100000000.0, df.iloc[:, 1].values) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import NetProfit, NetProfitGrowRateV2, EstimateNetProfitGrowRateFY1_6M factor_list = [NetProfit, NetProfitGrowRateV2, EstimateNetProfitGrowRateFY1_6M] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df.iloc[:, 1] = pd.to_numeric(df.iloc[:, 1]) df.iloc[:, 2] = pd.to_numeric(df.iloc[:, 2]) text = '\0\0净利润增长分析(数据截止' + self.date + '):' para_1 = rl_text(text) text = '公司净利润为%.2f亿元;净利润增长率为%.2f%%;分析师一致预期净利润增长率为%.2f%%;' text = text % (df.iloc[:, 0].values/100000000.0, df.iloc[:, 1].values, df.iloc[:, 2].values) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import SellExpense, SellExpenseRevenue, SellExpenseGrowth factor_list = [SellExpense, SellExpenseRevenue, SellExpenseGrowth] code = [self.code] df = get_factor_from_wind_without_cache(code, factor_list, self.date) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df.iloc[:, 1] = pd.to_numeric(df.iloc[:, 1]) df.iloc[:, 2] = pd.to_numeric(df.iloc[:, 2]) text = '\0\0经营理念分析——销售费用(数据截止' + self.date + '):' para_1 = rl_text(text) text = '销售费用为为%.2f亿元;销售费用占营业收入的比重为:%.2f%%;销售费用增长率为%.2f%%;' text = text % (df.iloc[:, 0].values/100000000.0, df.iloc[:, 1].values * 100.0, df.iloc[:, 2].values * 100) text_summary = self._get_summary(df) text = text + text_summary para_2 = rl_text(text) return [para_1, para_2, rl_text('\0')]
def output(self): from single_factor import RDExpense, RDExpenseRevenue factor_list = [RDExpense, RDExpenseRevenue] code = [self.code] date = self._get_last_year_end(self.date) df = get_factor_from_wind_without_cache(code, factor_list, date) df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0]) df.iloc[:, 1] = pd.to_numeric(df.iloc[:, 1]) text = '\0\0经营理念分析——研发费用(数据截止' + date + '):' para_1 = rl_text(text) text = '研发费用为%.2f亿元:占营业收入为%.2f%%。' text = text % (df.iloc[:, 0].values / 100000000.0, df.iloc[:, 1].values * 100.0) para_2 = rl_text(text) if np.isnan(df.iloc[:, 0].values): return [] else: return [para_1, para_2, rl_text('\0')]
def _get_summary(self, df): from single_factor import RevenueGrowthRate factor_list = [RevenueGrowthRate] code = [self.code] rev_growth = get_factor_from_wind_without_cache(code, factor_list, self.date).iloc[:, 0].values/100.0 sellexp_growth = df.iloc[:, 2] diff = (rev_growth - sellexp_growth)[0] if diff >= 0.03: text_summary = "销售费用的增长慢于销售收入增长,预期公司毛利率具有一定的增长潜力。" elif diff < -0.03: text_summary = "销售费用的增长快于销售收入增长,预期公司毛利率增长不乐观。" elif diff < 0.03 and diff > -0.03: text_summary = "销售费用的增长与销售收入增长基本持平,预期公司经营稳定。" elif np.isnan(diff): text_summary = "公司缺失相关数据,无法分析。" else: text_summary = "Warining: recoding is needed!" return text_summary
def _get_summary(self, df): from single_factor import NetProfit factor_list = [NetProfit] code = [self.code] netprofit = get_factor_from_wind_without_cache(code, factor_list, self.date).iloc[:, 0].values if df.iloc[:, 0].values < 0.0 and netprofit < 0.0: text_summary = "此时利润现金保障倍数无实际含义,公司目前整体亏损,公司主营业务经营活动并无现金流入,整体现金流情况较差。" elif df.iloc[:, 0].values < 0.0 and netprofit > 0.0: text_summary = "利润现金保障倍数为负值,财务报表中提现公司仍然盈利,但经营活动现金流为负值,说明公司造血能力较差," \ "日常经营消耗企业现存货币积累。此种情况可以从应收账款、投资活动、筹资活动或者会计记账原则的角度来进一步分析。" elif df.iloc[:, 0].values > 0.0 and netprofit < 0.0: text_summary = "企业经营活动现金流为正,但是公司整体亏损,说明公司在主营业务经营活动正常运转," \ "此类情况并不寻常,可以从成本端和营业外支出/收入中寻找原因。" elif df.iloc[:, 0].values > 0.0 and netprofit > 0.0: if df.iloc[:, 1].values > 0.85: # 利润现金保障倍数 text_summary = "净利润和经营现金流都为正数,企业健康发展,运营正常,自身能够产生充足经营现金流,公司产生的净利润是有足够的现金流支持。" elif df.iloc[:, 1].values <= 0.85 and df.iloc[:, 1].values > 0.5: text_summary = "净利润和经营现金流都为正数,企业经营活动能够正常运转,但是经营活动现金流入水平较低,公司产生的净利润是有一定的现金流支持,公司经营管理水平有待改善。" elif df.iloc[:, 1].values <= 0.5 and df.iloc[:, 1].values > 0.0: text_summary = "净利润和经营现金流都为正数,企业经营活动处于正常运转,但是经营活动现金流入水平偏低,公司产生的净利润缺乏足够的现金流支持,公司经营管理水平有待提高。" else: text_summary = "Warining: recoding is needed!" return text_summary