<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Etf on 格物堂</title><link>https://gewutang.cn/tags/etf/</link><description>Recent content in Etf on 格物堂</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Tue, 23 Dec 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://gewutang.cn/tags/etf/index.xml" rel="self" type="application/rss+xml"/><item><title>全天候动量ETF策略</title><link>https://gewutang.cn/2025/12/23/all-weather-momentum/</link><pubDate>Tue, 23 Dec 2025 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2025/12/23/all-weather-momentum/</guid><description>&#10;&#10;&#10;&lt;pre&gt;&lt;code&gt;## 正在从Yahoo Finance获取数据...&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;513100.SS&amp;quot; &amp;quot;510300.SS&amp;quot; &amp;quot;518880.SS&amp;quot;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 2. 计算指标：动量、波动率、调整动量&#10;calculate_metrics &amp;lt;- function(price_series, window = 20) {&#10; # 计算日收益率&#10; returns &amp;lt;- dailyReturn(price_series, type = &amp;quot;arithmetic&amp;quot;)&#10; colnames(returns) &amp;lt;- &amp;quot;Return&amp;quot;&#10; &#10; # 计算20日平均收益率（动量）&#10; momentum &amp;lt;- rollapply(returns, width = window, FUN = mean, align = &amp;quot;right&amp;quot;, fill = NA)&#10; colnames(momentum) &amp;lt;- &amp;quot;Momentum&amp;quot;&#10; &#10; # 计算20日收益率方差（波动率）&#10; volatility &amp;lt;- rollapply(returns, width = window, FUN = var, align = &amp;quot;right&amp;quot;, fill = NA)&#10; colnames(volatility) &amp;lt;- &amp;quot;Volatility&amp;quot;&#10; &#10; # 计算调整动量（动量/波动率）&#10; # 注意：使用标准差进行标准化（方差的平方根）&#10; adj_momentum &amp;lt;- momentum / sqrt(volatility)&#10; colnames(adj_momentum) &amp;lt;- &amp;quot;Adj_Momentum&amp;quot;&#10; &#10; return(list(returns = returns, &#10; momentum = momentum, &#10; volatility = volatility, &#10; adj_momentum = adj_momentum))&#10;}&#10;&#10;# 为每个ETF计算指标&#10;# cat(&amp;quot;正在计算动量指标...\n&amp;quot;)&#10;metrics_list &amp;lt;- list()&#10;for (etf in etf_names) {&#10; metrics_list[[etf]] &amp;lt;- calculate_metrics(price_df[, etf])&#10;}&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Warning in to_period(xx, period = on.opts[[period]], ...): missing values&#10;## removed from data&#10;## Warning in to_period(xx, period = on.opts[[period]], ...): missing values&#10;## removed from data&#10;## Warning in to_period(xx, period = on.opts[[period]], ...): missing values&#10;## removed from data&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 3. 生成交易信号和权重&#10;generate_weights &amp;lt;- function(adj_momentum_df) {&#10; # 初始化权重数据框&#10; weights_df &amp;lt;- as.data.frame(adj_momentum_df)&#10; weights_df[] &amp;lt;- 0 # 所有值初始化为0&#10; &#10; # 对每一行（每个交易日）计算权重&#10; for (i in 1:nrow(adj_momentum_df)) {&#10; # 获取当日的调整动量值&#10; current_momentum &amp;lt;- as.numeric(adj_momentum_df[i, ])&#10; &#10; # 筛选调整动量大于0的标的&#10; positive_idx &amp;lt;- which(current_momentum &amp;gt; 0 &amp;amp; !is.na(current_momentum))&#10; &#10; if (length(positive_idx) &amp;gt; 0) {&#10; # 获取正的调整动量值&#10; positive_momentum &amp;lt;- current_momentum[positive_idx]&#10; &#10; # 按调整动量大小归一化计算权重&#10; normalized_weights &amp;lt;- positive_momentum / sum(positive_momentum)&#10; &#10; # 分配权重&#10; weights_df[i, positive_idx] &amp;lt;- normalized_weights&#10; }&#10; }&#10; &#10; # 转换为时间序列&#10; weights_xts &amp;lt;- xts(weights_df, order.by = index(adj_momentum_df))&#10; colnames(weights_xts) &amp;lt;- colnames(adj_momentum_df)&#10; &#10; return(weights_xts)&#10;}&#10;&#10;# 提取所有ETF的调整动量&#10;adj_momentum_all &amp;lt;- do.call(merge, lapply(metrics_list, function(x) x$adj_momentum))&#10;colnames(adj_momentum_all) &amp;lt;- etf_names&#10;&#10;# 生成权重序列&#10;# cat(&amp;quot;正在计算每日权重...\n&amp;quot;)&#10;weights &amp;lt;- generate_weights(adj_momentum_all)&#10;&#10;# 4. 将权重数据整理到数据框中&#10;# 创建每日权重数据框（包含日期）&#10;daily_weights_df &amp;lt;- data.frame(Date = index(weights))&#10;for (etf in etf_names) {&#10; daily_weights_df[[etf]] &amp;lt;- as.numeric(weights[, etf])&#10;}&#10;&#10;# 计算每个交易日的权重合计（应为1或0）&#10;daily_weights_df$权重合计 &amp;lt;- rowSums(daily_weights_df[, etf_names], na.rm = TRUE)&#10;&#10;# 创建每个ETF的单独权重数据框&#10;etf_weight_dfs &amp;lt;- list()&#10;for (etf in etf_names) {&#10; etf_weight_dfs[[etf]] &amp;lt;- data.frame(&#10; Date = index(weights),&#10; ETF = etf,&#10; Weight = as.numeric(weights[, etf])&#10; )&#10;}&#10;&#10;# 合并所有ETF权重数据框&#10;all_etf_weights_df &amp;lt;- do.call(rbind, etf_weight_dfs)&#10;&#10;# 5. 回测计算&#10;# 计算每个ETF的日收益率&#10;returns_all &amp;lt;- do.call(merge, lapply(metrics_list, function(x) x$returns))&#10;colnames(returns_all) &amp;lt;- etf_names&#10;&#10;# 调整权重的时间索引，确保与收益率对齐&#10;# 使用T日的权重在T+1日交易&#10;lagged_weights &amp;lt;- lag(weights, 1) # 权重滞后一天&#10;lagged_weights &amp;lt;- lagged_weights[index(returns_all)] # 对齐索引&#10;&#10;# 处理缺失值&#10;lagged_weights[is.na(lagged_weights)] &amp;lt;- 0&#10;&#10;# 计算策略日收益率（按T+1日开盘价计算，这里用平均价近似）&#10;strategy_returns &amp;lt;- rowSums(returns_all * lagged_weights, na.rm = TRUE)&#10;strategy_returns &amp;lt;- xts(strategy_returns, order.by = index(returns_all))&#10;colnames(strategy_returns) &amp;lt;- &amp;quot;动量策略&amp;quot;&#10;&#10;# 6. 绩效指标计算&#10;# cat(&amp;quot;正在计算绩效指标...\n&amp;quot;)&#10;# 策略绩效&#10;strategy_perf &amp;lt;- table.AnnualizedReturns(strategy_returns)&#10;strategy_dd &amp;lt;- table.DownsideRisk(strategy_returns)&#10;max_dd &amp;lt;- maxDrawdown(strategy_returns)&#10;strategy_calmar &amp;lt;- CalmarRatio(strategy_returns)&#10;strategy_sortino &amp;lt;- SortinoRatio(strategy_returns)&#10;strategy_positive_returns &amp;lt;- sum(strategy_returns &amp;gt; 0, na.rm = TRUE)&#10;strategy_total_returns &amp;lt;- sum(!is.na(strategy_returns))&#10;strategy_win_rate &amp;lt;- strategy_positive_returns / strategy_total_returns&#10;&#10;# 基准绩效（沪深300ETF）&#10;benchmark_returns &amp;lt;- returns_all[, &amp;quot;沪深300ETF&amp;quot;]&#10;colnames(benchmark_returns) &amp;lt;- &amp;quot;沪深300ETF&amp;quot;&#10;benchmark_perf &amp;lt;- table.AnnualizedReturns(benchmark_returns)&#10;benchmark_dd &amp;lt;- table.DownsideRisk(benchmark_returns)&#10;benchmark_max_dd &amp;lt;- maxDrawdown(benchmark_returns)&#10;benchmark_calmar &amp;lt;- CalmarRatio(benchmark_returns)&#10;benchmark_sortino &amp;lt;- SortinoRatio(benchmark_returns)&#10;benchmark_positive_returns &amp;lt;- sum(benchmark_returns &amp;gt; 0, na.rm = TRUE)&#10;benchmark_total_returns &amp;lt;- sum(!is.na(benchmark_returns))&#10;benchmark_win_rate &amp;lt;- benchmark_positive_returns / benchmark_total_returns&#10;&#10;# 等权重组合绩效&#10;equal_weights &amp;lt;- matrix(1/3, nrow = nrow(returns_all), ncol = ncol(returns_all))&#10;equal_weights &amp;lt;- xts(equal_weights, order.by = index(returns_all))&#10;colnames(equal_weights) &amp;lt;- etf_names&#10;equal_returns &amp;lt;- rowSums(returns_all * equal_weights, na.rm = TRUE)&#10;equal_returns &amp;lt;- xts(equal_returns, order.by = index(returns_all))&#10;colnames(equal_returns) &amp;lt;- &amp;quot;等权重组合&amp;quot;&#10;equal_perf &amp;lt;- table.AnnualizedReturns(equal_returns)&#10;equal_max_dd &amp;lt;- maxDrawdown(equal_returns)&#10;equal_calmar &amp;lt;- CalmarRatio(equal_returns)&#10;equal_sortino &amp;lt;- SortinoRatio(equal_returns)&#10;equal_positive_returns &amp;lt;- sum(equal_returns &amp;gt; 0, na.rm = TRUE)&#10;equal_total_returns &amp;lt;- sum(!is.na(equal_returns))&#10;equal_win_rate &amp;lt;- equal_positive_returns / equal_total_returns&#10;&#10;# 7. 创建绩效指标汇总数据框&#10;# 格式化日期字符串&#10;start_date_str &amp;lt;- format(start_date, &amp;quot;%Y-%m-%d&amp;quot;)&#10;end_date_str &amp;lt;- format(end_date, &amp;quot;%Y-%m-%d&amp;quot;)&#10;period_str &amp;lt;- paste(start_date_str, &amp;quot;至&amp;quot;, end_date_str)&#10;&#10;performance_metrics_df &amp;lt;- data.frame(&#10; 策略 = c(&amp;quot;动量策略&amp;quot;, &amp;quot;沪深300ETF&amp;quot;, &amp;quot;等权重组合&amp;quot;),&#10; 年化收益率 = c(&#10; round(strategy_perf[1, 1] * 100, 2),&#10; round(benchmark_perf[1, 1] * 100, 2),&#10; round(equal_perf[1, 1] * 100, 2)&#10; ),&#10; 年化波动率 = c(&#10; round(strategy_perf[2, 1] * 100, 2),&#10; round(benchmark_perf[2, 1] * 100, 2),&#10; round(equal_perf[2, 1] * 100, 2)&#10; ),&#10; 夏普比率 = c(&#10; round(strategy_perf[3, 1], 3),&#10; round(benchmark_perf[3, 1], 3),&#10; round(equal_perf[3, 1], 3)&#10; ),&#10; 最大回撤 = c(&#10; round(max_dd * 100, 2),&#10; round(benchmark_max_dd * 100, 2),&#10; round(equal_max_dd * 100, 2)&#10; ),&#10; 卡尔马比率 = c(&#10; round(strategy_calmar, 3),&#10; round(benchmark_calmar, 3),&#10; round(equal_calmar, 3)&#10; ),&#10; 索提诺比率 = c(&#10; round(strategy_sortino, 3),&#10; round(benchmark_sortino, 3),&#10; round(equal_sortino, 3)&#10; ),&#10; 胜率 = c(&#10; round(strategy_win_rate * 100, 2),&#10; round(benchmark_win_rate * 100, 2),&#10; round(equal_win_rate * 100, 2)&#10; ),&#10; 正收益天数 = c(&#10; strategy_positive_returns,&#10; benchmark_positive_returns,&#10; equal_positive_returns&#10; ),&#10; 总交易天数 = c(&#10; strategy_total_returns,&#10; benchmark_total_returns,&#10; equal_total_returns&#10; ),&#10; 回测期间 = c(period_str, period_str, period_str)&#10;)&#10;&#10;# 8. 绩效指标输出&#10;# cat(&amp;quot;==================== 绩效指标汇总数据框 ====================\n\n&amp;quot;)&#10;print(performance_metrics_df)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 策略 年化收益率 年化波动率 夏普比率 最大回撤 卡尔马比率 索提诺比率&#10;## 1 动量策略 45.13 17.08 2.643 8.72 5.178 0.227&#10;## 2 沪深300ETF 20.31 19.27 1.054 16.25 1.250 0.103&#10;## 3 等权重组合 31.84 12.89 2.470 9.29 3.429 0.201&#10;## 胜率 正收益天数 总交易天数 回测期间&#10;## 1 53.04 253 477 2024-01-01 至 2025-12-23&#10;## 2 51.26 244 476 2024-01-01 至 2025-12-23&#10;## 3 59.33 283 477 2024-01-01 至 2025-12-23&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# cat(&amp;quot;\n&amp;quot;)&#10;&#10;# 9. 输出权重数据&#10;&#10;# cat(&amp;quot;每日组合权重数据框（后10行）:\n&amp;quot;)&#10;print(tail(daily_weights_df, 10))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Date 纳指ETF 沪深300ETF 黄金ETF 权重合计&#10;## 468 2025-12-08 0.09379501 0.00000000 0.9062050 1&#10;## 469 2025-12-09 0.00000000 0.00000000 0.0000000 0&#10;## 470 2025-12-10 0.00000000 0.00000000 1.0000000 1&#10;## 471 2025-12-11 0.00000000 0.00000000 0.0000000 0&#10;## 472 2025-12-12 0.05889600 0.00000000 0.9411040 1&#10;## 473 2025-12-15 0.00000000 0.00000000 1.0000000 1&#10;## 474 2025-12-16 0.16844695 0.00000000 0.8315530 1&#10;## 475 2025-12-17 0.31823928 0.01791372 0.6638470 1&#10;## 476 2025-12-18 0.00000000 0.00000000 1.0000000 1&#10;## 477 2025-12-19 0.22970999 0.26353990 0.5067501 1&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# cat(&amp;quot;\n&amp;quot;)&#10;&#10;&#10;# 10. 绘制图表&#10;# cat(&amp;quot;正在生成图表...\n&amp;quot;)&#10;# 准备累计收益率数据&#10;cumulative_returns &amp;lt;- merge(&#10; cumprod(1 + na.fill(strategy_returns, 0)) - 1,&#10; cumprod(1 + na.fill(benchmark_returns, 0)) - 1,&#10; cumprod(1 + na.fill(equal_returns, 0)) - 1&#10;)&#10;colnames(cumulative_returns) &amp;lt;- c(&amp;quot;动量策略&amp;quot;, &amp;quot;沪深300ETF&amp;quot;, &amp;quot;等权重组合&amp;quot;)&#10;&#10;# 转换为数据框用于ggplot&#10;cumulative_df &amp;lt;- data.frame(&#10; Date = index(cumulative_returns),&#10; as.data.frame(cumulative_returns)&#10;)&#10;cumulative_long &amp;lt;- pivot_longer(cumulative_df, &#10; cols = -Date, &#10; names_to = &amp;quot;Portfolio&amp;quot;, &#10; values_to = &amp;quot;CumulativeReturn&amp;quot;)&#10;&#10;# 图表1：策略 vs 基准累计收益率和最大回撤对比&#10;p1 &amp;lt;- ggplot(cumulative_long %&amp;gt;% filter(Portfolio %in% c(&amp;quot;动量策略&amp;quot;, &amp;quot;沪深300ETF&amp;quot;)), &#10; aes(x = Date, y = CumulativeReturn, color = Portfolio)) +&#10; geom_line(size = 1.2) +&#10; labs(title = &amp;quot;动量策略 vs 沪深300ETF: 累计收益率对比&amp;quot;,&#10; x = &amp;quot;日期&amp;quot;, y = &amp;quot;累计收益率&amp;quot;) +&#10; scale_y_continuous(labels = percent_format()) +&#10; scale_color_manual(values = c(&amp;quot;动量策略&amp;quot; = &amp;quot;blue&amp;quot;, &amp;quot;沪深300ETF&amp;quot; = &amp;quot;red&amp;quot;)) +&#10; theme_minimal() +&#10; theme(legend.position = &amp;quot;bottom&amp;quot;,&#10; plot.title = element_text(hjust = 0.5, size = 14, face = &amp;quot;bold&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.&#10;## ℹ Please use `linewidth` instead.&#10;## This warning is displayed once every 8 hours.&#10;## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was&#10;## generated.&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 图表2：策略 vs 各ETF Buy &amp;amp; Hold对比&#10;# 计算各ETF的累计收益率&#10;etf_cumulative &amp;lt;- do.call(merge, &#10; lapply(1:length(etf_names), &#10; function(i) cumprod(1 + na.fill(returns_all[, i], 0)) - 1))&#10;colnames(etf_cumulative) &amp;lt;- paste0(etf_names, &amp;quot; (Buy&amp;amp;Hold)&amp;quot;)&#10;&#10;all_cumulative &amp;lt;- merge(cumulative_returns[, &amp;quot;动量策略&amp;quot;], etf_cumulative)&#10;all_cumulative_df &amp;lt;- data.frame(Date = index(all_cumulative), &#10; as.data.frame(all_cumulative))&#10;all_cumulative_long &amp;lt;- pivot_longer(all_cumulative_df, &#10; cols = -Date, &#10; names_to = &amp;quot;Strategy&amp;quot;, &#10; values_to = &amp;quot;CumulativeReturn&amp;quot;)&#10;&#10;p2 &amp;lt;- ggplot(all_cumulative_long, aes(x = Date, y = CumulativeReturn, color = Strategy)) +&#10; geom_line(size = 1) +&#10; labs(title = &amp;quot;动量策略 vs 各ETF买入持有策略: 累计收益率对比&amp;quot;,&#10; x = &amp;quot;日期&amp;quot;, y = &amp;quot;累计收益率&amp;quot;) +&#10; scale_y_continuous(labels = percent_format()) +&#10; theme_minimal() +&#10; theme(legend.position = &amp;quot;bottom&amp;quot;,&#10; plot.title = element_text(hjust = 0.5, size = 14, face = &amp;quot;bold&amp;quot;))&#10;&#10;# 图表3：策略 vs 等权重组合对比&#10;p3 &amp;lt;- ggplot(cumulative_long %&amp;gt;% filter(Portfolio %in% c(&amp;quot;动量策略&amp;quot;, &amp;quot;等权重组合&amp;quot;)), &#10; aes(x = Date, y = CumulativeReturn, color = Portfolio)) +&#10; geom_line(size = 1.2) +&#10; labs(title = &amp;quot;动量策略 vs 等权重组合: 累计收益率对比&amp;quot;,&#10; x = &amp;quot;日期&amp;quot;, y = &amp;quot;累计收益率&amp;quot;) +&#10; scale_y_continuous(labels = percent_format()) +&#10; scale_color_manual(values = c(&amp;quot;动量策略&amp;quot; = &amp;quot;blue&amp;quot;, &amp;quot;等权重组合&amp;quot; = &amp;quot;green&amp;quot;)) +&#10; theme_minimal() +&#10; theme(legend.position = &amp;quot;bottom&amp;quot;,&#10; plot.title = element_text(hjust = 0.5, size = 14, face = &amp;quot;bold&amp;quot;))&#10;&#10;# 图表4：权重随时间变化图&#10;# 准备权重数据&#10;weights_long &amp;lt;- pivot_longer(daily_weights_df, &#10; cols = all_of(etf_names),&#10; names_to = &amp;quot;ETF&amp;quot;, &#10; values_to = &amp;quot;Weight&amp;quot;)&#10;&#10;p4 &amp;lt;- ggplot(weights_long, aes(x = Date, y = Weight, fill = ETF)) +&#10; geom_area(position = &amp;quot;stack&amp;quot;, alpha = 0.7) +&#10; labs(title = &amp;quot;动量策略: 每日权重分配&amp;quot;,&#10; x = &amp;quot;日期&amp;quot;, y = &amp;quot;权重&amp;quot;) +&#10; scale_y_continuous(labels = percent_format()) +&#10; scale_fill_manual(values = c(&amp;quot;纳指ETF&amp;quot; = &amp;quot;blue&amp;quot;, &#10; &amp;quot;沪深300ETF&amp;quot; = &amp;quot;red&amp;quot;, &#10; &amp;quot;黄金ETF&amp;quot; = &amp;quot;gold&amp;quot;)) +&#10; theme_minimal() +&#10; theme(legend.position = &amp;quot;bottom&amp;quot;,&#10; plot.title = element_text(hjust = 0.5, size = 14, face = &amp;quot;bold&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 12. 显示图表&#10;# cat(&amp;quot;\n正在显示图表...\n&amp;quot;)&#10;print(p1)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/12/23/all-weather-momentum/index_files/figure-html/unnamed-chunk-2-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# cat(&amp;quot;\n\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;print(p2)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/12/23/all-weather-momentum/index_files/figure-html/unnamed-chunk-3-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# cat(&amp;quot;\n\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;print(p3)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/12/23/all-weather-momentum/index_files/figure-html/unnamed-chunk-4-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# cat(&amp;quot;\n\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;print(p4)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/12/23/all-weather-momentum/index_files/figure-html/unnamed-chunk-5-1.png" width="672" /&gt;&lt;/p&gt;&#10;</description></item><item><title>如何根据事件研究来推测市场上涨幅度</title><link>https://gewutang.cn/2025/07/26/casestudy-etf-up/</link><pubDate>Sat, 26 Jul 2025 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2025/07/26/casestudy-etf-up/</guid><description>&#10;&#10;&#10;&lt;p&gt;先获取稀土ETF（代码为516780）的历史行情数据：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(quantmod)&#10;XT &amp;lt;- getSymbols(&amp;quot;516780.ss&amp;quot;, src = &amp;quot;yahoo&amp;quot;, auto.assign = FALSE)&#10;# 获取子集数据&#10;XT &amp;lt;- round(XT[&amp;quot;2025::&amp;quot;],2)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;绘制蜡烛图：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;chartSeries(XT, theme = &amp;quot;white&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/07/26/casestudy-etf-up/index_files/figure-html/unnamed-chunk-2-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;p&gt;下面标记重大事件。包括：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;2025年3月，份政府工作报告中提及要“整治行业内卷式竞争”。&lt;/li&gt;&#10;&lt;li&gt;2025年6月17日，全国人大公布修订后的《反不正当竞争法》。&lt;/li&gt;&#10;&lt;li&gt;2025年7月1日，中央财经委员会第七次会议公布要治理企业低价无序竞争。&lt;/li&gt;&#10;&lt;li&gt;2025年7月9日，工信部召开企业公平竞争座谈会。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;在图上标记重大事件：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 定义事件日期&#10;event_dates &amp;lt;- as.Date(c(&amp;quot;2025-03-07&amp;quot;, &#10; &amp;quot;2025-06-27&amp;quot;,&#10; &amp;quot;2025-07-01&amp;quot;,&#10; &amp;quot;2025-07-09&amp;quot;)&#10; )&#10;&#10;# 计算事件日期在子集中的相对索引&#10;event_index &amp;lt;- numeric(length(event_dates))&#10;for (i in seq_along(event_dates)) {&#10; event_index[i] &amp;lt;- which(index(XT) == event_dates[i])&#10;}&#10;&#10;# 添加标记点&#10;addPoints(&#10; x = event_index,&#10; y = Ad(XT[event_dates]),&#10; col = &amp;quot;blue&amp;quot;,&#10; pch = 24&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/07/26/casestudy-etf-up/index_files/figure-html/unnamed-chunk-3-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(qmao)&#10;addVLine(index(XT[c(&amp;quot;2025-03-05::2025-03-12&amp;quot;,&#10; &amp;quot;2025-06-17::2025-06-30&amp;quot;,&#10; &amp;quot;2025-07-01::2025-07-25&amp;quot;)&#10; ]),&#10; col = &amp;quot;lightblue&amp;quot;,&#10; border = &amp;quot;lightblue&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/07/26/casestudy-etf-up/index_files/figure-html/unnamed-chunk-3-2.png" width="672" /&gt;&lt;/p&gt;&#10;</description></item><item><title>ETF的跨市场套利交易</title><link>https://gewutang.cn/2013/08/30/etf/</link><pubDate>Fri, 30 Aug 2013 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2013/08/30/etf/</guid><description>&lt;p&gt;ETF的跨市场套利交易包括了三个步骤：上证50ETF二级市场买卖、一级市场申购赎回和一篮子股票二级市场的买卖三个交易程序。&lt;/p&gt;&#10;&lt;p&gt;在套利之前，首先要清楚除可在二级市场买卖之外，上证50ETF也可在一级市场上进行申购赎回。上证50ETF基金的申购、赎回时是用一篮子股票(50只成份股)与上证50ETF基金份额进行互换交易。&lt;/p&gt;&#10;&lt;p&gt;具体过程如下：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;申购：用一篮子股票从基金公司处换取上证50ETF基金份额。&lt;/li&gt;&#10;&lt;li&gt;赎回：用上证50ETF基金份额从基金公司处换取一篮子股票，一篮子股票各种股票比例与上证50指数一致。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;上证50ETF基金申购、赎回简称为&amp;quot;50申赎&amp;quot;，代码为&amp;quot;510051&amp;quot;。该代码显示值代表50ETF基金最新基金份额参考净值(即IOPV值)，是根据上证50指数50只成份股市场价格计算出来的，并根据成份股价格变化每15秒更新一次。最小申购赎回单位为100万份基金份额，申购、赎回均以份额申请，其申请提交后不得撤销。申购赎回费为申购或赎回份额的0.5%。&lt;/p&gt;&#10;&lt;p&gt;跨市套利交易:&amp;ldquo;50申赎&amp;quot;提供了短时间内的上证50ETF基金参考净值，也反映了一篮子股票当时的平均市场价格水平。大额资金投资者可以根据&amp;quot;50申赎&amp;quot;与&amp;quot;50ETF&amp;quot;两者之间的市场价格差进行短线套利交易，价格差大小用折/溢价率表示:&lt;/p&gt;&#10;&lt;p&gt;折/溢价率＝(50ETF二级市场价格P-申购赎回参考净值IOPV)/(申购赎回参考净值IOPV)×100%&lt;/p&gt;&#10;&lt;p&gt;折价套利：当ETF二级市场交易价格低于其份额净值，即发生折价交易时,大额资金投资者可以通过在二级市场大量低价买进ETF,然后在一级市场(即向基金公司)按净值赎回(高价卖出)份额,换回一篮子股票,再于二级市场上卖掉股票而实现套利交易。&lt;/p&gt;&#10;&lt;p&gt;溢价套利:当二级市场ETF交易价格高于其份额净值,即发生溢价交易时,大额资金投资者可以在二级市场买进一篮子股票,再用这些股票于一级市场(即向基金公司)申购ETF(低价买入ETF),再于二级市场上高价卖掉ETF而实现套利交易。&lt;/p&gt;&#10;&lt;p&gt;能够套利成功并获益的前提是折溢价率高于套利交易费用，一级交易券商的套利成本最低，仅0.3545%,只考虑免除佣金、申购赎回费用之后的其他必要交易费用，此时能够套利的折溢价空间只需30个基点以上，即0.3分的价格折价差；其次是普通交易券商，为0.8545%，在前者基础上增加了0.5%的申购赎回费；而一般投资者套利成本最高，为1.35%，如果能够享受佣金优惠，则可稍低。&lt;/p&gt;&#10;&lt;p&gt;假如上证50ETF二级市场价格即50ETF显示价格为0.865元，申购赎回基金参考净值IOPV为0.879元(即上证50ETF基金净值估计值)，则投资者进行套利的过程如下：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;二级市场买入50ETF至少100万份,则买入100万份ETF基金所需资金为0.865×1000000×(1+0.25%)＝867162.5元,其中缴纳交易佣金费率为0.25%。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;将买入的100万ETF基金在一级市场上向基金公司进行赎回，得到一篮子股票，其中要向券商缴纳0.5%的申购赎回费，计5000元。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;将得到的一篮子股票于二级市场同步卖出,卖出金额估计为0.879×1000000×(1-0.3%-0.1%-0.1%)＝874605元,其中缴纳0.3%的佣金、0.1%的印花税、0.1%的过户费。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;套利差价收益为:874605-5000-867162.5＝2442.5元。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;在该例折价套利投资过程中，这一系列操作程序可以借助ETF套利软件在短期内迅速完成,可以减少价格变动带来的市场风险，上述收益计算也是在市场价格没有发生变化的假设前提条件下进行的；如果投资者能够获得佣金、申购赎回费用的优惠，则套利收益大大增加。&lt;/p&gt;&#10;&lt;p&gt;如果瞬时折溢价率偏低，但是投资者认为当日后市上证50指数会上涨，这可以把上述一系列操作过程完成时间延长，等上证50指数(上证50ETF、50成份股)上涨之后，再将手中当日先前已经申购赎回成功的一篮子股票或ETF基金及时卖出，则可获得更高的可靠收益。&lt;/p&gt;&#10;</description></item></channel></rss>