dxhisboy / jbooktrader

Automatically exported from code.google.com/p/jbooktrader
0 stars 0 forks source link

Correcting calculation of the Standard Deviation, and adding Iterable interface to MovingWindow.java #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I believe the StdDeviation is not being calculated correctly in the 
MovingWindow class.
2. I believe the Std Deviation of the following numbers should be 6.48, where 
the code produces a different result.
3. The input was 1,3,4,6,9,19

What is the expected output? What do you see instead?
the standard Deviation should be 6.48

What version of the product are you using? On what operating system?
6.07  Windows XP.

I have an updated version of the code I can upload which fixes the problem, and 
also adds an Iterable interface to the MovingWindow to allow calculations such 
as Stochastics by Indicators.

I am not sure how to commit the changes, as the commit operation did not work 
for me when I tried. I have attached the new MovingWindow class.

Original issue reported on code.google.com by shortbus...@gmail.com on 15 Jun 2010 at 3:06

Attachments:

GoogleCodeExporter commented 9 years ago
I have come over from JSystemTrader, but now realize that JST is not a subset 
of JBT. There is no OHLC Quote history, and no download historical data 
feature. So some of the things I was doing in JST can not be done in JBT, e.g 
Stochastics or candle patterns :-(

Original comment by shortbus...@gmail.com on 15 Jun 2010 at 6:34

GoogleCodeExporter commented 9 years ago
shortbus, I've added your name to the "project committers" list. Please try to 
commit again. Thanks.

In regards to the stochastics or any other indicators, you can still do it by 
preserving the values you need in your own buffer within the indicator. Just 
keep in mind that if you iterate through the large array every time you 
calculate the indicator, it would dramatically slow the optimization. JBT deals 
with much larger datasets compared to JST, so that's the reason there is no 
default quote history.

Original comment by eugene.k...@gmail.com on 15 Jun 2010 at 7:52

GoogleCodeExporter commented 9 years ago
The existing code was calculating standard deviation, whereas 6.48 in the 
example above is a sample standard deviation. I made a small adjustment to the 
original code to calculate sample standard deviation. I am not making any other 
adjustments proposed in the attached MovingWindows.java. That's because the 
existing code calculates standard deviation in one pass, and the proposed code 
requires N passes. What this means is that if moving windows contains, say, 
1000 entries, the optimization will run about 1000 times slower. For reference, 
see "Rapid calculation methods" section in this document: 
http://en.wikipedia.org/wiki/Standard_deviation

The fix will be in release 7.07.

Original comment by eugene.k...@gmail.com on 16 Jun 2010 at 4:00

GoogleCodeExporter commented 9 years ago
good point, I was not aware of the rapid calculation method, I had only seen 
the slow method.

Original comment by shortbus...@gmail.com on 16 Jun 2010 at 6:19