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.

Javadoc incorrect IStrategyManager.getStartedStrategies() ?
 Post subject: Javadoc incorrect IStrategyManager.getStartedStrategies() ? Post rating: 0   New post Posted: Fri 14 Feb, 2014, 05:47 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
I'm probably not smart enough to realize these are
equivalent through inheritance, or perhaps it is a Javadoc error.

Javadoc seems incorrect, but it's probably just a more generic
superclass. Also, I'm not using the very latest API, so that may
also be the reason why DESCRIPTOR is not resolved...

is DESCRIPTOR supposed to be defined as an API type? Maybe
I have to move to a later API...

( DESCRIPTOR cannot be resolved to a type )
Future<IStrategyResponse<Set<DESCRIPTOR>>>
com.dukascopy.api.strategy.IStrategyManager.getStartedStrategies()

Eclipse recognizes this as sensible:
Future<IStrategyResponse<Set<IRemoteStrategyDescriptor>>> com.dukascopy.api.strategy.IStrategyManager.getStartedStrategies()

But I may be wrong since I'm not that knowledgeable.

HyperScalper


 
 Post subject: Re: Javadoc incorrect IStrategyManager.getStartedStrategies() ? Post rating: 0   New post Posted: Fri 14 Feb, 2014, 06:28 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
I can confirm that I was able to implement a Plugin,
whose purpose was to list running Remote Strategies
in the onStart of the Plugin implementation.

This allows my Linux strategy runner to determine
whether certain critical strategies are indeed running
on the Remote Server.

It works very well !! Thanks ! You guys/gals are the Best.

HyperScalper

   final public class MyPlugin extends Plugin {
      
      IPluginContext pluginContext;
      IRemoteStrategyManager remoteStrategyManager = null;
      
      final public IPluginContext getPluginContext() {
         return pluginContext;
      }
      
      @Override
      final public void onStart(final IPluginContext pluginContextArg) throws JFException {
         super.onStart(pluginContext);
         pluginContext = pluginContextArg; // allows access to all system functionality
         remoteStrategyManager = pluginContext.getRemoteStrategyManager();
         log("************** MyPlugin onStart..."); // print to console
         try {
            log("Trying to list all REMOTE Strategies...");
            //Future<IStrategyResponse<Set<DESCRIPTOR>>> startedStrategies =
            Future<IStrategyResponse<Set<IRemoteStrategyDescriptor>>> future =
                  remoteStrategyManager.getStartedStrategies(); // asynchronous ??
            IStrategyResponse<Set<IRemoteStrategyDescriptor>> strategyResponse = null;
            try {
               strategyResponse = future.get(60, TimeUnit.SECONDS); // wait for response
            }
            catch(Exception ee) {
               ee.printStackTrace();
            }
            Set<IRemoteStrategyDescriptor> strategyDescriptorSet = strategyResponse.getResult();
            if (strategyDescriptorSet!=null) {
               int count = 0;
               for (IRemoteStrategyDescriptor descriptor : strategyDescriptorSet) {
                  ++count;
                  log("RemoteStrategyDescriptor #"+count+" name: "+descriptor.getName());
               }
            }
            else {
               log("strategyDescriptorSet is null.");
            }
            log("After list all REMOTE Strategies.");
         }
         catch(Exception e) {
            e.printStackTrace();
         }
      }
      
      @Override
      final public void onStop() throws JFException {
         super.onStop();
         log("************** MyPlugin onStop...");
      }
   }
   


// run the plugin, which will list remote strategies
      myPlugin = new MyPlugin();
      new Thread(new PluginRunner()).start(); // asynchronous
//
//
//
   final public class PluginRunner implements Runnable {
      public void run() {
         try {
            log("PluginRunner start...");
            getIClient().runPlugin(myPlugin, myStrategyExceptionHandler);
            log("PluginRunner after runPlugin...");
         }
         catch(Exception e) {
            e.printStackTrace();
         }
      }
   }
   





Output of the listing is:

2014-Feb-14 05:22:16 ************** MyPlugin onStart...
2014-Feb-14 05:22:16 Trying to list all REMOTE Strategies...
2014-Feb-14 05:22:16 RemoteStrategyDescriptor #1 name: HyperScanner
2014-Feb-14 05:22:16 RemoteStrategyDescriptor #2 name: HyperBotWatchdog
2014-Feb-14 05:22:16 After list all REMOTE Strategies.
2014-Feb-14 05:22:16 PluginRunner after runPlugin...


 
 Post subject: Re: Javadoc incorrect IStrategyManager.getStartedStrategies() ? Post rating: 0   New post Posted: Fri 14 Feb, 2014, 08:39 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In fact there is an example in wiki for what you are trying to implement:
https://www.dukascopy.com/wiki/#IClient_functionality/Running_remote_strategies
Moreover, with the feature implementation there was also included an example Plugin in the JForex-SDK project, see: jforex.plugin.strategies.StratTablePlugin. You can build a jar from it that is runnable in the platform by using the strategy-manager-plugin profile (see the pom.xml) and run it from SDK with StrategyTableFromSdk.

hyperscalper wrote:
is DESCRIPTOR supposed to be defined as an API type? Maybe
I have to move to a later API...
No it is a generic type argument, have a look at the IStrategyManager extending interfaces ILocalStrategyManager and IRemoteStrategyManager. You can liken this to the java.util.List, which also uses a generic type parameter - works with some type E, likewise the strategy manager - it works with some type DESCRIPTOR and some LISTENER which uses the very same DESCRIPTOR type. Such generalization significantly eases switching from managing remote strategies to managing local strategies and vice versa. You can see how it is done in the upper given plugin example which works both with local and remote strategies. See more on generics here:
https://docs.oracle.com/javase/tutorial/java/generics/types.html


 

Jump to:  

  © 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