Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
alpha-mind
Commits
c9860107
Commit
c9860107
authored
May 04, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed some typo
parent
69471996
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
strategy.py
alphamind/strategy/strategy.py
+5
-3
No files found.
alphamind/strategy/strategy.py
View file @
c9860107
...
...
@@ -9,6 +9,7 @@ import copy
import
numpy
as
np
import
pandas
as
pd
from
PyFin.api
import
makeSchedule
from
PyFin.api
import
advanceDateByCalendar
from
alphamind.utilities
import
map_freq
from
alphamind.utilities
import
alpha_logger
from
alphamind.model.composer
import
train_model
...
...
@@ -44,6 +45,7 @@ class RunningSetting(object):
self
.
dates
=
[
d
.
strftime
(
'
%
Y-
%
m-
%
d'
)
for
d
in
self
.
dates
]
self
.
benchmark
=
benchmark
self
.
weights_bandwidth
=
weights_bandwidth
self
.
freq
=
freq
self
.
horizon
=
map_freq
(
freq
)
self
.
executor
=
NaiveExecutor
()
self
.
industry_cat
=
industry_cat
...
...
@@ -72,7 +74,7 @@ class Strategy(object):
dates
=
self
.
running_setting
.
dates
)
alpha_logger
.
info
(
"alpha factor data loading finished ..."
)
total_industry
=
self
.
engine
.
fetch_industry_matrix_range
(
universe
,
total_industry
=
self
.
engine
.
fetch_industry_matrix_range
(
self
.
running_setting
.
universe
,
dates
=
self
.
running_setting
.
dates
,
category
=
self
.
running_setting
.
industry_cat
,
level
=
self
.
running_setting
.
industry_level
)
...
...
@@ -83,7 +85,7 @@ class Strategy(object):
alpha_logger
.
info
(
"benchmark data loading finished ..."
)
total_risk_cov
,
total_risk_exposure
=
self
.
engine
.
fetch_risk_model_range
(
universe
,
self
.
running_setting
.
universe
,
dates
=
self
.
running_setting
.
dates
,
risk_model
=
self
.
data_meta
.
risk_model
)
...
...
@@ -187,7 +189,7 @@ class Strategy(object):
horizon
=
self
.
running_setting
.
horizon
,
offset
=
1
)
.
set_index
(
'trade_date'
)
ret_df
[
'benchmark_returns'
]
=
index_return
[
'dx'
]
ret_df
.
loc
[
advanceDateByCalendar
(
'china.sse'
,
ret_df
.
index
[
-
1
],
freq
)]
=
0.
ret_df
.
loc
[
advanceDateByCalendar
(
'china.sse'
,
ret_df
.
index
[
-
1
],
self
.
running_setting
.
freq
)]
=
0.
ret_df
=
ret_df
.
shift
(
1
)
ret_df
.
iloc
[
0
]
=
0.
ret_df
[
'excess_return'
]
=
ret_df
[
'returns'
]
-
ret_df
[
'benchmark_returns'
]
*
ret_df
[
'leverage'
]
...
...
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