# 资产配置理论介绍

## 广义风险平价模型（风险类目标函数）

σ ( ω ) = ω ′ Σ ω ′ \sigma(\omega)=\sqrt{\omega^{'}\Sigma\omega^{'} }

σ ( ω i ) = ω i ∗ ∂ σ ( ω ) ∂ ω i = ω i ( Σ ω ) i ω ′ Σ ω ′ = σ ( ω ) N \sigma(\omega_i)=\omega_i\ast \frac{\partial \sigma(\omega)}{\partial \omega_i} \\=\frac{\omega_{i}(\Sigma\omega)_{i}}{\sqrt{\omega^{'}\Sigma\omega^{'}} } =\frac{\sigma(\omega)}{N}

a r g m i n ω ∑ i = 1 N [ ω i − ω ( σ ) 2 ( Σ ω ) i N ] 2 argmin\omega \sum_{i=1}^{N}[\omega_i-\frac{\omega(\sigma)^{2}}{(\Sigma\omega)_iN}]^{2}

#定义波动率平价优化的目标函数
def funsRP(weight,sigma):
weight = np.array([weight]).T
X = np.multiply(weight,np.dot(sigma.values,weight))
result = np.square(np.dot(X,np.ones([1,X.shape[0]])) - X.T).sum()
return(result)


M S D m i n = ∑ R < R m i n ( R − R m i n ) 2 N MSD_{min}=\sqrt{\frac{\sum_{R<R_{min}}^{ } (R-R_{min})^{2}}{N}}

Σ s h r u n k = ( 1 − α ) Σ ^ + α T r Σ ^ \Sigma_{\rm shrunk}=(1-\alpha)\hat{\Sigma}+\alpha\frac{{\rm Tr}}{\hat{\Sigma}}

σ = n σ n + ( n − 1 ) σ n − 1 + ( n − 2 ) σ n − 2 + . . . n + ( n − 1 ) + ( n − 2 ) + . . . \sigma = \frac{n\sigma_n+(n-1)\sigma_{n-1}+(n-2)\sigma_{n-2}+...}{n+(n-1)+(n-2)+...}

#定义下行波动率平价优化的目标函数
def downward(RET,rollingtime=126):
i=130
data_cov = RET.iloc[i-int(rollingtime):i]
data_cov[data_cov>0] = 0
sigma = data_cov.cov()
return sigma

def getSigma(datas, method='Simple'):
asset = datas.columns
datas['n'] = np.arange(datas.shape[0])
datas['group'] = pd.qcut(datas.n, 4, labels=False)
weights = np.arange(1, datas.shape[1]) / 10

if method == 'Simple':
sigma_1 = datas.loc[datas.group == 0, asset].cov()
sigma_2 = datas.loc[datas.group == 1, asset].cov()
sigma_3 = datas.loc[datas.group == 2, asset].cov()
sigma_4 = datas.loc[datas.group == 3, asset].cov()
sigma = 0.1 * sigma_1 + sigma_2 * 0.2 + sigma_3 * 0.3 + sigma_4 * 0.4
elif method == 'Ledoit':
sigma_1, a = ledoit_wolf(datas.loc[datas.group == 0, asset])
sigma_2, a = ledoit_wolf(datas.loc[datas.group == 1, asset])
sigma_3, a = ledoit_wolf(datas.loc[datas.group == 2, asset])
sigma_4, a = ledoit_wolf(datas.loc[datas.group == 3, asset])
sigma = 0.1 * sigma_1 + sigma_2 * 0.2 + sigma_3 * 0.3 + sigma_4 * 0.4
sigma = pd.DataFrame(sigma)
elif method == 'DW':
datas[datas > 0] = 0
datas['n'] = np.arange(datas.shape[0])
datas['group'] = pd.qcut(datas.n, 4, labels=False)
sigma_1 = datas.loc[datas.group == 0, asset].cov()
sigma_2 = datas.loc[datas.group == 1, asset].cov()
sigma_3 = datas.loc[datas.group == 2, asset].cov()
sigma_4 = datas.loc[datas.group == 3, asset].cov()
sigma = 0.1 * sigma_1 + sigma_2 * 0.2 + sigma_3 * 0.3 + sigma_4 * 0.4
else:
pass
return sigma


## 广义均值方差模型（收益类目标函数）

E ( R p ) = ∑ i ω i E ( R i ) E(R_p)=\sum_{i}^{}\omega_iE(R_i)

σ p 2 = ∑ i ω i 2 σ i 2 + ∑ i ∑ i ≠ j ω i ω j σ i σ j ρ i j \sigma_{p}^{2}=\sum_{i}^{}\omega_{i}^{2}\sigma_{i}^{2}+\sum_{i}^{}\sum_{i\neq j}^{}\omega_i\omega_j\sigma_i\sigma_j\rho_{ij}

ω T ∑ ω −   q   ∗ R T ω \omega ^{T}\sum \omega-~q~*R^{T}\omega

#定义马科维茨优化的目标函数
def funs(weight,sigma):
weight = np.array([weight]).T
result = np.dot(np.dot(weight.T,np.mat(sigma)),weight)[0,0]
return(result)


