Skip to content

q-variance/Qvar_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Qvar Shiny app

The Qvar Shiny app allows the user to test the properties of q-variance and the q-distribution for a range of assets. The app is available online here.

Requirements: RStudio, Shiny, ggplot2

Introduction

Q-variance states that the expected variance over periods of length T is approximately:

Var = sig0^2 + z^2/2

where z = x/sqrt(T); x is log price change over the period, corrected for average drift; and sig0 is a parameter. This app illustrates the property for a number of data sets, including stocks from the SP500.

Instructions

To use the app, go to the Plots tab and select a ticker symbol and range of periods. The upper plot shows variance as a function of z for individual periods. Select points to see individual points. The blue line is an interpolation through the points: select either binned averages (default) or the LOESS algorithm, which also gives a shaded confidence estimate. The red line is the q-variance curve. The minimum volatility sig0 is computed by the program. Note that periods are non-overlapping, so if T=1 week there are more points than if T=50 weeks.

In practice a better fit can be obtained by applying a small shift zoff to account for effects such as asymmetry, so this can be set in the app, however the coefficient in z^2 is fixed at 1/2. The aim is not to fit the data by adjusting this coefficient, which is integral to the quantum model (it reflects an energy balance), but to test whether the quantum model is a good fit to the data. The only parameter fit by the program is sig0, while zoff must be adjusted manually.

The lower panel shows the density plot for the selected assets. The red line is the q-distribution with volatility adjusted by the program to fit the average data.

The price data for a selected stock, along with related variables, can be viewed and downloaded as a CSV file in the Data tab.

Set the data set to SP stocks (default), basket, or models. The first includes the 355 stocks which have been in the SP500 index for at least 75 percent of dates in the range 1992-01-02 to 2025-04-17. Set to basket to see a combination of GSPC (the SP 500 index since 1928), DJI (the Dow Jones), FTSE, GBPX (the GBP-USD exchange rate), GCF (gold in USD), BTCUSD (Bitcoin), and FVX (the 5-year Treasury yield). Set to models for random walk or jump volatility. The parameters for the walk and jump models can be adjusted, the defaults for the latter are calibrated to reproduce q-variance for periods of one week as described in the paper A Quantum Jump Model of Option Pricing. Select file and set a path in the Data tab to read a CSV file of price data in standard OHLCV format.

Notes

The data can be quite noisy especially when only a single period is selected. Short periods have few points with which to compute volatility, though this is partly compensated for by the fact that there are more such periods in the time series. Longer time periods have more points, but there are fewer such periods. An advantage of using a shorter period is that it gives more points which is useful because we are fitting a curve, not just estimating a single variance. The period length is capped at 26 weeks (6 months) which means there are at least 50 data points available per stock. This allows multiple stocks to be used without exceeding memory requirements, but it also means there are enough points for a reasonable interpolation. The presence of noise means that results improve when averaged over all stocks. This is better than using a stock index, which represents an average over stock prices and can distort the results.

Sources and references

The stock price data was obtained using the R package BatchGetSymbols and the command GetSP500Stocks() with the default settings. The complete dataset has about 2.9 million data points.

For more information on q-variance and its implications for topics including option pricing, see:

Orrell D (2025) A Quantum of Variance, and the Challenge for Finance. Wilmott 2025(138).

Orrell D (2025) Quantum impact and the supply–demand curve. Phil.Trans. R. Soc. A 383: 20240562.

Orrell D (2025) A Quantum Jump Model of Option Pricing. The Journal of Derivatives 33(1).

Wilmott P, Orrell D (2025) Q-Variance: or, a Duet Concerning the Two Chief World Systems. Wilmott 2025(138).

About

Qvar Shiny app

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages