Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
fund_report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
fund_report
Commits
30bd88a4
Commit
30bd88a4
authored
Dec 18, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
年化除0,画图标签位置
parent
c7e41142
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
result_service_v2.py
app/service/result_service_v2.py
+8
-2
draw.py
app/utils/draw.py
+4
-4
No files found.
app/service/result_service_v2.py
View file @
30bd88a4
...
...
@@ -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
...
...
app/utils/draw.py
View file @
30bd88a4
...
...
@@ -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
,
'
%.2
f万'
%
b
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
fontsize
)
ax1
.
text
(
a
,
b
*
1.08
,
'
%.2
f万'
%
b
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
fontsize
)
elif
b
<
0
:
ax1
.
text
(
a
,
b
-
0.1
,
'
%.2
f万'
%
b
,
ha
=
'center'
,
va
=
'top'
,
fontsize
=
fontsize
)
ax1
.
text
(
a
,
b
*
0.92
,
'
%.2
f万'
%
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
,
'
%.2
f'
%
b
+
'
%
'
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
fontsize
,
color
=
'#D40000'
)
ax2
.
text
(
a
*
1.05
,
b
*
1.05
,
'
%.2
f'
%
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
,
'
%.2
f'
%
b
+
'
%
'
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
fontsize
,
color
=
'#B40A15'
)
ax2
.
text
(
a
*
1.1
,
b
*
1.05
,
'
%.2
f'
%
b
+
'
%
'
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
fontsize
,
color
=
'#B40A15'
)
ax2
.
legend
(
loc
=
'upper left'
,
fontsize
=
fontsize
)
imgdata
=
BytesIO
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment