Having a separate Exit=0 threshold for closing out positions will reduce strategy risk

13 views
Skip to first unread message

Alexana

unread,
Aug 10, 2010, 10:49:27 PM8/10/10
to JArbitrager
Presently the strategies use single threshold Entry to enter and exit
the positions. If Value <= - Entry position is established. If Value
>= Entry position is closed and reversed.

This approach will result in substantially higher probability of loss
than if a separate Exit threshold was established. To illustrate my
point, assume that Value is stationary and normally distributed and
that transaction costs are negligible.

CASE 1, Entry used to open and close positions:

If Entry = 1*Standard Deviation, the probability of entering a
position is 16% and probability of closing it is also 16%. The
probability of both opening and closing a position is 16% * 16% =
2.56%
The probability of a loss, i.e. Value never reverts below Entry, is
16%


CASE 2, Entry used to open position and separate threshold EXIT = 0 is
used to close the position

If Entry = 2*Standard Deviation and Exit =0, the probability of
entering a position is 5% and closing it is 50%. The probability of
both, opening and closing a position is 5% * 50% = 2.5%, same as in
Case 1 above.

However, the probability of a loss, i.e. Value never reverts below
Entry is only 5%, less than 1/3 of the risk in Case 1!!


Modifying the Strategy code to incorporate a separate Exit=0 threshold
for closing the positions should not be too difficult. What do you
think?

John E. Cosgrove

unread,
Aug 11, 2010, 12:54:15 AM8/11/10
to jarbi...@googlegroups.com
If the current strategy used is indeed how it is described below, then this sounds correct; can anyone else second?

John

John-Crichton McCutcheon

unread,
Aug 11, 2010, 6:08:12 PM8/11/10
to jarbi...@googlegroups.com
Hi, You sound as though you have a strong math background. Thanks for
the input. While I can't dispute
the logic of the math, we have noticed that the more "optimizable"
parameters added to a strategy, the
more likely the optimizer will "fit the curve" during optimization runs
and therefore the less likely the optimization
results will say anything about the future.

nonlinear5

unread,
Aug 11, 2010, 8:24:16 PM8/11/10
to JArbitrager
I didn't quite follow your math, but I can tell you that I've already
experimented with the entry-exit parameter pairs and found out from
many millions of simulations that adding the exit parameter almost
always leads to inferior results. While it's true that with the exit,
you are more likely to lock in the profit, the size of that profit is
half of what it would potentially be if no exit is specified. All my
risk-adjusted metrics (such as Profit Factor, Performance Index, and
Kelly) indicate that the strategy would be better off without the
exit. However, this may be due to the nature of the strategies that
I've tested, so you may get different results. This would indeed be
very straightforward to implement, with just a couple of additional
lines of code in the strategy. Please let us know what you find.

Astor

unread,
Aug 11, 2010, 9:38:49 PM8/11/10
to jarbi...@googlegroups.com
Well, the Exit is always specified. It is either Exit = - Entry or something else, such Exit = 0. 

 

Another way of looking at it is this: if Value is normally distributed, at Value = 0, it is as likely to go up  (loss) as it is to go down (gain). Continuing to hold the position at this point is no longer an investment but a gamble with even odds, no different than betting on red or black in a casino.

 

It is very puzzling that in simulations the risk-adjusted metrics show consistently better performance when Exit = - Entry. One reason for this could be if Value is not normally distributed but is heavily skewed. That, however, would be highly unusual. Another explanation could lie in the way the simulations were conducted: sometimes optimization can lead to overfitting the data, leading to counterintuitive results. Very curious! 



From: nonlinear5 <eugene....@gmail.com>
To: JArbitrager <jarbi...@googlegroups.com>
Sent: Wed, August 11, 2010 7:24:16 PM
Subject: Re: Having a separate Exit=0 threshold for closing out positions will reduce strategy risk

Astor

unread,
Aug 11, 2010, 10:15:58 PM8/11/10
to jarbi...@googlegroups.com
I absolutely agree with you. Having too many optimizable parameters in the model will almost always lead to "curve fitting". However, the key word here is "optimizable". If the parameter is fixed based on theoretical considerations and is not used in optimization, then it does not increase the risk of "curve fitting". So, when the Exit is fixed at zero and is not used in optimization, there is still only one adjustable parameter, which is "Entry", and the risk of curve fitting will not increase.
 
The reason to fix Exit at zero is based on the assumption of normal or, at least, symmetric probability distribution of Value. Under that assumption, when Value = 0, it is as likely to go up as it is to go down. If that is the case, then holding an open position is no different than gambling on red and black in a casino. 



From: John-Crichton McCutcheon <john.crichto...@gmail.com>
To: jarbi...@googlegroups.com
Sent: Wed, August 11, 2010 5:08:12 PM

Subject: Re: Having a separate Exit=0 threshold for closing out positions will reduce strategy risk

John-Crichton McCutcheon

unread,
Aug 12, 2010, 10:11:02 AM8/12/10
to jarbi...@googlegroups.com
Yes, trial and error has lead me to resort to consider similar conventions for other parameters.  For example, time periods,  I don't like to
optimize for time periods.  What do you do with time period parameters? 

Astor

unread,
Aug 12, 2010, 11:17:07 AM8/12/10
to jarbi...@googlegroups.com
I assume we are talking about time periods for averaging the time series, such as simple or exponential moving average in jArbitrager. The objective of such averaging is to reduce the noise. If the noise is stationary (i.e. the probability density function of noise does not change with time), then the longer the period the better - noise will decrease as a sqrt( period).
 
In the real world, however, the noise will not be stationary. During the periods of high ot volatility the noise will increase and vice versa. So a single, fixed time period parameter will not work well during such regime changes. Too short a period will not reduce noise enough and too long a period will span volatility regimes and give erroneous results. Global optimization, of the type done by jArbitrager, will not mitigate this problem.
 
The best approach is an adaptive methodology, such as Kalman filter. ( Exponential moving average can be viewed as a very special case of Kalman filter). Kalman filter automatically adapts the time period based on the estimate of noise in the system. If you are using R or Matlab, Kalman filter is easy to implement. In C there are many libraries, which provide the code for Kalman filters. However, I have not seen any packages in Java that do that and I am too crappy a programmer to write my own.
 
It may be possible to get some of the benefit of Kalman filter by making the "Multiplier" parameter in the EMADifferential class of jArbitrager to be variable, dependent on the trailing Standard deviation of Value, instead of fixed, depenent on the optimization, as it is now.


From: John-Crichton McCutcheon <john.crichto...@gmail.com>
To: jarbi...@googlegroups.com
Sent: Thu, August 12, 2010 9:11:02 AM

John-Crichton McCutcheon

unread,
Aug 12, 2010, 1:54:23 PM8/12/10
to jarbi...@googlegroups.com
Thanks for the help.  This is a free scientific java library for non-commercial use: http://www.ee.ucl.ac.uk/~mflanaga/java/index.html.
I didn't see the Kalman filter in there.

There is java programming and the there is numerical java programming.


On 8/12/2010 11:17 AM, Astor wrote:
I assume we are talking about time periods for averaging the time series, such as simple or exponential moving average in jArbitrager. The objective of such averaging is to reduce thenoise. If the noise is stationary (i.e. the probability density function of noise does not change with time), then the longer the period the better - noise will decrease as a sqrt( period).

Astor

unread,
Aug 12, 2010, 5:42:03 PM8/12/10
to jarbi...@googlegroups.com
Thanks a lot! Looks like a great resource.
 
Here is a link to one possible implementation of kalman filter in java.
 
Here is another:

Not sure how good those implementations are, but could be  useful.
 
BTW, If you ever come across a java code for N-dimensional FFT please let me know. I tried to google it but keep on finding only plain old 1-D FFTs.


From: John-Crichton McCutcheon <john.crichto...@gmail.com>
To: jarbi...@googlegroups.com
Sent: Thu, August 12, 2010 12:54:23 PM

John-Crichton McCutcheon

unread,
Aug 13, 2010, 8:44:18 AM8/13/10
to jarbi...@googlegroups.com
I know a researcher who 's been trying to apply Fast Fourier Transforms to the stock market and was working on a java implementation. 
Will talk to him. 

bubbleRefuge

unread,
Sep 18, 2010, 12:20:52 PM9/18/10
to JArbitrager

> It may be possible to get some of the benefit of Kalman filter by making
> the "Multiplier" parameter in the EMADifferential class of jArbitrager to be
> variable, dependent on the trailing Standard deviation of Value, instead of
> fixed, depenent on the optimization, as it is now.
>
how would you propose to implement this idea.?
my first stab at it is:
double std = ..... get the standard deviaton of value;
multiplier += multiplier * std ;

