Commit 7c7c9fc7 authored by 吕先亚's avatar 吕先亚

动态调整UARC

parent b972442a
This diff is collapsed.
......@@ -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
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment