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
ed500fb3
Commit
ed500fb3
authored
Dec 04, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新组合结果
parent
6c75e21f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+3
-3
draw.py
app/utils/draw.py
+1
-1
jinjia2html.py
app/utils/jinjia2html.py
+7
-1
No files found.
app/service/portfolio_diagnose.py
View file @
ed500fb3
...
@@ -172,7 +172,7 @@ def get_index_daily(index_id):
...
@@ -172,7 +172,7 @@ def get_index_daily(index_id):
cur
=
tamp_product_session
.
execute
(
sql
)
cur
=
tamp_product_session
.
execute
(
sql
)
data
=
cur
.
fetchall
()
data
=
cur
.
fetchall
()
df
=
pd
.
DataFrame
(
list
(
data
),
columns
=
[
'ts_code'
,
'trade_
cod
e'
,
' close'
])
df
=
pd
.
DataFrame
(
list
(
data
),
columns
=
[
'ts_code'
,
'trade_
dat
e'
,
' close'
])
df
.
rename
({
'ts_code'
:
'fund_id'
,
'trade_date'
:
'end_date'
,
'close'
:
'adj_nav'
},
axis
=
1
,
inplace
=
True
)
df
.
rename
({
'ts_code'
:
'fund_id'
,
'trade_date'
:
'end_date'
,
'close'
:
'adj_nav'
},
axis
=
1
,
inplace
=
True
)
df
[
'end_date'
]
=
pd
.
to_datetime
(
df
[
'end_date'
])
df
[
'end_date'
]
=
pd
.
to_datetime
(
df
[
'end_date'
])
df
.
set_index
(
'end_date'
,
drop
=
True
,
inplace
=
True
)
df
.
set_index
(
'end_date'
,
drop
=
True
,
inplace
=
True
)
...
@@ -713,8 +713,8 @@ class PortfolioDiagnose(object):
...
@@ -713,8 +713,8 @@ class PortfolioDiagnose(object):
propose_fund_return_limit_data
[
"new_return"
]
=
(
propose_fund_return_limit_data
[
"return"
]
-
start_return
)
/
(
1
+
start_return
)
propose_fund_return_limit_data
[
"new_return"
]
=
(
propose_fund_return_limit_data
[
"return"
]
-
start_return
)
/
(
1
+
start_return
)
# 指数收益
# 指数收益
index_return
=
index_return
[
index_return
.
index
>=
group_order_start_date
]
index_return
=
index_return
[
index_return
.
index
>=
group_order_start_date
]
start_index_return
=
index_return
[
self
.
index_id
]
.
values
[
0
]
start_index_return
=
index_return
[
" close"
]
.
values
[
0
]
index_return
[
"new_index_return"
]
=
(
index_return
[
self
.
index_id
]
-
start_index_return
)
/
(
1
+
start_index_return
)
index_return
[
"new_index_return"
]
=
(
index_return
[
" close"
]
-
start_index_return
)
/
(
1
+
start_index_return
)
# 新组合区间年化收益率
# 新组合区间年化收益率
freq_max
=
group_order_df
[
"freq"
]
.
max
()
freq_max
=
group_order_df
[
"freq"
]
.
max
()
...
...
app/utils/draw.py
View file @
ed500fb3
...
@@ -105,7 +105,7 @@ def draw_contribution_chart(xlabels, product_list, cumulative):
...
@@ -105,7 +105,7 @@ def draw_contribution_chart(xlabels, product_list, cumulative):
fontsize
=
22
fontsize
=
22
# 初始化
# 初始化
fig
=
plt
.
figure
(
figsize
=
figsize
)
fig
=
plt
.
figure
(
figsize
=
figsize
)
ax1
=
fig
.
add_subplot
()
ax1
=
fig
.
add_subplot
(
111
)
ax2
=
ax1
.
twiny
()
ax2
=
ax1
.
twiny
()
max_x_count
=
max
([
x
[
'data'
]
.
size
for
x
in
product_list
])
max_x_count
=
max
([
x
[
'data'
]
.
size
for
x
in
product_list
])
loc
=
np
.
arange
(
max_x_count
)
# the x locations for the groups
loc
=
np
.
arange
(
max_x_count
)
# the x locations for the groups
...
...
app/utils/jinjia2html.py
View file @
ed500fb3
...
@@ -34,9 +34,11 @@ class DataIntegrate:
...
@@ -34,9 +34,11 @@ class DataIntegrate:
self
.
propose_fund
()
self
.
propose_fund
()
# 目标与业绩
# 目标与业绩
self
.
objectives_performance
(
self
.
group_result
)
self
.
objectives_performance
(
self
.
group_result
)
self
.
get_transfer_suggestions
()
# 渲染模版
# 渲染模版
self
.
render_data
()
self
.
render_data
()
def
get_summarize
(
self
):
def
get_summarize
(
self
):
"""几月综述部分."""
"""几月综述部分."""
self
.
total_cost
=
self
.
df
[
"total_cost"
]
/
10000
self
.
total_cost
=
self
.
df
[
"total_cost"
]
/
10000
...
@@ -73,6 +75,8 @@ class DataIntegrate:
...
@@ -73,6 +75,8 @@ class DataIntegrate:
})
})
# 调仓建议
# 调仓建议
def
get_transfer_suggestions
(
self
):
self
.
suggestions_result
,
self
.
suggestions_result_asset
=
portfolio_diagnose
.
new_evaluation
(
"default"
,
self
.
d
,
self
.
user_customer
)
# 收益比较
# 收益比较
...
@@ -155,7 +159,9 @@ class DataIntegrate:
...
@@ -155,7 +159,9 @@ class DataIntegrate:
'contribution_decomposition'
:
self
.
contribution_decomposition
,
'contribution_decomposition'
:
self
.
contribution_decomposition
,
'single_fund_data_list'
:
self
.
single_fund_data_list
,
'single_fund_data_list'
:
self
.
single_fund_data_list
,
'old_correlation'
:
self
.
old_correlation
,
'old_correlation'
:
self
.
old_correlation
,
'propose_fund_data_list'
:
self
.
propose_fund_data_list
'propose_fund_data_list'
:
self
.
propose_fund_data_list
,
'suggestions_result'
:
self
.
suggestions_result
,
'suggestions_result_asset'
:
self
.
suggestions_result_asset
}
}
# 开始渲染html模板
# 开始渲染html模板
env
=
Environment
(
loader
=
PackageLoader
(
'app'
,
'templates'
))
# 创建一个包加载器对象
env
=
Environment
(
loader
=
PackageLoader
(
'app'
,
'templates'
))
# 创建一个包加载器对象
...
...
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