🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 162 (from laksa038)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
26 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.9 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html
Last Crawled2026-03-23 23:37:24 (26 days ago)
First Indexed2021-06-09 04:39:39 (4 years ago)
HTTP Status Code200
Meta TitleRealized volatility — Econ/Fin250a: Forecasting In Finance and Economics
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 # Model code for processing # CRSP individual stock data + Index information # Mostly for aggregating to monthly # Clear variables rm ( list = ls ()) library ( plyr ) library ( forecast ) # set up functions # aggregate data over months # volume now becomes mean daily volume by $ monagg <- function ( data ) { data <- data [ data $ VOL != 0 ,] # store all data from data into temp temp <- tail ( data , n = 1 ) m <- nrow ( data ) # these are the three lines to really pay attention to # Using vW index returns (changing to RET would move to IBM) # first find std over month temp $ vol <- sd ( data $ vwretd ) # now return over month temp $ ret <- prod ( 1 + data $ vwretd ) -1 temp $ m <- m # number of days # All these values can be negative if there are no trades data $ PRC <- abs ( data $ PRC ) data $ ASKHI <- abs ( data $ ASKHI ) data $ BIDLO <- abs ( data $ BIDLO ) # bid/ask range (another sort of volatility estimate) dailyvol <- ( data $ ASKHI - data $ BIDLO ) / ( 0.5 * ( data $ ASKHI + data $ BIDLO )) # remove data errors dailyvol [ dailyvol > 1 ] <- 0 dailyturn <- data $ VOL / data $ SHROUT # volatility relative to turnover temp $ liq <- temp $ vol / mean ( dailyturn ) mturn <- mean ( dailyturn ) # set to mean if zero dailyturn [ dailyturn == 0 ] <- mturn temp $ turn <- mean ( dailyturn ) # return monthly record temp } dateProc <- function ( dateVec ) { # strip out years year <- trunc ( dateVec / 10000 ) month = trunc (( dateVec - year * 10000 ) / 100 ) day = trunc ( dateVec - year * 10000 - month * 100 ) strVec <- sprintf ( "%d-%d-%d" , year , month , day ) dateOut = as.Date ( strVec ) return ( dateOut ) } # read in raw crsp dowload - This is a long range daily series of IBMreturns # and CRSP value weighted returns # It also include some volume series as well as high/low range information allDay <- read.csv ( "ibmCRSP2018.csv" , header = TRUE , colClasses = c ( "numeric" )) # This is an R dataframe # eliminate some fields that are not used allDay $ PERMNO <- NULL allDay $ NUMTRD <- NULL allDay <- allDay [ -1 ,] # restrict to cases with all data fields allDay <- allDay [ complete.cases ( allDay ),] # Convert CRSP date allDay $ rdate <- dateProc ( allDay $ date ) # set up monthly key allDay $ key <- as.numeric ( format ( allDay $ rdate , "%Y" )) * 100 + as.numeric ( format ( allDay $ rdate , "%m" )) # use plyr to apply dayAgg by each date volMonth <- ddply ( allDay , . variables = "key" , . fun = monagg ) # volLR <- rollmean(volMonth$vol,6, align="right",fill=mean(volMonth$vol)) # 6 month volatility model volLR <- ma ( volMonth $ vol , order = 6 , centre = FALSE ) rv.ts <- ts ( volMonth $ vol , start = c ( 1926 , 1 ), freq = 12 ) rvLR.ts <- ts ( volLR , start = c ( 1926 , 1 ), freq = 12 ) ret.ts <- ts ( volMonth $ ret , start = c ( 1926 , 1 ), freq = 12 ) m.ts <- ts ( volMonth $ m , start = c ( 1926 , 1 ), freq = 12 ) rvtrain.ts <- window ( rv.ts , end = c ( 2008 , 10 )) rvtest.ts <- window ( rv.ts , start = c ( 2008 , 11 )) # Several AR models with extensions (ARMAX models) lagvol = cbind ( rv.ts , lag ( rv.ts , -1 , na.pad = TRUE ), lag ( rvLR.ts , -2 , na.pad = TRUE ), lag (( ret.ts ), -1 , na.pad = TRUE ), ret.ts , m.ts ) colnames ( lagvol ) <- c ( "vol" , "volL1" , "volL2" , "retL" , "ret" , "m" ) lagvol <- window ( lagvol , end = c ( 2016 , 12 )) lagvolTrain <- window ( lagvol , end = c ( 1990 , 12 )) lagvolValid <- window ( lagvol , start = c ( 1991 , 1 )) # Use basic model + leverage effect term volTrain.mod <- lm ( vol ~ volL1 + volL2 + retL , data = lagvolTrain ) print ( summary ( volTrain.mod )) # Build valid sample volatility forecast vol.fcast <- predict ( volTrain.mod , newdata = lagvolValid ) # Adjust this to monthly value (daily -> monthly) vol.fcast <- sqrt ( lagvolValid [, 6 ]) * vol.fcast # set for 10 percent annual standard deviation target <- 0.10 / sqrt ( 12 ) # now portfolio weight vector weight <- target / vol.fcast # constant portfolio benchmark mweight <- mean ( weight ) # dynamic monthly portfolio (assuming 3 percent/year interest) pret <- lagvolValid [, 5 ] * weight + 0.03 / 12. * ( 1 - weight ) pretConstant <- lagvolValid [, 5 ] * mweight + 0.03 / 12 * ( 1 - mweight ) pretEquity <- lagvolValid [, 5 ] * 1 # Volatility for portfolios (adjust for days of the month) pstd <- sqrt ( lagvolValid [, 6 ]) * lagvolValid [, 1 ] * weight pstdConstant <- sqrt ( lagvolValid [, 6 ]) * lagvolValid [, 1 ] * mweight pstdEquity <- sqrt ( lagvolValid [, 6 ]) * lagvolValid [, 1 ] * 1 # Convert to annual values (like target) pstd <- sqrt ( 12 ) * pstd pstdConstant <- sqrt ( 12 ) * pstdConstant pstdEquity <- sqrt ( 12 ) * pstdEquity # Look at the variability of returns around volatility targets print ( "Standard deviations and sd(standard deviations)" ) print ( cbind ( mean ( pstd ), sd ( pstd ))) print ( cbind ( mean ( pstdConstant ), sd ( pstdConstant ))) print ( cbind ( mean ( pstdEquity ), sd ( pstdEquity ))) # General mean and return for returns (annualized) print ( "mean and standard deviations for returns (annualized)" ) print ( cbind ( 12 * mean ( pret ), sqrt ( 12 ) * sd ( pret ))) print ( cbind ( 12 * mean ( pretConstant ), sqrt ( 12 ) * sd ( pretConstant ))) print ( cbind ( 12 * mean ( pretEquity ), sqrt ( 12 ) * sd ( pretEquity ))) # Sharpe ratios print ( "Sharpe ratios (annualized)" ) print ( ( 12 * mean ( pret ) -0.03 ) / ( sqrt ( 12 ) * sd ( pret ))) print ( ( 12 * mean ( pretConstant ) -0.03 ) / ( sqrt ( 12 ) * sd ( pretConstant ))) print ( ( 12 * mean ( pretEquity ) -0.03 ) / ( sqrt ( 12 ) * sd ( pretEquity ))) plot ( pstd , ylim = c ( 0 , 0.8 ), xlab = "year" , ylab = "annualized std" ) lines ( pstdEquity , col = "red" ) grid ()
Markdown
### Navigation - [index](https://people.brandeis.edu/~blebaron/classes/fin250a/genindex.html "General Index") - [next](https://people.brandeis.edu/~blebaron/classes/fin250a/directional/directional.html "Financial Forecasts: Directional") \| - [previous](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/arch.html "ARCH/GARCH models") \| - [Econ/Fin250a: Forecasting In Finance and Economics](https://people.brandeis.edu/~blebaron/classes/fin250a/index.html) » - [Sections](https://people.brandeis.edu/~blebaron/classes/fin250a/Sections.html) » - [Volatility](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/volatility.html) » # Realized volatility[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#realized-volatility "Permalink to this headline") Our last volatility model is called **realized volatility**. It may be the most important we will use, but also one of the easiest to implement. The objective of realized volatility models is to build a volatility time series from higher frequency data. For example take 5 minute interval returns data, and use this to estimate a standard deviation for each day. σt\=1M∑j\=1MR2t,j−−−−−−−−−⎷ σ t \= 1 M ∑ j \= 1 M R t , j 2 Rt,j R t , j represents a 5 minute return during day t. Note, this expression assumes a mean of zero. Not a crazy approximation for high frequency financial time series. At this point, a realized volatility model becomes a kind of standard time series model. One can fit an ARMA model to σt σ t, or just a simple autoregression on lags. σt\=α\+∑j\=1Kβjσt−j\+et σ t \= α \+ ∑ j \= 1 K β j σ t − j \+ e t There is a very obvious problem here. How does one impose the restriction that σt σ t stay positive? There are a few solutions for this. 1. Just use this AR model for forecasts (no monte-carlo simulations). As long as the coefficients are positive, your forecasts will be too. 2. Bound the above model so that when it ever goes negative it is bounced back into the positive region. 3. Use logs, ztσt\=log(σt)\=ezt z t \= log ⁡ ( σ t ) σ t \= e z t - This will solve all the sign problems since z can go wherever it wants. - There is no really accepted solution here. - For simplicity we will operate in standard deviation space since that is often what people want. - The model can also be run with variances as well, but they tend to have extreme distributions making them relatively impractical. ## Realized volatility series on the web[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#realized-volatility-series-on-the-web "Permalink to this headline") - A group at Oxford maintains an **excellent** realized volatility data set - This includes data on many global stock indices - The daily series are built from intraday returns - They are carefully cleaned and processed (which is not easy) - There is also a lot of econometrics that goes into many different ways of getting to the daily series from the intraday series - Questions about how frequently to sample data - Microstructure noise - One good solution is to go with 5 minute returns - Here is the link: <https://realized.oxford-man.ox.ac.uk> ## Estimating a realized volatility model[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#estimating-a-realized-volatility-model "Permalink to this headline") - R-code for realized volatility - Load CRSP data set > - Lot’s of R dataframe stuff > - See dateProc() function > - Convert YYYYMMDD to R-date - Build monthly data > - This uses the **plyr** library > - This is a powerful data manipulation library (similar to Pandas in Python) > - Key is YYYYMM, and is an identifier for a year/month combination > - **monagg** function is called for each year/month > - Finds standard deviation over the month > - Also, finds > > - monthly turnover > > - liquidity measure - Fit time series > - Optimal model and multiperiod forecasts > - Also, sweep through AR models > - Plot forecasts and confidence bands - CRSP Data is available on Latte as **ibmCRSP2.csv** [`rv`](https://people.brandeis.edu/~blebaron/classes/fin250a/_downloads/rv.R) ## More complex models[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#more-complex-models "Permalink to this headline") σtσ(6)t\=a\+β1σt−1\+β2σ(6)t−2\=16∑j\=05σt−j σ t \= a \+ β 1 σ t − 1 \+ β 2 σ t − 2 ( 6 ) σ t ( 6 ) \= 1 6 ∑ j \= 0 5 σ t − j - Use lagged σt σ t and also lagged 6 month average - Multi time interval model - MIDAS model: Mi(xed) Da(ta) S(ampling) models ## Leverage effect[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#leverage-effect "Permalink to this headline") σt\=a\+β1σt−1\+β2σ(6)t−2\+γRt−1 σ t \= a \+ β 1 σ t − 1 \+ β 2 σ t − 2 ( 6 ) \+ γ R t − 1 - **Leverage effect**: A new volatility feature - Volatility tends to rise when markets fall - Feature of equity markets, but not FX markets - Add lagged return to forecasting model > - You can also add a dummy variable for positive and negative lagged returns > - and interact this with > β1 > > β > > 1 ## Volatility control[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#volatility-control "Permalink to this headline") - Dynamic trading strategies designed to control portfolio volatility (not returns) - Strategy design - Forecast next period’s volatility, and when: > - Volatility high: Defensively move to cash holdings > - Volatility low: Aggressively move to risky assets (even use leverage) - The objective is a strategy which is much more stable than static portfolios - Example: S+P index, [spvolrc](http://us.spindices.com/indices/strategy/sp-500-low-volatility-daily-risk-control-10-usd-total-return-index). ### Quick stats reminder[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#quick-stats-reminder "Permalink to this headline") - With independent random variables var(X\+Y)\=var(X)\+var(Y) v a r ( X \+ Y ) \= v a r ( X ) \+ v a r ( Y ) - Now with M periods (assuming log returns so we can sum over days) var(∑i\=1MXi)var(∑i\=1MXi)sd(∑i\=1MXi)\=∑i\=1Mvar(Xi)\=Mσ2same variances\=M−−√σ v a r ( ∑ i \= 1 M X i ) \= ∑ i \= 1 M v a r ( X i ) v a r ( ∑ i \= 1 M X i ) \= M σ 2 same variances s d ( ∑ i \= 1 M X i ) \= M σ - Technically, these independence assumptions are wrong for stock returns - Not bad approximation, and we’ll use them ## Implementing volatility control[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#implementing-volatility-control "Permalink to this headline") - Assume risky asset returns (stock index) Rt R t - Assume a risk free asset exists with annual rate of 3 percent (constant, no risk) - Trading frequency is monthly - Portfolio std. - Fraction invested in stock, αt α t - σ(Rt) σ ( R t ) is the standard deviation of the risky asset over a month - Rf R f is the return of the risk free asset σ2p,t\+1σp,t\+1σ^p,t\+1\=var(αtRt\+1\+(1−αt)Rf)\=var(αtRt\+1)\+var(Rf)\+cvar(Rt\+1,Rf)\=α2tσ2(Rt\+1)\+0\+0\=αtσ(Rt\+1)\=αtσ^(Rt\+1) σ p , t \+ 1 2 \= v a r ( α t R t \+ 1 \+ ( 1 − α t ) R f ) \= v a r ( α t R t \+ 1 ) \+ v a r ( R f ) \+ c v a r ( R t \+ 1 , R f ) \= α t 2 σ 2 ( R t \+ 1 ) \+ 0 \+ 0 σ p , t \+ 1 \= α t σ ( R t \+ 1 ) σ ^ p , t \+ 1 \= α t σ ^ ( R t \+ 1 ) - These are the realized volatility and the forecast volatility respectively - Forecast volatility is based on some forecasting model for the future month’s standard deviation - A volatility control model tries to target a fixed volatility level, say σ∗ σ ∗ - If that is your target then setting the equation for forecast volatility to the target gives σ∗αt\=αtσ^(Rt\+1)\=σ∗σ^(Rt\+1) σ ∗ \= α t σ ^ ( R t \+ 1 ) α t \= σ ∗ σ ^ ( R t \+ 1 ) - This determines the dynamic strategy αt α t ### R-Code[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#r-code "Permalink to this headline") - Build volatility forecast - Construct volatility control strategy weights - Benchmark comparisons: > - Dynamic strategy > - Fixed (mean) portfolio weights > - All equity strategy - Compare: > - Monthly volatility estimates and their volatility > - Return means and standard deviations > - Sharpe ratios - Strategy results: > - Relatively tight control on volatility > - Favorable risk/return tradeoff (interesting) [`volControl`](https://people.brandeis.edu/~blebaron/classes/fin250a/_downloads/volControl.R) ## Summary[¶](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/rv.html#summary "Permalink to this headline") - Powerful volatility modeling tool - Competes well with GARCH/ARCH, filtering methods - Relatively easy technology (ARMA, regression) - Related tool: High/low range estimation > - All more powerful than basic squared returns - Useful in dynamic volatility control strategies ### Navigation - [index](https://people.brandeis.edu/~blebaron/classes/fin250a/genindex.html "General Index") - [next](https://people.brandeis.edu/~blebaron/classes/fin250a/directional/directional.html "Financial Forecasts: Directional") \| - [previous](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/arch.html "ARCH/GARCH models") \| - [Econ/Fin250a: Forecasting In Finance and Economics](https://people.brandeis.edu/~blebaron/classes/fin250a/index.html) » - [Sections](https://people.brandeis.edu/~blebaron/classes/fin250a/Sections.html) » - [Volatility](https://people.brandeis.edu/~blebaron/classes/fin250a/volatility/volatility.html) » © Copyright 2018, Fin250a. Created using [Sphinx](http://sphinx-doc.org/) 1.3.5.
Readable Markdownnull
Shard162 (laksa)
Root Hash17310880625491687562
Unparsed URLedu,brandeis!people,/~blebaron/classes/fin250a/volatility/rv.html s443