bubbleRefuge

unread,
Sep 18, 2010, 12:57:18 PM9/18/10
to JArbitrager

or better yet : multiplier = 2.0 / ((length + length*std) + 1.0);

On Sep 18, 12:20 pm, bubbleRefuge <john.crichton.mccutch...@gmail.com>
wrote:

Alexana

unread,
Sep 18, 2010, 1:03:40 PM9/18/10
to JArbitrager
That may capture some of the benefit of the Kalman filter but not all.
Exponential Moving Average (EMA) as all other measures of averages,
absolutely disregards any trends in the underlying trime series. It is
applicable if the true average is non-trending but will lag if the
moving average has a trend. Kalman filter not only adapts to the noise
level in the data but also can be used to forecast future values based
on the trends present in the data. Thus, forecasted current value is a
better measure of the expected spread than the EMA. A forecasted
future value can be used to determine the likelihood of the mean
reversion.

Here is a description of Kalman filter from Wikipedia:
"The Kalman filter produces estimates of the true values of
measurements and their associated calculated values by predicting a
value, estimating the uncertainty of the predicted value, and
computing a weighted average of the predicted value and the measured
value. The most weight is given to the value with the least
uncertainty. The estimates produced by the method tend to be closer to
the true values than the original measurements because the weighted
average has a better estimated uncertainty than either of the values
that went into the weighted average."

I have found on the Web quite a few Java classes that implement Kalman
filters. Here is one: http://mathstat.asu.edu/~eubank/kalman/kalman.html
That code appears to be well documented, with examples of usage, etc
by a statistics professor from Arizona State U. I am thinking that
rather than re-inventing the wheel with creating a noise - adapting
EMA, it may be easier to just implement that (or similar) code and get
the full benefit of this methodology.

On Sep 18, 11:20 am, bubbleRefuge

Alexana

unread,
Sep 18, 2010, 1:44:17 PM9/18/10
to JArbitrager
bubbleRefuge, I just took a quick look at the Kalman filter code that
I linked in my previous post and it seems that it would be very simple
to adapt it to jArbitrageur.
Eubank's example Ex.java has hard coded dependent and independent
vaiables ry and rt:

double[] ry={1,3, 5, 4, 6};//response
double[] rt={.2 , .4, .6, .8, 1};//t ordinates
int n=5;//number of data values

Looks like replacing these hard-coded variables with externally passed
vectors of dependent and independent variables is all that is needed
to incorporate Kalman into jArbitrageur. What do you think?

On Sep 18, 12:03 pm, Alexana <astorel...@yahoo.com> wrote:
> That may capture some of the benefit of the Kalman filter but not all
> > multiplier += multiplier * std ;- Hide quoted text -
>
> - Show quoted text -

bubbleRefuge

unread,
Sep 18, 2010, 3:27:30 PM9/18/10
to JArbitrager


On Sep 18, 1:03 pm, Alexana <astorel...@yahoo.com> wrote:
> That may capture some of the benefit of the Kalman filter but not all.
> Exponential Moving Average (EMA) as all other measures of averages,
> absolutely disregards any trends in the underlying trime series. It is
> applicable if the true average is non-trending but will lag if the
> moving average has a trend. Kalman filter not only adapts to the noise
> level in the data but also can be used to forecast future values based
> on the trends present in the data. Thus, forecasted current value is a
> better measure of the expected spread than the EMA. A forecasted
> future value can be used to determine the likelihood of the mean
> reversion.
>
Ok What about the Adaptive Moving Average. It reacts quickly to
trends.
I've got a implementation of that that I've tested a bit in
JBookTrader(Its been a while).
But in JBookTrader I've never found that it gave me better overall
performance than EMA
based strategies, although it did yield nice smoothness and
reactivity.

bubbleRefuge

unread,
Sep 18, 2010, 3:29:07 PM9/18/10
to JArbitrager
I have trouble mapping Kalman to this problem space. Not intuitive to
me. What is the state? How do we construct the output equation?
It seems very complex to me.

I'm trying to apply this concept to indicators in JBookTrader which is
the "Big Brother"
project of JArbitrager. Its all very similar in terms of how
Indicators are coded and how
the system cycles.

