Brian G. Peterson brian at braverock.com
Tue Apr 12 11:09:04 CEST 2016

```The output of adjustOHLC and {yahoo}.Adjusted will only rarely, if ever,
agree, since we don't know when they are starting the adjustment, or how
they are doing the adjustment.  There are many threads over the years on

Nevertheless ...

What 'most of the references' are those?

Your equation doesn't subtract dividends or apply splits to arrive at
the new ratio, and is not a continuous-time process.  (as such, it
cannot be correct) The ratio changes over time based on the accumulation
of splits and dividends.

We can easily reference the code, by typing

at the prompt, or you could produce an equation which actually includes
the splits and dividends for which we must adjust ...

I suggest that in addition to the code we use a slightly more
authoritative source than Yahoo, e.g. CRSP:

http://www.crsp.com/products/documentation/crsp-calculations

From my read of the code, this is what adjustOHLC is doing.

I believe that your error is in not realizing that the ratio changes
over time.

Brian

On 04/11/2016 08:48 PM, Ernie Stokely wrote:
> OK, I am prepared for the stones that will be thrown at me for being
> naive, but here goes anyway.
>
> Most of the references on adjusting OHLC values for splits and dividends
> say to use the following adjustment:
>
> K = Ca/C
> Om = K * O
> Hm = K * H
> Lm = K * L
> Cm = K * C = Ca
>
> where: Ca = adjusted close, OHLC are the unadjusted values, and OmHmLmCm
> are the modified (adjusted) values of OHLC.
>
> If I use adjustOHLC() in quantmod to do the adjustment I find these are
> not the equations being used. For example, for VTI here is the
>
> VTI.Open VTI.High VTI.Low VTI.Close VTI.Volume VTI.Adjusted
> 2006-03-01 128.15 128.90 127.79 128.70 216400 52.56795
> 2006-03-02 128.50 128.76 128.01 128.61 148800 52.53119
> 2006-03-03 128.26 129.43 128.20 128.40 323200 52.44541
> 2006-03-06 128.64 128.64 127.27 127.46 279800 52.06147
> 2006-03-07 127.15 127.31 126.65 126.94 218400 51.84907
> 2006-03-08 126.72 127.49 126.20 127.30 491800 51.99612
>
> If I apply adjustOHLC() to these data I get:
>
> VTI.Open VTI.High VTI.Low VTI.Close VTI.Volume VTI.Adjusted
> 2006-03-01 59.15007 59.49625 58.98391 59.40394 216400 52.56795
> 2006-03-02 59.31162 59.43163 59.08545 59.36240 148800 52.53119
> 2006-03-03 59.20084 59.74088 59.17315 59.26546 323200 52.44541
> 2006-03-06 59.37624 59.37624 58.74389 58.83159 279800 52.06147
> 2006-03-07 58.68851 58.76235 58.45772 58.59158 218400 51.84907
> 2006-03-08 58.49003 58.84544 58.25001 58.75774 491800 51.99612
>
> Obviously, VTI.Adjusted (Ca) is not equal to VTI.Close (Cm) as required
> by the formula above. I have a colleague who has been trading for 40
> years and he says this is an erroneous result (that Cm must equal Ca).
> When I explore the package reference file for adjustOHLC() I see this
> paragraph:
>
> "New columns are derived by taking the ratio of adjusted value to
> original Close, and multiplying by the difference of the respective
> column and the original Close. This is then added to the modified Close
> column to arrive at the remaining ‘adjusted’ Open, High, Low column
> values."
>
> I am not quite sure how to translate this verbal description into an
> equation, but it doesn't sound like the same correction I see
> recommended elsewhere and described at the beginning of this note.
>
> Can someone shed some light on this discrepancy or send me a link to
> more enlightenment? Thanks in advance.
>
> Ernie

```