@Test
public void analyseHistoricTweetsTest() {

	CopyTwitterStrategy<String> copyTwitterStrategy = new CopyTwitterStrategy<String>();
	double[] profits = { 13.45, 11.54, -8.9, 12.09, 21.67, 2.76, -3.5, 11.67, 9.21 };
	Collection<CloseFXTradeTweet<String>> closedTrades = createClosedTrades(profits);
	double takeProfit = 0.9812;
	double stopLoss = 0.949;
	double price = 0.9735;
	NewFXTradeTweet<String> newTrade = mock(NewFXTradeTweet.class);
	TradeableInstrument<String> usdchf = new TradeableInstrument<String>("USD_CHF");
	when(newTrade.getAction()).thenReturn(TradingSignal.LONG);
	when(newTrade.getInstrument()).thenReturn(usdchf);
	when(newTrade.getTakeProfit()).thenReturn(takeProfit);
	when(newTrade.getStopLoss()).thenReturn(stopLoss);
	when(newTrade.getPrice()).thenReturn(price);
	TradingDecision<String> tradingDecision = copyTwitterStrategy.analyseHistoricClosedTradesForInstrument(
			closedTrades, newTrade);
	assertEquals(TradingSignal.LONG, tradingDecision.getSignal());
	assertEquals(TradingDecision.SRCDECISION.SOCIAL_MEDIA, tradingDecision.getTradeSource());
	assertEquals(usdchf, tradingDecision.getInstrument());
	assertEquals(takeProfit, tradingDecision.getTakeProfitPrice(), ZERO);
	assertEquals(stopLoss, tradingDecision.getStopLossPrice(), ZERO);
	assertEquals(price, tradingDecision.getLimitPrice(), ZERO);
	double profits2[] = { -23.9, -10, -56.0, -12.9, -11.5, 8.5 };
	closedTrades = createClosedTrades(profits2);
	tradingDecision = copyTwitterStrategy.analyseHistoricClosedTradesForInstrument(closedTrades, newTrade);
	assertEquals(TradingSignal.SHORT, tradingDecision.getSignal());
	assertEquals(TradingDecision.SRCDECISION.SOCIAL_MEDIA, tradingDecision.getTradeSource());
	assertEquals(usdchf, tradingDecision.getInstrument());
	assertEquals(0.9658, tradingDecision.getTakeProfitPrice(), TradingAppTestConstants.precision);
	assertEquals(0.998, tradingDecision.getStopLossPrice(), TradingAppTestConstants.precision);
	assertEquals(price, tradingDecision.getLimitPrice(), ZERO);
	stopLoss = 1.1125;
	takeProfit = 1.0705;
	price = 1.0895;
	TradeableInstrument<String> eurchf = new TradeableInstrument<String>("EUR_CHF");
	NewFXTradeTweet<String> newTrade2 = mock(NewFXTradeTweet.class);
	when(newTrade2.getAction()).thenReturn(TradingSignal.SHORT);
	when(newTrade2.getInstrument()).thenReturn(eurchf);
	when(newTrade2.getTakeProfit()).thenReturn(takeProfit);
	when(newTrade2.getStopLoss()).thenReturn(stopLoss);
	when(newTrade2.getPrice()).thenReturn(price);
	tradingDecision = copyTwitterStrategy.analyseHistoricClosedTradesForInstrument(closedTrades, newTrade2);
	assertEquals(TradingSignal.LONG, tradingDecision.getSignal());
	assertEquals(TradingDecision.SRCDECISION.SOCIAL_MEDIA, tradingDecision.getTradeSource());
	assertEquals(eurchf, tradingDecision.getInstrument());
	assertEquals(1.1085, tradingDecision.getTakeProfitPrice(), TradingAppTestConstants.precision);
	assertEquals(1.0665, tradingDecision.getStopLossPrice(), TradingAppTestConstants.precision);
	assertEquals(price, tradingDecision.getLimitPrice(), ZERO);
	stopLoss = 15.0545;
	takeProfit = 15.0985;
	price = 0.0;
	TradeableInstrument<String> usdzar = new TradeableInstrument<>("USD_ZAR");
	NewFXTradeTweet<String> newTrade3 = mock(NewFXTradeTweet.class);
	when(newTrade3.getAction()).thenReturn(TradingSignal.LONG);
	when(newTrade3.getInstrument()).thenReturn(usdzar);
	when(newTrade3.getTakeProfit()).thenReturn(takeProfit);
	when(newTrade3.getStopLoss()).thenReturn(stopLoss);
	when(newTrade3.getPrice()).thenReturn(price);
	closedTrades = createClosedTrades(profits2);
	CurrentPriceInfoProvider<String> currPriceInfoProvider = mock(CurrentPriceInfoProvider.class);
	copyTwitterStrategy.currentPriceInfoProvider = currPriceInfoProvider;
	Map<TradeableInstrument<String>, Price<String>> priceMap = Maps.newHashMap();
	Price<String> usdzarPrice = new Price<>(usdzar, 15.0715, 15.0727, DateTime.now());
	priceMap.put(usdzar, usdzarPrice);
	when(currPriceInfoProvider.getCurrentPricesForInstruments(eq(Lists.newArrayList(usdzar)))).thenReturn(priceMap);
	tradingDecision = copyTwitterStrategy.analyseHistoricClosedTradesForInstrument(closedTrades, newTrade3);
	assertEquals(TradingSignal.SHORT, tradingDecision.getSignal());
	assertEquals(TradingDecision.SRCDECISION.SOCIAL_MEDIA, tradingDecision.getTradeSource());
	assertEquals(usdzar, tradingDecision.getInstrument());
	assertEquals(15.0445, tradingDecision.getTakeProfitPrice(), TradingAppTestConstants.precision);
	assertEquals(15.0885, tradingDecision.getStopLossPrice(), TradingAppTestConstants.precision);
	assertEquals(15.0715, tradingDecision.getLimitPrice(), ZERO);
}