Alexana

unread,
Sep 18, 2010, 6:59:50 PM9/18/10
to JArbitrager
Here is a comparison of EMA, AMA and Kalman. They all have some
similarities, the biggest difference is Kalman filter's use of change
in the past values to predict futurer values:

EMA computes estimate of the true value of a random variable by
computing weighted average of the new observation and the prior moving
average. The weight is constant.

AMA computes estimate of the true value of a random variable by
computing weighted average of the new observation and the prior moving
average. The weight is adaptive, dependent on price volatility.

Kalman computes estimate of the true value of a random variable by
computing weighted average of the new observation and the predicted
value of the new observation. (Note the key word: predicted value. The
prediction is based not only on the past values but also the change in
those past values). The weight is adaptive, dependent on uncertainty
of estimation.


On Sep 18, 2:27 pm, bubbleRefuge <john.crichton.mccutch...@gmail.com>
wrote:

Alexana

unread,
Sep 18, 2010, 7:25:52 PM9/18/10
to JArbitrager
Many descriptions of kalman filters are unnecessarily intimidating.
Imagine a car driving erratically on the road. Its "state" at any
point in time can be described by two variables: position and speed.
EMA (and AMA) would estimate the car's future position by averaging
the past values of the position and ignoring the speed. If the car
drives randomly changing directions, this may be a fair estimate.

The Kalman would estimate the car's future "state" (i.e. future
position and speed) by taking into account its present "state" (i.e.
position and speed) as well as changes in its present state. Those
future estimates can be used in turn to predict the next "state" and
so on. If the car drives randomly but with some preferred direction
(trend), these estimates will be better than the EMA's or AMA's ones.

For our purposes, we can treat Kalman filter as a black box, which
takes as input a series of past observations and outputs a prediction
of current or future values. Think of it as non-linear regression
with adaptive parameters.

On Sep 18, 2:29 pm, bubbleRefuge <john.crichton.mccutch...@gmail.com>
wrote:in those
> > > - Show quoted text -- Hide quoted text -

John-Crichton McCutcheon

unread,
Sep 20, 2010, 12:20:01 PM9/20/10
to jarbi...@googlegroups.com
Ok agreed on the black box approach. As I see it that entails
enumerating the various
parts of the Kalman filter first ( inputs and outputs) and thereafter
figuring
out which elements of an indicator/strategy map to those outputs inputs.

Another point. Why apply the Kalman filter at the indicator level only?
How about applying it at the strategy level? That way the predictive
value
of the Kalman filter is not focused on predicting a "Value" of an indicator
but whether that value in and of itself leads to successful trades.
This means the
filter has to be implemented at the strategy level.

Alexana

unread,
Sep 20, 2010, 3:26:46 PM9/20/10
to JArbitrager
Kalman filter can be a scalar filter, where the "state" is defined by
just one input variable, e.g. price spread. So, we have one input:
prior price spread, and one output, current or future expected price
spread. If the actual spread is greater than the expected one, we buy
cheap instrument, sell short expensive one and capture profit when the
actual spread mean reverts to the expected one.

Kalman filter can also be vector, where the "state" is defined by
multiple variables at each point in time, e.g. P/E ratio, various
technical indicators, etc. There is still one output, for example
return. Kalman filter will provide a prediction by weighting
contributions from each indicator in proportion to its most recent
accuracy.

I think, - if I understood you correctly, - you are proposing that the
"state" inputs to the vector kalman filter can be various strategies
and the filter will make the prediction of the future return by
weighted average of predictions from each input strategy. That could
be a good approach.

Now all we need is kalman filter class inside the jArbitrageur or
jBookTrader platform. The code that I linked before is for scalar
kalman filter: one input - one output. Adapting it to our trading
platform will be exremely easy: in ex.java class hard-coded array ry
has to be replaced by externally passed array, containing our input
data, and the prediction will be returned by the last element in the
vector fit.

I still have not found a java code that implements the code for
vector Kalman filter.

On Sep 20, 11:20 am, John-Crichton McCutcheon

bubbleRefuge

unread,
Sep 21, 2010, 10:14:31 AM9/21/10
to JArbitrager
Alex, Great explanations. Doesn't this one take
a vector for input ? http://the-lost-beauty.blogspot.com/2009/12/simulation-and-kalman-filter-for-3rd.html

