Merge branch 'PS' into 'master'

update ESG模型异常捕获

See merge request root/tfse_rating!41
This commit is contained in:
王思川 2022-03-08 05:43:33 +00:00
commit 93005df84e
3 changed files with 87 additions and 66 deletions

View File

@ -85,6 +85,7 @@ def calculation_01(param):
factor_04 = -0.02 < ((year_end/year_begin)**(1/2)-1) <= 0.01 and year_begin >= year_middle >= year_end
factor_05 = -0.01 < ((year_end/year_begin)**(1/2)-1) <= 0 and year_begin >= year_middle >= year_end
try:
if factor_01:
score = 15
elif factor_02:
@ -97,6 +98,8 @@ def calculation_01(param):
score = 3
else:
score = 0
except ZeroDivisionError:
score = 0
return score
@ -144,6 +147,7 @@ def calculation_02(param):
factor_03 = -0.02 < ((year_end/year_begin)**(1/2)-1) <= -0.01 and year_begin >= year_middle >= year_end
factor_04 = -0.01 < ((year_end/year_begin)**(1/2)-1) <= 0 and year_begin >= year_middle >= year_end
try:
if factor_01:
score = 11
elif factor_02:
@ -154,6 +158,8 @@ def calculation_02(param):
score = 2
else:
score = 0
except ZeroDivisionError:
score = 0
return score
@ -176,12 +182,15 @@ def calculation_03(param):
factor_01 = ((year_end/year_begin)**(1/2)-1) <= -0.01 and year_begin >= year_middle >= year_end
factor_02 = -0.01 < ((year_end/year_begin)**(1/2)-1) <= 0 and year_begin >= year_middle >= year_end
try:
if factor_01:
score = 6
elif factor_02:
score = 3
else:
score = 0
except ZeroDivisionError:
score = 0
return score
@ -196,7 +205,7 @@ def calculation_04(param):
"""
# Parameter
three_year_data = sorted(param['环境问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
try:
income = param['公司收入'][three_year_data[2]['年份']]
green_income = three_year_data[2]['公司当年绿色业务收入(万元)——包括不限于清洁能源、清洁交通、绿色建筑、清洁技术等']
prop = round(green_income / income, 2)
@ -211,6 +220,8 @@ def calculation_04(param):
score = 1
else:
score = 0
except ZeroDivisionError:
score = 0
return score
@ -358,3 +369,4 @@ def calculation_12(param):
score = 0
return score

View File

@ -114,7 +114,7 @@ def calculation_05(param):
Returns:
score int 得分
"""
answer = param['治理问卷']['其他类型问卷'][2] / param['治理问卷']['其他类型问卷'][3] * 100
answer = float(param['治理问卷']['其他类型问卷'][2]) / float(param['治理问卷']['其他类型问卷'][3]) * 100
if answer < 35:
score = 4
@ -173,6 +173,7 @@ def calculation_08(param):
# Parameter
three_year_data = sorted(param['治理问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
try:
year_begin = three_year_data[0]['公司净利润(万元)'] / three_year_data[0]['公司净资产(万元)'] * 100
year_middle = three_year_data[1]['公司净利润(万元)'] / three_year_data[1]['公司净资产(万元)'] * 100
year_end = three_year_data[2]['公司净利润(万元)'] / three_year_data[2]['公司净资产(万元)'] * 100
@ -187,6 +188,8 @@ def calculation_08(param):
score = 2
else:
score = 0
except ZeroDivisionError:
score = 0
return score

View File

@ -55,6 +55,7 @@ def calculation_01(param):
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
try:
year_begin = round(three_year_data[0]['当年离职人数'] / three_year_data[0]['员工总数(年底)'], 2)
year_middle = round(three_year_data[1]['当年离职人数'] / three_year_data[1]['员工总数(年底)'], 2)
year_end = round(three_year_data[2]['当年离职人数'] / three_year_data[2]['员工总数(年底)'], 2)
@ -68,6 +69,8 @@ def calculation_01(param):
score = 2
else:
score = 0
except ZeroDivisionError:
score = 0
return score
@ -83,6 +86,7 @@ def calculation_02(param):
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
try:
year_begin = three_year_data[0]['人均薪酬水平(元/月)']
year_end = three_year_data[2]['人均薪酬水平(元/月)']
@ -92,6 +96,8 @@ def calculation_02(param):
score = 2
else:
score = 0
except ZeroDivisionError:
score = 0
return score