TradeInfoService { public Collection<K> findAllAccountsWithInstrumentTrades(TradeableInstrument<N> instrument) { Collection<K> accountIds = Sets.newHashSet(); lock.readLock().lock(); try { for (K accountId : this.tradesCache.keySet()) { if (isTradeExistsForInstrument(instrument, accountId)) { accountIds.add(accountId); } } } finally { lock.readLock().unlock(); } return accountIds; } TradeInfoService(TradeManagementProvider<M, N, K> tradeManagementProvider,
			AccountDataProvider<K> accountDataProvider); Collection<K> findAllAccountsWithInstrumentTrades(TradeableInstrument<N> instrument); @PostConstruct void init(); int findNetPositionCountForCurrency(String currency); Collection<Trade<M, N, K>> getAllTrades(); Collection<Trade<M, N, K>> getTradesForAccountAndInstrument(K accountId, TradeableInstrument<N> instrument); Collection<Trade<M, N, K>> getTradesForAccount(K accountId); void refreshTradesForAccount(K accountId); boolean isTradeExistsForInstrument(TradeableInstrument<N> instrument);  }
@Test public void accountsForInstrumentsTest() { TradeInfoService<Long, String, Long> service = createService(); Collection<Long> accountIds = service .findAllAccountsWithInstrumentTrades(new TradeableInstrument<String>("EUR_USD")); assertEquals(2, accountIds.size()); accountIds = service.findAllAccountsWithInstrumentTrades(new TradeableInstrument<String>("EUR_JPY")); assertEquals(1, accountIds.size()); }