package com.dukascopy.visualforex.sankit; import java.util.*; import com.dukascopy.api.*; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.concurrent.CopyOnWriteArrayList; import java.lang.reflect.*; import java.math.BigDecimal; /* * Created by VisualJForex Generator, version 1.65 * Date: 12.02.2015 16:26 */ public class a23456 implements IStrategy { private CopyOnWriteArrayList tradeEventActions = new CopyOnWriteArrayList(); private static final String DATE_FORMAT_NOW = "yyyyMMdd_HHmmss"; private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface; @Configurable("defaultSlippage:") public int defaultSlippage = 5; @Configurable("defaultTradeAmount:") public double defaultTradeAmount = 10.0; @Configurable("defaultPeriod:") public Period defaultPeriod = Period.FIFTEEN_MINS; @Configurable("defaultInstrument:") public Instrument defaultInstrument = Instrument.EURUSD; @Configurable("defaultTakeProfit:") public int defaultTakeProfit = 1; @Configurable("defaultStopLoss:") public int defaultStopLoss = 830; private Candle _Candleshift2 = null ; private OfferSide _tempVar165 = OfferSide.ASK; private String AccountCurrency = ""; private int _tempVar166 = 2; private double _ResultSell; private Candle _Candleshift1 = null ; private double _upperBand12; private Tick LastTick = null ; private double _middleBand12; private double _Ref1 = 0.001; private double _Ref2 = 5.0E-4; private double _Ref3 = 7.0E-4; private int _XYZ = 35; private double _MI2; private double Equity; private double _MI1; private double _lowerBand12; private OfferSide _tempVar152 = OfferSide.ASK; private int _tempVar153 = 1; private double _UP2; private double _tempVar293 = 1.0; private double _UP1; private IOrder _pos = null ; private List AllPositions = null ; private IOrder _Close = null ; private Candle candle26 = null ; private Candle LastBidCandle = null ; private Candle candle27 = null ; private double Leverage; private String AccountId = ""; private double UseofLeverage; private double _Buy1; private List PendingPositions = null ; private double _Buy2; private double _tempVar276 = 10.0; private double _LO1; private double _ResultBuy; private int _stop = 30; private Candle LastAskCandle = null ; private int MarginCutLevel; private int OverWeekendEndLeverage; private boolean GlobalAccount; private double _LO2; private List OpenPositions = null ; private double _REFER; private double _Sell2; private IMessage LastTradeEvent = null ; private double _Sell1; public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators(); this.userInterface = context.getUserInterface(); subscriptionInstrumentCheck(defaultInstrument); ITick lastITick = context.getHistory().getLastTick(defaultInstrument); LastTick = new Tick(lastITick, defaultInstrument); IBar bidBar = context.getHistory().getBar(defaultInstrument, defaultPeriod, OfferSide.BID, 1); IBar askBar = context.getHistory().getBar(defaultInstrument, defaultPeriod, OfferSide.ASK, 1); LastAskCandle = new Candle(askBar, defaultPeriod, defaultInstrument, OfferSide.ASK); LastBidCandle = new Candle(bidBar, defaultPeriod, defaultInstrument, OfferSide.BID); if (indicators.getIndicator("BBANDS") == null) { indicators.registerDownloadableIndicator("1304","BBANDS"); } if (indicators.getIndicator("BBANDS") == null) { indicators.registerDownloadableIndicator("1304","BBANDS"); } if (indicators.getIndicator("BBANDS") == null) { indicators.registerDownloadableIndicator("1304","BBANDS"); } subscriptionInstrumentCheck(Instrument.fromString("EUR/USD")); } public void onAccount(IAccount account) throws JFException { AccountCurrency = account.getCurrency().toString(); Leverage = account.getLeverage(); AccountId= account.getAccountId(); Equity = account.getEquity(); UseofLeverage = account.getUseOfLeverage(); OverWeekendEndLeverage = account.getOverWeekEndLeverage(); MarginCutLevel = account.getMarginCutLevel(); GlobalAccount = account.isGlobal(); } private void updateVariables(Instrument instrument) { try { AllPositions = engine.getOrders(instrument); List listMarket = new ArrayList(); for (IOrder order: AllPositions) { if (order.getState().equals(IOrder.State.FILLED)){ listMarket.add(order); } } List listPending = new ArrayList(); for (IOrder order: AllPositions) { if (order.getState().equals(IOrder.State.OPENED)){ listPending.add(order); } } OpenPositions = listMarket; PendingPositions = listPending; } catch(JFException e) { e.printStackTrace(); } } public void onMessage(IMessage message) throws JFException { if (message.getOrder() != null) { updateVariables(message.getOrder().getInstrument()); LastTradeEvent = message; for (TradeEventAction event : tradeEventActions) { IOrder order = message.getOrder(); if (order != null && event != null && message.getType().equals(event.getMessageType())&& order.getLabel().equals(event.getPositionLabel())) { Method method; try { method = this.getClass().getDeclaredMethod(event.getNextBlockId(), Integer.class); method.invoke(this, new Integer[] {event.getFlowId()}); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } tradeEventActions.remove(event); } } } } public void onStop() throws JFException { } public void onTick(Instrument instrument, ITick tick) throws JFException { LastTick = new Tick(tick, instrument); updateVariables(instrument); } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { LastAskCandle = new Candle(askBar, period, instrument, OfferSide.ASK); LastBidCandle = new Candle(bidBar, period, instrument, OfferSide.BID); updateVariables(instrument); If_block_19(1); } public void subscriptionInstrumentCheck(Instrument instrument) { try { if (!context.getSubscribedInstruments().contains(instrument)) { Set instruments = new HashSet(); instruments.add(instrument); context.setSubscribedInstruments(instruments, true); Thread.sleep(100); } } catch (InterruptedException e) { e.printStackTrace(); } } public double round(double price, Instrument instrument) { BigDecimal big = new BigDecimal("" + price); big = big.setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP); return big.doubleValue(); } public ITick getLastTick(Instrument instrument) { try { return (context.getHistory().getTick(instrument, 0)); } catch (JFException e) { e.printStackTrace(); } return null; } private void If_block_10(Integer flow) { Instrument argument_1 = LastAskCandle.getInstrument(); Instrument argument_2 = defaultInstrument; if (!argument_1.equals(argument_2)) { } else if (argument_1.equals(argument_2)) { GetHistoricalCandle_block_27(flow); } } private void Calculation_block_11(Integer flow) { double argument_1 = _LO2; double argument_2 = _Candleshift2.getLow(); _Buy2 = argument_1 - argument_2; If_block_15(flow); } private void BBANDS_block_12(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = defaultPeriod; int argument_3 = 0; int argument_4 = 20; double argument_5 = 2.0; double argument_6 = 2.0; IIndicators.MaType argument_7 = IIndicators.MaType.SMA; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[4]; params[0] = 20; params[1] = 2.0; params[2] = 2.0; params[3] = 0; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "BBANDS", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._upperBand12 = Double.NaN; } else { this._upperBand12 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._middleBand12 = Double.NaN; } else { this._middleBand12 = (((double [])indicatorResult[1])[0]); } if ((new Double(((double [])indicatorResult[2])[0])) == null) { this._lowerBand12 = Double.NaN; } else { this._lowerBand12 = (((double [])indicatorResult[2])[0]); } } catch (JFException e) { e.printStackTrace(); } If_block_13(flow); } private void If_block_13(Integer flow) { double argument_1 = LastTick.getAsk(); double argument_2 = _middleBand12; if (argument_1< argument_2) { Calculation_block_11(flow); } else if (argument_1> argument_2) { Calculation_block_36(flow); } else if (argument_1== argument_2) { } } private void Calculation_block_14(Integer flow) { double argument_1 = LastTick.getAsk(); double argument_2 = _upperBand12; _ResultSell = argument_1 - argument_2; If_block_16(flow); } private void If_block_15(Integer flow) { double argument_1 = _Buy2; double argument_2 = _Ref1; if (argument_1< argument_2) { } else if (argument_1> argument_2) { Calculation_block_32(flow); } else if (argument_1== argument_2) { Calculation_block_32(flow); } } private void If_block_16(Integer flow) { double argument_1 = _ResultSell; double argument_2 = _Ref3; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_67(flow); } else if (argument_1== argument_2) { If_block_67(flow); } } private void OpenatMarket_block_17(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 15.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.SELL; double stopLoss = tick.getAsk() + argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getAsk() - argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_18(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 15.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_19(Integer flow) { int argument_1 = OpenPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { If_block_10(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void GetHistoricalCandle_block_26(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = defaultPeriod; OfferSide argument_3 = _tempVar152; int argument_4 = _tempVar153; subscriptionInstrumentCheck(argument_1); try { IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); _Candleshift1 = new Candle(tempBar, argument_2, argument_1, argument_3); } catch (JFException e) { e.printStackTrace(); } BBANDS_block_31(flow); } private void GetHistoricalCandle_block_27(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = defaultPeriod; OfferSide argument_3 = _tempVar165; int argument_4 = _tempVar166; subscriptionInstrumentCheck(argument_1); try { IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); _Candleshift2 = new Candle(tempBar, argument_2, argument_1, argument_3); } catch (JFException e) { e.printStackTrace(); } BBANDS_block_30(flow); } private void BBANDS_block_30(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = defaultPeriod; int argument_3 = _tempVar166; int argument_4 = 20; double argument_5 = 2.0; double argument_6 = 2.0; IIndicators.MaType argument_7 = IIndicators.MaType.SMA; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[4]; params[0] = 20; params[1] = 2.0; params[2] = 2.0; params[3] = 0; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "BBANDS", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._UP2 = Double.NaN; } else { this._UP2 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._MI2 = Double.NaN; } else { this._MI2 = (((double [])indicatorResult[1])[0]); } if ((new Double(((double [])indicatorResult[2])[0])) == null) { this._LO2 = Double.NaN; } else { this._LO2 = (((double [])indicatorResult[2])[0]); } } catch (JFException e) { e.printStackTrace(); } GetHistoricalCandle_block_26(flow); } private void BBANDS_block_31(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = defaultPeriod; int argument_3 = _tempVar153; int argument_4 = 20; double argument_5 = 2.0; double argument_6 = 2.0; IIndicators.MaType argument_7 = IIndicators.MaType.SMA; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[4]; params[0] = 20; params[1] = 2.0; params[2] = 2.0; params[3] = 0; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "BBANDS", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._UP1 = Double.NaN; } else { this._UP1 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._MI1 = Double.NaN; } else { this._MI1 = (((double [])indicatorResult[1])[0]); } if ((new Double(((double [])indicatorResult[2])[0])) == null) { this._LO1 = Double.NaN; } else { this._LO1 = (((double [])indicatorResult[2])[0]); } } catch (JFException e) { e.printStackTrace(); } BBANDS_block_12(flow); } private void Calculation_block_32(Integer flow) { double argument_1 = _LO1; double argument_2 = _Candleshift1.getLow(); _Buy1 = argument_1 - argument_2; If_block_33(flow); } private void If_block_33(Integer flow) { double argument_1 = _Buy1; double argument_2 = _Ref2; if (argument_1< argument_2) { } else if (argument_1> argument_2) { Calculation_block_35(flow); } else if (argument_1== argument_2) { Calculation_block_35(flow); } } private void If_block_34(Integer flow) { double argument_1 = _ResultBuy; double argument_2 = _Ref3; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_60(flow); } else if (argument_1== argument_2) { If_block_60(flow); } } private void Calculation_block_35(Integer flow) { double argument_1 = _lowerBand12; double argument_2 = LastTick.getAsk(); _ResultBuy = argument_1 - argument_2; If_block_34(flow); } private void Calculation_block_36(Integer flow) { double argument_1 = _Candleshift2.getHigh(); double argument_2 = _UP2; _Sell2 = argument_1 - argument_2; If_block_37(flow); } private void If_block_37(Integer flow) { double argument_1 = _Sell2; double argument_2 = _Ref1; if (argument_1< argument_2) { } else if (argument_1> argument_2) { Calculation_block_39(flow); } else if (argument_1== argument_2) { Calculation_block_39(flow); } } private void Calculation_block_39(Integer flow) { double argument_1 = _Candleshift1.getHigh(); double argument_2 = _UP1; _Sell1 = argument_1 - argument_2; If_block_40(flow); } private void If_block_40(Integer flow) { double argument_1 = _Sell1; double argument_2 = _Ref2; if (argument_1< argument_2) { } else if (argument_1> argument_2) { Calculation_block_14(flow); } else if (argument_1== argument_2) { Calculation_block_14(flow); } } private void If_block_60(Integer flow) { double argument_1 = Equity; double argument_2 = 250000.0; if (argument_1< argument_2) { If_block_62(flow); } else if (argument_1> argument_2) { OpenatMarket_block_17(flow); } else if (argument_1== argument_2) { OpenatMarket_block_17(flow); } } private void If_block_61(Integer flow) { double argument_1 = Equity; double argument_2 = 130000.0; if (argument_1< argument_2) { OpenatMarket_block_65(flow); } else if (argument_1> argument_2) { OpenatMarket_block_64(flow); } else if (argument_1== argument_2) { OpenatMarket_block_64(flow); } } private void If_block_62(Integer flow) { double argument_1 = Equity; double argument_2 = 200000.0; if (argument_1< argument_2) { If_block_61(flow); } else if (argument_1> argument_2) { OpenatMarket_block_63(flow); } else if (argument_1== argument_2) { OpenatMarket_block_63(flow); } } private void OpenatMarket_block_63(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 12.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.SELL; double stopLoss = tick.getAsk() + argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getAsk() - argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_64(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 10.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.SELL; double stopLoss = tick.getAsk() + argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getAsk() - argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_65(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 7.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.SELL; double stopLoss = tick.getAsk() + argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getAsk() - argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_67(Integer flow) { double argument_1 = Equity; double argument_2 = 250000.0; if (argument_1< argument_2) { If_block_68(flow); } else if (argument_1> argument_2) { OpenatMarket_block_18(flow); } else if (argument_1== argument_2) { OpenatMarket_block_18(flow); } } private void If_block_68(Integer flow) { double argument_1 = Equity; double argument_2 = 200000.0; if (argument_1< argument_2) { If_block_70(flow); } else if (argument_1> argument_2) { OpenatMarket_block_69(flow); } else if (argument_1== argument_2) { OpenatMarket_block_69(flow); } } private void OpenatMarket_block_69(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 12.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_70(Integer flow) { double argument_1 = Equity; double argument_2 = 130000.0; if (argument_1< argument_2) { OpenatMarket_block_72(flow); } else if (argument_1> argument_2) { OpenatMarket_block_71(flow); } else if (argument_1== argument_2) { OpenatMarket_block_71(flow); } } private void OpenatMarket_block_71(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 10.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_72(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 7.0; int argument_3 = defaultSlippage; int argument_4 = defaultStopLoss; int argument_5 = defaultTakeProfit; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } class Candle { IBar bar; Period period; Instrument instrument; OfferSide offerSide; public Candle(IBar bar, Period period, Instrument instrument, OfferSide offerSide) { this.bar = bar; this.period = period; this.instrument = instrument; this.offerSide = offerSide; } public Period getPeriod() { return period; } public void setPeriod(Period period) { this.period = period; } public Instrument getInstrument() { return instrument; } public void setInstrument(Instrument instrument) { this.instrument = instrument; } public OfferSide getOfferSide() { return offerSide; } public void setOfferSide(OfferSide offerSide) { this.offerSide = offerSide; } public IBar getBar() { return bar; } public void setBar(IBar bar) { this.bar = bar; } public long getTime() { return bar.getTime(); } public double getOpen() { return bar.getOpen(); } public double getClose() { return bar.getClose(); } public double getLow() { return bar.getLow(); } public double getHigh() { return bar.getHigh(); } public double getVolume() { return bar.getVolume(); } } class Tick { private ITick tick; private Instrument instrument; public Tick(ITick tick, Instrument instrument){ this.instrument = instrument; this.tick = tick; } public Instrument getInstrument(){ return instrument; } public double getAsk(){ return tick.getAsk(); } public double getBid(){ return tick.getBid(); } public double getAskVolume(){ return tick.getAskVolume(); } public double getBidVolume(){ return tick.getBidVolume(); } public long getTime(){ return tick.getTime(); } public ITick getTick(){ return tick; } } public class AssertException extends RuntimeException { public AssertException(Object primary, Object compared) { super("Primary object : " + primary.toString() + " is different from " + compared.toString()); } } protected String getLabel() { String label; label = "IVF" + getCurrentTime(LastTick.getTime()) + generateRandom(10000) + generateRandom(10000); return label; } private String getCurrentTime(long time) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return sdf.format(time); } private static String generateRandom(int n) { int randomNumber = (int) (Math.random() * n); String answer = "" + randomNumber; if (answer.length() > 3) { answer = answer.substring(0, 4); } return answer; } class TradeEventAction { private IMessage.Type messageType; private String nextBlockId = ""; private String positionLabel = ""; private int flowId = 0; public IMessage.Type getMessageType() { return messageType; } public void setMessageType(IMessage.Type messageType) { this.messageType = messageType; } public String getNextBlockId() { return nextBlockId; } public void setNextBlockId(String nextBlockId) { this.nextBlockId = nextBlockId; } public String getPositionLabel() { return positionLabel; } public void setPositionLabel(String positionLabel) { this.positionLabel = positionLabel; } public int getFlowId() { return flowId; } public void setFlowId(int flowId) { this.flowId = flowId; } } }