package singlejartest;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.IRenkoBar;
import com.dukascopy.api.feed.IRenkoBarFeedListener;


import org.slf4j.LoggerFactory;
import org.slf4j.Logger;

public class renkoTestStrategy implements IStrategy 
{

	// used for logging
	private static final Logger LOGGER = LoggerFactory.getLogger(renkoTestStrategy.class);

	//Configurable strategy parameters
    // general
    //@Configurable("Instrument") public Instrument instrument = Instrument.EURUSD;    
    //@Configurable("Renko Block Size") public PriceRange renkoBarPriceRange = PriceRange.valueOf(15);
    
        
// *****  JFOREX API EVENT HANDLERS ****************************************************************

    class wtlRenkoBarFeedListener implements IRenkoBarFeedListener
    {
		@Override
		public void onBar(Instrument instrument, OfferSide offerSide, PriceRange priceRange, IRenkoBar bar) 
		{
	       	LOGGER.info("wtlRenkoBarFeedListener.onBar() [" + instrument.toString() + "]: " + priceRange.toString() + " " + bar.toString());
		}
    }
    
    public void onStart(IContext context) throws JFException 
    {
		// subscribe to Renko Bar Feed
		context.subscribeToRenkoBarFeed(Instrument.EURUSD, OfferSide.BID, PriceRange.valueOf(15), new wtlRenkoBarFeedListener());
//		context.subscribeToRenkoBarFeed(instrument, OfferSide.BID, renkoBarPriceRange, new wtlRenkoBarFeedListener());
        
	}

    public void onMessage(IMessage message) throws JFException 
    {        

    }
    
    public void onStop() throws JFException 
    {

    }
    
    public void onBar(Instrument instrument, Period period, IBar askbar, IBar bidbar) throws JFException 
    {
    	LOGGER.info("renkoTestStrategy.onBar() [" + instrument.toString() + "]: " + bidbar.toString());

    }

    public void onTick(Instrument instrument, ITick tick) throws JFException 
    {
    
    }
    
    public void onAccount(IAccount account) throws JFException 
    {
        
    }

}