On Sep 20, 3:26 pm, Alexana <astorel...@yahoo.com> wrote:
> Kalman filter can be a scalar filter, where the "state" is defined by
> just one input variable, e.g. price spread. So, we have one input:
> prior price spread, and one output, current or future expected price
> spread. If the actual spread is greater than the expected one, we buy
> cheap instrument, sell short expensive one and capture profit when the
> actual spread mean reverts to the expected one.
>
For JArbitrager that sounds good. I'm just not convinced JArbitrager
has that much
potential for an ATS trader with a relatively small capital base.
Can't get much leverage
with this type of strategy. I've been recording data for the INTU -
ADBE stock pair thinking
there may be a statistical arbitrage opportunity there. After running
the strategy through
the optimizer the results are bread crumbs compared to what you get
for JBookTrader
when you run it through the optimizer with a single ES contract.
Obviously this is because of leverage.
Since I am amateur in this game, there maybe better ways to get more
leverage using JArbitrager by
choosing other pairs such as ES_SPY but I tend to believe the big
houses will squeeze swallow
these opportunities with superior networking, hardware, etc. Perhaps
using options as the trading
instruments are something worth exploring. Nevertheless, it may be
worth using JArbitrager as the
paradigm for implementing the Kalman Filter simply for academic
reasons.

> Kalman filter can also be vector, where the "state" is defined by
> multiple  variables at each point in time, e.g. P/E ratio, various
> technical indicators, etc. There is still one output, for example
> return.

Yes this would be ideal.

>Kalman filter will provide a prediction by weighting
> contributions from each indicator in proportion to its most recent
> accuracy.
Wow that sounds great! Is this concept already baked into the
Kalman filter?
>
> I think, - if I understood you correctly, - you are proposing that the
> "state" inputs to the vector kalman filter can be various strategies
> and the filter will make the prediction of the future return by
> weighted average of predictions from each input strategy. That could
> be a good approach.
No. See above. As you stated: Vector based input is what I was
thinking

Message has been deleted
Message has been deleted
Message has been deleted

Alexana

unread,
Sep 21, 2010, 11:13:36 AM9/21/10
to JArbitrager
The blogspot's implementation seems to be the vector kalman, but I
have not gone through the code thoroughly and have very little
knowledge of JAMA.

I did compile and run Dr. Eubank's scalar kalman filtercode and it
seems to work well. But it is only a scalar.

I am working now on a class that will enable jArbitrageur to read and
write XML files. The XML files wil contain all the parameters,
contract specifications, etc. Once finished, I will upload it to the
jArbitrageur's site. One of the benefits of using this approach is
that I can use Matlab or R to run Kalman filter,- or any other stat
package, - and send the results to jArbitrageur through XML to place
and monitor trades.

The concept of giving greater weight to the better performing
predictors is already baked into the Kalman filter. Kalman filter is
also known as Predictor - Corrector algorithm. It generates future
predictions as a weighted average of its own prior predictions and
current values of its state variables. The weighting scheme gives more
weight to the more accurate predictors.

Here is relatively simple description of the scalar kalman:
http://www.swarthmore.edu/NatSci/echeeve1/Ref/Kalman/ScalarKalman.html#Defining
the Problem

I do not have much familiarity with jBookTrader. I probably should get
more familiar with it.

My concept has been to do statistical arbitrage with ETFs. Here
jArbitrageur seems quite good. I am looking to generate modest returns
with minimal risk. High leverage strategy is likely to be high return
- high risk. I am scared of those because of the Gambler's ruin
problem - a winning strategy may be inadequate if several losing
trades can wipe out your capital base.

I am not terribly worried about "big houses". I have worked for a few
of them and mostly have not been impressed at all. I know I can not
compete on the speed of execution, but I have no such reservations
with respect to the knowledge of markets and creativity of the
methodology. Also, I am explicitely looking for low-capacity
strategies, which do not attract big boys.

