package com.dukascopy;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.FeedDescriptor;
import com.dukascopy.api.feed.IFeedDescriptor;
import java.util.*;
import java.util.concurrent.Callable;

public class StaticContextDemo_2 implements IStrategy {
    private static int g_nRun;
    private static IContext g_context;
 
    public void onStart(IContext context) throws JFException {
        g_context = context;
 
        final IFeedDescriptor fd = new FeedDescriptor();
 
        fd.setInstrument(Instrument.EURUSD);
        fd.setDataType(DataType.TIME_PERIOD_AGGREGATION);
        fd.setPeriod(Period.THIRTY_MINS);
        fd.setOfferSide(OfferSide.BID);
 
        ++g_nRun;
        g_context.getConsole().getInfo().println("Starting N: " + g_nRun + ", context: " + System.identityHashCode(g_context));
        g_context.openChart(fd);
        g_context.executeTask(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                g_context.getConsole().getInfo().println("Execute task N: " + g_nRun);
                return null;
            }
        });
    }
 
    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 {}
}