Skip to content

Commit 60edd7d

Browse files
huhaohuhao
authored andcommitted
uvxy+xiv
1 parent ab0991e commit 60edd7d

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

python/qlib-test/UVXY_XIV.ipynb

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "229cf035-7014-4c71-b435-e468deb43bd9",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import numpy as np\n",
11+
"import pandas as pd\n",
12+
"import matplotlib.pyplot as plt\n",
13+
"\n",
14+
"# Simulated historical VIX changes (daily % changes) - for demonstration\n",
15+
"np.random.seed(42)\n",
16+
"days = 1000\n",
17+
"vix_changes = np.random.normal(0, 0.02, days) # ~2% daily volatility\n",
18+
"\n",
19+
"# Simplified assumptions\n",
20+
"uvxy_returns = 2 * vix_changes\n",
21+
"xiv_returns = -1 * vix_changes\n",
22+
"\n",
23+
"# Strategies\n",
24+
"lsvx_returns = 0.3333 * uvxy_returns + 0.6667 * xiv_returns\n",
25+
"xivh_returns = 0.10 * uvxy_returns + 0.90 * xiv_returns\n",
26+
"\n",
27+
"# Convert to cumulative performance\n",
28+
"cum_uvxy = (1 + uvxy_returns).cumprod()\n",
29+
"cum_xiv = (1 + xiv_returns).cumprod()\n",
30+
"cum_lsvx = (1 + lsvx_returns).cumprod()\n",
31+
"cum_xivh = (1 + xivh_returns).cumprod()\n",
32+
"\n",
33+
"# Plot cumulative performance\n",
34+
"plt.figure(figsize=(10,6))\n",
35+
"plt.plot(cum_uvxy, label=\"UVXY (2x long VIX)\", alpha=0.7)\n",
36+
"plt.plot(cum_xiv, label=\"XIV (short VIX)\", alpha=0.7)\n",
37+
"plt.plot(cum_lsvx, label=\"LSVX (33% UVXY + 67% XIV)\", linewidth=2)\n",
38+
"plt.plot(cum_xivh, label=\"XIVH (10% UVXY + 90% XIV)\", linewidth=2)\n",
39+
"\n",
40+
"plt.title(\"Cumulative Performance Simulation\", fontsize=14)\n",
41+
"plt.xlabel(\"Days\", fontsize=12)\n",
42+
"plt.ylabel(\"Portfolio Value (normalized)\", fontsize=12)\n",
43+
"plt.legend()\n",
44+
"plt.grid(True, linestyle=\"--\", alpha=0.6)\n",
45+
"plt.show()\n"
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"id": "7c28f31b-b28f-4f08-a791-ab6fd6b25c4c",
51+
"metadata": {},
52+
"source": [
53+
"你给出的两个策略组合:\n",
54+
"\n",
55+
"* **LSVX = 33.33% UVXY + 66.67% XIV**\n",
56+
"* **XIVH = 10% UVXY + 90% XIV**\n",
57+
"\n",
58+
"其实都是 **UVXY(杠杆做多VIX期货)** 和 **XIV(做空VIX期货)** 的线性组合。\n",
59+
"UVXY 代表对波动率的正向敞口,XIV 代表对波动率的负向敞口。\n",
60+
"\n",
61+
"---\n",
62+
"\n",
63+
"## 1. 策略特征解析\n",
64+
"\n",
65+
"### **LSVX (Volatility-Neutral Approach)**\n",
66+
"\n",
67+
"* 配比:1/3 UVXY + 2/3 XIV\n",
68+
"* **逻辑**:由于 UVXY 和 XIV 的方向相反、杠杆不同(UVXY一般为2倍做多短期VIX,XIV为做空短期VIX),按比例配置可以让组合在“正常市场环境”中尽量中性,即对小幅的VIX波动不太敏感。\n",
69+
"* **特点**:\n",
70+
"\n",
71+
" * 对冲掉了部分波动率方向风险,目标是更平滑的收益曲线。\n",
72+
" * 在平稳/下跌的波动率环境中,仍然有正收益(因为XIV权重更大)。\n",
73+
" * 在大幅度 VIX 飙升时,损失相对小于单独持有 XIV,但仍可能显著亏损。\n",
74+
"\n",
75+
"---\n",
76+
"\n",
77+
"### **XIVH (Tail-Risk Hedging Approach)**\n",
78+
"\n",
79+
"* 配比:10% UVXY + 90% XIV\n",
80+
"* **逻辑**:几乎等同于持有 XIV(即长期做空波动率),但少量 UVXY 用作对冲极端风险。\n",
81+
"* **特点**:\n",
82+
"\n",
83+
" * 平时的收益主要由 XIV 驱动 → 表现类似单独持有 XIV。\n",
84+
" * 在 VIX 暴涨(黑天鹅事件)时,UVXY 部分提供对冲,能在最坏的情况下减少组合爆仓的概率。\n",
85+
" * 属于“带安全气囊的做空波动率策略”。\n",
86+
"\n",
87+
"---\n",
88+
"\n",
89+
"## 2. 风险–收益对比\n",
90+
"\n",
91+
"| 特征 | LSVX (中性) | XIVH (尾部风险对冲) |\n",
92+
"| ---------- | ------------------- | ----------------- |\n",
93+
"| **方向性敞口** | 接近中性,轻微偏空波动率 | 强烈偏空波动率 |\n",
94+
"| **正常环境收益** | 较稳定、但不如XIV高 | 高(接近XIV的水平) |\n",
95+
"| **尾部风险** | 对冲了一部分,但仍有较大损失可能 | UVXY少量对冲,损失幅度相对较轻 |\n",
96+
"| **波动性** | 较低 | 较高 |\n",
97+
"| **适用投资者** | 想降低净波动率敞口,追求更平滑收益曲线 | 想获得高收益但又怕极端风险 |\n",
98+
"\n",
99+
"---\n",
100+
"\n",
101+
"## 3. 总结\n",
102+
"\n",
103+
"* **LSVX** 更像是一个“平衡型”波动率套利组合,追求中性和稳定,适合规避大方向上的波动性风险。\n",
104+
"* **XIVH** 则是“高风险高收益”的 **做空波动率 + 少量保险**,长期预期收益更高,但依然承担较大尾部风险。\n",
105+
"\n",
106+
"---\n",
107+
"\n",
108+
"要不要我帮你画一张 **风险收益情景分析图**(横轴=VIX变动,纵轴=组合收益),直观对比 LSVX 和 XIVH 在不同市场环境下的表现?\n"
109+
]
110+
}
111+
],
112+
"metadata": {
113+
"kernelspec": {
114+
"display_name": "Python (qlib)",
115+
"language": "python",
116+
"name": "qlib"
117+
},
118+
"language_info": {
119+
"codemirror_mode": {
120+
"name": "ipython",
121+
"version": 3
122+
},
123+
"file_extension": ".py",
124+
"mimetype": "text/x-python",
125+
"name": "python",
126+
"nbconvert_exporter": "python",
127+
"pygments_lexer": "ipython3",
128+
"version": "3.11.9"
129+
}
130+
},
131+
"nbformat": 4,
132+
"nbformat_minor": 5
133+
}

0 commit comments

Comments
 (0)