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
3bf550ac
Commit
3bf550ac
authored
Nov 21, 2020
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FEATURE: update examples
parent
fdb2e572
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
126 deletions
+195
-126
1. debug examples.py
notebooks/1. debug examples.py
+62
-0
Example 1 - Factor IC analysis.ipynb
notebooks/Example 1 - Factor IC analysis.ipynb
+71
-85
Example 10 - Quadratic Optimizer Comparison with CVXOPT.ipynb
...ple 10 - Quadratic Optimizer Comparison with CVXOPT.ipynb
+12
-12
Example 11 - Long Short Strategy Model.ipynb
notebooks/Example 11 - Long Short Strategy Model.ipynb
+50
-29
No files found.
notebooks/1. debug examples.py
0 → 100644
View file @
3bf550ac
"""
Created on 2020-11-21
@author: cheng.li
"""
import
os
import
datetime
as
dt
import
numpy
as
np
import
pandas
as
pd
from
PyFin.api
import
*
from
alphamind.api
import
*
start_date
=
'2020-01-01'
end_date
=
'2020-02-21'
freq
=
'10b'
horizon
=
map_freq
(
freq
)
neutralized_risk
=
risk_styles
+
industry_styles
universe
=
Universe
(
'hs300'
)
data_source
=
"mysql+mysqldb://reader:Reader#2020@121.37.138.1:13317/vision?charset=utf8"
offset
=
1
method
=
'ls'
industry_name
=
'sw'
industry_level
=
1
risk_model
=
'short'
executor
=
NaiveExecutor
()
ref_dates
=
makeSchedule
(
start_date
,
end_date
,
freq
,
'china.sse'
)
engine
=
SqlEngine
(
data_source
)
alpha_factors
=
{
'f01'
:
LAST
(
'EMA5D'
),
'f02'
:
LAST
(
'EMV6D'
)
}
weights
=
dict
(
f01
=
1.0
,
f02
=
1.0
,
)
alpha_model
=
ConstLinearModel
(
features
=
alpha_factors
,
weights
=
weights
)
def
predict_worker
(
params
):
data_meta
=
DataMeta
(
freq
=
freq
,
universe
=
universe
,
batch
=
1
,
neutralized_risk
=
neutralized_risk
,
risk_model
=
'short'
,
pre_process
=
[
winsorize_normal
,
standardize
],
post_process
=
[
standardize
],
warm_start
=
0
,
data_source
=
data_source
)
ref_date
,
model
=
params
er
,
_
=
predict_by_model
(
ref_date
,
model
,
data_meta
)
return
er
predicts
=
[
predict_worker
((
d
.
strftime
(
'
%
Y-
%
m-
%
d'
),
alpha_model
))
for
d
in
ref_dates
]
notebooks/Example 1 - Factor IC analysis.ipynb
View file @
3bf550ac
This diff is collapsed.
Click to expand it.
notebooks/Example 10 - Quadratic Optimizer Comparison with CVXOPT.ipynb
View file @
3bf550ac
...
...
@@ -87,7 +87,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Wall time:
1.98
ms\n"
"Wall time:
3.22
ms\n"
]
}
],
...
...
@@ -134,17 +134,17 @@
" warm start: on, polish: on, time_limit: off\n",
"\n",
"iter objective pri res dua res rho time\n",
" 1 -7.8878e+03 4.61e+00 6.68e+04 1.00e-01 1.
10
e-03s\n",
" 125 -2.4830e+02 3.58e-07 2.76e-05 5.82e-01
3.80
e-03s\n",
" 1 -7.8878e+03 4.61e+00 6.68e+04 1.00e-01 1.
28
e-03s\n",
" 125 -2.4830e+02 3.58e-07 2.76e-05 5.82e-01
5.35
e-03s\n",
"\n",
"status: solved\n",
"solution polish: unsuccessful\n",
"number of iterations: 125\n",
"optimal objective: -248.2989\n",
"run time:
4.54
e-03s\n",
"run time:
7.43
e-03s\n",
"optimal rho estimate: 1.87e+00\n",
"\n",
"Wall time: 4
8
ms\n"
"Wall time: 4
3
ms\n"
]
},
{
...
...
@@ -211,9 +211,9 @@
"12 -2.483e+02 -2.483e+02 +3e-07 5e-13 2e-15 1e-10 8e-10 0.9775 1e-04 1 1 1 | 0 0\n",
"\n",
"OPTIMAL (within feastol=5.3e-13, reltol=1.3e-09, abstol=3.2e-07).\n",
"Runtime: 0.013
942
seconds.\n",
"Runtime: 0.013
621
seconds.\n",
"\n",
"Wall time: 5
1.3
ms\n"
"Wall time: 5
2
ms\n"
]
},
{
...
...
@@ -277,7 +277,7 @@
"12: -2.4829e+02 -2.4831e+02 1e-02 2e-16 4e-16\n",
"13: -2.4830e+02 -2.4830e+02 1e-04 2e-16 1e-15\n",
"Optimal solution found.\n",
"Wall time:
108
ms\n"
"Wall time:
80.5
ms\n"
]
}
],
...
...
@@ -315,7 +315,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Wall time: 2
4
ms\n"
"Wall time: 2
0.6
ms\n"
]
},
{
...
...
@@ -465,9 +465,9 @@
"output_type": "stream",
"text": [
"Scale(n) cvxpy cvxopt ipopt\n",
"100 0.052
7 0.0660 0.0142
\n",
"200 0.0
710 0.3040 0.0601
\n",
"300 0.
1614 0.0690 0.0155
\n"
"100 0.052
0 0.0440 0.0070
\n",
"200 0.0
413 0.0520 0.0120
\n",
"300 0.
0420 0.0630 0.0170
\n"
]
}
],
...
...
notebooks/Example 11 - Long Short Strategy Model.ipynb
View file @
3bf550ac
This diff is collapsed.
Click to expand it.
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