@Test
public void marginRateWhenAccountCurrencyBase() {

	/*account currency EUR and calculate margin for AUDUSD, effectively using AUDEUR rate*/
	AccountDataProvider<Long> accountDataProvider = mock(AccountDataProvider.class);
	CurrentPriceInfoProvider<String> currentPriceInfoProvider = mock(CurrentPriceInfoProvider.class);
	ProviderHelper providerHelper = mock(ProviderHelper.class);
	AccountInfoService<Long, String> accInfoService = new AccountInfoService<Long, String>(accountDataProvider,
			currentPriceInfoProvider, null, providerHelper);
	TradeableInstrument<String> audusd = new TradeableInstrument<String>("AUD_USD");
	TradeableInstrument<String> euraud = new TradeableInstrument<String>("EUR_AUD");
	TradeableInstrument<String> audeur = new TradeableInstrument<String>("AUD_EUR");
	Account<Long> account = mock(Account.class);
	when(accountDataProvider.getLatestAccountInfo(TradingTestConstants.accountId)).thenReturn(account);
	when(account.getCurrency()).thenReturn("EUR");
	when(account.getMarginRate()).thenReturn(marginRate);
	when(providerHelper.fromIsoFormat(eq("AUDEUR"))).thenReturn(audeur.getInstrument());
	when(providerHelper.fromIsoFormat(eq("EURAUD"))).thenReturn(euraud.getInstrument());
	Map<TradeableInstrument<String>, Price<String>> priceInfoMap = Maps.newHashMap();
	priceInfoMap.put(euraud, new Price<String>(euraud, 1.5636, 1.564, DateTime.now()));
	when(currentPriceInfoProvider.getCurrentPricesForInstruments(eq(Lists.newArrayList(audeur)))).thenReturn(
			Maps.<TradeableInstrument<String>, Price<String>> newHashMap());
	when(currentPriceInfoProvider.getCurrentPricesForInstruments(eq(Lists.newArrayList(euraud)))).thenReturn(
			priceInfoMap);
	double marginRate = accInfoService.calculateMarginForTrade(TradingTestConstants.accountId, audusd, units);
	assertEquals(383.6807, marginRate, TradingTestConstants.precision);
	marginRate = accInfoService.calculateMarginForTrade(TradingTestConstants.accountId, euraud, units);
	assertEquals(600.0, marginRate, TradingTestConstants.precision);
}