package jforex.utils; 
 
import com.dukascopy.api.*;
 
public class ErrorDemo3 implements IStrategy {
    private JFUtils utils;
    private IHistory history;
    private IConsole console;
    private IAccount account;
     
    public void onStart(IContext context) throws JFException {
        this.utils = context.getUtils();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.account = context.getAccount();
        
        for(Instrument instrument : context.getSubscribedInstruments()){
            ITick tick = history.getLastTick(instrument);
            double pipCost = utils.convertPipToCurrency(instrument, account.getCurrency());
            double rate = pipCost /instrument.getPipValue();
            console.getOut().println(String.format("%s pipCost=%.8f, rate=%.5f, last tick: %s", instrument.name(), pipCost, rate, tick));
        }       
    }
 
    public void onAccount(IAccount account) throws JFException {    } 
    public void onMessage(IMessage message) throws JFException {    } 
    public void onStop() throws JFException {    } 
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }     
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {    }
}