On Sep 21, 9:14 am, bubbleRefuge <john.crichton.mccutch...@gmail.com>
wrote:
> Alex, Great explanations.  Doesn't this one take
> a vector for input ?http://the-lost-beauty.blogspot.com/2009/12/simulation-and-kalman-fil...
>
> On Sep 20, 3:26 pm, Alexana <astorel...@yahoo.com> wrote:> Kalman filter can be a scalar filter, where the "state" is defined by
> > just one input variable, e.g. price spread. So, we have one input:
> > prior price spread, and one output, current or future expected price
> > spread. If the actual spread is greater than the expected one, we buy
> > cheap instrument, sell short expensive one and capture profit when the
> > actual spread mean reverts to the expected one.
>
> For JArbitrager that sounds good.  I'm just not convinced JArbitrager
> has that muche looked
> potential for an ATS trader with a relatively small capital  base.
> Can't get much leverage
> with this type of strategy.  I've been recording data for the INTU -
> ADBE stock pair  thinking
> there may be a statistical arbitrage opportunity there.  After running
> the strategy through
> the optimizer the results are bread crumbs compared to what you get
> for JBookTrader
> when you run it through the optimizer with a single ES contract.
> Obviously this is because of leverage.
> Since I am amateur in this game, there maybe better ways to get more
> leverage using JArbitrager by
> choosing other pairs such as ES_SPY but I tend to believe the big
> houses will squeeze swallow
> these opportunities with superior networking, hardware, etc.  Perhaps
> using options as the trading
> instruments are something worth exploring.   Nevertheless, it may be
> worth using  JArbitrager as the
> paradigm for implementing the Kalman Filter simply for academic
> reasons.
>
> > Kalman filter can also be vector, where the "state" is defined by
> > multiple  variables at each point in time, e.g. P/E ratio, various
> > technical indicators, etc. There is still one output, for example
> > return.
>
> Yes this would be ideal.
>
> >Kalman filter will provide a prediction by weighting
> > contributions from each indicator in proportion to its most recent
> > accuracy.
>
> Wow that sounds great!  Is  this concept  already baked into the
> Kalman filter?
>
> > I think, - if I understood you correctly, - you are proposing that the
> > "state" inputs to the vector kalman filter can be various strategies
> > and the filter will make the prediction of the future return by
> > weighted average of predictions from each input strategy. That could
> > be a good approach.
>

bubbleRefuge

unread,
Sep 21, 2010, 1:32:41 PM9/21/10
to JArbitrager


On Sep 21, 11:13 am, Alexana <astorel...@yahoo.com> wrote:
> The blogspot's implementation seems to be the vector kalman, but I
> have not gone through the code thoroughly and have very little
> knowledge of JAMA.
If you don't trust JAMA, it can probably be replaced with
http://math.asu.edu/~eubank/kalman/matrix_java

> I did compile and run Dr. Eubank's  scalar kalman filtercode and it
> seems to work well. But it is only a scalar.
>
> I am working now on a class that will enable jArbitrageur to read and
> write XML files. The XML files wil contain all the parameters,
> contract specifications, etc. Once finished, I will upload it to the
> jArbitrageur's site. One of the benefits of using this approach is
> that I can use Matlab or R to run Kalman filter,-  or any other stat
> package, - and send the results to jArbitrageur through XML to place
> and monitor trades.
Ok. You know R can be called from C and C can be called from Java?
>
> Here is relatively simple description of the scalar kalman:http://www.swarthmore.edu/NatSci/echeeve1/Ref/Kalman/ScalarKalman.htm...
> the Problem
>
> I do not have much familiarity with jBookTrader. I probably should get
> more familiar with it.
>
> My concept has been to do statistical arbitrage with ETFs. Here
> jArbitrageur seems quite good. I am looking to generate modest returns
> with minimal risk. High leverage strategy is likely to be high return
> - high risk. I am scared of those because of the Gambler's ruin
> problem - a winning strategy may be inadequate if several losing
> trades can wipe out your capital base.

I've got one strategy which uses stops to mitigate this.

> I am not terribly worried about "big houses". I have worked for a few
> of them and mostly have not been impressed at all. I know I can not
> compete on the speed of execution, but I have no such reservations
> with respect to the knowledge of markets and creativity of the
> methodology. Also, I am explicitely looking for low-capacity
> strategies, which do not attract big boys.
Agreed on that one.


Anyway, I will try to play with the "blogspot" Kalman Filter. Just
want to get a better feel
for it. Then I'll try to plug it in.

Alexana

unread,
Sep 22, 2010, 11:21:13 AM9/22/10
to JArbitrager
I neither trust nor distrust JAMA. I just am not familiar with it. I
did try http://math.asu.edu/~eubank/kalman/matrix_java code. That is
the one that I had referred to as Dr. Eubank's because it was written
by Randy Eubank, a professor at ASU, who has written and researched
extensively on Kalman filters. That code is fairly straight forward
and runs well, but, in its present form, it is a scalar filter.

