プラグインはプラットフォームの拡張機能で、JForexAPIを使って作成する事が出来ます。
JForexプラットフォーム内でプラグインを使用には、 it has to be compiled and archived into a single jar file.
注意:この機能はJForex-API 2.9.2以降で利用可能です。
プラグインを追加
プラグインは自作するか
JStoreからダウンロードします。
プラグインを追加して使用してみましょう。
(デューカスコピー・ジャパンでは
JStoreの提供は行っていないみたいです。)
1. Attach and activate the 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.
プラグインの作成
全てのプラグインファイル(.jar)は以下の条件を満たす必要があります。
1. jarファイルはPlugin拡張クラスを含んでいるクラスである必要があります。
2. jarマニフェストファイルは、プラグインクラスのpluginMainClassで始まる修飾子を含める必要があります。
例
pluginMainClass: mypackage.MyPlugin
JForexSDKでの使用例
プラグインを作成するには以下の手順通りに従って下さい。
1.Eclipse か NetBeansのいずれかで、JForexSDKプロジェクトをインポートします。
2.コマンドラインを開き、JForexSDKプロジェクトのrootフォルダに移動します。その後、次のコマンドを使用してOrderTable.jarをビルドします。
mvn assembly:assembly -P order-table
アセンブリ設定の詳細については、
pom.xmlとassemblies/jar-assembly-order-table-plugin.xmlファイルを参照して下さい。
また他の仕様例を参照して下さい。
・プラットフォーム外のプラグイン実行中にオーダーテーブルSDKプロファイルが見れます。
・プラグインのライブラリを使う。pom.xmlとassemblies\jar-assembly-summarizer-plugin.xmlのサマライズプラグインのプロフィール参照。
シンプルプラグインのビルド
簡単なプラグインを作成します。
SimplePlugin.java
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("プラグイン開始");
}
@Override
public void onStop() throws JFException {
console.getOut().println("プラグイン停止");
}
}
そして、マニフェストファイル(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.9.2.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:
Make sure you choose the Archive format to be zip:
Proceed with attaching the plugin in the platform.