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
adbb221f
Commit
adbb221f
authored
Jan 10, 2023
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加危机1信号判断逻辑
parent
2021b48e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
12 deletions
+39
-12
config.yml
config.yml
+1
-0
right_side.py
rebalance/signals/right_side.py
+38
-12
No files found.
config.yml
View file @
adbb221f
...
...
@@ -42,6 +42,7 @@ py-jftech:
crisis_one
:
rebalance.signals.crisis_signal.LastRateCrisisOneSignal
date-curve
:
rebalance.drift_solver.DateCurve
curve-drift
:
rebalance.signals.curve_drift.CurveDrift
market-right
:
rebalance.signals.right_side.MarketRight
email
:
server
:
smtphz.qiye.163.com
user
:
jft-ra@thizgroup.com
...
...
rebalance/signals/right_side.py
View file @
adbb221f
...
...
@@ -36,10 +36,18 @@ class MarketRight(BaseRebalanceSignal):
def
cvar_min_volume
(
self
):
return
self
.
_config
[
'cvar-min-volume'
]
@
property
def
include_last_type
(
self
):
return
[
SignalType
.
CRISIS_ONE
,
SignalType
.
CRISIS_TWO
,
SignalType
.
INIT
,
SignalType
.
MARKET_RIGHT
]
def
is_trigger
(
self
,
day
,
risk
:
PortfoliosRisk
)
->
bool
:
last_re
=
rrs
.
get_last_one
(
risk
=
risk
,
max_date
=
day
,
effective
=
True
)
if
last_re
is
not
None
and
SignalType
(
last_re
[
'type'
])
in
[
SignalType
.
CRISIS_ONE
,
SignalType
.
CRISIS_TWO
,
SignalType
.
MARKET_RIGHT
,
SignalType
.
INIT
]:
if
last_re
is
not
None
and
SignalType
(
last_re
[
'type'
])
in
self
.
include_last_type
:
return
False
spx
=
self
.
load_spx_close_rtns
(
day
)
...
...
@@ -51,16 +59,6 @@ class MarketRight(BaseRebalanceSignal):
cvar
=
self
.
get_cvar
(
day
,
risk
,
spx
=
spx
)
return
cvar
is
not
None
and
spx
[
-
1
][
'rtn'
]
<
cvar
def
is_fall
(
self
,
day
,
risk
:
PortfoliosRisk
,
spx
=
None
):
if
spx
is
None
:
spx
=
self
.
load_spx_close_rtns
(
day
)
start_date
=
self
.
find_cvar_start_date
(
day
,
risk
,
spx
=
spx
)
if
start_date
:
spx
=
pd
.
DataFrame
(
spx
)
spx
=
spx
[(
spx
.
date
>=
start_date
)
&
(
spx
.
date
<=
day
)]
return
spx
.
iloc
[
-
1
]
.
close
<
spx
.
iloc
[
0
]
.
close
return
False
def
get_cvar
(
self
,
day
,
risk
:
PortfoliosRisk
,
spx
=
None
):
if
spx
is
None
:
spx
=
self
.
load_spx_close_rtns
(
day
)
...
...
@@ -97,3 +95,31 @@ class MarketRight(BaseRebalanceSignal):
spx
.
dropna
(
inplace
=
True
)
spx
=
spx
[[
'date'
,
'close'
,
'rtn'
]]
return
spx
.
to_dict
(
'records'
)
@
component
(
bean_name
=
'market-right'
)
class
FallMarketRight
(
MarketRight
):
def
is_fall
(
self
,
day
,
risk
:
PortfoliosRisk
,
spx
=
None
):
if
spx
is
None
:
spx
=
self
.
load_spx_close_rtns
(
day
)
start_date
=
self
.
find_cvar_start_date
(
day
,
risk
,
spx
=
spx
)
if
start_date
:
spx
=
pd
.
DataFrame
(
spx
)
spx
=
spx
[(
spx
.
date
>=
start_date
)
&
(
spx
.
date
<=
day
)]
return
spx
.
iloc
[
-
1
]
.
close
<
spx
.
iloc
[
0
]
.
close
return
False
def
is_trigger
(
self
,
day
,
risk
:
PortfoliosRisk
)
->
bool
:
last_re
=
rrs
.
get_last_one
(
risk
=
risk
,
max_date
=
day
,
effective
=
True
)
if
last_re
is
not
None
and
SignalType
(
last_re
[
'type'
])
in
self
.
include_last_type
:
return
False
spx
=
self
.
load_spx_close_rtns
(
day
)
if
self
.
is_fall
(
day
,
risk
,
spx
=
spx
):
return
True
if
spx
[
-
1
][
'rtn'
]
>
self
.
min_threshold
:
return
False
cvar
=
self
.
get_cvar
(
day
,
risk
,
spx
=
spx
)
return
cvar
is
not
None
and
spx
[
-
1
][
'rtn'
]
<
cvar
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