Commit 30bd88a4 authored by 赵杰's avatar 赵杰

年化除0,画图标签位置

parent c7e41142
......@@ -86,7 +86,10 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
# 夏普比率
sim = simple_return(resample_df["cum_return_ratio"])
exc = excess_return(sim, BANK_RATE, n_freq)
sharpe = sharpe_ratio(exc, sim, n_freq)
try:
sharpe = sharpe_ratio(exc, sim, n_freq)
except ZeroDivisionError:
sharpe = 0.0
folio_report_data["sharpe"] = float(sharpe)
# 期末资产
......@@ -509,7 +512,10 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
# 夏普比率
sim = simple_return(fund_nav_df["cum_return_ratio"])
exc = excess_return(sim, BANK_RATE, n_freq)
sharpe = sharpe_ratio(exc, sim, n_freq)
try:
sharpe = sharpe_ratio(exc, sim, n_freq)
except ZeroDivisionError:
sharpe = 0.0
result["sharpe"] = float(sharpe)
return result
......
......@@ -74,9 +74,9 @@ def draw_month_return_chart(xlabels, product_list, cumulative):
ax = ax1.bar(loc, product_list[i]['data'], width, bottom=bottom, alpha=0.8)
for a, b in zip(range(len(xlabels)), product_list[0]['data']):
if b > 0:
ax1.text(a, b+0.1, '%.2f万' % b, ha='center', va='bottom', fontsize=fontsize)
ax1.text(a, b*1.08, '%.2f万' % b, ha='center', va='bottom', fontsize=fontsize)
elif b < 0:
ax1.text(a, b-0.1, '%.2f万' % b, ha='center', va='top', fontsize=fontsize)
ax1.text(a, b*0.92, '%.2f万' % b, ha='center', va='top', fontsize=fontsize)
prod_legend.append(ax[0])
ax1.legend(prod_legend, [prod['name'] for prod in product_list], loc='upper left', fontsize=fontsize)
......@@ -84,7 +84,7 @@ def draw_month_return_chart(xlabels, product_list, cumulative):
ax2.plot(loc, cumulative['data'], color='#D40000', marker='.', linewidth=3, label=cumulative['name'])
# 添加数字标签
for a, b in zip(range(len(xlabels)), cumulative['data']):
ax2.text(a+0.1, b + 0.1, '%.2f' % b + '%', ha='center', va='bottom', fontsize=fontsize, color='#D40000')
ax2.text(a*1.05, b*1.05, '%.2f' % b + '%', ha='center', va='bottom', fontsize=fontsize, color='#D40000')
ax2.legend(loc='upper center', fontsize=fontsize)
# plt.show()
......@@ -148,7 +148,7 @@ def draw_contribution_chart(xlabels, product_list, cumulative):
ax2.plot(loc, cumulative['data'], color='#B40A15', marker='', linewidth=3, label=cumulative['name'])
# 添加数字标签
for a, b in zip(range(len(xlabels)), cumulative['data']):
ax2.text(a + 0.2, b + 0.1, '%.2f' % b + '%', ha='center', va='bottom', fontsize=fontsize, color='#B40A15')
ax2.text(a*1.1, b *1.05, '%.2f' % b + '%', ha='center', va='bottom', fontsize=fontsize, color='#B40A15')
ax2.legend(loc='upper left', fontsize=fontsize)
imgdata = BytesIO()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment