import com.dukascopy.api.*;

public class GetLotStrat implements IStrategy {

    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    
    @Configurable("risk in percent")
    public int risk = 2;

    public void onStart(IContext context) throws JFException {        
        IAccount account = context.getAccount();
        if(risk < 1 || risk > 100) {
            throw new JFException("Invalid risk value: "+risk);
        }
        
        double lot = account.getEquity() * account.getLeverage() * risk / 100;
        lot = lot / 1000000; // convert to millions
        
        context.getConsole().getOut().println(lot);
    }

    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 {
    }
}
