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.

context.executeTask in strategy thread in TESTER
 Post subject: context.executeTask in strategy thread in TESTER Post rating: 0   New post Posted: Fri 28 Jan, 2011, 15:29 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Dear support team,

In thread https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=17&t=268&p=2417&hilit=onActionInfo#p2417 support wrote:
Quote:
1. Original issue of this thread about calling submitOrder from onStart method is fixed. Now onStart method is run in strategy thread. That was changed in version 1.8.1 and it seems it's breaking old functionality. We will change it so that when you call executeTask from strategy thread it will be executed in the call itself


We've seen that executeTask now can successfully be called from within the strategy thread only in LIVE and DEMO mode.
In TESTER mode however, the strategy will hang when future = context.executeTask with a future.get() is called from within the strategy thread.

Best, RR.

PS: I know we should avoid executeTask calls from within the strategy code. We however use general functions that can be called from strategy and non-strategy threads. Is there a way to determine if the current thread is the strategy thread?


 
 Post subject: Re: JFOREX-2697 context.executeTask in strategy thread in TE Post rating: 0   New post Posted: Mon 31 Jan, 2011, 11:50 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
https://www.dukascopy.com/wiki/index.php?title=Threading


1) How to determine if the current thread is the strategy thread:

   if(Thread.currentThread().getName().equals("StrategyRunner Thread")){ 
      //Do something
   }


All methods defined in IStrategy interface are called in a strategy thread.

2) About "future.get()" in the historical tester.
If you call the "future.get()" from the strategy thread do it in the following way:


   if(Thread.currentThread().getName().equals("StrategyRunner Thread")){ 
      if(future.isDone()){
         future.get();
      }
   }


 

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