m a x i m u m   d r a w d o w n = m a x ( P x − P y ) P x maximum~drawdown=\frac{max(P_x-P_y)}{P_x}

#--* define objective functions*--
def minMDD(weights, Returns):
weights = np.array(weights)
RET = np.sum(Returns * weights, axis=1)
value = (RET+1).cumprod()
MDD = ffn.calc_max_drawdown(value)
return (-MDD)


V a R t + 1 p = − P e r c e n t i l e ( R P F , t + 1 − τ τ = 1 m , 100 p ) VaR_{t+1}^{p}=-Percentile({R_{PF,t+1-\tau}}_{\tau=1}^{m},100p)

#--*define VaR*--
def maxR2VaR(weights,Returns,method='historical',
alpha=0.99):
weights = np.array(weights)
RET = np.sum(Returns *weights,axis=1)
sorted_Returns = np.sort(RET)
index = int(alpha * len(sorted_Returns))
var = abs(sorted_Returns[index])
result = var/(np.average(RET)++10000000)
return(result)
#--*define CVaR*--
def maxR2CVaR(weights,Returns,alpha=0.99):
weights = np.array(weights)
RET = np.sum(Returns *weights,axis=1)
sorted_Returns = np.sort(RET)
index = int(alpha * len(sorted_Returns))
sum_var = sorted_Returns[0]
for i in range(1, index):
sum_var += sorted_Returns[i]
CVaR=abs(sum_var / index)
result = CVaR/(np.average(RET)++10000000)
return(result)


## 宏观观点下的Black Littterman模型

Black Litterman模型对马科维兹模型进行改进，在收益率序列分布上，用贝叶斯统计理论将投资者对大类资产的观点与市场均衡回报相结合。

β = C o v ( r , w T r ) V a r ( w T r ) = C o v ( r , r ) w V a r ( w T r ) = 1 σ 2 Σ w \beta=\frac{Cov(r,w^Tr)}{Var(w^Tr)}=\frac{Cov(r,r)w}{Var(w^Tr)}=\frac{1}{\sigma^2}\Sigma w

E x c e s s   R e t u r n = ( w T r ) β = ( w T r ) β = w T r σ 2 Σ w Excess~Return=(w^Tr)\beta \\=(w^Tr)\beta=\frac{w^Tr}{\sigma^2}\Sigma w

P E ( r ) = q + v v ∼ N ( 0 , Ω ) P E ( r ) ∼ N ( q , Ω ) 假 设   E x c e s s   e t u r n ∣ E ( r ) ∼ N ( E ( r ) , τ Σ ) PE(r)=q+v \\ v\sim N(0,\Omega) \\ PE(r)\sim N(q,\Omega) \\假设~Excess~eturn|E(r)\sim N(E(r),\tau\Sigma)

min ⁡ E ( r )   ( E ( r ) − E x c e s s   R e t u r n ) T ( τ Σ ) − 1 ( E ( r ) − E x c e s s   R e t u r n ) s . t .   P E ( r ) = q \min_{E(r)}\ (E(r)-Excess~Return)^T(\tau\Sigma)^{-1}(E(r)-Excess~Return) \\ s.t.\ PE(r)=q

CPI同比通胀
PPI同比通胀
M1同比流动性
M2同比流动性
M2-M1同比流动性

# 资产配置实证分析

## 基准投资组合

EWEV

T检验值2.3495174.849205

## 广义风险平价模型

variance0.0613035.7719920.0376070.1143152.1672780.832393-0.03409-1.59811
downward0.0808615.3017750.0538670.0947192.7479540.944198-0.03448-1.69246
ledoit_wolf0.0688653.6464370.0681480.2582952.3768280.570309-0.02366-2.47014
shrinkage0.0691976.6361710.0367180.0962172.3864521.067529-0.04066-1.49989
shrinkage_DW0.0766595.1443260.0527440.0846642.6122670.884644-0.03159-1.73889
shrinkage_Ledoit0.0716643.172710.0825290.3207472.459020.504842-0.02105-3.0959

ledoit_wolf平价模型的权重变化图

shrinkage_Ledoit 平价模型的权重变化图

shrinkage_DW平价模型的权重变化图

## 广义均值方差模型

MAC0.0694093.437730.0731930.2111362.3926060.538428-0.02438-2.31929
minMDD0.0625818.4734430.0259710.0436032.2014351.254488-0.04804-1.37752
historical VaR0.062043.2704880.0689790.1829042.1869130.464489-0.01978-3.3727
historical CVaR0.0636312.8085320.0836940.1495412.2298780.40183-0.01841-2.81145

## Black Littterman模型

T检验值3.438521.957171

BL模型的投资组合净值曲线图

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏 11
• 打赏

打赏

天天学习的零柒贰幺

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 举报
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

03-09 8849
04-11 2万+
09-17 917
08-31
10-26 984
01-04 526
10-05 3560
04-27 1210
06-08 613
06-10 1151
11-25 143