I did find an open source Java to R interface, http://rosuda.org/JRI/
, which, suppposedly, allows to call R functions from within JAVA. It
probably runs far slower than anything directly implemented in JAVA
but has its advantages as well. I want to finish the XML piece anyway,
so that jArbitrageur can run without recompiling evry time strategy
changes, etc.

bubble, sorry for the unsolicited sdvice but ...do not count too much
on stops to mitigate risks of a very volatile strategy. When the stop
is touched, your order becomes a market order but that does not
guarantee that it will be filled at that price - the actual fill price
can be very different and losses much larger than expected. I have
seen that happen.

Let me know your opinion of the blog-spot filter. If it works well and
if you can plug it into the platform, it will be a fantastic tool.



On Sep 21, 12:32 pm, bubbleRefuge <john.crichton.mccutch...@gmail.com>
wrote:
> On Sep 21, 11:13 am, Alexana <astorel...@yahoo.com> wrote:> The blogspot's implementation seems to be the vector kalman, but I
> > have not gone through the code thoroughly and have very little
> > knowledge of JAMA.
>
> If you don't trust JAMA, it can probably be  replaced withhttp://math.asu.edu/~eubank/kalman/matrix_java
> > > thinking- Hide quoted text -

Alexana

unread,
Sep 22, 2010, 12:13:23 PM9/22/10
to JArbitrager
Here is one more open source Java implementation of Kalman filter. At
first blush, looks like it is vector and well written:

http://code.google.com/p/efficient-java-matrix-library/wiki/KalmanFilterExamples



On Sep 21, 12:32 pm, bubbleRefuge <john.crichton.mccutch...@gmail.com>
wrote:
> On Sep 21, 11:13 am, Alexana <astorel...@yahoo.com> wrote:> The blogspot's implementation seems to be the vector kalman, but I
> > have not gone through the code thoroughly and have very little
> > knowledge of JAMA.
>
> If you don't trust JAMA, it can probably be  replaced withhttp://math.asu.edu/~eubank/kalman/matrix_java
> > > thinking- Hide quoted text -

bubbleRefuge

unread,
Sep 22, 2010, 12:14:28 PM9/22/10
to JArbitrager

> I did find an open source Java to R interface,http://rosuda.org/JRI/
> , which, suppposedly, allows to call R functions from within JAVA. It
> probably runs far slower than anything directly implemented in JAVA
> but has its advantages as well. I want to finish the XML piece anyway,
> so that jArbitrageur can run without recompiling evry time strategy
> changes, etc.
I C. If the R interpreter is slow it will bring the optimizer to a
crawl when
running big optimizations.
>
> bubble, sorry for the unsolicited sdvice but ...do not count too much
> on stops to mitigate risks of a very volatile strategy. When the stop
> is touched, your order becomes a market order but that does not
> guarantee that it will be filled at that price - the actual fill price
> can be very different and losses much larger than expected. I have
> seen that happen.
Please all advice is welcome at any time. Since I am an Amateur in
the ATS game
and I am trying to learn and grow ( maybe I can escape the cube
someday with a great ATS). Do you think
this "frictional/slippage risk" is significant for highly liquid
instruments such as the ES when
trading in low quantities.

> Let me know your opinion of the blog-spot filter. If it works well and
> if you can plug it into the platform, it will be a fantastic tool.
Yeah I will. When I get to nitty-gritty of it I'll probably have some
questions.

Alexana

unread,
Sep 22, 2010, 2:15:31 PM9/22/10
to JArbitrager
Generally, ES is should not have too much slippage when traded in low
quantities. The problem arises when there are market - wide
volatility spikes, such as the flash crash last spring. On those days
even the usually liquid instruments can gap down and go right through
your stop loss. Magnify those losses by large leverage and your equity
can get completely wiped out. Sometimes, to add insult to injury, they
bounce right back up but you are already out of the market.

I prefer using both, liquid, well diversified instruments and hedged
positions, so that when the entire market rolls down, my hedge
protects me to some extent.

On Sep 22, 11:14 am, bubbleRefuge <john.crichton.mccutch...@gmail.com>
> > > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages