I agree. That is why I am puzzled. I wanted to get a better feel for the way Kalman filter class was working.
First, I took your KalmanTest.java and TensionKalman.java classes and, to make things simple, removed one of the kalman filters. So, only kalmanFastPrice is left. Then, I modified thegetPostState( ) method in TensionKalman, so it would return a 2-element array double[] kalmanResult, where kalmanResult[0] held the smoothed price and kalmanResult[1] held the error covariance for this smoothed price. Then, in calculate( ) method in TensionKalman, I added the following line: out.println(price + "," + kalmanResult[0]); I ran a backtest on the strategy, just to get the values of the price and smoothed price. Per your advice, I copied and pasted into Excel the values of price and kalmanResult[0] (i.e. smoothed price). When I ran the backtest again, with different FAST_ERROR value, I noticed that the price values were lagged relative to the first run. I tried with several more FAST_ERROR values and each time got a different shift in the price time series. If you repeat those steps above, you should be able to reproduce the problem. I ran the backtest on ES test file on a single date: Aug. 12, 2009. ________________________________ From: nonlinear5 <[email protected]> To: [email protected] Sent: Wed, December 15, 2010 10:10:46 PM Subject: Re: [JBookTrader] Re: Status of Kalman filter? Please explain how to reproduce the problem. The price should not be affected by indicator parameters. On Wednesday, December 15, 2010 10:10:18 PM UTC-5, Alexana wrote: >I see a very puzzling behavior in JBT, which may be important. > >I have been looking at Kalman filter as a replacement for EMA. The parameter >Measurement Noise serves the same function for Kalman filter as Period for >EMA. >So, I am optimizing the Measurement Noise to control the level of smoothing >that >the filter provides. > >As per Eugene's suggestion below, I have added the following line to the >calculate( ) method: > >System.out.println(price + ","+ kalmanResult[0]); > >I then copied the output and pasted it into Excel. The puzzling thing is that >the values of price changed when the parameter value is changed from the >backtest GUI in JBT. Of course I would expect that the value of >kalmanResult[0] >would change in response to changing parameter, but the values of price should >remain constant. If the values of price are affected by changes in the value >of >the parameter, then the backtester may not be working properly. > >I used ES test file in my backtest and ran the backtest for one day only, Aug. >12, 2009. > > ________________________________ From: nonlinear5 <[email protected]> >To: JBookTrader <[email protected]> >Sent: Mon, December 6, 2010 4:36:13 PM >Subject: [JBookTrader] Re: Status of Kalman filter? > >> Eugene, I have added the process noise to your code and am trying to replicate >> the graphs for Kalman and EMA that you have posted below. Is there a feature >in >> JBT to create those graphs or did you have to export the data to external >> package? >> > >No, there is no direct support for that in JBT. What I did was simply >print a comma-separated list of indicator values from the >onBookSnapshot method, and then copy and save the output in a file, >which can then be imported to Excel. Example: > double priceKalmanFast = priceKalmanFastInd.getValue(); > double priceKalmanSlow = priceKalmanSlowInd.getValue(); > double priceEMAFast = priceEMAFastInd.getValue(); > double priceEMASlow = priceEMASlowInd.getValue(); > double price = getMarketBook().getSnapshot(). getPrice(); > System.out.println(price + "," + priceEMAFast + "," + priceEMASlow >+ "," + priceKalmanFast + "," + priceKalmanSlow); > >-- >You received this message because you are subscribed to the Google Groups >"JBookTrader" group. >To post to this group, send email to [email protected]. >To unsubscribe from this group, send email to jbooktrader+unsub...@ >googlegroups.com. >For more options, visit this group at >http://groups.google.com/group/jbooktrader?hl=en. > > >-- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en. -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en.
