AccountInfoOnAccount.java

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



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


import com.dukascopy.api.*;

public class AccountInfoOnAccount implements IStrategy {

    private IEngine engine;
    private IConsole console;
    private IHistory history;
    
    @Override
    public void onStart(IContext context) throws JFException {
        engine  = context.getEngine();
        console = context.getConsole();
        history = context.getHistory();
    }
    
    @Override
    public void onAccount(IAccount account) throws JFException {
        double profitLoss = 0;
        double totalAmount = 0;  
        for (IOrder order : engine.getOrders()) {
            if(order.getState() == IOrder.State.FILLED){
                profitLoss += order.getProfitLossInUSD();
                totalAmount += order.getAmount();
            }
        }     
        //account.getEquity()は5秒毎に更新します。gets updated every 5 seconds 
        //しかし、history.getEquity()は最後に受信したティック価格から算出します。
        console.getOut().format("証拠金=%.2f 算出した証拠金=%.2f 損益合計=%.2f " + 
            "クレジットライン=%.2f 残高=%.2f 建玉合計=%.3f", 
            account.getEquity(),
            history.getEquity(),
            profitLoss, account.getCreditLine(),
            account.getBalance(),
            totalAmount
        ).println();
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}
    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
    @Override
    public void onMessage(IMessage message) throws JFException {}
    @Override
    public void onStop() throws JFException {}
}







スポンサーリンク

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


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


Top

inserted by FC2 system