トップ  >  リファレンス  >  ストラテジーAPI  >  通貨ペア
通貨ペア


通貨ペアのトレードをするには、銘柄登録する必要があります。
IContext.getSubscribedInstruments()メソッドを使用し、既に登録済みの通貨ペアを取得出来ます。
IContext.setSubscribedInstruments()メソッドを使用し、通貨ペアを銘柄登録する事が出来ます。
非同期メソッドを使用する場合、銘柄登録は即座に行われない可能性があります、
その為、その通貨ペアが取引可能かどうか確認する為、オーダーする前に銘柄登録完了の為に待つことをお勧めします。

同期銘柄登録



Consider subscribing to two instruments EURSEK and AUDUSD:
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.EURUSD);
instruments.add(Instrument.AUDUSD);

context.setSubscribedInstruments(instruments, true);


非同期銘柄登録

以下サンプルは、EURUSDとAUDUSDの通貨ペアを銘柄登録し、最大1秒間待ちます。



Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.EURSEK);
instruments.add(Instrument.AUDUSD);

context.setSubscribedInstruments(instruments);

// 銘柄登録の為に最大1秒間待ちます
int i = 10;
while (!context.getSubscribedInstruments().containsAll(instruments) && i>=0) {
    try {
        console.getOut().println("まだ銘柄登録されていません " + i);
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        console.getOut().println(e.getMessage());
    }
    i--;
}





スポンサーリンク

スポンサーリンク
検索
リファレンスツリー


Copyright ©2016 JForexAPIで自動売買させ隊! All Rights Reserved.


Top

inserted by FC2 system