Plugins

Create plugin

For every plugin jar file the following conditions must be met:

  • The jar file has to contain a class which extends the Plugin class.
  • The jar manifest file has to contain qualified location of the plugin class prefixed by "pluginMainClass: ", e.g.:
pluginMainClass: mypackage.MyPlugin.

Build simple plugin

Consider a trivial plugin program:

import com.dukascopy.api.IConsole;
import com.dukascopy.api.JFException;
import com.dukascopy.api.plugins.IPluginContext;
import com.dukascopy.api.plugins.Plugin;

public class SimplePlugin extends Plugin {    

    private IConsole console;

    @Override
    public void onStart(IPluginContext context) throws JFException {
        console = context.getConsole();
        console.getOut().println("Plugin started");
    }

    @Override
    public void onStop() throws JFException {
        console.getOut().println("Plugin stopped");
    }

}


And a manifest file META-INF\MANIFEST.MF:

pluginMainClass: SimplePlugin
Manifest-Version: 1.0


Download the latest JForex-API version from the public repository and make the following file structure:

C:\TEMP\PLUGINS
|   JForex-API-2.9.2.jar
|   SimplePlugin.java
|
----META-INF
        MANIFEST.MF


Compile the plugin with the following command:

javac -source 7 -target 7 SimplePlugin.java -cp JForex-API-2.12.41.jar


Archive the compiled SimplePlugin.class file together with the META-INF folder to a jar file created using the zip compressing format. Consider using the 7-zip to do this:

Using JForex-SDK examples

In order to create a plugin go through the following steps:

  1. Import the JForex-SDK project either by using Eclipse, Intellij IDEA or NetBeans.
  2. Open command line and navigate to the JForex-SDK project folder root, then build the OrderTable.jar with the following command.
    mvn assembly:assembly -P order-table

Attaching plugin

One can either create his own plugins or download them from the JStore. Consider attaching and activating a plugin:

  1. Attach and activate plugin:

    open-plgin activate-plugin

  2. Deselect "Allow auto trading" if you wish to prohibit the plugin to make any order changes. Select "Activate plugin on platform startup" if you wish the plugin to auto-start.

    plugin-allow-auto-trading

The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.