Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
R
robo-dividend
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
wenwen.tang
robo-dividend
Commits
bae42e5b
Commit
bae42e5b
authored
Jan 06, 2023
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6258
parent
66653eb0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
config.yml
config.yml
+2
-2
crisis_signal.py
rebalance/signals/crisis_signal.py
+9
-3
No files found.
config.yml
View file @
bae42e5b
...
...
@@ -139,12 +139,12 @@ rebalance: # 再平衡模块
signals
:
# 信号相关
crisis-signal
:
# 危机信号相关
exp-years
:
3
# 预警期时长,单位自然年,点到点计算
#
exp-init: 2008-01-01 # 设置起始危机预警开始时间,如果关闭初始预警起,注释到这一条即可
exp-init
:
2008-01-01
# 设置起始危机预警开始时间,如果关闭初始预警起,注释到这一条即可
inversion-years
:
1
# 利率倒挂计算时长,单位自然年,点到点取值
inversion-threshold
:
0.3
# 利率倒挂触发阀值
crisis-1
:
# 危机1相关
mean-count
:
850
# spx去多少交易日计算平均值
consecut-days
:
5
# spx连续多少
年
跌破平均值则触发
consecut-days
:
5
# spx连续多少
天
跌破平均值则触发
crisis-2
:
# 危机2相关
negative-growth
:
1
# 实际利率负增长时长,单位年,点到点取值
fed-months
:
3
# fed 滚动月份,点到点取值
...
...
rebalance/signals/crisis_signal.py
View file @
bae42e5b
...
...
@@ -77,9 +77,15 @@ class CrisisOneSignal(CrisisSignal, BaseRebalanceSignal):
if
exp_date
:
crisis_one
=
rrs
.
get_first_after
(
type
=
SignalType
.
CRISIS_ONE
,
risk
=
risk
,
min_date
=
exp_date
)
if
not
crisis_one
:
spx
=
self
.
_navs
.
get_last_index_close
(
max_date
=
day
,
ticker
=
'SPX Index'
,
count
=
self
.
mean_count
)
spx_ma850
=
pd
.
DataFrame
(
spx
)
.
close
.
mean
()
return
len
([
x
for
x
in
spx
[
0
:
5
]
if
x
[
'close'
]
>
spx_ma850
])
==
0
spx
=
self
.
_navs
.
get_last_index_close
(
max_date
=
day
,
ticker
=
'SPX Index'
,
count
=
self
.
mean_count
+
self
.
consecut_days
)
spx
=
pd
.
DataFrame
(
spx
)
spx
.
sort_values
(
by
=
'date'
,
inplace
=
True
,
ascending
=
False
)
spx
.
reset_index
(
drop
=
True
,
inplace
=
True
)
for
offset
in
range
(
self
.
consecut_days
):
spx
.
loc
[
0
+
offset
,
'mean'
]
=
spx
.
loc
[
0
+
offset
:
850
+
offset
]
.
close
.
mean
()
spx
.
dropna
(
inplace
=
True
)
spx
[
'diff'
]
=
spx
[
'close'
]
-
spx
[
'mean'
]
return
spx
[
spx
[
'diff'
]
>=
0
]
.
empty
return
False
...
...
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