_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › UPRO-TMFEWMA覲煙
|
|
譴...
譴... 譴... 譴... t0 蠏碁 蠏 螳
EWMA(t) = a * x(t) + (1-a) * EWMA(t-1) [edit]
EWMA Volatility #
$$ \sigma_t^2 = (1-\lambda)\cdot\gamma_t-1^2 + \lambda\cdot\sigma_t-1^2 $$
$$ where, $$
$$ \ \ \sigma : 譴ク谿 $$
$$ \ \ \lambda: 螳譴豺 $$
$$ \ \ \gamma : 給 $$
$$ \ \ t : $$
[edit]
蟲 ##install.packages("RiskPortfolios") library(tidyquant) library(MTS) library(scales) library(qpcR) library(TTR) options("getSymbols.warning4.0"=FALSE) options("getSymbols.yahoo.warning"=FALSE) # Downloading Apple price using quantmod ewma.func <- function(rets, lambda) { sig.p <- 0 sig.s <- vapply(rets, function(r) sig.p <<- sig.p*lambda + (r^2)*(1 - lambda), 0) return(sqrt(sig.s)) } cash <- 0.4 from_dt <- as.character(today()-20) to_dt <- today() tickers = c("UPRO", "TMF") getSymbols(tickers, from = from_dt, to = to_dt,warnings = FALSE, auto.assign = TRUE) #tail(UPRO) #tail(TMF) UPRO_sd <- sd(ewma.func(as.numeric(UPRO$UPRO.Close), 0.94)) TMF_sd <- sd(ewma.func(as.numeric(TMF$TMF.Close), 0.94)) p1 <- TMF_sd/(UPRO_sd+TMF_sd) p2 <- UPRO_sd/(UPRO_sd+TMF_sd) p1 <- round(p1*(1-cash),2) p2 <- round(p2*(1-cash),2) p3 <- 1 - (p1 + p2) print(paste("UPRO=",percent(p1),"TMF=",percent(p2), "蠍=",percent(p3)))
鏤
|
一 レ . 蠏碁覃 轟蟆 る 螳 殊 襷 襷譟煙る 蟆企. 豺蟲れ 轟 襦 轟 蠏碁れ蟆 譴る 轟 螻 至鍵 蠏碁れ 襦 譬 豺蟲れ 譴 蟆企. 襦燕襦郁 襷 豺蟲襯 螳讌る 豺蟲螳 企. (企 るΠろ "蟆壱狩讌 讀蟇一"筝) |