Welcome to the Traders Laboratory Forums.
Technical Analysis The technical discussion forum for traders.

Reply
Old 02-01-2010, 04:47 PM   #1

Join Date: Sep 2009
Posts: 34
Ignore this user

Thanks: 40
Thanked 3 Times in 3 Posts

Best Open-source Data Smoother?

I am looking for an open-source smoother to down-sample data. I know there are many such as Hull Moving average, but I have data logged at the ms scale at non-fixed time intervals and I want to sample it on the second / minute / hour etc. range at fixed time intervals. Does anyone know of a good smoother to do this? The key is that the input data is not logged at a constant frequency.
SNYP40A1 is offline  
Reply With Quote
Old 02-02-2010, 05:58 AM   #2

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Best Open-source Data Smoother?

Aren't sampling and smoothing different issues? Not sure exactly what you want to end up with. The 'normal' way of dealing with the data would be to sample it (highest high lowest low of sample period) then smooth it. You could of course smooth the data in each sample first (e.g. take an hours data average it and use that price as your sample value for that discrete period)

As to actual smoothing algorithms there are whole bunch here (and other places too).
BlowFish is offline  
Reply With Quote
Old 02-02-2010, 06:19 PM   #3

Join Date: Sep 2009
Posts: 34
Ignore this user

Thanks: 40
Thanked 3 Times in 3 Posts

Re: Best Open-source Data Smoother?

It's basically an exponential moving average...that's what would allow for smoothing and downsampling in the same pass. The idea is that as data-points start coming in, they are entered into a distribution such that each datapoint's weight in the distribution decreases with time. Then the average or preferably median of the distribution can be sampled at any time to get the value most closely representing the real-time sample average. One way to get the sample is to re-evaluate all data in the distribution to find whatever info is of interest. But I think there is a more efficient way, that's what I am looking for. Key is smoothing function where the input data does not have a fixed period. Used for plotting tick data on time vs. price chart where each pixel may correspond to seconds or minutes rather than microseconds. How do most software packages handle this issue? I think they just group everything into time periods and then average the time period, as you suggested. That would provide some smoothing...it just seems like it would be more accurate to smooth and down-sample at the same time rather than smoothing on already-downsampled data. I'll think about this some more...the accuracy difference might be insignificant.
SNYP40A1 is offline  
Reply With Quote
Old 02-03-2010, 04:56 AM   #4

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Best Open-source Data Smoother?

Are you weighting by time or actually by position in the time series? Will later data effect weights of earlier data (that becomes processor intensive). Just a couple of things to consider.

What platform btw?
BlowFish is offline  
Reply With Quote
Old 02-03-2010, 10:50 AM   #5

Join Date: May 2009
Location: Dallas
Posts: 93
Ignore this user

Thanks: 52
Thanked 136 Times in 56 Posts

Re: Best Open-source Data Smoother?

The keyword to search for in the literature is "non-uniform sampling," and most algorithms I'm aware of interpolate to find uniform samples and then do typical DSP (choose your favorite low-pass filter) on the uniform samples. How accurate you need the results to be will dictate how complex the interpolation process is. Of course for some purposes you could apply a (possibly non-linear) least-squares fitted model, or a spline etc. to the data, and call the resulting model the "smoothed" data with no further filtering.

Last edited by RichardTodd; 02-03-2010 at 10:53 AM. Reason: added model suggestion
RichardTodd is offline  
Reply With Quote
Old 02-03-2010, 01:50 PM   #6

Join Date: Sep 2009
Posts: 34
Ignore this user

Thanks: 40
Thanked 3 Times in 3 Posts

Re: Best Open-source Data Smoother?

Quote:
Originally Posted by BlowFish »
Are you weighting by time or actually by position in the time series? Will later data effect weights of earlier data (that becomes processor intensive). Just a couple of things to consider.

What platform btw?
Weighing by time rather than position in the time series would be more accurate. If I weighted only by position, then I could basically apply any moving average -- that would essentially be treating the data as uniform sampled. I could go even more complicated. I could weight the data by time as well as volume to reflect more of the instantaneous "force" of the market. Or weight by bid vs. ask bias, etc. Although, at that point, I have a new indicator beyond just plotting the data. For now I simply want to feed in the tick data and for any given point in time, get an estimate for what the price is at that point. What I plan to do now is simply take the last trade behind my desired sample point. Been a while since I took a signals and systems class, but I think this process is referred to as zero-order hold:

Continuous/Discrete Conversions of LTI Models :: Operations on LTI Models (Control System Toolbox™)

I am developing my own platform in Java -- at least the analysis part.
SNYP40A1 is offline  
Reply With Quote
Old 02-03-2010, 01:58 PM   #7

Join Date: Sep 2009
Posts: 34
Ignore this user

Thanks: 40
Thanked 3 Times in 3 Posts

Re: Best Open-source Data Smoother?

Quote:
Originally Posted by RichardTodd »
The keyword to search for in the literature is "non-uniform sampling," and most algorithms I'm aware of interpolate to find uniform samples and then do typical DSP (choose your favorite low-pass filter) on the uniform samples. How accurate you need the results to be will dictate how complex the interpolation process is. Of course for some purposes you could apply a (possibly non-linear) least-squares fitted model, or a spline etc. to the data, and call the resulting model the "smoothed" data with no further filtering.
Non-uniform sampling. That's what I am looking for. I thought about doing least-squares analysis / linear regression, but I think that's probably getting too complicated...I guess all I am really trying to do at this point is plot the data. In Ninjatrader, it looks like what they do is simply group all the data into time intervals (1-minute, 5-minute, 233 tick, etc) and then plot the close of the given bar and hold that level until the next close. Essentially, they are doing zero-order hold. That's simple and it works, but seems like there must be an algorithm I could use and get a much smoother plot for very little effort.
SNYP40A1 is offline  
Reply With Quote
Old 02-03-2010, 07:19 PM   #8

Join Date: Sep 2009
Posts: 34
Ignore this user

Thanks: 40
Thanked 3 Times in 3 Posts

Re: Best Open-source Data Smoother?

I found this thread very relevant, especially the long post on the second page mentioning Jurik's MA:

Designing Filters with non-uniform sampling | Comp.DSP | DSPRelated.com

Still looking for my filter.
SNYP40A1 is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Open Source Project - MS Sql Server Market Data Colletor. Szymon Automated Trading 43 10-07-2011 10:43 PM
Past Open/close Data For ES and TF bond2k Trading and the Markets 6 08-09-2009 11:51 PM
Need a Source for Upcoming Announcements TraderFoo Market Analysis 4 07-19-2009 01:26 PM
Open ECry Data Feed Tresor Open E Cry 10 04-20-2009 11:04 PM
Open Interest Data Provider on EUREX ? paolfili Market Analysis 2 01-29-2009 03:01 AM

All times are GMT -4. The time now is 08:59 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.