Thanks, Astor. I took your code, compiled, and tested it. Everything worked
as expected: the indicator values were affected by parameters, but the price
was not affected. So, I was not able to reproduce your problem. I'd note
that you are referring to FAST_ERROR, but there is no such thing in either
KalmanTestN.java or TensionKalman.java, which are the two files that you
posted. Instead, your parameters are PROCESS_NOISE and MEASUREMENT_NOISE,
and these are the ones which are passed to your indicator used in your
strategy.
Here is an excerpt from my test results with your code:
with these parameters:
addParam(PROCESS_NOISE, 10, 20, 1, 25);
addParam(MEASUREMENT_NOISE, 200, 230, 1, 50000);
I get this output:
1250105908000,1009.625,1009.8842495795236,1.1056038636906638
1250105909000,1009.875,1009.8840450521064,1.1056038636906638
and with these parameters:
addParam(PROCESS_NOISE, 10, 20, 1, 16);
addParam(MEASUREMENT_NOISE, 200, 230, 1, 10000);
I get this output:
1250105908000,1009.625,1009.7869935893319,0.3920799920016001
1250105909000,1009.875,1009.790444144611,0.3920799920016001
As can be seen, the timestamps and the prices for these two samples match,
while the indicator values are different, which is what one would expect.
On Thursday, December 16, 2010 1:30:34 AM UTC-5, Alexana wrote:
>
>
> I have uploaded KalmanTestN and TensionKalman.
>
> ------------------------------
> *From:* Eugene Kononov <[email protected]>
> *To:* [email protected]
> *Sent:* Wed, December 15, 2010 11:28:14 PM
> *Subject:* Re: [JBookTrader] Re: Status of Kalman filter?
>
> Would you mind posting your KalmanTest.java and TensionKalman.java to the
> group so that we know that we are testing the same thing? Thanks.
>
> On Wed, Dec 15, 2010 at 11:59 PM, Astor <[email protected]> wrote:
>
>>
>> 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 the* getPostState( )* 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.
>>
>
> --
> 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.