Quantifying randomness: variance ratio

Discussion in 'Strategy Building' started by stephencrowley, Feb 14, 2006.

  1. gbos

    gbos

    Use something like this in the vba editor...

    Sub VR_Profile()
    Dim a(1000) 'close data
    Dim v(30) 'vr profile data
    For i = 1 To 1000
    a(i) = Cells(i + 1, 1)
    Next i
    For j = 1 To 30
    ct = 0
    For i = j To 999 Step j
    v(j) = v(j) + (Log(a(i + 1) / a(i + 1 - j))) ^ 2
    ct = ct + 1
    Next i
    v(j) = v(j) / ct
    Next j
    For j = 1 To 30
    Cells(j + 1, 6) = v(j) / j
    Next j
    End Sub

    A quick example follows. Looks ok by I haven't test it extensively. The only thing missing is a smoothing line for the scatter data.

    Regards
     
    #71     Feb 18, 2006
  2. mahras2

    mahras2

    VR profiles look pretty interesting. If I have a sample size of 10000 should the following code from gbos' post work properly (interms of size of larger array to that of smaller array)?>

    Sub VR_Profile()
    Dim a(10000) 'close data
    Dim v(300) 'vr profile data
    For i = 1 To 10000
    a(i) = Cells(i + 1, 1)
    Next i
    For j = 1 To 300
    ct = 0
    For i = j To 10000 Step j
    v(j) = v(j) + (Log(a(i + 1) / a(i + 1 - j))) ^ 2
    ct = ct + 1
    Next i
    v(j) = v(j) / ct
    Next j
    For j = 1 To 300
    Cells(j + 1, 6) = v(j) / j
    Next j
    End Sub

    Thanks!
     
    #72     Feb 18, 2006
  3. Oh shit, I must have been retarded from sleep deprivation. The bias is still there, but it is not only 10 samples because it uses overlapping returns, but the same principle applies.

    100:1 means the ratio of 100-period changes to 1-period changes.

    To calculate the 100 period changes you must sum the changes for 100 periods.. move forward 1 period.. sum the 100 period changes again (so your window now contains 99 samples from the last window and 1 from the new one).

     
    #73     Feb 18, 2006
  4. GTG

    GTG

    What I meant was this. I've only been looking at high frequency data for a little while, and I've been going back and forth on what type of datastream to use for my investigations.

    For example, If I'm looking at the last trade price, one way is to treat it simply as a sequence of numbers "as is", and then say compute a statistic on the last 30 prices that printed on the tape as trades. This is what I meant by trading time, because the time frame for the computed statistic is independent of actual real world time. In the morning a stock might do 30 prints in a minute, and at lunch it might take 5 minutes or so. So, the computed statistic will be for a variable length of time depending on how fast the instrument is trading.

    The other way is to organize the data over time in some way like for example sampling the price once every minute, or taking an average price over a period of a minute. Then do a calculation on say the last 30 samples. If the sampling period is 1 minute, then the statistic computed over 30 samples will always be for the last 30 minutes.
     
    #74     Feb 18, 2006
  5. This is actually a common idea, get the book "Introduction to High-Frequency Finance" from Olsen.

    http://www.olsen.ch/research/approach.html

    The Business Time Scale

    To allow for this seasonality when analyzing intra-day data, Olsen has developed a model of time in which data from periods when there are fewer traders present in the market is compressed, and data from active periods is expanded. For example, the Asian lunch hour is contracted and the afternoon period, when both the European and New York markets are open, is expanded. This "business time scale" ensures that the behavior of the market at any particular moment is interpreted in the context of the number of participants present.

    Apart from the daily and weekly seasonality, Olsen applies business time in a more general way. During any period of high activity, the scale at which the activity is measured is made more fine so that the full detail of the market dynamics is captured. The opposite applies during periods of low activity.

    The presence in the markets of a scaling law and seasonality leads to the possibility of forecasting. The fractal nature of the market means that short-term volatility - for example, over one hour-can be predicted by longer-term volatility-such as over one day. But why are there fractal patterns in the markets? Classical theory has no explanation. Olsen believes the answer lies in the differences between market participants, a factor that classical theory does not address.



     
    #75     Feb 18, 2006
  6. cnms2

    cnms2

    Check Multiscaling and non-universality in fluctuations of driven complex systems for a discussion of differences between intraday / larger time frames, internal / external market factors, and intraday trading activity patterns.
     
    #76     Feb 18, 2006
  7. There is also another measure which can be used, fit an ARMA(1,1) model to the data and then check the coeffcient of the parameter.

    if it is mean reverting the impulse response will slope down, if is trending it will slope upwards.

    If it is mean reverting the half-life of deviations from the mean can be calculated as: log(0.5)/log(-p)

    I generated 10 random walks, and then 10 more with drift (half up half down)

    [​IMG]

    Here is the impulse responses for the random walks.

    [​IMG]

    Now here are the impulse responses for the random walks w/ drift.

    [​IMG]

    Note that the impulse slopes upwards regardless of the trend direction.
     
    #77     Feb 18, 2006
  8. Hi stephen,

    some good work on this thread for a change - as many of us (myself included) mainly come to ET for the mirth and comedy - and to expose any potential snake-oilers, I'm starting to wonder if this is ET on some bizarro parallel universe! :D

    There is a paper on Olsen's site discussing the concepts of business and intrinsic time - of course their background is spot FX, as there is no "real" tick or volume data on the total interbank market so to speak.

    Link to paper...
    http://www.olsen.ch/research/302_realTimeEconometr10.93.pdf

    EQ
     
    #78     Feb 18, 2006
  9. And don't forget the charts made in matlab....and not with one of these numerous poor charting software...
     
    #79     Feb 18, 2006
  10. Thanks for the kind words Equalizer :) ET is definately comical most of the time.. maybe the geeky words in the thread title scared off the trolls.

    I must admit that Olsen's concept of intrinsic time is a little odd.. especially that there isn't a straightforward way to extend it to multiple variables.

     
    #80     Feb 19, 2006