Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Questions about behavior of the API and strategy tester
 Post subject: Questions about behavior of the API and strategy tester Post rating: 0   Post Posted: Tue 29 Jun, 2010, 21:24 

User rating: 0
Joined: Fri 07 May, 2010, 02:59
Posts: 61
I have a few questions about the strategy backtester (both from the perspective of the gui and ITesterClient):

* When I attempt to start multiple strategies, after the first one is started an exception is thrown that says a strategy is already running. The IClient interface has a function getStartedStrategies(), so I assume it's intended we can start multiple strategies.
** How do we start another strategy without waiting for all strategies to complete?
** Do they execute serially or in parallel?
** Do they run in their own 'sandbox', so to speak, or are they running on the same virtual account? Or to put it another way, does each one have its own bankroll.
* When you opt to close a filled order, in a live test it takes some time for the close operation to complete, however I may wish to get an immediate estimate of the account equity that is as accurate as possible. With this in mind:
** In live testing I could just call IOrder.waitForUpdate ( milliseconds ), but in the strategy backtester this seems like a bad idea. I don't know how long the other thread(s) involved in that estimation will take to respond, and even a 1ms delay can significantly increase the time a test takes if the test is large enough. Is there a better way?
* If, after I'm finished retrieving my cache, I know I won't need any data on the server anymore: is it possible to disconnect and have the tester just assume the disk cache is up to date? This would, for example, be very handy in skipping the logon process altogether if the local cache is known to be good.
* How do you detect a margin call within a strategy? I haven't seen any messages that come through onMessage() that make it obvious, and I'm not sure where or if an exception is being thrown in order to catch/handle it.

This is all that comes to mind for now.

-Brian


 
 Post subject: Re: Questions about behavior of the API and strategy tester Post rating: 0   Post Posted: Fri 02 Jul, 2010, 09:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Quote:
When I attempt to start multiple strategies, after the first one is started an exception is thrown that says a strategy is already running. The IClient interface has a function getStartedStrategies(), so I assume it's intended we can start multiple strategies.
Running multiple strategies simultaneously from a single jar will be available with a next release, which is coming in a near future.
Quote:
How do we start another strategy without waiting for all strategies to complete?
Use a method startStrategy on the same client instance. The startSrategy method returns an id. This is the same id, that is used as a key in the map which is returned by the getStartedStrategies method.
long strAID = client.startStrategy(new ClassA());
long strBID = client.startStrategy(new ClassB());
Quote:
Do they execute serially or in parallel?
They are executed in a parallel threads.
Quote:
Do they run in their own 'sandbox', so to speak, or are they running on the same virtual account? Or to put it another way, does each one have its own bankroll.
Each strategy is using it's own virtual account.
Quote:
When you opt to close a filled order, in a live test it takes some time for the close operation to complete, however I may wish to get an immediate estimate of the account equity that is as accurate as possible. With this in mind:
** In live testing I could just call IOrder.waitForUpdate ( milliseconds ), but in the strategy backtester this seems like a bad idea. I don't know how long the other thread(s) involved in that estimation will take to respond, and even a 1ms delay can significantly increase the time a test takes if the test is large enough. Is there a better way?
It's reasonable to test the same strategy, that you will use in a live. It's just to be sure that it will behave like it supposed to. It's better to use the same IOrder.waitForUpdate
Quote:
If, after I'm finished retrieving my cache, I know I won't need any data on the server anymore: is it possible to disconnect and have the tester just assume the disk cache is up to date? This would, for example, be very handy in skipping the logon process altogether if the local cache is known to be good.
Due to our implementation it's not possible
Quote:
How do you detect a margin call within a strategy? I haven't seen any messages that come through onMessage() that make it obvious, and I'm not sure where or if an exception is being thrown in order to catch/handle it.
Use an IAccount.getUseOfLeverage() to determin it. When the value returned by this method is close to IAccount.getMarginCutLevel() (by default it's 200%), it means that margin cut will happen.


 
 Post subject: Re: Questions about behavior of the API and strategy tester Post rating: 0   Post Posted: Fri 02 Jul, 2010, 18:34 

User rating: 0
Joined: Fri 07 May, 2010, 02:59
Posts: 61
Quote:
Use a method startStrategy on the same client instance. The startSrategy method returns an id. This is the same id, that is used as a key in the map which is returned by the getStartedStrategies method.

long strAID = client.startStrategy(new ClassA());
long strBID = client.startStrategy(new ClassB());



As a followup to this, I'd like to offer a few possible suggestions for its implementation:

* add a parameter to limit the # of concurrent threads executing at once
* add a feature that would run all strategies in lockstep

The 2nd one would help a lot with cutting down on the effect of any delays that might occur while the StrategyRunner thread is waiting for things to happen in other threads.

Also, thanks for the responses; I sincerely appreciate it. I'm also very excited to see the new changes.

-Brian


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com