Closing a running strategy

14 views
Skip to first unread message

Alexana

unread,
Sep 29, 2010, 9:18:34 AM9/29/10
to JArbitrager
Is there a method in jArbitrageur to prevent a currently trading
strategy from further trading? Such method would be extemely useful
when the markets experience unusual events. Of course, one way to stop
the strategy is to exit the jArbitrageur, but that would close all the
strategies, not just the affected one.
The strategy.closePosition() method does not do the job - it closes
the existing positions but the strategy continues to trade and
establish new positions. Any suggestions guys?

bubbleRefuge

unread,
Sep 29, 2010, 1:53:32 PM9/29/10
to JArbitrager
In JBookTrader, I added a button -called it "go flat now"- to the
popup menu which would close the current
position and then enter forward test mode. Unfortunately, forward
test mode is a global variable/condition and
therefore it would apply to all strategies. I'm assuming JBooktrader
and JArbitrager are similar in this respect.

Astor

unread,
Sep 29, 2010, 3:28:59 PM9/29/10
to jarbi...@googlegroups.com
Thanks. I did add a button "stop trading" to the jArbitrager but can not seem to find the right method to associate with the button. strategy.closePosition() does not do the job, nor does "setIsActive(false)" nor setting the "mode" to something other than "trade", e.g "forward test", because it is\ global, as you had pointed out. I must be overlooking some method.

From: bubbleRefuge <jn.crichton...@gmail.com>
To: JArbitrager <jarbi...@googlegroups.com>
Sent: Wed, September 29, 2010 12:53:32 PM
Subject: Re: Closing a running strategy

bubbleRefuge

unread,
Sep 29, 2010, 4:30:40 PM9/29/10
to JArbitrager
My solution just changes the global mode to forward test mode and
closes the positions
within that particular strategy. Since I never traded more than one
strategy at
a time, it works fine for me. Now, for your case, off the top of my
head, a
hack solution would be to have the button call a method
on your strategy which sets a flag that prevents and trades after
closing the position. A more elegant hack would be to bake that
functionality
into the Strategy base class and then the execution engine could then
read that
attribute and trade/ not trade on an individual basis. Maybe call
this isDailyStop.
Which would be usefull not only by GUI invokation but also
programmatic.
The best way to do it, IMHO, is to eliminate the global "mode"
setting and replace it with a mode setting
at the Strategy level and fold this change into the architecture of
JArbitrager
(the execution engine , UI , profit manager ,backtester, etc). The
architectural change
should not be to bad, but it needs to be examined.

On Sep 29, 3:28 pm, Astor <astorel...@yahoo.com> wrote:
> Thanks. I did add a button "stop trading" to the jArbitrager but can not seem to
> find the right method to associate with the button. strategy.closePosition()
> does not do the job, nor does "setIsActive(false)" nor setting the "mode" to
> something other than "trade", e.g "forward test", because it is\ global, as you
> had pointed out. I must be overlooking some method.
>
> ________________________________
> From: bubbleRefuge <jn.crichton.mccutch...@gmail.com>

Eugene Kononov

unread,
Sep 29, 2010, 8:47:41 PM9/29/10
to jarbi...@googlegroups.com


A more elegant hack would be to bake that
functionality
into the Strategy base class and then the execution engine could then
read that
attribute and trade/ not trade on an individual basis.  Maybe call
this isDailyStop.
Which would be usefull not only  by GUI invokation but also
programmatic.


I would advocate this approach as well. That would require just a few lines of code. As suggested above, clicking the "Stop Trading" button would set the corresponding flag in the Startegy.java, and that flag would be checked before Trader.java submits an order. The reason this functionality does not exist in either JBookTrader or JArbitrager is because both systems are meant to be fully automated. The idea is that they would be run unsupervised, i.e., your presense would not be needed. If you feel that some sort of "stop trading" signal should trigger under certain market conditions (such as high volatility), ideally that should be coded in the strategy itself. That way, you can backtest, forward test, and optimize your strategy in the same way as you would trade it.

Astor

unread,
Sep 29, 2010, 9:41:22 PM9/29/10
to jarbi...@googlegroups.com

Eugene, such button is not meant for routine trading operations. Those definitely should be automated. Rather, it is meant for those emergency / extreme situations which can not be backtested or optimized, precisely because these events are unforeseable. In equities one example of such event could be when the trading in one of the traded instruments is halted pending an announcement. In currencies it could be a political event, such as a terror attack or unexpected interest rate change by the central bank. It could be a simple human error, when you realize that you have accidentally launched live the strategy that you did not want to launch live just yet. etc.

From: Eugene Kononov <eugene....@gmail.com>
To: jarbi...@googlegroups.com
Sent: Wed, September 29, 2010 7:47:41 PM

Subject: Re: Closing a running strategy

Astor

unread,
Sep 29, 2010, 9:56:55 PM9/29/10
to jarbi...@googlegroups.com

Ironically, one of those events that could use the Stop trading button may have happened to me today. I was using JArbitrager to trade IVW, an S&P500 Growth ETF, vs QQQQ. For some strange reason I started getting sporadic IB message (transmitted through the jArbitrager) that it was not recognizing QQQQ symbol. Orders for IVW were executed unhedged. It was in paper trading account, so I did not care. In live trading, I would have to shut the strategy down immediately until I figured out what was causing the problem.


From: Eugene Kononov <eugene....@gmail.co
To: jarbi...@googlegroups.com
Sent: Wed, September 29, 2010 7:47:41 PM

Subject: Re: Closing a running strategy
Reply all
Reply to author
Forward
0 new messages