583 lines
22 KiB
Python
583 lines
22 KiB
Python
"""
|
||
财务指标模型
|
||
"""
|
||
from Modules.Company.CompanyObject import FinancialData
|
||
from Utils.ValidateUtil import ValidateAttr, Validate
|
||
|
||
|
||
class FinancialIndicatorsModel(FinancialData.FinancialIndicator):
|
||
|
||
rid = ValidateAttr(field="rid", type=str)
|
||
cid = ValidateAttr(field="cid", type=str)
|
||
report_date = ValidateAttr(field="report_date", func=Validate.date_format)
|
||
|
||
fields_map = {
|
||
"rid": "评级ID",
|
||
"cid": "企业ID",
|
||
"report_date": "报告期",
|
||
"guaranteed_insured_balance_growth_rate": "担保在保余额增长率(%)",
|
||
"guaranteed_revenue_growth_rate": "担保收入增长率(%)",
|
||
"growth_rate_of_total_assets": "资产总额增长率(%)",
|
||
"cash_assets_ratio": "现金类资产比率(%)",
|
||
"current_ratio": "流动比率(%)",
|
||
"compensation_reserve_ratio": "代偿准备金比率(%)",
|
||
"compensation_rate": "代偿保障率(%)",
|
||
"risk_reserve_adequacy_ratio": "风险准备金充足率(%)",
|
||
"single_customer_concentration": "单一客户集中度(%)",
|
||
"current_guarantee_compensation_rate": "当期担保代偿率(%)",
|
||
"current_compensation_recovery_rate": "当期代偿回收率(%)",
|
||
"financing_guarantee_magnification": "融资担保放大倍数(倍)",
|
||
"industry_concentration": "行业集中度(%)",
|
||
"return_total_assets": "总资产收益率(%)",
|
||
"operating_margin": "营业利润率(%)",
|
||
"roe": "净资产收益率(%)",
|
||
"actual_asset_liability_ratio": "实际资产负债率(%)",
|
||
"capital_adequacy_ratio": "资本充足率(%)",
|
||
"paid_capital": "实收资本(亿元)",
|
||
"guarantee_business_income": "担保业务收入(万元)",
|
||
"cumulative_guarantee_compensation_rate": "近三年累计担保代偿率(%)",
|
||
"cumulative_compensation_recovery_rate": "近三年累计代偿回收率(%)",
|
||
"risk_coverage_ratio": "风险覆盖率(%)",
|
||
"cash_asset_compensation_rate": "现金类资产代偿保障率(%)",
|
||
"margin_ratio": "保证金比率(%)",
|
||
"proportion_investment_business_income": "投资业务收入占比(%)",
|
||
"investment_income_growth_rate": "投资收益增长率(%)",
|
||
"one_proportion_class_assets": "I类资产占比(%)",
|
||
"customer_concentration": "客户集中度(%)",
|
||
"proportion_income_guarantee_business": "担保业务收入占比(%)",
|
||
"two_proportion_class_assets": "II类资产占比(%)",
|
||
"three_proportion_class_assets": "III类资产占比(%)"
|
||
}
|
||
|
||
def eval_guaranteed_insured_balance_growth_rate(self, *args):
|
||
"""
|
||
担保在保余额增长率(%)
|
||
公式: 担保在保余额增长率 = (期末担保在保余额 - 期初担保在保余额) / 期初担保在保余额
|
||
args[0]: 期末担保在保余额
|
||
args[1]: 期初担保在保余额
|
||
"""
|
||
try:
|
||
value = ((args[0]-args[1]) / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.guaranteed_insured_balance_growth_rate = value
|
||
except TypeError:
|
||
self.guaranteed_insured_balance_growth_rate = None
|
||
except ZeroDivisionError:
|
||
self.guaranteed_insured_balance_growth_rate = None
|
||
|
||
|
||
def eval_guaranteed_revenue_growth_rate(self, *args):
|
||
"""
|
||
担保收入增长率(%)
|
||
公式: 担保收入增长率 =(当期担保业务收入-上期担保业务收入)/ 上期担保业务收入
|
||
args[0]: 当期担保业务收入
|
||
args[1]: 上期担保业务收入
|
||
"""
|
||
try:
|
||
value = ((args[0]-args[1]) / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.guaranteed_revenue_growth_rate = value
|
||
except TypeError:
|
||
self.guaranteed_revenue_growth_rate = None
|
||
except ZeroDivisionError:
|
||
self.guaranteed_revenue_growth_rate = None
|
||
|
||
def eval_growth_rate_of_total_assets(self, *args):
|
||
"""
|
||
资产总额增长率(%)
|
||
公式: 资产总额 = (期末资产总额 - 期初资产总额) / 期初资产总额
|
||
args[0]: 期末资产总额
|
||
args[1]: 期初资产总额
|
||
"""
|
||
try:
|
||
value = ((args[0] - args[1]) / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.growth_rate_of_total_assets = value
|
||
except TypeError:
|
||
self.growth_rate_of_total_assets = None
|
||
except ZeroDivisionError:
|
||
self.growth_rate_of_total_assets = None
|
||
|
||
def eval_cash_assets_ratio(self, *args):
|
||
"""
|
||
现金类资产比率(%)
|
||
公式: 现金类资产比率=(货币资金+可供出售金融资产+存出保证金-存入保证金) / 资产总额
|
||
args[0]: 货币资金
|
||
args[1]: 可供出售金融资产
|
||
args[2]: 存出保证金
|
||
args[3]: 存入保证金
|
||
args[4]: 资产总额
|
||
"""
|
||
try:
|
||
value = ((args[0]+args[1]+args[2]-args[3]) / args[4]) * 100
|
||
value = round(value, 2)
|
||
self.cash_assets_ratio = value
|
||
except TypeError:
|
||
self.cash_assets_ratio = None
|
||
except ZeroDivisionError:
|
||
self.cash_assets_ratio = None
|
||
|
||
def eval_current_ratio(self, *args):
|
||
"""
|
||
流动比率(%)
|
||
公式: 流动比率 = 流动资产合计 / 流动负债合计
|
||
args[0]: 流动资产合计
|
||
args[1]: 流动负债合计
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.current_ratio = value
|
||
except TypeError:
|
||
self.current_ratio = None
|
||
except ZeroDivisionError:
|
||
self.current_ratio = None
|
||
|
||
def eval_compensation_reserve_ratio(self, *args):
|
||
"""
|
||
代偿准备金比率(%)
|
||
公式: 代偿准备金比率 = 当期代偿金额 /(未到期责任准备金+担保赔偿准备金)
|
||
args[0]: 当期代偿金额
|
||
args[1]: 未到期责任准备金
|
||
args[2]: 担保赔偿准备金
|
||
"""
|
||
try:
|
||
value = (args[0] / (args[1]+args[2])) * 100
|
||
value = round(value, 2)
|
||
self.compensation_reserve_ratio = value
|
||
except TypeError:
|
||
self.compensation_reserve_ratio = None
|
||
except ZeroDivisionError:
|
||
self.compensation_reserve_ratio = None
|
||
|
||
def eval_compensation_rate(self, *args):
|
||
"""
|
||
代偿保障率(%)
|
||
公式: 代偿保障率 = (货币资金+可供出售金融资产+存出保证金-存入保证金) / 最大被担保企业融资担保责任余额
|
||
args[0]: 货币资金
|
||
args[1]: 可供出售金融资产
|
||
args[2]: 存出保证金
|
||
args[3]: 存入保证金
|
||
args[4]: 最大被担保企业融资担保责任余额
|
||
"""
|
||
try:
|
||
value = ((args[0]+args[1]+args[2]-args[3]) / args[4]) * 100
|
||
value = round(value, 2)
|
||
self.compensation_rate = value
|
||
except TypeError:
|
||
self.compensation_rate = None
|
||
except ZeroDivisionError:
|
||
self.compensation_rate = None
|
||
|
||
def eval_risk_reserve_adequacy_ratio(self, *args):
|
||
"""
|
||
风险准备金充足率(%)
|
||
公式: 风险准备金充足率=担保风险准备金余额 / 融资担保责任余额
|
||
其中:担保风险准备金余额=担保赔偿准备金+未到期责任准备金+一般风险准备金
|
||
args[0]: 担保赔偿准备金
|
||
args[1]: 未到期责任准备金
|
||
args[2]: 一般风险准备金
|
||
args[3]: 融资担保责任余额
|
||
"""
|
||
try:
|
||
value = ((args[0]+args[1]+args[2]) / args[3]) * 100
|
||
value = round(value, 2)
|
||
self.risk_reserve_adequacy_ratio = value
|
||
except TypeError:
|
||
self.risk_reserve_adequacy_ratio = None
|
||
except ZeroDivisionError:
|
||
self.risk_reserve_adequacy_ratio = None
|
||
|
||
def eval_single_customer_concentration(self, *args):
|
||
"""
|
||
单一客户集中度(%)
|
||
公式: 单一客户集中度 = 最大被担保企业融资担保责任余额 / 融资担保责任余额
|
||
args[0]: 最大被担保企业融资担保责任余额
|
||
args[1]: 融资担保责任余额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.single_customer_concentration = value
|
||
except TypeError:
|
||
self.single_customer_concentration = None
|
||
except ZeroDivisionError:
|
||
self.single_customer_concentration = None
|
||
|
||
def eval_current_guarantee_compensation_rate(self, *args):
|
||
"""
|
||
当期担保代偿率(%)
|
||
公式: 当期担保代偿率 = 当期代偿金额 / 当期解除担保责任余额
|
||
args[0]: 当期代偿金额
|
||
args[1]: 当期解除担保责任余额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.current_guarantee_compensation_rate = value
|
||
except TypeError:
|
||
self.current_guarantee_compensation_rate = None
|
||
except ZeroDivisionError:
|
||
self.current_guarantee_compensation_rate = None
|
||
|
||
def eval_current_compensation_recovery_rate(self, *args):
|
||
"""
|
||
当期代偿回收率(%)
|
||
公式: 当期代偿回收率 = 当期代偿回收金额 / 当期代偿金额
|
||
args[0]: 当期代偿回收金额
|
||
args[1]: 当期代偿金额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.current_compensation_recovery_rate = value
|
||
except TypeError:
|
||
self.current_compensation_recovery_rate = None
|
||
except ZeroDivisionError:
|
||
self.current_compensation_recovery_rate = None
|
||
|
||
def eval_financing_guarantee_magnification(self, *args):
|
||
"""
|
||
融资担保放大倍数(倍)
|
||
公式: 融资担保放大倍数 = 融资担保责任余额 / 净资产
|
||
args[0]: 融资担保责任余额
|
||
args[1]: 净资产
|
||
"""
|
||
try:
|
||
value = args[0] / args[1]
|
||
value = round(value, 2)
|
||
self.financing_guarantee_magnification = value
|
||
except TypeError:
|
||
self.financing_guarantee_magnification = None
|
||
except ZeroDivisionError:
|
||
self.financing_guarantee_magnification = None
|
||
|
||
def eval_industry_concentration(self, *args):
|
||
"""
|
||
行业集中度(%)
|
||
公式: 行业集中度 = 最大单一行业融资担保责任余额 / 融资担保责任余额
|
||
args[0]: 最大单一行业融资担保责任余额
|
||
args[1]: 融资担保责任余额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.industry_concentration = value
|
||
except TypeError:
|
||
self.industry_concentration = None
|
||
except ZeroDivisionError:
|
||
self.industry_concentration = None
|
||
|
||
def eval_return_total_assets(self, *args):
|
||
"""
|
||
总资产收益率(%)
|
||
公式: 总资产收益率 = 净利润 / (期初资产总额+期末资产总额)/2
|
||
args[0]: 净利润
|
||
args[1]: 期初资产总额
|
||
args[2]: 期末资产总额
|
||
"""
|
||
try:
|
||
value = (args[0] / (args[1]+args[2])/2) * 100
|
||
value = round(value, 2)
|
||
self.return_total_assets = value
|
||
except TypeError:
|
||
self.return_total_assets = None
|
||
except ZeroDivisionError:
|
||
self.return_total_assets = None
|
||
|
||
def eval_operating_margin(self, *args):
|
||
"""
|
||
营业利润率(%)
|
||
公式: 营业利润率 =(营业利润-投资收益-公允价值变动收益)/ 营业收入
|
||
args[0]: 营业利润
|
||
args[1]: 投资收益
|
||
args[2]: 公允价值变动收益
|
||
args[3]: 营业收入
|
||
"""
|
||
try:
|
||
value = ((args[0]-args[1]-args[2]) / args[3]) * 100
|
||
value = round(value, 2)
|
||
self.operating_margin = value
|
||
except TypeError:
|
||
self.operating_margin = None
|
||
except ZeroDivisionError:
|
||
self.operating_margin = None
|
||
|
||
def eval_roe(self, *args):
|
||
"""
|
||
净资产收益率(%)
|
||
公式: 净资产收益率 = 净利润 / (期初净资产+期末净资产)/2
|
||
args[0]: 净利润
|
||
args[1]: 期初净资产
|
||
args[2]: 期末净资产
|
||
"""
|
||
try:
|
||
value = (args[0] / (args[1]+args[2])/2) * 100
|
||
value = round(value, 2)
|
||
self.roe = value
|
||
except TypeError:
|
||
self.roe = None
|
||
except ZeroDivisionError:
|
||
self.roe = None
|
||
|
||
def eval_actual_asset_liability_ratio(self, *args):
|
||
"""
|
||
实际资产负债率(%)
|
||
公式: 实际资产负债率 = (负债合计-未到期责任准备金-担保赔偿准备金) / 资产总额
|
||
args[0]: 负债合计
|
||
args[1]: 未到期责任准备金
|
||
args[2]: 担保赔偿准备金
|
||
args[3]: 资产总额
|
||
"""
|
||
try:
|
||
value = ((args[0]-args[1]-args[2]) / args[3]) * 100
|
||
value = round(value, 2)
|
||
self.actual_asset_liability_ratio = value
|
||
except TypeError:
|
||
self.actual_asset_liability_ratio = None
|
||
except ZeroDivisionError:
|
||
self.actual_asset_liability_ratio = None
|
||
|
||
def eval_capital_adequacy_ratio(self, *args):
|
||
"""
|
||
资本充足率(%)
|
||
公式: 资本充足率 = 净资产 / 风险加权资产
|
||
args[0]: 净资产
|
||
args[1]: 风险加权资产
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.capital_adequacy_ratio = value
|
||
except TypeError:
|
||
self.capital_adequacy_ratio = None
|
||
except ZeroDivisionError:
|
||
self.capital_adequacy_ratio = None
|
||
|
||
def eval_paid_capital(self, *args):
|
||
"""
|
||
实收资本(亿元)
|
||
公式: 即实缴资本
|
||
args[0]: 实缴资本
|
||
"""
|
||
try:
|
||
value = args[0]/10000
|
||
value = round(value, 2)
|
||
self.paid_capital = value
|
||
except TypeError:
|
||
self.paid_capital = None
|
||
except ZeroDivisionError:
|
||
self.paid_capital = None
|
||
|
||
def eval_guarantee_business_income(self, *args):
|
||
"""
|
||
担保业务收入(万元)
|
||
公式: 即当期担保业务收入
|
||
args[0]: 担保业务收入
|
||
"""
|
||
try:
|
||
value = args[0]
|
||
value = round(value, 2)
|
||
self.guarantee_business_income = value
|
||
except TypeError:
|
||
self.guarantee_business_income = None
|
||
except ZeroDivisionError:
|
||
self.guarantee_business_income = None
|
||
|
||
def eval_cumulative_guarantee_compensation_rate(self, *args):
|
||
"""
|
||
近三年累计担保代偿率(%)
|
||
公式: 近三年累计担保代偿率 = 近三年累计代偿金额 / 近三年累计解除担保责任金额
|
||
args[0]: 近三年累计代偿金额
|
||
args[1]: 近三年累计解除担保责任金额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.cumulative_guarantee_compensation_rate = value
|
||
except TypeError:
|
||
self.cumulative_guarantee_compensation_rate = None
|
||
except ZeroDivisionError:
|
||
self.cumulative_guarantee_compensation_rate = None
|
||
|
||
def eval_cumulative_compensation_recovery_rate(self, *args):
|
||
"""
|
||
近三年累计代偿回收率(%)
|
||
公式: 近三年累计代偿回收率 = 近三年累计代偿回收金额 / 近三年累计代偿金额
|
||
args[0]: 近三年累计代偿回收金额
|
||
args[1]: 近三年累计代偿金额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.cumulative_compensation_recovery_rate = value
|
||
except TypeError:
|
||
self.cumulative_compensation_recovery_rate = None
|
||
except ZeroDivisionError:
|
||
self.cumulative_compensation_recovery_rate = None
|
||
|
||
def eval_risk_coverage_ratio(self, *args):
|
||
"""
|
||
风险覆盖率(%)
|
||
公式: 风险覆盖率 = 担保赔偿准备金 / 近三年累计代偿金额
|
||
args[0]: 担保赔偿准备金
|
||
args[1]: 近三年累计代偿金额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.risk_coverage_ratio = value
|
||
except TypeError:
|
||
self.risk_coverage_ratio = None
|
||
except ZeroDivisionError:
|
||
self.risk_coverage_ratio = None
|
||
|
||
def eval_cash_asset_compensation_rate(self, *args):
|
||
"""
|
||
现金类资产代偿保障率(%)
|
||
公式: 现金类资产代偿保障率 = (货币资金+可供出售金融资产+存出保证金-存入保证金) / 融资担保责任余额
|
||
args[0]: 货币资金
|
||
args[1]: 可供出售金融资产
|
||
args[2]: 存出保证金
|
||
args[3]: 存入保证金
|
||
args[4]: 融资担保责任余额
|
||
"""
|
||
try:
|
||
value = ((args[0]+args[1]+args[2]-args[3]) / args[4]) * 100
|
||
value = round(value, 2)
|
||
self.cash_asset_compensation_rate = value
|
||
except TypeError:
|
||
self.cash_asset_compensation_rate = None
|
||
except ZeroDivisionError:
|
||
self.cash_asset_compensation_rate = None
|
||
|
||
def eval_margin_ratio(self, *args):
|
||
"""
|
||
保证金比率(%)
|
||
公式: 保证金比率 = 存入保证金 / 存出保证金
|
||
args[0]: 存入保证金
|
||
args[1]: 存出保证金
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.margin_ratio = value
|
||
except TypeError:
|
||
self.margin_ratio = None
|
||
except ZeroDivisionError:
|
||
self.margin_ratio = None
|
||
|
||
def eval_proportion_investment_business_income(self, *args):
|
||
"""
|
||
投资业务收入占比(%)
|
||
公式: 投资业务收入占比 = 投资业务收入 / 营业收入
|
||
args[0]: 投资业务收入
|
||
args[1]: 营业收入
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.proportion_investment_business_income = value
|
||
except TypeError:
|
||
self.proportion_investment_business_income = None
|
||
except ZeroDivisionError:
|
||
self.proportion_investment_business_income = None
|
||
|
||
def eval_investment_income_growth_rate(self, *args):
|
||
"""
|
||
投资收益增长率(%)
|
||
公式: 投资收益增长率 = 期末投资收益 / 期初投资收益
|
||
args[0]: 期末投资收益
|
||
args[1]: 期初投资收益
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.investment_income_growth_rate = value
|
||
except TypeError:
|
||
self.investment_income_growth_rate = None
|
||
except ZeroDivisionError:
|
||
self.investment_income_growth_rate = None
|
||
|
||
def eval_customer_concentration(self, *args):
|
||
"""
|
||
客户集中度(%)
|
||
公式: 客户集中度 = 前五大被担保企业融资担保责任余额 / 融资担保责任余额
|
||
args[0]: 前五大被担保企业融资担保责任余额
|
||
args[1]: 融资担保责任余额
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.customer_concentration = value
|
||
except TypeError:
|
||
self.customer_concentration = None
|
||
except ZeroDivisionError:
|
||
self.customer_concentration = None
|
||
|
||
def eval_proportion_income_guarantee_business(self, *args):
|
||
"""
|
||
担保业务收入占比(%)
|
||
公式: 担保业务收入占比 = 当期担保业务收入 / 营业收入
|
||
args[0]: 当期担保业务收入
|
||
args[1]: 营业收入
|
||
"""
|
||
try:
|
||
value = (args[0] / args[1]) * 100
|
||
value = round(value, 2)
|
||
self.proportion_income_guarantee_business = value
|
||
except TypeError:
|
||
self.proportion_income_guarantee_business = None
|
||
except ZeroDivisionError:
|
||
self.proportion_income_guarantee_business = None
|
||
|
||
def eval_one_proportion_class_assets(self, *args):
|
||
"""
|
||
I类资产占比(%)
|
||
公式: I类资产占比 = I类资产 /(资产总额-应收代偿款)
|
||
args[0]: I类资产
|
||
args[1]: 资产总额
|
||
args[2]: 应收代偿款
|
||
"""
|
||
try:
|
||
value = (args[0] / (args[1]-args[2])) * 100
|
||
value = round(value, 2)
|
||
self.one_proportion_class_assets = value
|
||
except TypeError:
|
||
self.one_proportion_class_assets = None
|
||
except ZeroDivisionError:
|
||
self.one_proportion_class_assets = None
|
||
|
||
def eval_two_proportion_class_assets(self, *args):
|
||
"""
|
||
II类资产占比(%)
|
||
公式: II类资产占比 = II类资产 /(资产总额-应收代偿款)
|
||
args[0]: II类资产
|
||
args[1]: 资产总额
|
||
args[2]: 应收代偿款
|
||
"""
|
||
try:
|
||
value = (args[0] / (args[1]-args[2])) * 100
|
||
value = round(value, 2)
|
||
self.two_proportion_class_assets = value
|
||
except TypeError:
|
||
self.two_proportion_class_assets = None
|
||
except ZeroDivisionError:
|
||
self.two_proportion_class_assets = None
|
||
|
||
def eval_three_proportion_class_assets(self, *args):
|
||
"""
|
||
III类资产占比(%)
|
||
公式: III类资产占比 = III类资产 /(资产总额-应收代偿款)
|
||
args[0]: III类资产
|
||
args[1]: 资产总额
|
||
args[2]: 应收代偿款
|
||
"""
|
||
try:
|
||
value = (args[0] / (args[1]-args[2])) * 100
|
||
value = round(value, 2)
|
||
self.three_proportion_class_assets = value
|
||
except TypeError:
|
||
self.three_proportion_class_assets = None
|
||
except ZeroDivisionError:
|
||
self.three_proportion_class_assets = None |