MarketOrder.java

注意事項:
サンプルソースコードには実際にオーダーを発注するものがあります。
サンプルソースコードのストラテジーを起動する場合は、注意して下さい。



// Copyright (c) 2009 Dukascopy (Suisse) SA. All Rights Reserved.
package jforex.orders;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;

public class MarketOrder implements IStrategy {

    private IEngine engine;
    private IConsole console;
    private IOrder order;
    
    @Override
    public void onStart(IContext context) throws JFException {
        engine = context.getEngine();
        console = context.getConsole();
        context.setSubscribedInstruments(java.util.Collections.singleton(Instrument.EURUSD), true);
        order = engine.submitOrder(
                                  "MaketBuyOrder1",  // オーダーラベル
                                  Instrument.EURUSD, // 通貨ペア
                                  OrderCommand.BUY,  // オーダーコマンド
                                  0.001              // 取引数量[分解能:100万通貨]
                                 );
    }
    
    public void onMessage(IMessage message) throws JFException {
        if( message.getOrder() == order ){ // このストラテジーのオーダーメッセージをログ出力
            console.getOut().println(message);
        }
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {}
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
    public void onAccount(IAccount account) throws JFException {}
    public void onStop() throws JFException {}
}






スポンサーリンク

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


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


Top

inserted by FC2 system