package jforex;

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

public class TestOrderSubmit implements IStrategy {
	private IContext context;
    private IOrder order;
	
	public void onStart(IContext context) throws JFException {
        this.context = context;
        order = context.getEngine().submitOrder("MyOrder", Instrument.USDJPY, OrderCommand.BUY, 0.1);
	}

	public void onAccount(IAccount account) throws JFException {
	}

	public void onMessage(IMessage message) throws JFException {
	}

	public void onStop() throws JFException {
        if (order != null){
	        if(!order.getState().equals(IOrder.State.CLOSED)
	               && !order.getState().equals(IOrder.State.CANCELED)){
	           order.close();
	        }
        }
	}

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