{'fraction_non_alphanumeric': 0.03391149655325773, 'fraction_numerical': 0.013842561707805203, 'mean_word_length': 4.795425257731959, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Exploring the predictability of range-based volatility estimators using RNNs

We investigate the predictability of several range-based stock volatility estimators, and compare them to the standard close-to-close estimator which is most commonly acknowledged as the volatility. The patterns of volatility changes are analyzed using LSTM recurrent neural networks, which are a state of the art method of sequence learning. We implement the analysis on all current constituents of the Dow Jones Industrial Average index, and report averaged evaluation results. We find that changes in the values of range-based estimators are more predictable than that of the estimator using daily closing values only.


Motivation
The volatility of assets has an important role in several areas of finance. As a measure of riskiness, it is a key factor in, for example, portfolio management and option pricing. A good understanding of the nature and evolution of return volatilities is obviously valuable for financial practitioners. Volatility quantifies the dispersion of returns. Unfortunately, this dispersion can not be measured -volatility is not directly observable. Hence we need to estimate it, with not having a reliable benchmark. Several studies have tried to explore and understand the nature of this unknown volatility. One reasonable approach is sampling from the price process frequently, so that we do not lose too much data. [Andersen et al., 2001] analyzed the properties of stock market volatility using five-minute returns. They report that daily variances significantly fluctuate through time, and their distributions are extremely right-skewed and leptokurtic, while logarithmic standard deviations approximate the normal distribution well. [Engle and Patton, 2007] outlined several stylised facts of volatility that have emerged in previous studies. Persistence: large moves are usually followed by large moves, and small moves are usually followed by small moves in the price process. Mean reversion: usually there's a normal level of volatility to which it returns after uplifts and falls. Asymmetric impact of innovations: positive and negative shocks have different impacts on volatility. Influence of exogenous variables: information outside the price series (e.g., announcements) could have an impact on volatility. Those features suggest that if we could measure volatility, it should be somewhat forecastable. But we can not measure it -the best we can do is coming up with reasonable proxies. One such proxy is the standard deviation of returns -returns, which are usually calculated from daily closing prices. It is obvious that by sampling the asset's price more frequently, we could make better estimates of its unobservable true volatility. If, for example, we measured the daily price ranges (i.e. daily high minus daily low), we would already know a lot more about the unseen path of the prices. Unlike high-frequency (say, minutely) data, daily open, high, low and close values are freely available. Finding good estimators that use these 4 daily values only is therefore a challenging and important task. It this paper we are going to compare various range-based volatility estimators according to their predictability. We argue that those estimators whose changes are easier to predict, can be more useful in practice. Forecasts can move historical volatilities a bit forward into the future, and knowing something about the future is valuable.

Volatility estimators
Volatility is most often calculated simply as the standard deviation of returns (1). In the formula below, C t is the closing price of day t, and N is the number of days used in the calculation. As volatility should measure the dispersion of the prices, standard deviation is a very reasonable proxy.
However, when returns are calculated on a daily basis (as the difference of log closing prices), this simple and intuitive formula ignores all intraday price movements, which is a great loss of information. The so-called range-based volatility estimators use daily open, high, low and close values to make volatility estimates. Several such formulas has been proposed in the history of volatility estimation. Here we are going to present some of the better known range-based volatility formulas. O t , H t , L t , and C t stand for the open, high, low, and close price at time t, respectively. N , again, is the size of the time window in days for calculating the volatilities, while F is just for scaling the results to another time unit. [Parkinson, 1980] proposed the extreme value method for variance estimation (2). He showed that using high and low prices, we may get an estimate that is far superior to the standard close-to-close formula.
(2) [Garman and Klass, 1980] published estimators using open, high, low and close values (3). Their results demonstrate much higher efficiency factors than that of the close-to-close estimator.
The Parkinson and Garman-Klass volatility estimators assume the asset prices follow a continuous Brownian motion with no drift. [Rogers and Satchell, 1991] proposed a formula that allows for drifts (4). [Rogers et al., 1994] investigated the efficiency of volatility estimators through simulation, and found that the Rogers-Satchell method is superior to the Garman-Klass if there is a time-varying drift in the data. However, when there's no drift, Garman-Klass outperforms Rogers-Satchell, so the former should be preferred when the expected returns are less volatile. [Yang and Zhang, 2000] published a formula which is unbiased, driftindependent, and consistent in dealing with opening jumps (5). This latter feature is unique among the examined formulas.
(5) Range-based volatility estimation has quite a long history and evolution.
Here we have only mentioned the formulas that we are going to use in this work. [Chou et al., 2010] gives a detailed review of the development of rangebased volatility estimators.
All of those range-based estimators assume that the asset price follows a continuous geometric Brownian motion. This is a strict assumption. [Shu and Zhang, 2006] analyzed all 4 range-based estimators that we investigate, in an attempt to measure the degree to which they can be useful in real markets that deviate from the geometric Brownian motion. They found that estimates from range-based models are quite close to integrated variances computed from intraday returns with much higher computational requirements. Using simulations, Shu and Zhang also confirmed the expectation that when there is just a  We've just got the gist of the behavior of some available volatility estimators. Yet, since we can never know the true variances, it's pretty hard to assess each formula's exact accuracy and usefulness in real practice. We argue that a measure of forecastability could be useful for evaluating and comparing these volatility proxies.

Volatility forecasting
While forecasting changes in stock returns is a very hard task, forecasting the size of changes (i.e. the volatility) seems more promising. It also has a high importance in financial practice, and it has already been the subject of many researches. [Poon and Granger, 2003] give a detailed review on 93 papers that study the forecasting power of volatility models. [Poon and Granger, 2005] provide a summary of the findings. They survey historical volatility, ARCH, stochastic volatility and option-implied volatility models. For modeling the changes in volatility, artificial neural networks also seem a natural choice. Neural networks, even with a single hidden layer, are universal approximators [Hornik, 1991], and it makes them a strong competitor of traditional learning algorithms and time series methods. [Malliaris and Salchenberger, 1996] forecasted implied volatilities using neural networks trained on past volatilities and other options market factors. [Donaldson and Kamstra, 1996] used ANNs to combine different time series forecasts of stock market volatilities, and concluded that combining forecasts using ANNs generally outperforms traditional combining methods due to its flexibility. [Roh, 2007] proposed new hybrid models combining neural networks and time series models for improving volatility predictions in terms of deviation and direction accuracy. Recurrent neural networks have also been applied to volatility forecasting. [Xiong et al., 2015] used LSTM networks on Google Domestic Trends data to forecast S&P 500 volatilities. Their article is similar to ours, since we too apply LSTM RNNs to forecast range-based volatility. However, they used external data while we only use historical stock prices, and they made predictions for the daily values of the volatility estimates, while we aim for predicting the directions of daily changes.
Making reasonable forecasts about volatility changes can potentially help one to make profitable trading decisions. [Tino et al., 2000], for example, used volatility forecasts to buy or sell straddles, except when their model was uncertain about the sign of volatility change. A similar strategy is applied by [Dunis and Huang, 2002], using RNNs for forecasting volatilities. In this article, we are going to explore the forecastability of the directions of volatility changes, which could provide some information on which positions to take.

Recurrent neural networks
Recurrent neural networks are neural networks for sequential data -instead of relying on a single data point, recurrent neural networks take into account a whole sequence. An RNN (6) uses the most recent observation together with the past to make a good decision. This trait makes them a reasonable choice for modeling the behavior of time series.
Yet, plain RNN models (e.g., [Elman, 1990]) suffer from the vanishing gradient problem and are hard to train [Hochreiter et al., 2001]. They are unable to model long-term dependencies in the data. Luckily, there are some more advanced RNN architectures that solve this problem on the expense of some model complexity. One such architecture is long short-term memory (LSTM). LSTMs were invented by [Hochreiter and Schmidhuber, 1997]. An LSTM cell gives memory to the RNN, and the ability to read, write and forget data. The cell uses separate gating units to operate these memory management abilities.
This looks a bit complicated, but it is just as easy to train as any other neural network. It learns what it needs to learn, and forgets what it needs to forget -this makes LSTM well suited for analyzing long time series data.
x t ∈ R n is the input to the LSTM cell. h t ∈ R h denotes the output from the LSTM, which is usually called the hidden state (11). c t ∈ R h is the so-called cell state (10), which represents the memory. i t ∈ R h , f t ∈ R h , and o t ∈ R h are the input, forget and output gates. The input gate (7) calculates what to keep in memory, the forget gate (8) calculates what to remember, the output gate (9) calculates which part of the memory to use immediately. They do these things by applying some simple mathematical operations on the input data, the previous hidden state, and the corresponding learnable weights W ∈ R h×n and U ∈ R h×h , which can easily be optimized using backpropagation through time (e.g., [Greff et al., 2017]). The LSTM formulas are rather formidable at first sight, but they form a system that is fairly intuitive, and works, in many cases, amazingly well. Some recent applications of RNNs to time series forecasting are, e.g., [Che et al., 2016], [Cinar et al., 2017b], [Cinar et al., 2017a], [Hsu, 2017], [Laptev et al., 2017]. LSTMs are also used in some financial studies for modeling time series data like historical volatility. This study aims to contribute to this research area by comparing the predictability of range-based volatility estimates using LSTM networks.

Data
Our dataset was obtained from Yahoo Finance (https://finance.yahoo.com/). We have downloaded 10 years (from 2008-01-01 to 2017-12-31) of daily open, high, low and close values for all current constituents of the Dow Jones Industrial Average index. (1 out of the 30 stocks is missing the first few months' data since its IPO took place in March 2008.) We used the previously presented formulas for quantifying volatility, namely, the close-to-close, the Garman-Klass, the Parkinson, the Rogers-Satchell, and the Yang-Zhang estimator. All volatility estimates were calculated using a window of 21 days. We used very few data for training our neural networks. The exact values of the estimates has been dropped, and we only kept a single binary variable indicating the direction of daily changes -1s for upward movements, 0s everywhere else. We used the first 70% of the available data for training the LSTM models, and we made one-day-ahead forecasts on the remaining 30%, which is roughly the last 3 years.

Neural Network Architecture
Our LSTM recurrent neural network was built in Keras [Chollet et al., 2015] with TensorFlow citetensorflow2015-whitepaper backend. We used a 2-layer RNN with 10 hidden units in each layer. We chose the Adam optimizer [Kingma and Ba, 2014] to minimize the loss function, in this case, binary cross entropy. A dropout [Srivastava et al., 2014] of .3 was applied on the non-recurrent connections. The learning rate was set to .001. The series of volatility directions were unrolled for 10 days, and the unrolled subsequences were fed to the algorithm in batches of 32. All experiments were run for no more than 300 epochs with the following early stopping rule: the training stops when it fails to improve the validation loss for 50 epochs in a row. No thorough hyperparameter optimization was conducted. We only aimed to find a reasonable setting which is appropriate for comparing the predictability of our examined volatility formulas.

Results
We used roughly the last 3 years of our 10-year dataset for out-of-sample validation. 4 evaluation metrics are reported: accuracy, precision, recall and F1 score.  Table 2: Evaluation metrics for one-day-ahead direction-of-change forecasts Table 2 displays our results for this experiment. While the close-to-close estimator's accuracy was barely higher than 50%, neither of the range-based volatilities' averaged accuracies was below 55%. It seems to be a considerable difference. Despite the promising accuracies, the F1 score, being the harmonic mean of precision and recall, was consistently below .5 in each case.
Precision is the fraction of our predicted upward movements that really were increases in the volatility. Recall is the fraction of real upward movements that we've predicted to be so. While each estimator's precision was higher than the overall accuracy, the recall was very poor. It means that our algorithm struggled in finding the upward movements. It simply follows from the fact that the RNN has chosen to predict downward movements in a higher proportion. Since the ratio of upward movements was usually close to .5, this behavior of the algorithm does not invalidate its prediction ability. Yet, it is obviously not a preferred property, especially when we assume that identifying a rise in the volatility is more valuable than identifying a drop. To solve the issue of low recall, we tried lowering the threshold of making an upward guess from the default of .5.

Accuracy
Precision Recall   Table 3 displays our results using a threshold of .45. In this case, we force the RNN to predict more increases. The recall values increased, leading to above .5 F1 scores, while not sacrificing the overall accuracy. In fact, the accuracy increased a bit for all range-based estimators. Finally, we freed the algorithm from having to make predictions at all times. It may be preferable to let the algorithm decide if it has the necessary confidence to make a prediction. We chose to flag prediction probabilities between .4 and .5 as unconfident, and only kept the days with estimated probabilities outside this range. (All those thresholds were chosen arbitrarily.)

Accuracy
Precision Recall F1 mean std mean std mean std mean std close-to-close 0.   Table 4 presents the evaluation metrics for the confident predictions. By dropping (quite) some uncertain predictions, we have exceeded 60% accuracy with 3 out of 4 range-based estimators. Table 5 displays the proportions of predictions that remained after excluding the uncertain ones. It seems that estimators with lower accuracies has more predictions close to the .45 binary decision threshold. Hence weak forecasts make less guesses, which is preferable. close-to-close Garman-Klass Parkinson Rogers-Satchell Yang-Zhang 0.28 0.66 0.67 0.54 0.64 Table 5: Average proportions of confidently predicted directions In this experiment, all four range-based estimators clearly outperformed the benchmark close-to-close estimator in terms of predictability. The range-based estimators generated similar results, though the Rogers-Satchell estimator performed slightly worse than the other three. All of those volatility estimators move closely together, as expected, having above .95 correlations for the Dow Jones Industrial Average index (Table 1). We could observe similary high correlation in case of the individual components as well. It is therefore quite remarkable, that while the close-to-close estimator seems essentially unpredictable, the directional changes of range-based estimators were so easily detected from so few data to near 60% accuracy, that it calls for further research.

Conclusions
We can conclude that the movements of range-based volatility calculations can be forecasted to some degree, using long short-term memory recurrent neural networks and very little data -only historical patterns of up and down movements.
There's not much difference in the predictability of the range-based volatility estimators, however they all seem to be easier to forecast than the baseline closeto-close estimator, which is most commonly used and acknowledged as financial volatility.