@Test
public void marginRateWhenAccountCurrencyNominated() {

	/*account currency CHF and calculate margin for GBPUSD, effectively using GBPCHF 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> gbpusd = new TradeableInstrument<String>("GBP_USD");
	TradeableInstrument<String> gbpchf = new TradeableInstrument<String>("GBP_CHF");
	Account<Long> account = mock(Account.class);
	when(accountDataProvider.getLatestAccountInfo(TradingTestConstants.accountId)).thenReturn(account);
	when(account.getCurrency()).thenReturn("CHF");
	when(account.getMarginRate()).thenReturn(marginRate);
	when(providerHelper.fromIsoFormat(eq("GBPCHF"))).thenReturn(gbpchf.getInstrument());
	Map<TradeableInstrument<String>, Price<String>> priceInfoMap = Maps.newHashMap();
	priceInfoMap.put(gbpchf, new Price<String>(gbpchf, 1.4811, 1.4813, DateTime.now()));
	when(currentPriceInfoProvider.getCurrentPricesForInstruments(eq(Lists.newArrayList(gbpchf)))).thenReturn(
			priceInfoMap);
	double marginRate = accInfoService.calculateMarginForTrade(TradingTestConstants.accountId, gbpusd, units);
	assertEquals(888.72, marginRate, TradingTestConstants.precision);
}