jonathancornelissen / highfrequency

The highfrequency package contains an extensive toolkit for the use of highfrequency financial data in R. It contains functionality to manage, clean and match highfrequency trades and quotes data. Furthermore, it enables users to: calculate easily various liquidity measures, estimate and forecast volatility, and investigate microstructure noise and intraday periodicity.
147 stars 63 forks source link

initial value in 'vmmin' is not finite #57

Closed MislavSag closed 2 years ago

MislavSag commented 3 years ago

I am experimenting with spotVol¸ function. Many model incorporate in that one function.

A get following error very often:

initial value in 'vmmin' is not finite

It can't understand when this error occurs. I think the error should be more informative. It seems it is connected with number of observations in current day. If I supply data with incomplete bars for specific date (mostly beginning and end of series), the error occurs.

It's hard to get reprex since error raises in different occasions.

P.S. Is there possibility to monitor volatility, that is to estimate with new observation in effective way?

emilsjoerup commented 3 years ago

Hello,

Sorry for the late answer. I checked our code and it does not seem that the error is something that comes from our code base. I think it is a function that we call. In order for me to look further into it, you would have to give a reprex - otherwise I have nothing to work with (I understand that this may be impossible as data may be proprietary). It seems you have NA's and if that is the case I suggest you do something to eliminate them first to see if that solves your issue.

As for monitoring volatility with new observations in real time it's not something we provide functionality for.

MislavSag commented 3 years ago

I use volatility for algorithmic trading. I must use only t-1, t-2... values to calculate spot volatility. It seems to me that some methods in spotVol use values t+1 (but not sure). Can you confirm this?

Second, I would like to estimate intraday volatility from highrequency data. For example, I would like to calculate 30 min volatility from 1min or 5 min volatility. When I Try that in use the spotVol I missed some observation on the beginning of each day.

I would like to monitor volatility with new data, as they are coming. Is that even possible with this package? Or to just use roll and repeat functions many times to calculate volatility for every period.

emilsjoerup commented 3 years ago

I use volatility for algorithmic trading. I must use only t-1, t-2... values to calculate spot volatility. It seems to me that some methods in spotVol use values t+1 (but not sure). Can you confirm this?

Yes, some estimators may use data from time t+1 to filter the volatility at time t. Technically all parametric estimators would do this as the estimates are constructed by optimizing over the entire provided sample, and then filtering is done with these optimal values.

Second, I would like to estimate intraday volatility from highrequency data. For example, I would like to calculate 30 min volatility from 1min or 5 min volatility. When I Try that in use the spotVol I missed some observation on the beginning of each day.

Without an example, I cannot see if this error is on our end or your end, sorry.

I would like to monitor volatility with new data, as they are coming. Is that even possible with this package? Or to just use roll and repeat functions many times to calculate volatility for every period.

I think currently you would have to repeatedly call spotVol on all the data as new observations arrive from your ticker plant. This is not an optimal way of doing it. You will have to code this up yourself - if you do, feel free to share with us! Unfortunately, I don't think we are going to be implementing this feature any time soon.