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
7c7c9fc7
Commit
7c7c9fc7
authored
Oct 10, 2024
by
吕先亚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态调整UARC
parent
b972442a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
316 additions
and
5 deletions
+316
-5
config-stable_prr3_t.yml
config-stable_prr3_t.yml
+291
-0
builder.py
portfolios/builder.py
+1
-2
solver.py
portfolios/solver.py
+24
-3
No files found.
config-stable_prr3_t.yml
0 → 100644
View file @
7c7c9fc7
This diff is collapsed.
Click to expand it.
portfolios/builder.py
View file @
7c7c9fc7
...
...
@@ -95,6 +95,7 @@ class PoemPortfoliosBuilder(MptPortfoliosBuilder):
portfolios
=
{}
for
risk
in
PortfoliosRisk
:
solver
=
self
.
_factory
.
create_solver
(
risk
,
type
)
self
.
__day
=
day
navs_group
=
solver
.
reset_navs
(
day
)
for
category
,
navs
in
navs_group
.
items
():
solver
.
set_navs
(
navs
)
...
...
@@ -222,5 +223,3 @@ class RiskParityARCPortfoliosBuilder(MptPortfoliosBuilder):
'solve'
:
SolveType
.
INFEASIBLE
}
return
result
portfolios/solver.py
View file @
7c7c9fc7
import
math
import
os
import
statistics
import
sys
from
logging
import
DEBUG
,
getLogger
...
...
@@ -344,6 +345,26 @@ class ARCSolver(DefaultSolver):
count
=
self
.
get_config
(
'asset-count'
)
return
min
(
count
[
0
]
if
isinstance
(
count
,
list
)
else
count
,
len
(
self
.
rtn_annualized
))
@
property
def
LARC
(
self
):
return
self
.
_config
[
'LARC'
]
@
property
def
UARC
(
self
):
ecos
=
self
.
_datum
.
get_datums
(
ticker
=
[
'CPI YOY Index'
,
'FDTR Index'
])
cpi_id
=
[
data
[
'id'
]
for
data
in
ecos
if
data
[
'bloombergTicker'
]
==
'CPI YOY Index'
]
fdtr_id
=
[
data
[
'id'
]
for
data
in
ecos
if
data
[
'bloombergTicker'
]
==
'FDTR Index'
]
cpi
=
self
.
_navs
.
get_last_eco_values
(
max_date
=
self
.
date
,
datum_id
=
cpi_id
,
count
=
2
,
by_release_date
=
True
)
cpi
=
statistics
.
mean
([
c
[
'indicator'
]
for
c
in
cpi
])
fdtr
=
self
.
_navs
.
get_last_eco_values
(
max_date
=
self
.
date
,
datum_id
=
fdtr_id
,
by_release_date
=
True
)[
'indicator'
]
cash_uarc
=
round
(
self
.
_config
[
'fix-w'
]
+
self
.
_config
[
'fdtr-w'
]
*
fdtr
+
abs
(
cpi
-
self
.
_config
[
'cpi-expect'
])
*
self
.
_config
[
'cpiyoy-w'
],
2
)
cash_uarc
=
self
.
_config
[
'max-w'
]
if
cash_uarc
>
self
.
_config
[
'max-w'
]
else
cash_uarc
UARC
=
self
.
_config
[
'UARC'
]
UARC
[
self
.
_config
[
'uarc-index'
]]
=
cash_uarc
return
UARC
def
create_model
(
self
):
low_weight
=
self
.
get_config
(
'mpt.low-weight'
)
high_weight
=
self
.
get_config
(
'mpt.high-weight'
)
...
...
@@ -361,8 +382,8 @@ class ARCSolver(DefaultSolver):
model
.
cons_bounds_low
=
Constraint
(
model
.
indices
,
rule
=
lambda
m
,
i
:
m
.
z
[
i
]
*
low_weight
<=
m
.
w
[
i
])
model
.
cons_bounds_up
=
Constraint
(
model
.
indices
,
rule
=
lambda
m
,
i
:
m
.
z
[
i
]
*
high_weight
>=
m
.
w
[
i
])
if
self
.
_config
[
'arc'
]:
LARC
=
self
.
_config
[
'LARC'
]
UARC
=
self
.
_config
[
'UARC'
]
LARC
=
self
.
LARC
UARC
=
self
.
UARC
numARC
=
len
(
LARC
)
# this is the M in the doc
numAsset
=
len
(
self
.
navs
.
columns
)
...
...
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