[R-SIG-Finance] Length of a curve?

R. Michael Weylandt michael.weylandt at gmail.com
Wed Apr 24 17:35:19 CEST 2013


On Wed, Apr 24, 2013 at 4:32 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> On Wed, Apr 24, 2013 at 12:26 PM, wlblount <bill at easterngrain.com> wrote:
>> how would i calculate the length of this plot for a trading day?  i am using
>> ibrokers data for stocks in 3 min. bars
>>
>> library(quantmod)
>> load("~/R/UVXY")          #3 min xts  stock data
>>
>> reg10 <- rollSFM(Cl(pricedata),seq(nrow(pricedata)),10)
>> rma10 <- reg10$alpha + reg10$beta*seq(nrow(pricedata))
>>
>>
>>
>> i am looking for the length of the rma10 plot for one trading day (ie. if it
>> were a piece of string, the measurement once straightened out) .  i would
>> like to compare this measurement to the same measurement for previous days
>> (regular trading hours 9:30am-4:00pm).
>>
>> sorry for the non-technical language.  Bill
>>
>>
>
> I'd assume that, for regular data, you'd just add up the absolute
> values of the differences between observations.
>

Sorry -- that's not quite correct. But the idea's right: to be the
length of a curve, you just want to do

sum(sqrt((dx)^2 + (dy)^2))

If your dx is constant, it's an easy enough calculation but you'll
need to define a 'conversion' from 3 minutes to distance and from
price differences to distance.

> MW



More information about the R-SIG-Finance mailing list